Permalink
Browse files

API Marked statics private, use Config API instead (#8317)

See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
  • Loading branch information...
chillu committed Mar 18, 2013
1 parent 1f14654 commit 51c8e8639e9b5f1c258f21f640df2a6cf2af12df
Showing with 414 additions and 338 deletions.
  1. +10 −9 code/controllers/AssetAdmin.php
  2. +5 −5 code/controllers/CMSFileAddController.php
  3. +9 −9 code/controllers/CMSMain.php
  4. +6 −6 code/controllers/CMSPageAddController.php
  5. +5 −5 code/controllers/CMSPageEditController.php
  6. +8 −8 code/controllers/CMSPageHistoryController.php
  7. +5 −5 code/controllers/CMSPageSettingsController.php
  8. +6 −6 code/controllers/CMSPagesController.php
  9. +6 −6 code/controllers/CMSSettingsController.php
  10. +3 −3 code/controllers/ContentController.php
  11. +3 −3 code/controllers/ModelAsController.php
  12. +5 −7 code/controllers/ReportAdmin.php
  13. +9 −4 code/controllers/RootURLController.php
  14. +8 −4 code/controllers/SilverStripeNavigator.php
  15. +2 −2 code/controllers/StaticExporter.php
  16. +1 −1 code/forms/SiteTreeURLSegmentField.php
  17. +19 −14 code/model/ErrorPage.php
  18. +5 −6 code/model/RedirectorPage.php
  19. +14 −5 code/model/SiteConfig.php
  20. +78 −56 code/model/SiteTree.php
  21. +1 −1 code/model/SiteTreeFileExtension.php
  22. +9 −9 code/model/VirtualPage.php
  23. +9 −5 code/reports/Report.php
  24. +1 −1 code/search/ContentControllerSearchExtension.php
  25. +28 −15 code/staticpublisher/FilesystemPublisher.php
  26. +18 −8 code/staticpublisher/RsyncMultiHostPublisher.php
  27. +34 −15 code/staticpublisher/StaticPublisher.php
  28. +3 −3 tasks/RebuildStaticCacheTask.php
  29. +1 −1 tasks/RemoveOrphanedPagesTask.php
  30. +1 −1 tasks/SiteTreeMaintenanceTask.php
  31. +2 −1 tasks/UpgradeSiteTreePermissionSchemaTask.php
  32. +7 −5 tests/controller/CMSMainTest.php
  33. +1 −1 tests/controller/CMSPageHistoryControllerTest.php
  34. +1 −1 tests/controller/CMSSiteTreeFilterTest.php
  35. +9 −9 tests/controller/ContentControllerTest.php
  36. +5 −5 tests/controller/ModelAsControllerTest.php
  37. +3 −3 tests/controller/RootURLControllerTest.php
  38. +1 −1 tests/controller/SilverStripeNavigatorTest.php
  39. +5 −7 tests/model/ErrorPageTest.php
  40. +1 −1 tests/model/FileLinkTrackingTest.php
  41. +2 −2 tests/model/RedirectorPageTest.php
  42. +1 −1 tests/model/SiteConfigTest.php
  43. +1 −1 tests/model/SiteTreeActionsTest.php
  44. +2 −2 tests/model/SiteTreeBacklinksTest.php
  45. +1 −1 tests/model/SiteTreeBrokenLinksTest.php
  46. +2 −2 tests/model/SiteTreeHTMLEditorFieldTest.php
  47. +1 −1 tests/model/SiteTreePermissionsTest.php
  48. +27 −27 tests/model/SiteTreeTest.php
  49. +15 −15 tests/model/VirtualPageTest.php
  50. +2 −2 tests/reports/SideReportTest.php
  51. +1 −1 tests/search/CMSMainSearchFormTest.php
  52. +1 −1 tests/search/SearchFormTest.php
  53. +7 −21 tests/staticpublisher/FilesystemPublisherTest.php
  54. +2 −2 tests/tasks/MigrateSiteTreeLinkingTaskTest.php
  55. +2 −2 tests/tasks/RemoveOrphanedPagesTaskTest.php
@@ -8,21 +8,22 @@
*/
class AssetAdmin extends LeftAndMain implements PermissionProvider{
- static $url_segment = 'assets';
+ private static $url_segment = 'assets';
- static $url_rule = '/$Action/$ID';
+ private static $url_rule = '/$Action/$ID';
- static $menu_title = 'Files';
+ private static $menu_title = 'Files';
- public static $tree_class = 'Folder';
+ private static $tree_class = 'Folder';
/**
+ * @config
* @see Upload->allowedMaxFileSize
* @var int
*/
- public static $allowed_max_file_size;
+ private static $allowed_max_file_size;
- public static $allowed_actions = array(
+ private static $allowed_actions = array(
'addfolder',
'delete',
'AddForm',
@@ -121,8 +122,8 @@ public function getList() {
// Category filter
if(isset($params['AppCategory'])) {
- if(isset(File::$app_categories[$params['AppCategory']])) {
- $exts = File::$app_categories[$params['AppCategory']];
+ if(isset(File::config()->app_categories[$params['AppCategory']])) {
+ $exts = File::config()->app_categories[$params['AppCategory']];
} else {
$exts = array();
}
@@ -470,7 +471,7 @@ public function doAdd($data, $form) {
$record->write();
mkdir($record->FullPath);
- chmod($record->FullPath, Filesystem::$file_create_mask);
+ chmod($record->FullPath, Filesystem::config()->file_create_mask);
if($parentRecord) {
return $this->redirect(Controller::join_links($this->Link('show'), $parentRecord->ID));
@@ -1,11 +1,11 @@
<?php
class CMSFileAddController extends LeftAndMain {
- static $url_segment = 'assets/add';
- static $url_priority = 60;
- static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
- static $menu_title = 'Files';
- public static $tree_class = 'Folder';
+ private static $url_segment = 'assets/add';
+ private static $url_priority = 60;
+ private static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
+ private static $menu_title = 'Files';
+ private static $tree_class = 'Folder';
// public function upload($request) {
// $formHtml = $this->renderWith(array('AssetAdmin_UploadContent'));
@@ -11,23 +11,23 @@
*/
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
- static $url_segment = 'pages';
+ private static $url_segment = 'pages';
- static $url_rule = '/$Action/$ID/$OtherID';
+ private static $url_rule = '/$Action/$ID/$OtherID';
// Maintain a lower priority than other administration sections
// so that Director does not think they are actions of CMSMain
- static $url_priority = 39;
+ private static $url_priority = 39;
- static $menu_title = 'Edit Page';
+ private static $menu_title = 'Edit Page';
- static $menu_priority = 10;
+ private static $menu_priority = 10;
- static $tree_class = "SiteTree";
+ private static $tree_class = "SiteTree";
- static $subitem_class = "Member";
+ private static $subitem_class = "Member";
- static $allowed_actions = array(
+ private static $allowed_actions = array(
'buildbrokenlinks',
'deleteitems',
'DeleteItemsForm',
@@ -1125,7 +1125,7 @@ public function batchactions() {
}
public function BatchActionParameters() {
- $batchActions = CMSBatchActionHandler::$batch_actions;
+ $batchActions = CMSBatchActionHandler::config()->batch_actions;
$forms = array();
foreach($batchActions as $urlSegment => $batchAction) {
@@ -1,13 +1,13 @@
<?php
class CMSPageAddController extends CMSPageEditController {
- static $url_segment = 'pages/add';
- static $url_rule = '/$Action/$ID/$OtherID';
- static $url_priority = 42;
- static $menu_title = 'Add page';
- static $required_permission_codes = 'CMS_ACCESS_CMSMain';
+ private static $url_segment = 'pages/add';
+ private static $url_rule = '/$Action/$ID/$OtherID';
+ private static $url_priority = 42;
+ private static $menu_title = 'Add page';
+ private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
- static $allowed_actions = array(
+ private static $allowed_actions = array(
'AddForm',
'doAdd',
);
@@ -5,11 +5,11 @@
*/
class CMSPageEditController extends CMSMain {
- static $url_segment = 'pages/edit';
- static $url_rule = '/$Action/$ID/$OtherID';
- static $url_priority = 41;
- static $required_permission_codes = 'CMS_ACCESS_CMSMain';
- static $session_namespace = 'CMSMain';
+ private static $url_segment = 'pages/edit';
+ private static $url_rule = '/$Action/$ID/$OtherID';
+ private static $url_priority = 41;
+ private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
+ private static $session_namespace = 'CMSMain';
public function Breadcrumbs($unlinked = false) {
$crumbs = parent::Breadcrumbs($unlinked);
@@ -6,21 +6,21 @@
*/
class CMSPageHistoryController extends CMSMain {
- static $url_segment = 'pages/history';
- static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
- static $url_priority = 42;
- static $menu_title = 'History';
- static $required_permission_codes = 'CMS_ACCESS_CMSMain';
- static $session_namespace = 'CMSMain';
+ private static $url_segment = 'pages/history';
+ private static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
+ private static $url_priority = 42;
+ private static $menu_title = 'History';
+ private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
+ private static $session_namespace = 'CMSMain';
- static $allowed_actions = array(
+ private static $allowed_actions = array(
'VersionsForm',
'CompareVersionsForm',
'show',
'compare'
);
- public static $url_handlers = array(
+ private static $url_handlers = array(
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction'
);
@@ -5,11 +5,11 @@
*/
class CMSPageSettingsController extends CMSMain {
- static $url_segment = 'pages/settings';
- static $url_rule = '/$Action/$ID/$OtherID';
- static $url_priority = 42;
- static $required_permission_codes = 'CMS_ACCESS_CMSMain';
- static $session_namespace = 'CMSMain';
+ private static $url_segment = 'pages/settings';
+ private static $url_rule = '/$Action/$ID/$OtherID';
+ private static $url_priority = 42;
+ private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
+ private static $session_namespace = 'CMSMain';
public function getEditForm($id = null, $fields = null) {
$record = $this->getRecord($id ? $id : $this->currentPageID());
@@ -5,12 +5,12 @@
*/
class CMSPagesController extends CMSMain {
- static $url_segment = 'pages';
- static $url_rule = '/$Action/$ID/$OtherID';
- static $url_priority = 40;
- static $menu_title = 'Pages';
- static $required_permission_codes = 'CMS_ACCESS_CMSMain';
- static $session_namespace = 'CMSMain';
+ private static $url_segment = 'pages';
+ private static $url_rule = '/$Action/$ID/$OtherID';
+ private static $url_priority = 40;
+ private static $menu_title = 'Pages';
+ private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
+ private static $session_namespace = 'CMSMain';
public function LinkPreview() {
return false;
@@ -1,12 +1,12 @@
<?php
class CMSSettingsController extends LeftAndMain {
- static $url_segment = 'settings';
- static $url_rule = '/$Action/$ID/$OtherID';
- static $menu_priority = -1;
- static $menu_title = 'Settings';
- static $tree_class = 'SiteConfig';
- static $required_permission_codes = array('EDIT_SITECONFIG');
+ private static $url_segment = 'settings';
+ private static $url_rule = '/$Action/$ID/$OtherID';
+ private static $menu_priority = -1;
+ private static $menu_title = 'Settings';
+ private static $tree_class = 'SiteConfig';
+ private static $required_permission_codes = array('EDIT_SITECONFIG');
public function init() {
parent::init();
@@ -22,7 +22,7 @@ class ContentController extends Controller {
protected $dataRecord;
- public static $allowed_actions = array(
+ private static $allowed_actions = array(
'successfullyinstalled',
'deleteinstallfiles' // secured through custom code
);
@@ -119,7 +119,7 @@ public function init() {
// Use theme from the site config
if(($config = SiteConfig::current_site_config()) && $config->Theme) {
- SSViewer::set_theme($config->Theme);
+ Config::inst()->update('SSViewer', 'theme', $config->Theme);
}
}
@@ -137,7 +137,7 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model = null)
// If nested URLs are enabled, and there is no action handler for the current request then attempt to pass
// control to a child controller. This allows for the creation of chains of controllers which correspond to a
// nested URL.
- if($action && SiteTree::nested_urls() && !$this->hasAction($action)) {
+ if($action && SiteTree::config()->nested_urls && !$this->hasAction($action)) {
// See ModelAdController->getNestedController() for similar logic
if(class_exists('Translatable')) Translatable::disable_locale_filter();
// look for a page with this URLSegment
@@ -95,7 +95,7 @@ public function getNestedController() {
sprintf(
'"URLSegment" = \'%s\' %s',
Convert::raw2sql(rawurlencode($URLSegment)),
- (SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null)
+ (SiteTree::config()->nested_urls ? 'AND "ParentID" = 0' : null)
)
);
if(class_exists('Translatable')) Translatable::enable_locale_filter();
@@ -148,10 +148,10 @@ public function getNestedController() {
static public function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
$URLSegment = Convert::raw2sql(rawurlencode($URLSegment));
- $useParentIDFilter = SiteTree::nested_urls() && $parentID;
+ $useParentIDFilter = SiteTree::config()->nested_urls && $parentID;
// First look for a non-nested page that has a unique URLSegment and can be redirected to.
- if(SiteTree::nested_urls()) {
+ if(SiteTree::config()->nested_urls) {
$pages = DataObject::get(
'SiteTree',
"\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '')
@@ -13,17 +13,15 @@
*/
class ReportAdmin extends LeftAndMain implements PermissionProvider {
- static $url_segment = 'reports';
+ private static $url_segment = 'reports';
- static $url_rule = '/$ReportClass/$Action';
+ private static $url_rule = '/$ReportClass/$Action';
- static $menu_title = 'Reports';
+ private static $menu_title = 'Reports';
- static $template_path = null; // defaults to (project)/templates/email
-
- static $tree_class = 'SS_Report';
+ private static $tree_class = 'SS_Report';
- public static $url_handlers = array(
+ private static $url_handlers = array(
'$ReportClass/$Action' => 'handleAction'
);
@@ -11,9 +11,10 @@ class RootURLController extends Controller {
protected static $is_at_root = false;
/**
+ * @config
* @var string
*/
- protected static $default_homepage_link = 'home';
+ private static $default_homepage_link = 'home';
/**
* @var string
@@ -49,7 +50,7 @@ class_exists('Translatable')
) {
self::$cached_homepage_link = $link;
} else {
- self::$cached_homepage_link = self::get_default_homepage_link();
+ self::$cached_homepage_link = Config::inst()->get('RootURLController', 'default_homepage_link');
}
}
}
@@ -61,19 +62,23 @@ class_exists('Translatable')
* Set the URL Segment used for your homepage when it is created by dev/build.
* This allows you to use home page URLs other than the default "home".
*
+ * @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead
* @param string $urlsegment the URL segment for your home page
*/
static public function set_default_homepage_link($urlsegment = "home") {
- self::$default_homepage_link = $urlsegment;
+ Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead');
+ Config::inst()->update('RootURLController', 'default_homepage_link', $urlsegment);
}
/**
* Gets the link that denotes the homepage if there is not one explicitly defined for this HTTP_HOST value.
*
+ * @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead
* @return string
*/
static public function get_default_homepage_link() {
- return self::$default_homepage_link;
+ Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead');
+ return Config::inst()->get('RootURLController', 'default_homepage_link');
}
/**
@@ -219,7 +219,8 @@ public function isArchived() {
* @subpackage content
*/
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
- static $priority = 10;
+ /** @config */
+ private static $priority = 10;
public function getHTML() {
return sprintf(
@@ -257,7 +258,8 @@ public function canView($member = null) {
* @subpackage content
*/
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
- static $priority = 20;
+ /** @config */
+ private static $priority = 20;
public function getHTML() {
$draftPage = $this->getDraftPage();
@@ -316,7 +318,8 @@ protected function getDraftPage() {
* @subpackage content
*/
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
- static $priority = 30;
+ /** @config */
+ private static $priority = 30;
public function getHTML() {
$livePage = $this->getLivePage();
@@ -369,7 +372,8 @@ protected function getLivePage() {
* @subpackage content
*/
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
- static $priority = 40;
+ /** @config */
+ private static $priority = 40;
public function getHTML() {
$this->recordLink = $this->record->AbsoluteLink();
Oops, something went wrong.

0 comments on commit 51c8e86

Please sign in to comment.