当前位置: 首页>>代码示例>>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;未经允许,请勿转载。