本文整理汇总了PHP中phid_get_type函数的典型用法代码示例。如果您正苦于以下问题:PHP phid_get_type函数的具体用法?PHP phid_get_type怎么用?PHP phid_get_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phid_get_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: withIdentifiers
public function withIdentifiers(array $identifiers)
{
$ids = array();
$callsigns = array();
$phids = array();
$monograms = array();
foreach ($identifiers as $identifier) {
if (ctype_digit($identifier)) {
$ids[$identifier] = $identifier;
} else {
if (preg_match('/^(r[A-Z]+)|(R[1-9]\\d*)\\z/', $identifier)) {
$monograms[$identifier] = $identifier;
} else {
$repository_type = PhabricatorRepositoryRepositoryPHIDType::TYPECONST;
if (phid_get_type($identifier) === $repository_type) {
$phids[$identifier] = $identifier;
} else {
$callsigns[$identifier] = $identifier;
}
}
}
}
$this->numericIdentifiers = $ids;
$this->callsignIdentifiers = $callsigns;
$this->phidIdentifiers = $phids;
$this->monogramIdentifiers = $monograms;
return $this;
}
开发者ID:demon,项目名称:phabricator,代码行数:28,代码来源:PhabricatorRepositoryQuery.php
示例2: execute
protected function execute(ConduitAPIRequest $request)
{
$user = $request->getUser()->getPHID();
$phid = $request->getValue('objectPHID');
$new = false;
$flag = id(new PhabricatorFlag())->loadOneWhere('objectPHID = %s AND ownerPHID = %s', $phid, $user);
if ($flag) {
$params = $request->getAllParameters();
if (isset($params['color'])) {
$flag->setColor($params['color']);
}
if (isset($params['note'])) {
$flag->setNote($params['note']);
}
} else {
$default_color = PhabricatorFlagColor::COLOR_BLUE;
$flag = id(new PhabricatorFlag())->setOwnerPHID($user)->setType(phid_get_type($phid))->setObjectPHID($phid)->setReasonPHID($user)->setColor($request->getValue('color', $default_color))->setNote($request->getValue('note', ''));
$new = true;
}
$this->attachHandleToFlag($flag, $request->getUser());
$flag->save();
$ret = $this->buildFlagInfoDictionary($flag);
$ret['new'] = $new;
return $ret;
}
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:FlagEditConduitAPIMethod.php
示例3: markupHandle
public function markupHandle(array $matches)
{
$engine = $this->getEngine();
$viewer = $engine->getConfig('viewer');
if (!$this->isFlatText($matches[0])) {
return $matches[0];
}
$phid_type = phid_get_type($matches[1]);
if ($phid_type == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) {
return $matches[0];
}
$token = $engine->storeText($matches[0]);
if ($engine->isTextMode()) {
return $token;
}
$original_key = self::KEY_RULE_HANDLE_ORIGINAL;
$original = $engine->getTextMetadata($original_key, array());
$original[$token] = $matches[0];
$engine->setTextMetadata($original_key, $original);
$metadata_key = self::KEY_RULE_HANDLE;
$metadata = $engine->getTextMetadata($metadata_key, array());
$phid = $matches[1];
if (empty($metadata[$phid])) {
$metadata[$phid] = array();
}
$metadata[$phid][] = $token;
$engine->setTextMetadata($metadata_key, $metadata);
return $token;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:29,代码来源:PhabricatorHandleRemarkupRule.php
示例4: renderView
public function renderView()
{
$view = $this->newStoryView();
$handle = $this->getHandle($this->getPrimaryObjectPHID());
$view->setHref($handle->getURI());
$type = phid_get_type($handle->getPHID());
$phid_types = PhabricatorPHIDType::getAllTypes();
$icon = null;
if (!empty($phid_types[$type])) {
$phid_type = $phid_types[$type];
$class = $phid_type->getPHIDTypeApplicationClass();
if ($class) {
$application = PhabricatorApplication::getByClass($class);
$icon = $application->getIcon();
}
}
$view->setAppIcon($icon);
$xaction_phids = $this->getValue('transactionPHIDs');
$xaction = $this->getPrimaryTransaction();
$xaction->setHandles($this->getHandles());
$view->setTitle($xaction->getTitleForFeed());
foreach ($xaction_phids as $xaction_phid) {
$secondary_xaction = $this->getObject($xaction_phid);
$secondary_xaction->setHandles($this->getHandles());
$body = $secondary_xaction->getBodyForFeed($this);
if (nonempty($body)) {
$view->appendChild($body);
}
}
$view->setImage($this->getHandle($xaction->getAuthorPHID())->getImageURI());
return $view;
}
开发者ID:truSense,项目名称:phabricator,代码行数:32,代码来源:PhabricatorApplicationTransactionFeedStory.php
示例5: loadAffiliatedUserPHIDs
public static function loadAffiliatedUserPHIDs(array $package_ids)
{
if (!$package_ids) {
return array();
}
$owners = id(new PhabricatorOwnersOwner())->loadAllWhere('packageID IN (%Ls)', $package_ids);
$type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
$user_phids = array();
$project_phids = array();
foreach ($owners as $owner) {
$owner_phid = $owner->getUserPHID();
switch (phid_get_type($owner_phid)) {
case PhabricatorPeopleUserPHIDType::TYPECONST:
$user_phids[] = $owner_phid;
break;
case PhabricatorProjectProjectPHIDType::TYPECONST:
$project_phids[] = $owner_phid;
break;
}
}
if ($project_phids) {
$projects = id(new PhabricatorProjectQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($project_phids)->needMembers(true)->execute();
foreach ($projects as $project) {
foreach ($project->getMemberPHIDs() as $member_phid) {
$user_phids[] = $member_phid;
}
}
}
$user_phids = array_fuse($user_phids);
return array_values($user_phids);
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:32,代码来源:PhabricatorOwnersOwner.php
示例6: execute
public function execute()
{
$phids = array_fuse($this->phids);
$actors = array();
$type_map = array();
foreach ($phids as $phid) {
$type_map[phid_get_type($phid)][] = $phid;
}
// TODO: Generalize this somewhere else.
$results = array();
foreach ($type_map as $type => $phids) {
switch ($type) {
case PhabricatorProjectProjectPHIDType::TYPECONST:
// NOTE: We're loading the projects here in order to respect policies.
$projects = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withPHIDs($phids)->execute();
$subscribers = id(new PhabricatorSubscribersQuery())->withObjectPHIDs($phids)->execute();
$projects = mpull($projects, null, 'getPHID');
foreach ($phids as $phid) {
$project = idx($projects, $phid);
if (!$project) {
$results[$phid] = array();
} else {
$results[$phid] = idx($subscribers, $phid, array());
}
}
break;
default:
break;
}
}
return $results;
}
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:PhabricatorMetaMTAMemberQuery.php
示例7: getValueFromRequest
protected function getValueFromRequest(AphrontRequest $request, $key)
{
$list = $this->getListFromRequest($request, $key);
$phids = array();
$slugs = array();
$project_type = PhabricatorProjectProjectPHIDType::TYPECONST;
foreach ($list as $item) {
$type = phid_get_type($item);
if ($type == $project_type) {
$phids[] = $item;
} else {
if (PhabricatorTypeaheadDatasource::isFunctionToken($item)) {
// If this is a function, pass it through unchanged; we'll evaluate
// it later.
$phids[] = $item;
} else {
$slugs[] = $item;
}
}
}
if ($slugs) {
$projects = id(new PhabricatorProjectQuery())->setViewer($this->requireViewer())->withSlugs($slugs)->execute();
foreach ($projects as $project) {
$phids[] = $project->getPHID();
}
$phids = array_unique($phids);
}
return $phids;
}
开发者ID:patelhardik,项目名称:phabricator,代码行数:29,代码来源:PhabricatorProjectSearchField.php
示例8: execute
public function execute()
{
$phids = array_fuse($this->phids);
$actors = array();
$type_map = array();
foreach ($phids as $phid) {
$type_map[phid_get_type($phid)][] = $phid;
$actors[$phid] = id(new PhabricatorMetaMTAActor())->setPHID($phid);
}
// TODO: Move this to PhabricatorPHIDType, or the objects, or some
// interface.
foreach ($type_map as $type => $phids) {
switch ($type) {
case PhabricatorPeopleUserPHIDType::TYPECONST:
$this->loadUserActors($actors, $phids);
break;
case PhabricatorPeopleExternalPHIDType::TYPECONST:
$this->loadExternalUserActors($actors, $phids);
break;
default:
$this->loadUnknownActors($actors, $phids);
break;
}
}
return $actors;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorMetaMTAActorQuery.php
示例9: loadPropertyObject
protected function loadPropertyObject()
{
$viewer = $this->getViewer();
$request = $this->getRequest();
$object_phid = $request->getStr('objectPHID');
switch (phid_get_type($object_phid)) {
case AlmanacBindingPHIDType::TYPECONST:
$query = new AlmanacBindingQuery();
break;
case AlmanacDevicePHIDType::TYPECONST:
$query = new AlmanacDeviceQuery();
break;
case AlmanacServicePHIDType::TYPECONST:
$query = new AlmanacServiceQuery();
break;
default:
return new Aphront404Response();
}
$object = $query->setViewer($viewer)->withPHIDs(array($object_phid))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needProperties(true)->executeOne();
if (!$object) {
return new Aphront404Response();
}
if (!$object instanceof AlmanacPropertyInterface) {
return new Aphront404Response();
}
$this->propertyObject = $object;
return null;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:28,代码来源:AlmanacPropertyController.php
示例10: withIdentifiers
public function withIdentifiers(array $identifiers)
{
$identifiers = array_fuse($identifiers);
$ids = array();
$callsigns = array();
$phids = array();
$monograms = array();
$slugs = array();
foreach ($identifiers as $identifier) {
if (ctype_digit((string) $identifier)) {
$ids[$identifier] = $identifier;
continue;
}
if (preg_match('/^(r[A-Z]+|R[1-9]\\d*)\\z/', $identifier)) {
$monograms[$identifier] = $identifier;
continue;
}
$repository_type = PhabricatorRepositoryRepositoryPHIDType::TYPECONST;
if (phid_get_type($identifier) === $repository_type) {
$phids[$identifier] = $identifier;
continue;
}
if (preg_match('/^[A-Z]+\\z/', $identifier)) {
$callsigns[$identifier] = $identifier;
continue;
}
$slugs[$identifier] = $identifier;
}
$this->numericIdentifiers = $ids;
$this->callsignIdentifiers = $callsigns;
$this->phidIdentifiers = $phids;
$this->monogramIdentifiers = $monograms;
$this->slugIdentifiers = $slugs;
return $this;
}
开发者ID:truSense,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRepositoryQuery.php
示例11: resolvePHIDs
private function resolvePHIDs(array $phids)
{
// If we have a function like `projects(alincoln)`, try to resolve the
// username first. This won't happen normally, but can be passed in from
// the query string.
// The user might also give us an invalid username. In this case, we
// preserve it and return it in-place so we get an "invalid" token rendered
// in the UI. This shows the user where the issue is and best represents
// the user's input.
$usernames = array();
foreach ($phids as $key => $phid) {
if (phid_get_type($phid) != PhabricatorPeopleUserPHIDType::TYPECONST) {
$usernames[$key] = $phid;
}
}
if ($usernames) {
$users = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames($usernames)->execute();
$users = mpull($users, null, 'getUsername');
foreach ($usernames as $key => $username) {
$user = idx($users, $username);
if ($user) {
$phids[$key] = $user->getPHID();
}
}
}
return $phids;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:27,代码来源:PhabricatorProjectLogicalUserDatasource.php
示例12: getUsersFromRequest
protected function getUsersFromRequest(AphrontRequest $request, $key, array $allow_types = array())
{
$list = $this->getListFromRequest($request, $key);
$phids = array();
$names = array();
$allow_types = array_fuse($allow_types);
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
foreach ($list as $item) {
$type = phid_get_type($item);
if ($type == $user_type) {
$phids[] = $item;
} else {
if (isset($allow_types[$type])) {
$phids[] = $item;
} else {
if (PhabricatorTypeaheadDatasource::isFunctionToken($item)) {
// If this is a function, pass it through unchanged; we'll evaluate
// it later.
$phids[] = $item;
} else {
$names[] = $item;
}
}
}
}
if ($names) {
$users = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames($names)->execute();
foreach ($users as $user) {
$phids[] = $user->getPHID();
}
$phids = array_unique($phids);
}
return $phids;
}
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhabricatorSearchTokenizerField.php
示例13: loadITem
protected function loadITem(PhutilArgumentParser $argv, $key)
{
$item = $argv->getArg($key);
if (!strlen($item)) {
throw new PhutilArgumentUsageException(pht('Specify a item with %s.', '--' . $key));
}
$query = id(new NuanceItemQuery())->setViewer($this->getViewer())->setRaisePolicyExceptions(true);
$type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
if (ctype_digit($item)) {
$kind = 'id';
$query->withIDs(array($item));
} else {
if (phid_get_type($item) !== $type_unknown) {
$kind = 'phid';
$query->withPHIDs($item);
} else {
throw new PhutilArgumentUsageException(pht('Specify the ID or PHID of an item to update. Parameter "%s" ' . 'is not an ID or PHID.', $item));
}
}
$items = $query->execute();
if (!$items) {
switch ($kind) {
case 'id':
$message = pht('No item exists with ID "%s".', $item);
break;
case 'phid':
$message = pht('No item exists with PHID "%s".', $item);
break;
}
throw new PhutilArgumentUsageException($message);
}
return head($items);
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:33,代码来源:NuanceManagementWorkflow.php
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$phid = $request->getURIData('phid');
$action = $request->getURIData('action');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
switch ($action) {
case 'add':
$is_add = true;
break;
case 'delete':
$is_add = false;
break;
default:
return new Aphront400Response();
}
$handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
if (phid_get_type($phid) == PhabricatorProjectProjectPHIDType::TYPECONST) {
// TODO: This is a big hack, but a weak argument for adding some kind
// of "load for role" feature to ObjectQuery, and also not a really great
// argument for adding some kind of "load extra stuff" feature to
// SubscriberInterface. Do this for now and wait for the best way forward
// to become more clear?
$object = id(new PhabricatorProjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->needWatchers(true)->executeOne();
} else {
$object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
}
if (!$object instanceof PhabricatorSubscribableInterface) {
return $this->buildErrorResponse(pht('Bad Object'), pht('This object is not subscribable.'), $handle->getURI());
}
if ($object->isAutomaticallySubscribed($viewer->getPHID())) {
return $this->buildErrorResponse(pht('Automatically Subscribed'), pht('You are automatically subscribed to this object.'), $handle->getURI());
}
if ($object instanceof PhabricatorApplicationTransactionInterface) {
if ($is_add) {
$xaction_value = array('+' => array($viewer->getPHID()));
} else {
$xaction_value = array('-' => array($viewer->getPHID()));
}
$xaction = id($object->getApplicationTransactionTemplate())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue($xaction_value);
$editor = id($object->getApplicationTransactionEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request);
$editor->applyTransactions($object->getApplicationTransactionObject(), array($xaction));
} else {
// TODO: Eventually, get rid of this once everything implements
// PhabriatorApplicationTransactionInterface.
$editor = id(new PhabricatorSubscriptionsEditor())->setActor($viewer)->setObject($object);
if ($is_add) {
$editor->subscribeExplicit(array($viewer->getPHID()), $explicit = true);
} else {
$editor->unsubscribe(array($viewer->getPHID()));
}
$editor->save();
}
// TODO: We should just render the "Unsubscribe" action and swap it out
// in the document for Ajax requests.
return id(new AphrontReloadResponse())->setURI($handle->getURI());
}
开发者ID:truSense,项目名称:phabricator,代码行数:59,代码来源:PhabricatorSubscriptionsEditController.php
示例15: getAttachmentForObject
public function getAttachmentForObject($object, $data, $spec)
{
$uris = array();
foreach ($object->getURIs() as $uri) {
$uris[] = array('id' => $uri->getID(), 'type' => phid_get_type($uri->getPHID()), 'phid' => $uri->getPHID(), 'fields' => $uri->getFieldValuesForConduit());
}
return array('uris' => $uris);
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:8,代码来源:DiffusionRepositoryURIsSearchEngineAttachment.php
示例16: phid_group_by_type
/**
* Group a list of phids by type.
*
* @param phids array of phids
* @return map of phid type => list of phids
*/
function phid_group_by_type($phids)
{
$result = array();
foreach ($phids as $phid) {
$type = phid_get_type($phid);
$result[$type][] = $phid;
}
return $result;
}
开发者ID:pugong,项目名称:phabricator,代码行数:15,代码来源:utils.php
示例17: computeRawFactsForObject
public function computeRawFactsForObject(PhabricatorLiskDAO $object)
{
$facts = array();
$phid = $object->getPHID();
$type = phid_get_type($phid);
foreach (array('N:*', 'N:' . $type) as $fact_type) {
$facts[] = id(new PhabricatorFactRaw())->setFactType($fact_type)->setObjectPHID($phid)->setValueX(1)->setEpoch($object->getDateCreated());
}
return $facts;
}
开发者ID:pugong,项目名称:phabricator,代码行数:10,代码来源:PhabricatorFactCountEngine.php
示例18: loadObjects
public function loadObjects()
{
$types = array();
foreach ($this->phids as $phid) {
$type = phid_get_type($phid);
$types[$type][] = $phid;
}
$objects = array();
foreach ($types as $type => $phids) {
switch ($type) {
case PhabricatorPHIDConstants::PHID_TYPE_USER:
$user_dao = new PhabricatorUser();
$users = $user_dao->loadAllWhere('phid in (%Ls)', $phids);
foreach ($users as $user) {
$objects[$user->getPHID()] = $user;
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_CMIT:
$commit_dao = new PhabricatorRepositoryCommit();
$commits = $commit_dao->loadAllWhere('phid IN (%Ls)', $phids);
$commit_data = array();
if ($commits) {
$data_dao = new PhabricatorRepositoryCommitData();
$commit_data = $data_dao->loadAllWhere('commitID IN (%Ld)', mpull($commits, 'getID'));
$commit_data = mpull($commit_data, null, 'getCommitID');
}
foreach ($commits as $commit) {
$data = idx($commit_data, $commit->getID());
if ($data) {
$commit->attachCommitData($data);
$objects[$commit->getPHID()] = $commit;
} else {
// If we couldn't load the commit data, just act as though we
// couldn't load the object at all so we don't load half an object.
}
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_TASK:
$task_dao = new ManiphestTask();
$tasks = $task_dao->loadAllWhere('phid IN (%Ls)', $phids);
foreach ($tasks as $task) {
$objects[$task->getPHID()] = $task;
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_DREV:
$revision_dao = new DifferentialRevision();
$revisions = $revision_dao->loadAllWhere('phid IN (%Ls)', $phids);
foreach ($revisions as $revision) {
$objects[$revision->getPHID()] = $revision;
}
break;
}
}
return $objects;
}
开发者ID:nexeck,项目名称:phabricator,代码行数:55,代码来源:PhabricatorObjectHandleData.php
示例19: handleEvent
public function handleEvent(PhutilEvent $event)
{
$phid = $event->getValue('phid');
$type = phid_get_type($phid);
// For now, we only index projects.
if ($type != PhabricatorProjectProjectPHIDType::TYPECONST) {
return;
}
$document = $event->getValue('document');
ManiphestNameIndex::updateIndex($phid, $document->getDocumentTitle());
}
开发者ID:patelhardik,项目名称:phabricator,代码行数:11,代码来源:ManiphestNameIndexEventListener.php
示例20: applyEffect
public function applyEffect($object, HeraldEffect $effect)
{
$phid = $this->getAdapter()->getPHID();
$rule = $effect->getRule();
$author = $rule->getAuthor();
$flag = PhabricatorFlagQuery::loadUserFlag($author, $phid);
if ($flag) {
$this->logEffect(self::DO_IGNORE, $flag->getColor());
return;
}
$flag = id(new PhabricatorFlag())->setOwnerPHID($author->getPHID())->setType(phid_get_type($phid))->setObjectPHID($phid)->setReasonPHID($rule->getPHID())->setColor($effect->getTarget())->setNote('')->save();
$this->logEffect(self::DO_FLAG, $flag->getColor());
}
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhabricatorFlagAddFlagHeraldAction.php
注:本文中的phid_get_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论