mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Replace use of Configurable stat() with config()->get(), will be deprecated in future
This commit is contained in:
parent
2bbb21a450
commit
f2e22ef18a
@ -278,7 +278,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
{
|
{
|
||||||
$link = Controller::join_links(
|
$link = Controller::join_links(
|
||||||
AdminRootController::admin_url(),
|
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!
|
'/', // trailing slash needed if $action is null!
|
||||||
"$action"
|
"$action"
|
||||||
);
|
);
|
||||||
@ -418,7 +418,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Pre-cache sitetree version numbers for querying efficiency
|
// Pre-cache sitetree version numbers for querying efficiency
|
||||||
Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::DRAFT);
|
Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::DRAFT);
|
||||||
Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::LIVE);
|
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);
|
$this->extend('updateSiteTreeAsUL', $html);
|
||||||
|
|
||||||
@ -566,7 +566,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function getsubtree($request)
|
public function getsubtree($request)
|
||||||
{
|
{
|
||||||
$html = $this->getSiteTreeFor(
|
$html = $this->getSiteTreeFor(
|
||||||
$this->stat('tree_class'),
|
$this->config()->get('tree_class'),
|
||||||
$request->getVar('ID'),
|
$request->getVar('ID'),
|
||||||
null,
|
null,
|
||||||
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
|
// TODO: These methods should really be in hierarchy - for a start it assumes Sort exists
|
||||||
$prev = null;
|
$prev = null;
|
||||||
|
|
||||||
$className = $this->stat('tree_class');
|
$className = $this->config()->get('tree_class');
|
||||||
$next = DataObject::get($className)
|
$next = DataObject::get($className)
|
||||||
->filter('ParentID', $record->ParentID)
|
->filter('ParentID', $record->ParentID)
|
||||||
->filter('Sort:GreaterThan', $record->Sort)
|
->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');
|
$id = $request->requestVar('ID');
|
||||||
$parentID = $request->requestVar('ParentID');
|
$parentID = $request->requestVar('ParentID');
|
||||||
if (!is_numeric($id) || !is_numeric($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
|
// Check if can be created at the root
|
||||||
$needsPerm = $obj->stat('need_permission');
|
$needsPerm = $obj->config()->get('need_permission');
|
||||||
if (!$obj->stat('can_be_root')
|
if (!$obj->config()->get('can_be_root')
|
||||||
|| (!array_key_exists($class, $cacheCanCreate) || !$cacheCanCreate[$class])
|
|| (!array_key_exists($class, $cacheCanCreate) || !$cacheCanCreate[$class])
|
||||||
|| ($needsPerm && !$this->can($needsPerm))
|
|| ($needsPerm && !$this->can($needsPerm))
|
||||||
) {
|
) {
|
||||||
@ -1012,7 +1012,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip this type if it is restricted
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,7 +1024,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'AddAction' => $singularName,
|
'AddAction' => $singularName,
|
||||||
'Description' => $description,
|
'Description' => $description,
|
||||||
// TODO Sprite support
|
// TODO Sprite support
|
||||||
'IconURL' => $instance->stat('icon'),
|
'IconURL' => $instance->config()->get('icon'),
|
||||||
'Title' => $singularName,
|
'Title' => $singularName,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -1046,7 +1046,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if (!$id) {
|
if (!$id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$treeClass = $this->stat('tree_class');
|
$treeClass = $this->config()->get('tree_class');
|
||||||
if ($id instanceof $treeClass) {
|
if ($id instanceof $treeClass) {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
@ -1395,7 +1395,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if ($filter = $this->getQueryFilter($params)) {
|
if ($filter = $this->getQueryFilter($params)) {
|
||||||
return $filter->getFilteredPages();
|
return $filter->getFilteredPages();
|
||||||
} else {
|
} else {
|
||||||
$list = DataList::create($this->stat('tree_class'));
|
$list = DataList::create($this->config()->get('tree_class'));
|
||||||
$parentID = is_numeric($parentID) ? $parentID : 0;
|
$parentID = is_numeric($parentID) ? $parentID : 0;
|
||||||
return $list->filter("ParentID", $parentID);
|
return $list->filter("ParentID", $parentID);
|
||||||
}
|
}
|
||||||
@ -1530,7 +1530,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
*/
|
*/
|
||||||
public function save($data, $form)
|
public function save($data, $form)
|
||||||
{
|
{
|
||||||
$className = $this->stat('tree_class');
|
$className = $this->config()->get('tree_class');
|
||||||
|
|
||||||
// Existing or new record?
|
// Existing or new record?
|
||||||
$id = $data['ID'];
|
$id = $data['ID'];
|
||||||
@ -1606,7 +1606,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
*/
|
*/
|
||||||
public function getNewItem($id, $setID = true)
|
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);
|
list(, $className, $parentID) = array_pad(explode('-', $id), 3, null);
|
||||||
|
|
||||||
if (!is_a($className, $parentClass, true)) {
|
if (!is_a($className, $parentClass, true)) {
|
||||||
@ -1798,7 +1798,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
public function unpublish($data, $form)
|
public function unpublish($data, $form)
|
||||||
{
|
{
|
||||||
$className = $this->stat('tree_class');
|
$className = $this->config()->get('tree_class');
|
||||||
/** @var SiteTree $record */
|
/** @var SiteTree $record */
|
||||||
$record = DataObject::get_by_id($className, $data['ID']);
|
$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;
|
$version = (isset($data['Version'])) ? (int) $data['Version'] : null;
|
||||||
|
|
||||||
/** @var DataObject|Versioned $record */
|
/** @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()) {
|
if ($record && !$record->canEdit()) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class LeftAndMainPageIconsExtension extends Extension
|
|||||||
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
$obj = singleton($class);
|
$obj = singleton($class);
|
||||||
$iconSpec = $obj->stat('icon');
|
$iconSpec = $obj->config()->get('icon');
|
||||||
|
|
||||||
if (!$iconSpec) {
|
if (!$iconSpec) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -88,7 +88,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority()
|
||||||
{
|
{
|
||||||
return $this->stat('priority');
|
return $this->config()->get('priority');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -452,7 +452,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
|
|
||||||
// do any of the progeny want to hide an ancestor?
|
// 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
|
// note for killing later
|
||||||
$kill_ancestors[] = $ancestor_to_hide;
|
$kill_ancestors[] = $ancestor_to_hide;
|
||||||
}
|
}
|
||||||
@ -990,7 +990,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
return true;
|
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
|
// "Can be root" validation
|
||||||
if (!$this->stat('can_be_root') && !$this->ParentID) {
|
if (!$this->config()->get('can_be_root') && !$this->ParentID) {
|
||||||
$result->addError(
|
$result->addError(
|
||||||
_t(
|
_t(
|
||||||
'SilverStripe\\CMS\\Model\\SiteTree.PageTypNotAllowedOnRoot',
|
'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)) {
|
if (!$this->can($perms)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2498,7 +2498,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
*/
|
*/
|
||||||
public function defaultChild()
|
public function defaultChild()
|
||||||
{
|
{
|
||||||
$default = $this->stat('default_child');
|
$default = $this->config()->get('default_child');
|
||||||
$allowed = $this->allowedChildren();
|
$allowed = $this->allowedChildren();
|
||||||
if ($allowed) {
|
if ($allowed) {
|
||||||
if (!$default || !in_array($default, $allowed)) {
|
if (!$default || !in_array($default, $allowed)) {
|
||||||
@ -2516,7 +2516,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
*/
|
*/
|
||||||
public function defaultParent()
|
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]);
|
$base = in_array(static::class, [Page::class, self::class]);
|
||||||
if ($base) {
|
if ($base) {
|
||||||
return $this->stat('base_singular_name');
|
return $this->config()->get('base_singular_name');
|
||||||
}
|
}
|
||||||
return parent::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]);
|
$base = in_array(static::class, [Page::class, self::class]);
|
||||||
if ($base) {
|
if ($base) {
|
||||||
return $this->stat('base_plural_name');
|
return $this->config()->get('base_plural_name');
|
||||||
}
|
}
|
||||||
return parent::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]);
|
$base = in_array(static::class, [Page::class, self::class]);
|
||||||
if ($base) {
|
if ($base) {
|
||||||
return $this->stat('base_description');
|
return $this->config()->get('base_description');
|
||||||
}
|
}
|
||||||
return $this->stat('description');
|
return $this->config()->get('description');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,7 +335,7 @@ class VirtualPage extends Page
|
|||||||
|
|
||||||
// "Can be root" validation
|
// "Can be root" validation
|
||||||
$orig = $this->CopyContentFrom();
|
$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(
|
$result->addError(
|
||||||
_t(
|
_t(
|
||||||
'SilverStripe\\CMS\\Model\\VirtualPage.PageTypNotAllowedOnRoot',
|
'SilverStripe\\CMS\\Model\\VirtualPage.PageTypNotAllowedOnRoot',
|
||||||
|
@ -174,7 +174,7 @@ class CMSMainTest extends FunctionalTest
|
|||||||
if ($page instanceof TestOnly) {
|
if ($page instanceof TestOnly) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$page->stat('can_be_root')) {
|
if (!$page->config()->get('can_be_root')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user