mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-29 07:59:37 +02:00
MINOR: class name references
- Replace get_class($this) with static::class - Replace __CLASS__ with self::class
This commit is contained in:
parent
47d066a0a0
commit
0a561f1656
|
@ -314,7 +314,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||||
return $this->customise(array(
|
return $this->customise(array(
|
||||||
"EditForm" => $form
|
"EditForm" => $form
|
||||||
))->renderWith(array(
|
))->renderWith(array(
|
||||||
get_class($this) . '_EditForm',
|
static::class . '_EditForm',
|
||||||
'LeftAndMain_Content'
|
'LeftAndMain_Content'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||||
return $this->customise(array(
|
return $this->customise(array(
|
||||||
"EditForm" => $this->ShowVersionForm($versionID)
|
"EditForm" => $this->ShowVersionForm($versionID)
|
||||||
))->renderWith(array(
|
))->renderWith(array(
|
||||||
get_class($this) . '_EditForm',
|
static::class . '_EditForm',
|
||||||
'LeftAndMain_Content'
|
'LeftAndMain_Content'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ContentController extends Controller {
|
||||||
if($this->hasMethod("Title")) {
|
if($this->hasMethod("Title")) {
|
||||||
$dataRecord->Title = $this->Title();
|
$dataRecord->Title = $this->Title();
|
||||||
}
|
}
|
||||||
$dataRecord->URLSegment = get_class($this);
|
$dataRecord->URLSegment = static::class;
|
||||||
$dataRecord->ID = -1;
|
$dataRecord->ID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,10 +419,10 @@ HTML;
|
||||||
// Find templates by dataRecord
|
// Find templates by dataRecord
|
||||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"),
|
SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"),
|
||||||
// Next, we need to add templates for all controllers
|
// Next, we need to add templates for all controllers
|
||||||
SSViewer::get_templates_by_class(get_class($this), $action, "SilverStripe\\Control\\Controller"),
|
SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"),
|
||||||
// Fail-over to the same for the "index" action
|
// Fail-over to the same for the "index" action
|
||||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"),
|
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"),
|
||||||
SSViewer::get_templates_by_class(get_class($this), "", "SilverStripe\\Control\\Controller")
|
SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller")
|
||||||
);
|
);
|
||||||
|
|
||||||
return new SSViewer($templates);
|
return new SSViewer($templates);
|
||||||
|
|
|
@ -52,7 +52,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return substr(get_class($this), strpos(get_class($this), '_') + 1);
|
return substr(static::class, strpos(static::class, '_') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,7 +122,7 @@ class ErrorPage extends Page {
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// Only run on ErrorPage class directly, not subclasses
|
// Only run on ErrorPage class directly, not subclasses
|
||||||
if (get_class($this) !== 'SilverStripe\\CMS\\Model\\ErrorPage' || !SiteTree::config()->create_default_pages) {
|
if (static::class !== self::class || !SiteTree::config()->create_default_pages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,12 +330,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
||||||
}
|
}
|
||||||
/** @var SiteTree $sitetree */
|
/** @var SiteTree $sitetree */
|
||||||
$sitetree = DataObject::get_one(__CLASS__, $conditions, $cache);
|
$sitetree = DataObject::get_one(self::class, $conditions, $cache);
|
||||||
|
|
||||||
/// Fall back on a unique URLSegment for b/c.
|
/// Fall back on a unique URLSegment for b/c.
|
||||||
if( !$sitetree
|
if( !$sitetree
|
||||||
&& self::config()->nested_urls
|
&& self::config()->nested_urls
|
||||||
&& $sitetree = DataObject::get_one(__CLASS__, array(
|
&& $sitetree = DataObject::get_one(self::class, array(
|
||||||
'"SiteTree"."URLSegment"' => $URLSegment
|
'"SiteTree"."URLSegment"' => $URLSegment
|
||||||
), $cache)
|
), $cache)
|
||||||
) {
|
) {
|
||||||
|
@ -400,7 +400,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
public static function page_type_classes() {
|
public static function page_type_classes() {
|
||||||
$classes = ClassInfo::getValidSubClasses();
|
$classes = ClassInfo::getValidSubClasses();
|
||||||
|
|
||||||
$baseClassIndex = array_search(__CLASS__, $classes);
|
$baseClassIndex = array_search(self::class, $classes);
|
||||||
if($baseClassIndex !== false) {
|
if($baseClassIndex !== false) {
|
||||||
unset($classes[$baseClassIndex]);
|
unset($classes[$baseClassIndex]);
|
||||||
}
|
}
|
||||||
|
@ -449,8 +449,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
|
|
||||||
/** @var SiteTree $page */
|
/** @var SiteTree $page */
|
||||||
if (
|
if (
|
||||||
!($page = DataObject::get_by_id(__CLASS__, $arguments['id'])) // Get the current page by ID.
|
!($page = DataObject::get_by_id(self::class, $arguments['id'])) // Get the current page by ID.
|
||||||
&& !($page = Versioned::get_latest_version(__CLASS__, $arguments['id'])) // Attempt link to old version.
|
&& !($page = Versioned::get_latest_version(self::class, $arguments['id'])) // Attempt link to old version.
|
||||||
) {
|
) {
|
||||||
return null; // There were no suitable matches at all.
|
return null; // There were no suitable matches at all.
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$parent = $this->Parent();
|
$parent = $this->Parent();
|
||||||
// If page is removed select parent from version history (for archive page view)
|
// If page is removed select parent from version history (for archive page view)
|
||||||
if((!$parent || !$parent->exists()) && $this->getIsDeletedFromStage()) {
|
if((!$parent || !$parent->exists()) && $this->getIsDeletedFromStage()) {
|
||||||
$parent = Versioned::get_latest_version(__CLASS__, $this->ParentID);
|
$parent = Versioned::get_latest_version(self::class, $this->ParentID);
|
||||||
}
|
}
|
||||||
$base = $parent->RelativeLink($this->URLSegment);
|
$base = $parent->RelativeLink($this->URLSegment);
|
||||||
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
||||||
|
@ -562,7 +562,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$oldReadingMode = Versioned::get_reading_mode();
|
$oldReadingMode = Versioned::get_reading_mode();
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
/** @var SiteTree $live */
|
/** @var SiteTree $live */
|
||||||
$live = Versioned::get_one_by_stage(__CLASS__, Versioned::LIVE, array(
|
$live = Versioned::get_one_by_stage(self::class, Versioned::LIVE, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
if($live) {
|
if($live) {
|
||||||
|
@ -1070,7 +1070,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
// Check parent (custom canCreate option for SiteTree)
|
// Check parent (custom canCreate option for SiteTree)
|
||||||
// Block children not allowed for this parent type
|
// Block children not allowed for this parent type
|
||||||
$parent = isset($context['Parent']) ? $context['Parent'] : null;
|
$parent = isset($context['Parent']) ? $context['Parent'] : null;
|
||||||
if($parent && !in_array(get_class($this), $parent->allowedChildren())) {
|
if($parent && !in_array(static::class, $parent->allowedChildren())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1170,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
*/
|
*/
|
||||||
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
||||||
if(!$batchCallback) {
|
if(!$batchCallback) {
|
||||||
$batchCallback = __CLASS__ . "::can_{$permission}_multiple";
|
$batchCallback = self::class . "::can_{$permission}_multiple";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_callable($batchCallback)) {
|
if(is_callable($batchCallback)) {
|
||||||
|
@ -1447,7 +1447,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
$generator = trim(Config::inst()->get(__CLASS__, 'meta_generator'));
|
$generator = trim(Config::inst()->get(self::class, 'meta_generator'));
|
||||||
if (!empty($generator)) {
|
if (!empty($generator)) {
|
||||||
$tags[] = FormField::create_tag('meta', array(
|
$tags[] = FormField::create_tag('meta', array(
|
||||||
'name' => 'generator',
|
'name' => 'generator',
|
||||||
|
@ -1513,7 +1513,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// default pages
|
// default pages
|
||||||
if(get_class($this) == __CLASS__ && $this->config()->create_default_pages) {
|
if(static::class == self::class && $this->config()->create_default_pages) {
|
||||||
if(!SiteTree::get_by_link(RootURLController::config()->default_homepage_link)) {
|
if(!SiteTree::get_by_link(RootURLController::config()->default_homepage_link)) {
|
||||||
$homepage = new Page();
|
$homepage = new Page();
|
||||||
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
||||||
|
@ -2160,7 +2160,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fieldLabels($includerelations = true) {
|
public function fieldLabels($includerelations = true) {
|
||||||
$cacheKey = get_class($this) . '_' . $includerelations;
|
$cacheKey = static::class . '_' . $includerelations;
|
||||||
if(!isset(self::$_cache_field_labels[$cacheKey])) {
|
if(!isset(self::$_cache_field_labels[$cacheKey])) {
|
||||||
$labels = parent::fieldLabels($includerelations);
|
$labels = parent::fieldLabels($includerelations);
|
||||||
$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
|
$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
|
||||||
|
@ -2231,7 +2231,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
$infoTemplate = SSViewer::get_templates_by_class(get_class($this), '_Information', __CLASS__);
|
$infoTemplate = SSViewer::get_templates_by_class(static::class, '_Information', self::class);
|
||||||
$moreOptions->push(
|
$moreOptions->push(
|
||||||
new LiteralField('Information',
|
new LiteralField('Information',
|
||||||
$this->customise(array(
|
$this->customise(array(
|
||||||
|
@ -2244,7 +2244,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$moreOptions->push(AddToCampaignHandler_FormAction::create());
|
$moreOptions->push(AddToCampaignHandler_FormAction::create());
|
||||||
|
|
||||||
// "readonly"/viewing version that isn't the current version of the record
|
// "readonly"/viewing version that isn't the current version of the record
|
||||||
$stageOrLiveRecord = Versioned::get_one_by_stage(get_class($this), Versioned::get_stage(), array(
|
$stageOrLiveRecord = Versioned::get_one_by_stage(static::class, Versioned::get_stage(), array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
if($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
|
if($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
|
||||||
|
@ -2430,7 +2430,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$this->write();
|
$this->write();
|
||||||
|
|
||||||
/** @var SiteTree $result */
|
/** @var SiteTree $result */
|
||||||
$result = DataObject::get_by_id(__CLASS__, $this->ID);
|
$result = DataObject::get_by_id(self::class, $this->ID);
|
||||||
|
|
||||||
// Need to update pages linking to this one as no longer broken
|
// Need to update pages linking to this one as no longer broken
|
||||||
foreach($result->DependentPages(false) as $page) {
|
foreach($result->DependentPages(false) as $page) {
|
||||||
|
@ -2722,7 +2722,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
$controller = ContentController::class;
|
$controller = ContentController::class;
|
||||||
|
|
||||||
//go through the ancestry for this class looking for
|
//go through the ancestry for this class looking for
|
||||||
$ancestry = ClassInfo::ancestry(get_class($this));
|
$ancestry = ClassInfo::ancestry(static::class);
|
||||||
// loop over the array going from the deepest descendant (ie: the current class) to SiteTree
|
// loop over the array going from the deepest descendant (ie: the current class) to SiteTree
|
||||||
while ($class = array_pop($ancestry)) {
|
while ($class = array_pop($ancestry)) {
|
||||||
//we don't need to go any deeper than the SiteTree class
|
//we don't need to go any deeper than the SiteTree class
|
||||||
|
@ -2746,7 +2746,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
||||||
$classes = sprintf('class-%s', get_class($this));
|
$classes = sprintf('class-%s', static::class);
|
||||||
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
||||||
$classes .= " BrokenLink";
|
$classes .= " BrokenLink";
|
||||||
}
|
}
|
||||||
|
@ -2897,9 +2897,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
||||||
/** @skipUpgrade */
|
/** @skipUpgrade */
|
||||||
// @todo When we namespace translations, change 'SiteTree' to FQN of the class
|
// @todo When we namespace translations, change 'SiteTree' to FQN of the class
|
||||||
$class = (get_class($this) == 'Page' || get_class($this) === __CLASS__)
|
$class = (static::class == 'Page' || static::class === self::class)
|
||||||
? 'SiteTree'
|
? 'SiteTree'
|
||||||
: get_class($this);
|
: static::class;
|
||||||
return _t($class.'.SINGULARNAME', $this->singular_name());
|
return _t($class.'.SINGULARNAME', $this->singular_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2915,7 +2915,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
if(isset($entities['Page.SINGULARNAME'])) $entities['Page.SINGULARNAME'][3] = CMS_DIR;
|
if(isset($entities['Page.SINGULARNAME'])) $entities['Page.SINGULARNAME'][3] = CMS_DIR;
|
||||||
if(isset($entities['Page.PLURALNAME'])) $entities['Page.PLURALNAME'][3] = CMS_DIR;
|
if(isset($entities['Page.PLURALNAME'])) $entities['Page.PLURALNAME'][3] = CMS_DIR;
|
||||||
|
|
||||||
$entities[get_class($this) . '.DESCRIPTION'] = array(
|
$entities[static::class . '.DESCRIPTION'] = array(
|
||||||
$this->stat('description'),
|
$this->stat('description'),
|
||||||
'Description of the page type (shown in the "add page" dialog)'
|
'Description of the page type (shown in the "add page" dialog)'
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,7 +62,7 @@ class SiteTreeFileExtension extends DataExtension {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function BackLinkHTMLList() {
|
public function BackLinkHTMLList() {
|
||||||
$viewer = new SSViewer(["type" => "Includes", __CLASS__ . "_description"]);
|
$viewer = new SSViewer(["type" => "Includes", self::class . "_description"]);
|
||||||
|
|
||||||
return $viewer->process($this->owner);
|
return $viewer->process($this->owner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -587,7 +587,7 @@ class CMSMainTest_ClassA extends Page implements TestOnly {
|
||||||
{
|
{
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
|
|
||||||
if ($this->ClassName !== __CLASS__) {
|
if ($this->ClassName !== self::class) {
|
||||||
throw new ValidationException("Class saved with incorrect ClassName");
|
throw new ValidationException("Class saved with incorrect ClassName");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,7 +599,7 @@ class CMSMainTest_ClassB extends Page implements TestOnly {
|
||||||
{
|
{
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
|
|
||||||
if ($this->ClassName !== __CLASS__) {
|
if ($this->ClassName !== self::class) {
|
||||||
throw new ValidationException("Class saved with incorrect ClassName");
|
throw new ValidationException("Class saved with incorrect ClassName");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class SilverStripeNavigatorTest extends SapphireTest {
|
||||||
|
|
||||||
class SilverStripeNavigatorTest_TestItem extends SilverStripeNavigatorItem implements TestOnly {
|
class SilverStripeNavigatorTest_TestItem extends SilverStripeNavigatorItem implements TestOnly {
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
return __CLASS__;
|
return self::class;
|
||||||
}
|
}
|
||||||
public function getHTML() {
|
public function getHTML() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -63,7 +63,7 @@ class SilverStripeNavigatorTest_TestItem extends SilverStripeNavigatorItem imple
|
||||||
class SilverStripeNavigatorTest_ProtectedTestItem extends SilverStripeNavigatorItem implements TestOnly {
|
class SilverStripeNavigatorTest_ProtectedTestItem extends SilverStripeNavigatorItem implements TestOnly {
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
return __CLASS__;
|
return self::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHTML() {
|
public function getHTML() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user