當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。