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


PHP SiteTree::get_one方法代碼示例

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


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

示例1: onAfterWrite

 /**
  *	Update link mappings when replacing the default automated URL handling.
  */
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     // Determine whether the default automated URL handling has been replaced.
     if (Config::inst()->get('MisdirectionRequestFilter', 'replace_default')) {
         // Determine whether the URL segment or parent ID has been updated.
         $changed = $this->owner->getChangedFields();
         if (isset($changed['URLSegment']['before']) && isset($changed['URLSegment']['after']) && $changed['URLSegment']['before'] != $changed['URLSegment']['after'] || isset($changed['ParentID']['before']) && isset($changed['ParentID']['after']) && $changed['ParentID']['before'] != $changed['ParentID']['after']) {
             // The link mappings should only be created for existing pages.
             $URL = isset($changed['URLSegment']['before']) ? $changed['URLSegment']['before'] : $this->owner->URLSegment;
             if (strpos($URL, 'new-') !== 0) {
                 // Determine the page URL.
                 $parentID = isset($changed['ParentID']['before']) ? $changed['ParentID']['before'] : $this->owner->ParentID;
                 $parent = SiteTree::get_one('SiteTree', "SiteTree.ID = {$parentID}");
                 while ($parent) {
                     $URL = Controller::join_links($parent->URLSegment, $URL);
                     $parent = SiteTree::get_one('SiteTree', "SiteTree.ID = {$parent->ParentID}");
                 }
                 // Instantiate a link mapping for this page.
                 singleton('MisdirectionService')->createPageMapping($URL, $this->owner->ID);
                 // Purge any link mappings that point back to the same page.
                 $this->owner->regulateMappings($this->owner->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $this->owner->Link(), $this->owner->ID);
                 // Recursively create link mappings for any children.
                 $children = $this->owner->AllChildrenIncludingDeleted();
                 if ($children->count()) {
                     $this->owner->recursiveMapping($URL, $children);
                 }
             }
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:nglasl-silverstripe-misdirection,代碼行數:34,代碼來源:SiteTreeMisdirectionExtension.php

示例2: eLink

 function eLink()
 {
     $page = SiteTree::get_one("ProjectPage");
     $link = $page->Link() . "edit/" . $this->ID;
     return $link;
 }
開發者ID:micschk,項目名稱:SilverProject,代碼行數:6,代碼來源:Project.php

示例3: Link

 function Link()
 {
     $page = SiteTree::get_one("TaskPage");
     $link = $page->Link() . "show/" . $this->ID;
     return $link;
 }
開發者ID:micschk,項目名稱:SilverProject,代碼行數:6,代碼來源:Task.php


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