Replace use of Configurable stat() with config()->get(), will be deprecated in future

This commit is contained in:
Robbie Averill 2017-08-23 09:46:46 +12:00
parent 2bbb21a450
commit f2e22ef18a
6 changed files with 29 additions and 29 deletions

View File

@ -278,7 +278,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
{
$link = Controller::join_links(
AdminRootController::admin_url(),
$this->stat('url_segment'), // in case we want to change the segment
$this->config()->get('url_segment'), // in case we want to change the segment
'/', // trailing slash needed if $action is null!
"$action"
);
@ -418,7 +418,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// Pre-cache sitetree version numbers for querying efficiency
Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::DRAFT);
Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::LIVE);
$html = $this->getSiteTreeFor($this->stat('tree_class'));
$html = $this->getSiteTreeFor($this->config()->get('tree_class'));
$this->extend('updateSiteTreeAsUL', $html);
@ -566,7 +566,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function getsubtree($request)
{
$html = $this->getSiteTreeFor(
$this->stat('tree_class'),
$this->config()->get('tree_class'),
$request->getVar('ID'),
null,
null,
@ -615,7 +615,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// TODO: These methods should really be in hierarchy - for a start it assumes Sort exists
$prev = null;
$className = $this->stat('tree_class');
$className = $this->config()->get('tree_class');
$next = DataObject::get($className)
->filter('ParentID', $record->ParentID)
->filter('Sort:GreaterThan', $record->Sort)
@ -677,7 +677,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
}
$className = $this->stat('tree_class');
$className = $this->config()->get('tree_class');
$id = $request->requestVar('ID');
$parentID = $request->requestVar('ParentID');
if (!is_numeric($id) || !is_numeric($parentID)) {
@ -963,8 +963,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
// Check if can be created at the root
$needsPerm = $obj->stat('need_permission');
if (!$obj->stat('can_be_root')
$needsPerm = $obj->config()->get('need_permission');
if (!$obj->config()->get('can_be_root')
|| (!array_key_exists($class, $cacheCanCreate) || !$cacheCanCreate[$class])
|| ($needsPerm && !$this->can($needsPerm))
) {
@ -1012,7 +1012,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
// skip this type if it is restricted
if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) {
if ($instance->config()->get('need_permission') && !$this->can(singleton($class)->config()->get('need_permission'))) {
continue;
}
@ -1024,7 +1024,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'AddAction' => $singularName,
'Description' => $description,
// TODO Sprite support
'IconURL' => $instance->stat('icon'),
'IconURL' => $instance->config()->get('icon'),
'Title' => $singularName,
)));
}
@ -1046,7 +1046,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
if (!$id) {
return null;
}
$treeClass = $this->stat('tree_class');
$treeClass = $this->config()->get('tree_class');
if ($id instanceof $treeClass) {
return $id;
}
@ -1395,7 +1395,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
if ($filter = $this->getQueryFilter($params)) {
return $filter->getFilteredPages();
} else {
$list = DataList::create($this->stat('tree_class'));
$list = DataList::create($this->config()->get('tree_class'));
$parentID = is_numeric($parentID) ? $parentID : 0;
return $list->filter("ParentID", $parentID);
}
@ -1530,7 +1530,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
*/
public function save($data, $form)
{
$className = $this->stat('tree_class');
$className = $this->config()->get('tree_class');
// Existing or new record?
$id = $data['ID'];
@ -1606,7 +1606,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
*/
public function getNewItem($id, $setID = true)
{
$parentClass = $this->stat('tree_class');
$parentClass = $this->config()->get('tree_class');
list(, $className, $parentID) = array_pad(explode('-', $id), 3, null);
if (!is_a($className, $parentClass, true)) {
@ -1798,7 +1798,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function unpublish($data, $form)
{
$className = $this->stat('tree_class');
$className = $this->config()->get('tree_class');
/** @var SiteTree $record */
$record = DataObject::get_by_id($className, $data['ID']);
@ -1845,7 +1845,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$version = (isset($data['Version'])) ? (int) $data['Version'] : null;
/** @var DataObject|Versioned $record */
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
$record = DataObject::get_by_id($this->config()->get('tree_class'), $id);
if ($record && !$record->canEdit()) {
return Security::permissionFailure($this);
}

View File

@ -31,7 +31,7 @@ class LeftAndMainPageIconsExtension extends Extension
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree');
foreach ($classes as $class) {
$obj = singleton($class);
$iconSpec = $obj->stat('icon');
$iconSpec = $obj->config()->get('icon');
if (!$iconSpec) {
continue;

View File

@ -88,7 +88,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData
*/
public function getPriority()
{
return $this->stat('priority');
return $this->config()->get('priority');
}
/**

View File

@ -452,7 +452,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$instance = singleton($class);
// do any of the progeny want to hide an ancestor?
if ($ancestor_to_hide = $instance->stat('hide_ancestor')) {
if ($ancestor_to_hide = $instance->config()->get('hide_ancestor')) {
// note for killing later
$kill_ancestors[] = $ancestor_to_hide;
}
@ -990,7 +990,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
return true;
}
return $this->canEdit($member) && $this->stat('allowed_children') !== 'none';
return $this->canEdit($member) && $this->config()->get('allowed_children') !== 'none';
}
/**
@ -1522,7 +1522,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
}
// "Can be root" validation
if (!$this->stat('can_be_root') && !$this->ParentID) {
if (!$this->config()->get('can_be_root') && !$this->ParentID) {
$result->addError(
_t(
'SilverStripe\\CMS\\Model\\SiteTree.PageTypNotAllowedOnRoot',
@ -2419,7 +2419,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
}
}
if ($perms = $instance->stat('need_permission')) {
if ($perms = $instance->config()->get('need_permission')) {
if (!$this->can($perms)) {
continue;
}
@ -2498,7 +2498,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/
public function defaultChild()
{
$default = $this->stat('default_child');
$default = $this->config()->get('default_child');
$allowed = $this->allowedChildren();
if ($allowed) {
if (!$default || !in_array($default, $allowed)) {
@ -2516,7 +2516,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/
public function defaultParent()
{
return $this->stat('default_parent');
return $this->config()->get('default_parent');
}
/**
@ -2802,7 +2802,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{
$base = in_array(static::class, [Page::class, self::class]);
if ($base) {
return $this->stat('base_singular_name');
return $this->config()->get('base_singular_name');
}
return parent::singular_name();
}
@ -2816,7 +2816,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{
$base = in_array(static::class, [Page::class, self::class]);
if ($base) {
return $this->stat('base_plural_name');
return $this->config()->get('base_plural_name');
}
return parent::plural_name();
}
@ -2830,9 +2830,9 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{
$base = in_array(static::class, [Page::class, self::class]);
if ($base) {
return $this->stat('base_description');
return $this->config()->get('base_description');
}
return $this->stat('description');
return $this->config()->get('description');
}
/**

View File

@ -335,7 +335,7 @@ class VirtualPage extends Page
// "Can be root" validation
$orig = $this->CopyContentFrom();
if ($orig && $orig->exists() && !$orig->stat('can_be_root') && !$this->ParentID) {
if ($orig && $orig->exists() && !$orig->config()->get('can_be_root') && !$this->ParentID) {
$result->addError(
_t(
'SilverStripe\\CMS\\Model\\VirtualPage.PageTypNotAllowedOnRoot',

View File

@ -174,7 +174,7 @@ class CMSMainTest extends FunctionalTest
if ($page instanceof TestOnly) {
continue;
}
if (!$page->stat('can_be_root')) {
if (!$page->config()->get('can_be_root')) {
continue;
}