本文整理汇总了PHP中mfilter函数的典型用法代码示例。如果您正苦于以下问题:PHP mfilter函数的具体用法?PHP mfilter怎么用?PHP mfilter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mfilter函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(ConduitAPIRequest $request)
{
$arc_project_name = $request->getValue('arcProjectName');
if ($arc_project_name) {
$arc_project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $arc_project_name);
if (!$arc_project) {
throw id(new ConduitException('ERR_UNKNOWN_ARC'))->setErrorDescription("Unknown Arcanist project '{$arc_project_name}': " . "are you using the correct Conduit URI?");
}
$releeph_projects = id(new ReleephProject())->loadAllWhere('arcanistProjectID = %d', $arc_project->getID());
} else {
$releeph_projects = id(new ReleephProject())->loadAll();
}
$releeph_projects = mfilter($releeph_projects, 'getIsActive');
$result = array();
foreach ($releeph_projects as $releeph_project) {
$selector = $releeph_project->getReleephFieldSelector();
$fields = $selector->getFieldSpecifications();
$fields_info = array();
foreach ($fields as $field) {
$field->setReleephProject($releeph_project);
if ($field->isEditable()) {
$key = $field->getKeyForConduit();
$fields_info[$key] = array('class' => get_class($field), 'name' => $field->getName(), 'key' => $key, 'arcHelp' => $field->renderHelpForArcanist());
}
}
$releeph_branches = mfilter(id(new ReleephBranch())->loadAllWhere('releephProjectID = %d', $releeph_project->getID()), 'getIsActive');
$releeph_branches_struct = array();
foreach ($releeph_branches as $branch) {
$releeph_branches_struct[] = array('branchName' => $branch->getName(), 'projectName' => $releeph_project->getName(), 'projectPHID' => $releeph_project->getPHID(), 'branchPHID' => $branch->getPHID());
}
$result[] = array('projectName' => $releeph_project->getName(), 'projectPHID' => $releeph_project->getPHID(), 'branches' => $releeph_branches_struct, 'fields' => $fields_info);
}
return $result;
}
示例2: renderEditControl
public function renderEditControl(array $handles)
{
$engines = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorApplicationSearchEngine')->loadObjects();
$engines = mfilter($engines, 'canUseInPanelContext');
$value = $this->getFieldValue();
$queries = array();
$seen = false;
foreach ($engines as $engine_class => $engine) {
$engine->setViewer($this->getViewer());
$engine_queries = $engine->loadEnabledNamedQueries();
$query_map = mpull($engine_queries, 'getQueryName', 'getQueryKey');
asort($query_map);
foreach ($query_map as $key => $name) {
$queries[$engine_class][] = array('key' => $key, 'name' => $name);
if ($key == $value) {
$seen = true;
}
}
}
if (strlen($value) && !$seen) {
$name = pht('Custom Query ("%s")', $value);
} else {
$name = pht('(None)');
}
$options = array($value => $name);
$app_control_key = $this->getFieldConfigValue('control.application');
Javelin::initBehavior('dashboard-query-panel-select', array('applicationID' => $this->getFieldControlID($app_control_key), 'queryID' => $this->getFieldControlID(), 'options' => $queries, 'value' => array('key' => strlen($value) ? $value : null, 'name' => $name)));
return id(new AphrontFormSelectControl())->setID($this->getFieldControlID())->setLabel($this->getFieldName())->setCaption($this->getCaption())->setName($this->getFieldKey())->setValue($this->getFieldValue())->setOptions($options);
}
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:29,代码来源:PhabricatorDashboardPanelSearchQueryCustomField.php
示例3: loadArcProjects
private function loadArcProjects()
{
$viewer = $this->getRequest()->getUser();
$projects = id(new PhabricatorRepositoryArcanistProjectQuery())->setViewer($viewer)->needRepositories(true)->execute();
$projects = mfilter($projects, 'getRepository');
$projects = msort($projects, 'getName');
return $projects;
}
示例4: testMFilterWithEmptyValueNegateFiltered
public function testMFilterWithEmptyValueNegateFiltered()
{
$a = new MFilterTestHelper('o', 'p', 'q');
$b = new MFilterTestHelper('o', '', 'q');
$c = new MFilterTestHelper('o', 'p', 'q');
$list = ['a' => $a, 'b' => $b, 'c' => $c];
$actual = mfilter($list, 'getI', true);
$expected = ['b' => $b];
$this->assertEquals($expected, $actual);
}
示例5: renderEditControl
public function renderEditControl(array $handles)
{
$engines = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorApplicationSearchEngine')->loadObjects();
$engines = mfilter($engines, 'canUseInPanelContext');
$all_apps = id(new PhabricatorApplicationQuery())->setViewer($this->getViewer())->withUnlisted(false)->withInstalled(true)->execute();
foreach ($engines as $index => $engine) {
if (!isset($all_apps[$engine->getApplicationClassName()])) {
unset($engines[$index]);
continue;
}
}
$options = array();
$value = $this->getFieldValue();
if (strlen($value) && empty($engines[$value])) {
$options[$value] = $value;
}
$engines = msort($engines, 'getResultTypeDescription');
foreach ($engines as $class_name => $engine) {
$options[$class_name] = $engine->getResultTypeDescription();
}
return id(new AphrontFormSelectControl())->setID($this->getFieldControlID())->setLabel($this->getFieldName())->setCaption($this->getCaption())->setName($this->getFieldKey())->setValue($this->getFieldValue())->setOptions($options);
}
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:22,代码来源:PhabricatorDashboardPanelSearchApplicationCustomField.php
示例6: publishFeedStory
/**
* @task feed
*/
protected function publishFeedStory(PhabricatorLiskDAO $object, array $xactions, array $mailed_phids)
{
$xactions = mfilter($xactions, 'shouldHideForFeed', true);
if (!$xactions) {
return;
}
$related_phids = $this->getFeedRelatedPHIDs($object, $xactions);
$subscribed_phids = $this->getFeedNotifyPHIDs($object, $xactions);
$story_type = $this->getFeedStoryType();
$story_data = $this->getFeedStoryData($object, $xactions);
id(new PhabricatorFeedStoryPublisher())->setStoryType($story_type)->setStoryData($story_data)->setStoryTime(time())->setStoryAuthorPHID($this->getActingAsPHID())->setRelatedPHIDs($related_phids)->setPrimaryObjectPHID($object->getPHID())->setSubscribedPHIDs($subscribed_phids)->setMailRecipientPHIDs($mailed_phids)->setMailTags($this->getMailTags($object, $xactions))->publish();
}
示例7: loadMap
/**
* Generate the core query results.
*
* This method is used to fill the cache.
*
* @return map<string, object> Realized class map.
* @task exec
*/
private function loadMap()
{
$ancestor = $this->ancestorClass;
if (!strlen($ancestor)) {
throw new PhutilInvalidStateException('setAncestorClass');
}
if (!class_exists($ancestor) && !interface_exists($ancestor)) {
throw new Exception(pht('Trying to execute a class map query for descendants of class ' . '"%s", but no such class or interface exists.', $ancestor));
}
$expand = $this->expandMethod;
$filter = $this->filterMethod;
$unique = $this->uniqueMethod;
$sort = $this->sortMethod;
if (strlen($expand)) {
if (!strlen($unique)) {
throw new Exception(pht('Trying to execute a class map query for descendants of class ' . '"%s", but the query specifies an "expand method" ("%s") without ' . 'specifying a "unique method". Class maps which support expansion ' . 'must have unique keys.', $ancestor, $expand));
}
}
$objects = id(new PhutilSymbolLoader())->setAncestorClass($ancestor)->loadObjects();
// Apply the "expand" mechanism, if it is configured.
if (strlen($expand)) {
$list = array();
foreach ($objects as $object) {
foreach (call_user_func(array($object, $expand)) as $instance) {
$list[] = $instance;
}
}
} else {
$list = $objects;
}
// Apply the "unique" mechanism, if it is configured.
if (strlen($unique)) {
$map = array();
foreach ($list as $object) {
$key = call_user_func(array($object, $unique));
if ($key === null && $this->filterNull) {
continue;
}
if (empty($map[$key])) {
$map[$key] = $object;
continue;
}
throw new Exception(pht('Two objects (of classes "%s" and "%s", descendants of ancestor ' . 'class "%s") returned the same key from "%s" ("%s"), but each ' . 'object in this class map must be identified by a unique key.', get_class($object), get_class($map[$key]), $ancestor, $unique . '()', $key));
}
} else {
$map = $list;
}
// Apply the "filter" mechanism, if it is configured.
if (strlen($filter)) {
$map = mfilter($map, $filter);
}
// Apply the "sort" mechanism, if it is configured.
if (strlen($sort)) {
$map = msort($map, $sort);
}
return $map;
}
示例8: loadImages
private function loadImages(array $mocks)
{
assert_instances_of($mocks, 'PholioMock');
$mock_map = mpull($mocks, null, 'getID');
$all_images = id(new PholioImageQuery())->setViewer($this->getViewer())->setMockCache($mock_map)->withMockIDs(array_keys($mock_map))->needInlineComments($this->needInlineComments)->execute();
$image_groups = mgroup($all_images, 'getMockID');
foreach ($mocks as $mock) {
$mock_images = idx($image_groups, $mock->getID(), array());
$mock->attachAllImages($mock_images);
$active_images = mfilter($mock_images, 'getIsObsolete', true);
$mock->attachImages(msort($active_images, 'getSequence'));
}
}
示例9: shouldSendMail
protected function shouldSendMail(PhabricatorLiskDAO $object, array $xactions)
{
// Avoid sending emails that only talk about commit discovery.
$types = array_unique(mpull($xactions, 'getTransactionType'));
if ($types === array(ReleephRequestTransaction::TYPE_DISCOVERY)) {
return false;
}
// Don't email people when we discover that something picks or reverts OK.
if ($types === array(ReleephRequestTransaction::TYPE_PICK_STATUS)) {
if (!mfilter($xactions, 'isBoringPickStatus', true)) {
// If we effectively call "isInterestingPickStatus" and get nothing...
return false;
}
}
return true;
}
示例10: shouldSendMail
protected function shouldSendMail(PhabricatorLiskDAO $object, array $xactions)
{
$xactions = mfilter($xactions, 'shouldHide', true);
return $xactions;
}