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


PHP SiteTree::allowedChildren方法代码示例

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


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

示例1: getAllowedChildren

 public function getAllowedChildren(SiteTree $parent)
 {
     $allowedChildren = $parent->allowedChildren();
     if (empty($allowedChildren)) {
         return array();
     }
     $children = array();
     foreach ($allowedChildren as $class) {
         if (Config::inst()->get($class, "show_in_sitetree") === false) {
             $children[$class] = Injector::inst()->create($class)->i18n_singular_name();
         }
     }
     return $children;
 }
开发者ID:micmania1,项目名称:silverstripe-lumberjack,代码行数:14,代码来源:GridFieldSiteTreeAddNewButton.php

示例2: getAllowedChildren

 /**
  * Determine the list of classnames and titles allowed for a given parent object
  *
  * @param SiteTree $parent
  * @return boolean
  */
 public function getAllowedChildren(SiteTree $parent = null)
 {
     if (!$parent || !$parent->canAddChildren()) {
         return array();
     }
     $allowedChildren = $parent->allowedChildren();
     $children = array();
     foreach ($allowedChildren as $class) {
         if (Config::inst()->get($class, "show_in_sitetree") === false) {
             $instance = Injector::inst()->get($class);
             // Note: Second argument to SiteTree::canCreate will support inherited permissions
             // post 3.1.12, and will default to the old permission model in 3.1.11 or below
             // See http://docs.silverstripe.org/en/changelogs/3.1.11
             if ($instance->canCreate(null, array('Parent' => $parent))) {
                 $children[$class] = $instance->i18n_singular_name();
             }
         }
     }
     return $children;
 }
开发者ID:sentromedia,项目名称:letsfund,代码行数:26,代码来源:GridFieldSiteTreeAddNewButton.php

示例3: testAllowedChildren

 public function testAllowedChildren()
 {
     $page = new SiteTree();
     $this->assertContains('VirtualPage', $page->allowedChildren(), 'Includes core subclasses by default');
     $classA = new SiteTreeTest_ClassA();
     $this->assertEquals(array('SiteTreeTest_ClassB'), $classA->allowedChildren(), 'Direct setting of allowed children');
     $classB = new SiteTreeTest_ClassB();
     $this->assertEquals(array('SiteTreeTest_ClassC', 'SiteTreeTest_ClassCext'), $classB->allowedChildren(), 'Includes subclasses');
     $classD = new SiteTreeTest_ClassD();
     $this->assertEquals(array('SiteTreeTest_ClassC'), $classD->allowedChildren(), 'Excludes subclasses if class is prefixed by an asterisk');
     $classC = new SiteTreeTest_ClassC();
     $this->assertEquals(array(), $classC->allowedChildren(), 'Null setting');
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:13,代码来源:SiteTreeTest.php

示例4: testAllowedChildrenContainsCoreSubclassesButNotHiddenClass

 /**
  * Tests that core subclasses of SiteTree are included in allowedChildren() by default, but not instances of
  * HiddenClass
  */
 public function testAllowedChildrenContainsCoreSubclassesButNotHiddenClass()
 {
     $page = new SiteTree();
     $allowedChildren = $page->allowedChildren();
     $this->assertContains('VirtualPage', $allowedChildren, 'Includes core subclasses by default');
     $this->assertNotContains('SiteTreeTest_ClassE', $allowedChildren, 'HiddenClass instances should not be returned');
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:11,代码来源:SiteTreeTest.php


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