本文整理汇总了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;
}
示例3: Link
function Link()
{
$page = SiteTree::get_one("TaskPage");
$link = $page->Link() . "show/" . $this->ID;
return $link;
}