当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorContentSource::getSourceNameMap方法代码示例

本文整理汇总了PHP中PhabricatorContentSource::getSourceNameMap方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorContentSource::getSourceNameMap方法的具体用法?PHP PhabricatorContentSource::getSourceNameMap怎么用?PHP PhabricatorContentSource::getSourceNameMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorContentSource的用法示例。


在下文中一共展示了PhabricatorContentSource::getSourceNameMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render()
 {
     require_celerity_resource('phabricator-content-source-view-css');
     $map = PhabricatorContentSource::getSourceNameMap();
     $source = $this->contentSource->getSource();
     $type = idx($map, $source, null);
     if (!$type) {
         return null;
     }
     return phutil_tag('span', array('class' => 'phabricator-content-source-view'), pht('Via %s', $type));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:11,代码来源:PhabricatorContentSourceView.php

示例2: setupEditorBehavior

 private function setupEditorBehavior(HeraldRule $rule, array $handles, HeraldAdapter $adapter)
 {
     $serial_conditions = array(array('default', 'default', ''));
     if ($rule->getConditions()) {
         $serial_conditions = array();
         foreach ($rule->getConditions() as $condition) {
             $value = $adapter->getEditorValueForCondition($this->getViewer(), $condition, $handles);
             $serial_conditions[] = array($condition->getFieldName(), $condition->getFieldCondition(), $value);
         }
     }
     $serial_actions = array(array('default', ''));
     if ($rule->getActions()) {
         $serial_actions = array();
         foreach ($rule->getActions() as $action) {
             switch ($action->getAction()) {
                 case HeraldAdapter::ACTION_FLAG:
                 case HeraldAdapter::ACTION_BLOCK:
                     $current_value = $action->getTarget();
                     break;
                 default:
                     if (is_array($action->getTarget())) {
                         $target_map = array();
                         foreach ((array) $action->getTarget() as $fbid) {
                             $target_map[$fbid] = $handles[$fbid]->getName();
                         }
                         $current_value = $target_map;
                     } else {
                         $current_value = $action->getTarget();
                     }
                     break;
             }
             $serial_actions[] = array($action->getAction(), $current_value);
         }
     }
     $all_rules = $this->loadRulesThisRuleMayDependUpon($rule);
     $all_rules = mpull($all_rules, 'getName', 'getPHID');
     asort($all_rules);
     $all_fields = $adapter->getFieldNameMap();
     $all_conditions = $adapter->getConditionNameMap();
     $all_actions = $adapter->getActionNameMap($rule->getRuleType());
     $fields = $adapter->getFields();
     $field_map = array_select_keys($all_fields, $fields);
     // Populate any fields which exist in the rule but which we don't know the
     // names of, so that saving a rule without touching anything doesn't change
     // it.
     foreach ($rule->getConditions() as $condition) {
         $field_name = $condition->getFieldName();
         if (empty($field_map[$field_name])) {
             $field_map[$field_name] = pht('<Unknown Field "%s">', $field_name);
         }
     }
     $actions = $adapter->getActions($rule->getRuleType());
     $action_map = array_select_keys($all_actions, $actions);
     // Populate any actions which exist in the rule but which we don't know the
     // names of, so that saving a rule without touching anything doesn't change
     // it.
     foreach ($rule->getActions() as $action) {
         $action_name = $action->getAction();
         if (empty($action_map[$action_name])) {
             $action_map[$action_name] = pht('<Unknown Action "%s">', $action_name);
         }
     }
     $config_info = array();
     $config_info['fields'] = $field_map;
     $config_info['conditions'] = $all_conditions;
     $config_info['actions'] = $action_map;
     foreach ($config_info['fields'] as $field => $name) {
         try {
             $field_conditions = $adapter->getConditionsForField($field);
         } catch (Exception $ex) {
             $field_conditions = array(HeraldAdapter::CONDITION_UNCONDITIONALLY);
         }
         $config_info['conditionMap'][$field] = $field_conditions;
     }
     foreach ($config_info['fields'] as $field => $fname) {
         foreach ($config_info['conditionMap'][$field] as $condition) {
             $value_type = $adapter->getValueTypeForFieldAndCondition($field, $condition);
             $config_info['values'][$field][$condition] = $value_type;
         }
     }
     $config_info['rule_type'] = $rule->getRuleType();
     foreach ($config_info['actions'] as $action => $name) {
         try {
             $action_value = $adapter->getValueTypeForAction($action, $rule->getRuleType());
         } catch (Exception $ex) {
             $action_value = array(HeraldAdapter::VALUE_NONE);
         }
         $config_info['targets'][$action] = $action_value;
     }
     $changeflag_options = PhabricatorRepositoryPushLog::getHeraldChangeFlagConditionOptions();
     Javelin::initBehavior('herald-rule-editor', array('root' => 'herald-rule-edit-form', 'conditions' => (object) $serial_conditions, 'actions' => (object) $serial_actions, 'select' => array(HeraldAdapter::VALUE_CONTENT_SOURCE => array('options' => PhabricatorContentSource::getSourceNameMap(), 'default' => PhabricatorContentSource::SOURCE_WEB), HeraldAdapter::VALUE_FLAG_COLOR => array('options' => PhabricatorFlagColor::getColorNameMap(), 'default' => PhabricatorFlagColor::COLOR_BLUE), HeraldPreCommitRefAdapter::VALUE_REF_TYPE => array('options' => array(PhabricatorRepositoryPushLog::REFTYPE_BRANCH => pht('branch (git/hg)'), PhabricatorRepositoryPushLog::REFTYPE_TAG => pht('tag (git)'), PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK => pht('bookmark (hg)')), 'default' => PhabricatorRepositoryPushLog::REFTYPE_BRANCH), HeraldPreCommitRefAdapter::VALUE_REF_CHANGE => array('options' => $changeflag_options, 'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD)), 'template' => $this->buildTokenizerTemplates($handles) + array('rules' => $all_rules), 'author' => array($rule->getAuthorPHID() => $handles[$rule->getAuthorPHID()]->getName()), 'info' => $config_info));
 }
开发者ID:ThomasWo,项目名称:phabricator,代码行数:92,代码来源:HeraldRuleController.php

示例3: getHeraldFieldValueType

 public function getHeraldFieldValueType($condition)
 {
     $map = PhabricatorContentSource::getSourceNameMap();
     asort($map);
     return id(new HeraldSelectFieldValue())->setKey(self::FIELDCONST)->setDefault(PhabricatorContentSource::SOURCE_WEB)->setOptions($map);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:6,代码来源:HeraldContentSourceField.php


注:本文中的PhabricatorContentSource::getSourceNameMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。