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


PHP ClassInfo::subclassesfor方法代码示例

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


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

示例1: updateCMSFields

 /**
  * CMS Fields
  * @return FieldList
  */
 function updateCMSFields(FieldList $fields)
 {
     if (!Permission::check("VIEW_SECTIONS")) {
         return $fields;
     }
     $SectionGrid = GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewMultiClass())->addComponent(new GridFieldOrderableRows());
     $SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('AdminTitle'))->setResultsFormat('$AdminTitle');
     $SectionSubClasses = ClassInfo::subclassesfor('Section');
     unset($SectionSubClasses['Section'], $SectionSubClasses['MainSection']);
     foreach ($SectionSubClasses as $key => $value) {
         $SectionSubClasses[$key] = Section::Type($value);
     }
     # Limit sections based on type
     $LimitSectionTypes = Config::inst()->get($this->owner->ClassName, 'LimitSectionTypes');
     // debug::dump($LimitSectionTypes);
     if ($LimitSectionTypes) {
         foreach ($LimitSectionTypes as $type => $value) {
             if ($value == 0) {
                 unset($SectionSubClasses[$type]);
                 continue;
             }
             $CurrentSectionCount = $this->owner->Sections()->filter('ClassName', $type)->count();
             if ($CurrentSectionCount >= $value) {
                 unset($SectionSubClasses[$type]);
                 continue;
             }
         }
     }
     $SectionGrid->getComponentByType('GridFieldAddNewMultiClass')->setClasses($SectionSubClasses);
     # Limit total sections
     $LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
     // debug::dump($PageLimits);
     if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
         // remove the buttons if we don't want to allow more records to be added/created
         $SectionGrid->removeComponentsByType('GridFieldAddNewButton');
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
         $SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
     }
     if (!Permission::check("LINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
     }
     if (!Permission::check("REORDER_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldOrderableRows');
     }
     if (!Permission::check("UNLINK_SECTIONS")) {
         $SectionGrid->removeComponentsByType('GridFieldDeleteAction');
     }
     $fields->addFieldToTab('Root.Section', GridField::create('Sections', 'Current Section(s)', $this->owner->Sections(), $SectionGrid));
     $fields->addFieldToTab('Root.Preview', UploadField::create('PreviewImage', 'Preview image'));
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:coreiho-silverstripe-sections,代码行数:55,代码来源:SectionPageExtension.php

示例2: updateCMSFields

 /**
  * @return FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     $allow_page_types = $this->owner->config()->SectionIncludedPageTypes;
     $allow_page_types[] = 'SectionsPage';
     if (in_array($this->owner->ClassName, $allow_page_types)) {
         $SectionSubClasses = ClassInfo::subclassesfor('Section');
         unset($SectionSubClasses['Section']);
         foreach ($SectionSubClasses as $key => $value) {
             $SectionSubClasses[$key] = Section::NiceClass($value);
         }
         $SectionGridConfig = GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewMultiClass())->addComponent(new GridFieldOrderableRows('Sort'));
         $SectionGridConfig->getComponentByType('GridFieldAddNewMultiClass')->setClasses($SectionSubClasses);
         $fields->addFieldToTab('Root.Sections', GridField::create('Sections', 'Current Section(s)', $this->owner->Sections(), $SectionGridConfig));
     }
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:plato-creative-plato-silverstripe-sections,代码行数:19,代码来源:SectionPageExtension.php

示例3: AvailableSectionTypes

 /**
  * Lists all sections types and their settings relative to the current page type.
  * @return array
  */
 public function AvailableSectionTypes()
 {
     $AvailableTypes = ClassInfo::subclassesfor('Section');
     unset($AvailableTypes['Section']);
     # Get section options from each page type.
     $pageTypeOptions = Config::inst()->get($this->owner->ClassName, 'section_options');
     foreach ($AvailableTypes as $key => $value) {
         $Config = Config::inst();
         $selectable_option = true;
         if ($Config->get($value, 'selectable_option') !== null) {
             $selectable_option = $Config->get($value, 'selectable_option');
         }
         $AvailableTypes[$key] = array('classname' => $value, 'type' => Section::Type($value), 'presets' => $Config->get($value, 'presets'), 'selectable_option' => $selectable_option, 'limit' => $Config->get($value, 'limit'));
         if (isset($pageTypeOptions[$key])) {
             $AvailableTypes[$key] = array_merge($AvailableTypes[$key], $pageTypeOptions[$key]);
         }
         $AvailableTypes[$key]['limit_reached'] = false;
         if (isset($AvailableTypes[$key]['limit'])) {
             if ($AvailableTypes[$key]['limit'] == 0) {
                 $AvailableTypes[$key]['limit_reached'] = true;
             }
             $CurrentSectionCount = $this->owner->Sections()->filter('ClassName', $AvailableTypes[$key]['type'])->count();
             if ($CurrentSectionCount >= $AvailableTypes[$key]['limit']) {
                 $AvailableTypes[$key]['limit_reached'] = true;
             }
         }
     }
     return $AvailableTypes;
 }
开发者ID:coreiho,项目名称:silverstripe-sections,代码行数:33,代码来源:SectionPageExtension.php


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