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


PHP PhabricatorCustomField::buildFieldList方法代码示例

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


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

示例1: getObjectFields

 /**
  * @task apps
  */
 public static function getObjectFields(PhabricatorCustomFieldInterface $object, $role)
 {
     try {
         $attachment = $object->getCustomFields();
     } catch (PhabricatorDataNotAttachedException $ex) {
         $attachment = new PhabricatorCustomFieldAttachment();
         $object->attachCustomFields($attachment);
     }
     try {
         $field_list = $attachment->getCustomFieldList($role);
     } catch (PhabricatorCustomFieldNotAttachedException $ex) {
         $base_class = $object->getCustomFieldBaseClass();
         $spec = $object->getCustomFieldSpecificationForRole($role);
         if (!is_array($spec)) {
             $obj_class = get_class($object);
             throw new Exception("Expected an array from getCustomFieldSpecificationForRole() for " . "object of class '{$obj_class}'.");
         }
         $fields = PhabricatorCustomField::buildFieldList($base_class, $spec, $object);
         foreach ($fields as $key => $field) {
             if (!$field->shouldEnableForRole($role)) {
                 unset($fields[$key]);
             }
         }
         foreach ($fields as $field) {
             $field->setObject($object);
         }
         $field_list = new PhabricatorCustomFieldList($fields);
         $attachment->addCustomFieldList($role, $field_list);
     }
     return $field_list;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:34,代码来源:PhabricatorCustomField.php

示例2: renderControl

 public function renderControl(PhabricatorConfigOption $option, $display_value, $e_value)
 {
     $field_base_class = $option->getCustomData();
     $field_spec = $display_value;
     if (!is_array($field_spec)) {
         $field_spec = PhabricatorEnv::getEnvConfig($option->getKey());
     }
     // Get all of the fields (including disabled fields) by querying for them
     // with a faux spec where no fields are disabled.
     $faux_spec = $field_spec;
     foreach ($faux_spec as $key => $spec) {
         unset($faux_spec[$key]['disabled']);
     }
     // TODO: We might need to build a real object here eventually.
     $faux_object = null;
     $fields = PhabricatorCustomField::buildFieldList($field_base_class, $faux_spec, $faux_object);
     $list_id = celerity_generate_unique_node_id();
     $input_id = celerity_generate_unique_node_id();
     $list = id(new PHUIObjectItemListView())->setFlush(true)->setID($list_id);
     foreach ($fields as $key => $field) {
         $item = id(new PHUIObjectItemView())->addSigil('field-spec')->setMetadata(array('fieldKey' => $key))->setGrippable(true)->addAttribute($field->getFieldDescription())->setHeader($field->getFieldName());
         $is_disabled = !empty($field_spec[$key]['disabled']);
         $disabled_item = clone $item;
         $enabled_item = clone $item;
         if ($is_disabled) {
             $list->addItem($disabled_item);
         } else {
             $list->addItem($enabled_item);
         }
         $disabled_item->addIcon('none', pht('Disabled'));
         $disabled_item->setDisabled(true);
         $disabled_item->addAction(id(new PHUIListItemView())->setHref('#')->addSigil('field-spec-toggle')->setIcon('fa-plus'));
         $enabled_item->setBarColor('green');
         if (!$field->canDisableField()) {
             $enabled_item->addAction(id(new PHUIListItemView())->setIcon('fa-lock grey'));
             $enabled_item->addIcon('none', pht('Permanent Field'));
         } else {
             $enabled_item->addAction(id(new PHUIListItemView())->setHref('#')->addSigil('field-spec-toggle')->setIcon('fa-times'));
         }
         $fields[$key] = array('disabled' => $is_disabled, 'disabledMarkup' => $disabled_item->render(), 'enabledMarkup' => $enabled_item->render());
     }
     $input = phutil_tag('input', array('id' => $input_id, 'type' => 'hidden', 'name' => 'value', 'value' => json_encode($display_value)));
     Javelin::initBehavior('config-reorder-fields', array('listID' => $list_id, 'inputID' => $input_id, 'fields' => $fields));
     return id(new AphrontFormMarkupControl())->setLabel(pht('Value'))->setError($e_value)->setValue(array($list, $input));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:45,代码来源:PhabricatorCustomFieldConfigOptionType.php


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