Skip to content
This repository
Browse code

MINOR Using late static binding instead of Object::create() calls

  • Loading branch information...
commit de573e087d4a9d05692a0f665e836f489ccaf9a5 1 parent 070c9c2
Ingo Schommer authored April 04, 2012
6  code/controllers/AssetAdmin.php
@@ -211,8 +211,8 @@ public function getEditForm($id = null, $fields = null) {
211 211
 
212 212
 		// List view
213 213
 		$fields->addFieldsToTab('Root.ListView', array(
214  
-			$actionsComposite = Object::create('CompositeField',
215  
-				Object::create('CompositeField',
  214
+			$actionsComposite = CompositeField::create(
  215
+				CompositeField::create(
216 216
 					$uploadBtn,
217 217
 					$addFolderBtn,
218 218
 					$syncButton //TODO: add this into a batch actions menu as in https://github.com/silverstripe/silverstripe-design/raw/master/Design/ss3-ui_files-manager-list-view.jpg
@@ -311,7 +311,7 @@ public function SearchForm() {
311 311
 
312 312
 		$fields = $context->getSearchFields();
313 313
 		$actions = new FieldList(
314  
-			Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.CLEAR', 'Clear'))
  314
+			ResetFormAction::create('clear', _t('CMSMain_left.ss.CLEAR', 'Clear'))
315 315
 				->addExtraClass('ss-ui-action-minor'),
316 316
 			FormAction::create('doSearch',  _t('CMSMain_left.ss.SEARCH', 'Search'))
317 317
 		);
2  code/controllers/CMSFileAddController.php
@@ -57,7 +57,7 @@ public function getEditForm($id = null, $fields = null) {
57 57
 
58 58
 		$folder = $this->currentPage();
59 59
 
60  
-		$uploadField = Object::create('UploadField', 'AssetUploadField', '');
  60
+		$uploadField = UploadField::create('AssetUploadField', '');
61 61
 		$uploadField->setConfig('previewMaxWidth', 40);
62 62
 		$uploadField->setConfig('previewMaxHeight', 30);
63 63
 		$uploadField->addExtraClass('ss-assetuploadfield');
2  code/controllers/CMSMain.php
@@ -200,7 +200,7 @@ function SearchForm() {
200 200
 		$dateTo->setConfig('showcalendar', true);
201 201
 
202 202
 		$actions = new FieldList(
203  
-			Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.CLEAR', 'Clear'))
  203
+			ResetFormAction::create('clear', _t('CMSMain_left.ss.CLEAR', 'Clear'))
204 204
 				->addExtraClass('ss-ui-action-minor'),
205 205
 			FormAction::create('doSearch',  _t('CMSMain_left.ss.SEARCH', 'Search'))
206 206
 		);
2  code/controllers/ContentController.php
@@ -376,7 +376,7 @@ public function SilverStripeNavigator() {
376 376
 		} else {
377 377
 			if($date = Versioned::current_archived_date()) {
378 378
 				Requirements::css(CMS_DIR . '/css/SilverStripeNavigator.css');
379  
-				$dateObj = Object::create('Datetime', $date, null);
  379
+				$dateObj = Datetime::create($date, null);
380 380
 				// $dateObj->setVal($date);
381 381
 				return "<div id=\"SilverStripeNavigatorMessage\">". _t('ContentController.ARCHIVEDSITEFROM') ."<br>" . $dateObj->Nice() . "</div>";
382 382
 			}
2  code/controllers/SilverStripeNavigator.php
@@ -299,7 +299,7 @@ function getHTML() {
299 299
 	
300 300
 	function getMessage() {
301 301
 		if($date = Versioned::current_archived_date()) {
302  
-			$dateObj = Object::create('Datetime');
  302
+			$dateObj = Datetime::create();
303 303
 			$dateObj->setValue($date);
304 304
 			return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
305 305
 		}
6  code/model/SiteConfig.php
@@ -56,13 +56,13 @@ function getCMSFields($params = null) {
56 56
 				),
57 57
 				$tabAccess = new Tab('Access',
58 58
 					$viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")),
59  
-					$viewerGroupsField = Object::create('ListboxField', "ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
  59
+					$viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
60 60
 						->setMultiple(true)->setSource($groupsMap),
61 61
 					$editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")),
62  
-					$editorGroupsField = Object::create('ListboxField', "EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
  62
+					$editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
63 63
 						->setMultiple(true)->setSource($groupsMap),
64 64
 					$topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")),
65  
-					$topLevelCreatorsGroupsField = Object::create('ListboxField', "CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))
  65
+					$topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))
66 66
 						->setMultiple(true)->setSource($groupsMap)
67 67
 				)
68 68
 			)
10  code/model/SiteTree.php
@@ -1374,7 +1374,7 @@ protected function onBeforeWrite() {
1374 1374
 		if((!$this->URLSegment || $this->URLSegment == 'new-page') && $this->Title) {
1375 1375
 			$this->URLSegment = $this->generateURLSegment($this->Title);
1376 1376
 		} else if($this->isChanged('URLSegment')) {
1377  
-			$filter = Object::create('URLSegmentFilter');
  1377
+			$filter = URLSegmentFilter::create();
1378 1378
 			$this->URLSegment = $filter->filter($this->URLSegment);
1379 1379
 			// If after sanitising there is no URLSegment, give it a reasonable default
1380 1380
 			if(!$this->URLSegment) $this->URLSegment = "page-$this->ID";
@@ -1583,7 +1583,7 @@ public function validURLSegment() {
1583 1583
 	 * @return string Generated url segment
1584 1584
 	 */
1585 1585
 	function generateURLSegment($title){
1586  
-		$filter = Object::create('URLSegmentFilter');
  1586
+		$filter = URLSegmentFilter::create();
1587 1587
 		$t = $filter->filter($title);
1588 1588
 		
1589 1589
 		// Fallback to generic page name if path is empty (= no valid, convertable characters)
@@ -1906,13 +1906,13 @@ function getSettingsFields() {
1906 1906
 						"CanViewType", 
1907 1907
 						_t('SiteTree.ACCESSHEADER', "Who can view this page?")
1908 1908
 					),
1909  
-					$viewerGroupsField = Object::create('ListboxField', "ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
  1909
+					$viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))
1910 1910
 						->setMultiple(true)->setSource($groupsMap),
1911 1911
 					$editorsOptionsField = new OptionsetField(
1912 1912
 						"CanEditType", 
1913 1913
 						_t('SiteTree.EDITHEADER', "Who can edit this page?")
1914 1914
 					),
1915  
-					$editorGroupsField = Object::create('ListboxField', "EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
  1915
+					$editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))
1916 1916
 						->setMultiple(true)->setSource($groupsMap)
1917 1917
 				)
1918 1918
 			)
@@ -2022,7 +2022,7 @@ function fieldLabels($includerelations = true) {
2022 2022
 	 * @return FieldList The available actions for this page.
2023 2023
 	 */
2024 2024
 	function getCMSActions() {
2025  
-		$minorActions = Object::create('CompositeField')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
  2025
+		$minorActions = CompositeField::create()->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
2026 2026
 		$actions = new FieldList($minorActions);
2027 2027
 
2028 2028
 		// "readonly"/viewing version that isn't the current version of the record
2  tasks/RemoveOrphanedPagesTask.php
@@ -106,7 +106,7 @@ function Form() {
106 106
 				$orphan->ID,
107 107
 				$orphan->Title,
108 108
 				$orphan->ID,
109  
-				DBField::create('Date', $orphan->LastEdited)->Nice(),
  109
+				Date::create($orphan->LastEdited)->Nice(),
110 110
 				($latestAuthor) ? $latestAuthor->Title : 'unknown',
111 111
 				($liveRecord) ? 'is published' : 'not published'
112 112
 			);

0 notes on commit de573e0

Please sign in to comment.
Something went wrong with that request. Please try again.