當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PHUIPropertyListView::invokeWillRenderEvent方法代碼示例

本文整理匯總了PHP中PHUIPropertyListView::invokeWillRenderEvent方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHUIPropertyListView::invokeWillRenderEvent方法的具體用法?PHP PHUIPropertyListView::invokeWillRenderEvent怎麽用?PHP PHUIPropertyListView::invokeWillRenderEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PHUIPropertyListView的用法示例。


在下文中一共展示了PHUIPropertyListView::invokeWillRenderEvent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: appendFieldsToPropertyList

 public function appendFieldsToPropertyList(PhabricatorCustomFieldInterface $object, PhabricatorUser $viewer, PHUIPropertyListView $view)
 {
     $this->readFieldsFromStorage($object);
     $fields = $this->fields;
     foreach ($fields as $field) {
         $field->setViewer($viewer);
     }
     // Move all the blocks to the end, regardless of their configuration order,
     // because it always looks silly to render a block in the middle of a list
     // of properties.
     $head = array();
     $tail = array();
     foreach ($fields as $key => $field) {
         $style = $field->getStyleForPropertyView();
         switch ($style) {
             case 'property':
             case 'header':
                 $head[$key] = $field;
                 break;
             case 'block':
                 $tail[$key] = $field;
                 break;
             default:
                 throw new Exception(pht("Unknown field property view style '%s'; valid styles are " . "'%s' and '%s'.", $style, 'block', 'property'));
         }
     }
     $fields = $head + $tail;
     $add_header = null;
     $phids = array();
     foreach ($fields as $key => $field) {
         $phids[$key] = $field->getRequiredHandlePHIDsForPropertyView();
     }
     $all_phids = array_mergev($phids);
     if ($all_phids) {
         $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($all_phids)->execute();
     } else {
         $handles = array();
     }
     foreach ($fields as $key => $field) {
         $field_handles = array_select_keys($handles, $phids[$key]);
         $label = $field->renderPropertyViewLabel();
         $value = $field->renderPropertyViewValue($field_handles);
         if ($value !== null) {
             switch ($field->getStyleForPropertyView()) {
                 case 'header':
                     // We want to hide headers if the fields the're assciated with
                     // don't actually produce any visible properties. For example, in a
                     // list like this:
                     //
                     //   Header A
                     //   Prop A: Value A
                     //   Header B
                     //   Prop B: Value B
                     //
                     // ...if the "Prop A" field returns `null` when rendering its
                     // property value and we rendered naively, we'd get this:
                     //
                     //   Header A
                     //   Header B
                     //   Prop B: Value B
                     //
                     // This is silly. Instead, we hide "Header A".
                     $add_header = $value;
                     break;
                 case 'property':
                     if ($add_header !== null) {
                         // Add the most recently seen header.
                         $view->addSectionHeader($add_header);
                         $add_header = null;
                     }
                     $view->addProperty($label, $value);
                     break;
                 case 'block':
                     $icon = $field->getIconForPropertyView();
                     $view->invokeWillRenderEvent();
                     if ($label !== null) {
                         $view->addSectionHeader($label, $icon);
                     }
                     $view->addTextContent($value);
                     break;
             }
         }
     }
 }
開發者ID:barcelonascience,項目名稱:phabricator,代碼行數:84,代碼來源:PhabricatorCustomFieldList.php


注:本文中的PHUIPropertyListView::invokeWillRenderEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。