From 84feab5a684ecb75e72fe80e27bd84fee19f76df Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Thu, 3 Aug 2017 16:25:49 +1200 Subject: [PATCH] Yeah psr2 functions --- docs/en/01_Tutorials/03_Forms.md | 3 +- .../00_Model/01_Data_Model_and_ORM.md | 3 +- .../00_Model/02_Relations.md | 3 +- .../00_Model/04_Data_Types_and_Casting.md | 12 +++++--- .../00_Model/05_Extending_DataObjects.md | 6 ++-- .../00_Model/07_Permissions.md | 12 +++++--- .../00_Model/09_Validation.md | 3 +- .../00_Model/10_Versioning.md | 15 ++++++---- .../00_Model/11_Scaffolding.md | 6 ++-- .../01_Templates/07_Caching.md | 3 +- .../01_Templates/09_Casting.md | 6 ++-- .../01_Templates/How_Tos/02_Pagination.md | 3 +- .../How_Tos/03_Disable_Anchor_Links.md | 3 +- .../02_Controllers/01_Introduction.md | 24 ++++++++++----- .../02_Controllers/03_Access_Control.md | 27 +++++++++++------ .../03_Forms/Field_types/02_DateField.md | 3 +- .../Field_types/03_HTMLEditorField.md | 12 +++++--- .../03_Forms/Field_types/04_GridField.md | 15 ++++++---- .../03_Forms/How_Tos/01_Encapsulate_Forms.md | 9 ++++-- .../03_Forms/How_Tos/02_Lightweight_Form.md | 3 +- .../04_Create_a_GridField_ActionProvider.md | 21 ++++++++----- .../How_Tos/05_Simple_Contact_Form.md | 12 +++++--- .../04_Configuration/01_SiteConfig.md | 3 +- .../05_Extending/01_Extensions.md | 24 ++++++++++----- .../05_Extending/04_Shortcodes.md | 6 ++-- .../05_Extending/05_Injector.md | 9 ++++-- .../05_Extending/06_Aspects.md | 3 +- .../How_Tos/03_Track_member_logins.md | 12 +++++--- .../How_Tos/01_Write_a_FunctionalTest.md | 3 +- .../06_Testing/How_Tos/03_Testing_Email.md | 3 +- .../08_Performance/00_Partial_Caching.md | 6 ++-- .../08_Performance/05_Resource_Usage.md | 3 +- .../09_Security/00_Member.md | 9 ++++-- .../09_Security/04_Secure_Coding.md | 30 ++++++++++++------- .../11_Integration/00_CSV_Import.md | 15 ++++++---- .../11_Integration/01_RestfulService.md | 9 ++++-- .../11_Integration/02_RSSFeed.md | 21 ++++++++----- .../Import_CSV_through_a_Controller.md | 9 ++++-- .../How_Tos/custom_csvbulkloader.md | 6 ++-- .../11_Integration/How_Tos/embed_rss.md | 3 +- .../12_Search/01_Searchcontext.md | 15 ++++++---- .../14_Files/03_File_Security.md | 6 ++-- .../01_ModelAdmin.md | 30 ++++++++++++------- .../02_CMS_Architecture.md | 12 +++++--- .../06_Javascript_Development.md | 3 +- .../How_Tos/CMS_Alternating_Button.md | 6 ++-- .../How_Tos/Customise_CMS_Menu.md | 3 +- .../How_Tos/Customise_CMS_Tree.md | 6 ++-- .../How_Tos/Customise_Site_Reports.md | 9 ++++-- .../How_Tos/Extend_CMS_Interface.md | 6 ++-- .../Extending_An_Existing_ModelAdmin.md | 3 +- .../16_Execution_Pipeline/01_Flushable.md | 9 ++++-- docs/en/04_Changelogs/3.0.0.md | 3 +- docs/en/04_Changelogs/3.0.9.md | 3 +- docs/en/04_Changelogs/3.1.0.md | 27 +++++++++++------ docs/en/04_Changelogs/3.1.11.md | 3 +- docs/en/04_Changelogs/3.1.16.md | 3 +- docs/en/04_Changelogs/3.1.2.md | 3 +- docs/en/04_Changelogs/3.1.9.md | 3 +- docs/en/04_Changelogs/3.2.0.md | 12 +++++--- docs/en/04_Changelogs/3.2.1.md | 3 +- docs/en/04_Changelogs/4.0.0.md | 6 ++-- docs/en/04_Changelogs/alpha/4.0.0-alpha1.md | 21 ++++++++----- docs/en/04_Changelogs/beta/3.2.0-beta1.md | 12 +++++--- docs/en/04_Changelogs/rc/3.1.2-rc1.md | 3 +- docs/en/05_Contributing/04_Release_Process.md | 3 +- .../14_PHP_Coding_Conventions.md | 6 ++-- 67 files changed, 398 insertions(+), 199 deletions(-) diff --git a/docs/en/01_Tutorials/03_Forms.md b/docs/en/01_Tutorials/03_Forms.md index 6b9216bf2..91f920ce6 100644 --- a/docs/en/01_Tutorials/03_Forms.md +++ b/docs/en/01_Tutorials/03_Forms.md @@ -216,7 +216,8 @@ use PageController; class HomePageController extends PageController { // ... - public function doBrowserPoll($data, $form) { + public function doBrowserPoll($data, $form) + { $submission = new BrowserPollSubmission(); $form->saveInto($submission); $submission->write(); diff --git a/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md b/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md index 384e3c7ae..602f06adf 100644 --- a/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md +++ b/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md @@ -604,7 +604,8 @@ table and column. ```php - public function countDuplicates($model, $fieldToCheck) { + public function countDuplicates($model, $fieldToCheck) + { $table = DataObject::getSchema()->tableForField($model, $field); $query = new SQLSelect(); $query->setFrom("\"{$table}\""); diff --git a/docs/en/02_Developer_Guides/00_Model/02_Relations.md b/docs/en/02_Developer_Guides/00_Model/02_Relations.md index a52ddf20e..13f8fe384 100644 --- a/docs/en/02_Developer_Guides/00_Model/02_Relations.md +++ b/docs/en/02_Developer_Guides/00_Model/02_Relations.md @@ -423,7 +423,8 @@ See [DataObject::$has_many](api:SilverStripe\ORM\DataObject::$has_many) for more "Players" => "Player" ]; - public function ActivePlayers() { + public function ActivePlayers() + { return $this->Players()->filter('Status', 'Active'); } } diff --git a/docs/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md b/docs/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md index f964ab9e2..3302a939b 100644 --- a/docs/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md +++ b/docs/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md @@ -112,7 +112,8 @@ object we can control the formatting and it allows us to call methods defined fr .. - public function getName() { + public function getName() + { return DBField::create_field('Varchar', $this->FirstName . ' '. $this->LastName); } } @@ -145,7 +146,8 @@ Rather than manually returning objects from your custom functions. You can use t "Name" => 'Varchar', ]; - public function getName() { + public function getName() + { return $this->FirstName . ' '. $this->LastName; } } @@ -183,7 +185,8 @@ context. Through a `$casting` array, arbitrary properties and getters can be cas 'MyDate' => 'Date' ]; - public function getMyDate() { + public function getMyDate() + { return '1982-01-01'; } } @@ -222,7 +225,8 @@ database column using `dbObject`. "Status" => "Enum(array('Active', 'Injured', 'Retired'))" ]; - public function getStatus() { + public function getStatus() + { return (!$this->obj("Birthday")->InPast()) ? "Unborn" : $this->dbObject('Status')->Value(); } diff --git a/docs/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md b/docs/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md index 137899d4b..217fc6ba4 100644 --- a/docs/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md +++ b/docs/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md @@ -26,7 +26,8 @@ Example: Disallow creation of new players if the currently logged-in player is n "Teams"=>"Team" ]; - public function onBeforeWrite() { + public function onBeforeWrite() + { // check on first write action, aka "database row creation" (ID-property is not set) if(!$this->isInDb()) { $currentPlayer = Security::getCurrentUser(); @@ -66,7 +67,8 @@ member is logged in who belongs to a group containing the permission "PLAYER_DEL "Teams" => "Team" ]; - public function onBeforeDelete() { + public function onBeforeDelete() + { if(!Permission::check('PLAYER_DELETE')) { Security::permissionFailure($this); exit(); diff --git a/docs/en/02_Developer_Guides/00_Model/07_Permissions.md b/docs/en/02_Developer_Guides/00_Model/07_Permissions.md index c6c2d2d06..8faf40615 100644 --- a/docs/en/02_Developer_Guides/00_Model/07_Permissions.md +++ b/docs/en/02_Developer_Guides/00_Model/07_Permissions.md @@ -20,19 +20,23 @@ code. class MyDataObject extends DataObject { - public function canView($member = null) { + public function canView($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canEdit($member = null) { + public function canEdit($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canDelete($member = null) { + public function canDelete($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canCreate($member = null) { + public function canCreate($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } } diff --git a/docs/en/02_Developer_Guides/00_Model/09_Validation.md b/docs/en/02_Developer_Guides/00_Model/09_Validation.md index f974b8a15..2bf34ce4f 100644 --- a/docs/en/02_Developer_Guides/00_Model/09_Validation.md +++ b/docs/en/02_Developer_Guides/00_Model/09_Validation.md @@ -30,7 +30,8 @@ The return value of `validate()` is a [ValidationResult](api:SilverStripe\ORM\Va 'Postcode' => 'Varchar' ]; - public function validate() { + public function validate() + { $result = parent::validate(); if($this->Country == 'DE' && $this->Postcode && strlen($this->Postcode) != 5) { diff --git a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md index bddbfb98f..59cac04e5 100644 --- a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md +++ b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md @@ -235,7 +235,8 @@ E.g. private static $owns = [ 'ChildObjects' ]; - public function ChildObjects() { + public function ChildObjects() + { return MyChild::get(); } } @@ -247,7 +248,8 @@ E.g. private static $owned_by = [ 'Parent' ]; - public function Parent() { + public function Parent() + { return MyParent::get()->first(); } } @@ -302,7 +304,8 @@ E.g. Versioned::class, ]; - public function canViewVersioned($member = null) { + public function canViewVersioned($member = null) + { // Check if site is live $mode = $this->getSourceQueryParam("Versioned.mode"); $stage = $this->getSourceQueryParam("Versioned.stage"); @@ -331,7 +334,8 @@ E.g. ```php class MyObjectExtension extends DataExtension { - public function canViewNonLive($member = null) { + public function canViewNonLive($member = null) + { return Permission::check($member, 'DRAFT_STATUS'); } } @@ -369,7 +373,8 @@ to force a specific stage, we recommend the `Controller->init()` method for this **mysite/code/MyController.php** ```php - public function init() { + public function init() + { parent::init(); Versioned::set_stage(Versioned::DRAFT); } diff --git a/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md b/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md index 47dcabb25..5483c88a8 100644 --- a/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md +++ b/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md @@ -22,7 +22,8 @@ An example is `DataObject`, SilverStripe will automatically create your CMS inte 'Content' => 'Text' ]; - public function getCMSFields() { + public function getCMSFields() + { // parent::getCMSFields() does all the hard work and creates the fields for Title, IsActive and Content. $fields = parent::getCMSFields(); $fields->dataFieldByName('IsActive')->setTitle('Is active?'); @@ -37,7 +38,8 @@ To fully customise your form fields, start with an empty FieldList. ```php - public function getCMSFields() { + public function getCMSFields() + { $fields = FieldList::create( TabSet::create("Root.Main", CheckboxSetField::create('IsActive','Is active?'), diff --git a/docs/en/02_Developer_Guides/01_Templates/07_Caching.md b/docs/en/02_Developer_Guides/01_Templates/07_Caching.md index e8612d5a1..8f0a9edf0 100644 --- a/docs/en/02_Developer_Guides/01_Templates/07_Caching.md +++ b/docs/en/02_Developer_Guides/01_Templates/07_Caching.md @@ -11,7 +11,8 @@ example, this controller method will not behave as you might imagine. ```php private $counter = 0; - public function Counter() { + public function Counter() + { $this->counter += 1; return $this->counter; diff --git a/docs/en/02_Developer_Guides/01_Templates/09_Casting.md b/docs/en/02_Developer_Guides/01_Templates/09_Casting.md index 93fff37cd..cd949e135 100644 --- a/docs/en/02_Developer_Guides/01_Templates/09_Casting.md +++ b/docs/en/02_Developer_Guides/01_Templates/09_Casting.md @@ -51,7 +51,8 @@ provide default template for an object. class Page extends SiteTree { - public function forTemplate() { + public function forTemplate() + { return "Page: ". $this->Title; } } @@ -78,7 +79,8 @@ to a template, SilverStripe will ensure that the object is wrapped in the correc 'MyCustomMethod' => 'HTMLText' ]; - public function MyCustomMethod() { + public function MyCustomMethod() + { return "

This is my header

"; } } diff --git a/docs/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md b/docs/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md index 04bc90d4a..6ba10d9ae 100644 --- a/docs/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md +++ b/docs/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md @@ -14,7 +14,8 @@ The `PaginatedList` will automatically set up query limits and read the request /** * Returns a paginated list of all pages in the site. */ - public function PaginatedPages() { + public function PaginatedPages() + { $list = Page::get(); return new PaginatedList($list, $this->getRequest()); diff --git a/docs/en/02_Developer_Guides/01_Templates/How_Tos/03_Disable_Anchor_Links.md b/docs/en/02_Developer_Guides/01_Templates/How_Tos/03_Disable_Anchor_Links.md index 40c35ec04..a0802a025 100644 --- a/docs/en/02_Developer_Guides/01_Templates/How_Tos/03_Disable_Anchor_Links.md +++ b/docs/en/02_Developer_Guides/01_Templates/How_Tos/03_Disable_Anchor_Links.md @@ -37,7 +37,8 @@ SSViewer: Or, a better way is to call this just for the rendering phase of this particular file: :::php - public function RenderCustomTemplate() { + public function RenderCustomTemplate() + { Config::inst()->update('SSViewer', 'rewrite_hash_links', false); $html = $this->renderWith('MyCustomTemplate'); Config::inst()->update('SSViewer', 'rewrite_hash_links', true); diff --git a/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md b/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md index 32c701004..31b813afe 100644 --- a/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md +++ b/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md @@ -17,11 +17,13 @@ subclass the base `Controller` class. 'index' ]; - public function index(HTTPRequest $request) { + public function index(HTTPRequest $request) + { // .. } - public function players(HTTPRequest $request) { + public function players(HTTPRequest $request) + { print_r($request->allParams()); } } @@ -81,7 +83,8 @@ Action methods can return one of four main things: * Return some additional data to the current response that is waiting to go out, this makes $Title set to * 'MyTeamName' and continues on with generating the response. */ - public function index(HTTPRequest $request) { + public function index(HTTPRequest $request) + { return [ 'Title' => 'My Team Name' ]; @@ -90,7 +93,8 @@ Action methods can return one of four main things: /** * We can manually create a response and return that to ignore any previous data. */ - public function someaction(HTTPRequest $request) { + public function someaction(HTTPRequest $request) + { $this->setResponse(new HTTPResponse()); $this->getResponse()->setStatusCode(400); $this->getResponse()->setBody('invalid'); @@ -101,7 +105,8 @@ Action methods can return one of four main things: /** * Or, we can modify the response that is waiting to go out. */ - public function anotheraction(HTTPRequest $request) { + public function anotheraction(HTTPRequest $request) + { $this->getResponse()->setStatusCode(400); return $this->getResponse(); @@ -110,7 +115,8 @@ Action methods can return one of four main things: /** * We can render HTML and leave SilverStripe to set the response code and body. */ - public function htmlaction() { + public function htmlaction() + { return $this->customise(new ArrayData([ 'Title' => 'HTML Action' ]))->renderWith('MyCustomTemplate'); @@ -119,7 +125,8 @@ Action methods can return one of four main things: /** * We can send stuff to the browser which isn't HTML */ - public function ajaxaction() { + public function ajaxaction() + { $this->getResponse()->setBody(json_encode([ 'json' => true ])); @@ -158,7 +165,8 @@ Each controller should define a `Link()` method. This should be used to avoid ha **mysite/code/controllers/TeamController.php** ```php - public function Link($action = null) { + public function Link($action = null) + { return Controller::join_links('teams', $action); } ``` diff --git a/docs/en/02_Developer_Guides/02_Controllers/03_Access_Control.md b/docs/en/02_Developer_Guides/02_Controllers/03_Access_Control.md index 4c8515d8d..e6d394a31 100644 --- a/docs/en/02_Developer_Guides/02_Controllers/03_Access_Control.md +++ b/docs/en/02_Developer_Guides/02_Controllers/03_Access_Control.md @@ -50,7 +50,8 @@ is specifically restricted. class MyController extends Controller { - public function index() { + public function index() + { // allowed without an $allowed_action defined } } @@ -80,11 +81,13 @@ Only public methods can be made accessible. // secureaction won't work as it's private. ]; - public function secure() { + public function secure() + { // .. } - private function secureaction() { + private function secureaction() + { // .. } } @@ -100,7 +103,8 @@ If a method on a parent class is overwritten, access control for it has to be re 'action', ]; - public function action() { + public function action() + { // .. } } @@ -111,7 +115,8 @@ If a method on a parent class is overwritten, access control for it has to be re 'action', // required as we are redefining action ]; - public function action() { + public function action() + { } } @@ -134,11 +139,13 @@ as an `allowed_action`. 'ContactForm' // use the Form method, not the action ]; - public function ContactForm() { + public function ContactForm() + { return new Form(..); } - public function doContactForm($data, $form) { + public function doContactForm($data, $form) + { // .. } } @@ -158,7 +165,8 @@ the passed request data. 'myaction' ]; - public function myaction($request) { + public function myaction($request) + { if(!$request->getVar('apikey')) { return $this->httpError(403, 'No API key provided'); } @@ -189,7 +197,8 @@ execution. This behavior can be used to implement permission checks. private static $allowed_actions = []; - public function init() { + public function init() + { parent::init(); if(!Permission::check('ADMIN')) { diff --git a/docs/en/02_Developer_Guides/03_Forms/Field_types/02_DateField.md b/docs/en/02_Developer_Guides/03_Forms/Field_types/02_DateField.md index 36ec00f1f..70eff180e 100644 --- a/docs/en/02_Developer_Guides/03_Forms/Field_types/02_DateField.md +++ b/docs/en/02_Developer_Guides/03_Forms/Field_types/02_DateField.md @@ -23,7 +23,8 @@ The following example will add a simple DateField to your Page, allowing you to 'MyDate' => 'Date', ]; - public function getCMSFields() { + public function getCMSFields() + { $fields = parent::getCMSFields(); $fields->addFieldToTab( diff --git a/docs/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md b/docs/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md index c0f2cd646..188347638 100644 --- a/docs/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md +++ b/docs/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md @@ -24,7 +24,8 @@ functionality. It is usually added through the [DataObject::getCMSFields()](api: 'Content' => 'HTMLText' ]; - public function getCMSFields() { + public function getCMSFields() + { return new FieldList( new HTMLEditorField('Content') ); @@ -53,7 +54,8 @@ This is particularly useful if you need different configurations for multiple [H 'OtherContent' => 'HTMLText' ]; - public function getCMSFields() { + public function getCMSFields() + { return new FieldList([ new HTMLEditorField('Content'), new HTMLEditorField('OtherContent', 'Other content', $this->OtherContent, 'myConfig') @@ -247,7 +249,8 @@ Example: Remove field for "image captions" // File: mysite/code/MyToolbarExtension.php class MyToolbarExtension extends Extension { - public function updateFieldsForImage(&$fields, $url, $file) { + public function updateFieldsForImage(&$fields, $url, $file) + { $fields->removeByName('CaptionText'); } } @@ -288,7 +291,8 @@ of the CMS you have to take care of instantiate yourself: // File: mysite/code/MyController.php class MyObjectController extends Controller { - public function Modals() { + public function Modals() + { return ModalController::create($this, "Modals"); } } diff --git a/docs/en/02_Developer_Guides/03_Forms/Field_types/04_GridField.md b/docs/en/02_Developer_Guides/03_Forms/Field_types/04_GridField.md index 9d59373da..c54e7ef85 100644 --- a/docs/en/02_Developer_Guides/03_Forms/Field_types/04_GridField.md +++ b/docs/en/02_Developer_Guides/03_Forms/Field_types/04_GridField.md @@ -32,7 +32,8 @@ actions such as deleting records. class Page extends SiteTree { - public function getCMSFields() { + public function getCMSFields() + { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Pages', @@ -64,7 +65,8 @@ the `getConfig()` method on `GridField`. class Page extends SiteTree { - public function getCMSFields() { + public function getCMSFields() + { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Pages', @@ -297,7 +299,8 @@ The namespace notation is `ManyMany[]`, so for example `Ma ] ]; - public function getCMSFields() { + public function getCMSFields() + { $fields = parent::getCMSFields(); if($this->ID) { @@ -355,7 +358,8 @@ create an area rendered before the table wrapped in a simple `
`. class MyAreaComponent implements GridField_HTMLProvider { - public function getHTMLFragments( $gridField) { + public function getHTMLFragments( $gridField) + { return [ 'before' => '
$DefineFragment(my-area)
' ]; @@ -377,7 +381,8 @@ Now you can add other components into this area by returning them as an array fr class MyShareLinkComponent implements GridField_HTMLProvider { - public function getHTMLFragments( $gridField) { + public function getHTMLFragments( $gridField) + { return [ 'my-area' => '...' ]; diff --git a/docs/en/02_Developer_Guides/03_Forms/How_Tos/01_Encapsulate_Forms.md b/docs/en/02_Developer_Guides/03_Forms/How_Tos/01_Encapsulate_Forms.md index 717489dae..2be887d5f 100644 --- a/docs/en/02_Developer_Guides/03_Forms/How_Tos/01_Encapsulate_Forms.md +++ b/docs/en/02_Developer_Guides/03_Forms/How_Tos/01_Encapsulate_Forms.md @@ -14,7 +14,8 @@ code for a `Form` is to create it as a subclass to `Form`. Let's look at a examp class PageController extends ContentController { - public function SearchForm() { + public function SearchForm() + { $fields = new FieldList( HeaderField::create('Header', 'Step 1. Basics'), OptionsetField::create('Type', '', [ @@ -77,7 +78,8 @@ should be. Good practice would be to move this to a subclass and create a new in * method. We'll create the fields and actions in here. * */ - public function __construct($controller, $name) { + public function __construct($controller, $name) + { $fields = new FieldList( HeaderField::create('Header', 'Step 1. Basics'), OptionsetField::create('Type', '', [ @@ -138,7 +140,8 @@ Our controller will now just have to create a new instance of this form object. 'SearchForm', ]; - public function SearchForm() { + public function SearchForm() + { return new SearchForm($this, 'SearchForm'); } } diff --git a/docs/en/02_Developer_Guides/03_Forms/How_Tos/02_Lightweight_Form.md b/docs/en/02_Developer_Guides/03_Forms/How_Tos/02_Lightweight_Form.md index 4b38a0e64..176ffcd11 100644 --- a/docs/en/02_Developer_Guides/03_Forms/How_Tos/02_Lightweight_Form.md +++ b/docs/en/02_Developer_Guides/03_Forms/How_Tos/02_Lightweight_Form.md @@ -14,7 +14,8 @@ totally custom template to meet our needs. To do this, we'll provide the class w ```php - public function SearchForm() { + public function SearchForm() + { $fields = new FieldList( TextField::create('q') ); diff --git a/docs/en/02_Developer_Guides/03_Forms/How_Tos/04_Create_a_GridField_ActionProvider.md b/docs/en/02_Developer_Guides/03_Forms/How_Tos/04_Create_a_GridField_ActionProvider.md index 391e9b346..70befc562 100644 --- a/docs/en/02_Developer_Guides/03_Forms/How_Tos/04_Create_a_GridField_ActionProvider.md +++ b/docs/en/02_Developer_Guides/03_Forms/How_Tos/04_Create_a_GridField_ActionProvider.md @@ -22,27 +22,32 @@ below: class GridFieldCustomAction implements GridField_ColumnProvider, GridField_ActionProvider { - public function augmentColumns($gridField, &$columns) { + public function augmentColumns($gridField, &$columns) + { if(!in_array('Actions', $columns)) { $columns[] = 'Actions'; } } - public function getColumnAttributes($gridField, $record, $columnName) { + public function getColumnAttributes($gridField, $record, $columnName) + { return ['class' => 'grid-field__col-compact']; } - public function getColumnMetadata($gridField, $columnName) { + public function getColumnMetadata($gridField, $columnName) + { if($columnName == 'Actions') { return ['title' => '']; } } - public function getColumnsHandled($gridField) { + public function getColumnsHandled($gridField) + { return ['Actions']; } - public function getColumnContent($gridField, $record, $columnName) { + public function getColumnContent($gridField, $record, $columnName) + { if(!$record->canEdit()) return; $field = GridField_FormAction::create( @@ -56,11 +61,13 @@ below: return $field->Field(); } - public function getActions($gridField) { + public function getActions($gridField) + { return ['docustomaction']; } - public function handleAction(GridField $gridField, $actionName, $arguments, $data) { + public function handleAction(GridField $gridField, $actionName, $arguments, $data) + { if($actionName == 'docustomaction') { // perform your action here diff --git a/docs/en/02_Developer_Guides/03_Forms/How_Tos/05_Simple_Contact_Form.md b/docs/en/02_Developer_Guides/03_Forms/How_Tos/05_Simple_Contact_Form.md index f20e8a6f7..39ea34bfd 100644 --- a/docs/en/02_Developer_Guides/03_Forms/How_Tos/05_Simple_Contact_Form.md +++ b/docs/en/02_Developer_Guides/03_Forms/How_Tos/05_Simple_Contact_Form.md @@ -12,7 +12,8 @@ Let's start by defining a new `ContactPage` page type: class ContactPageController extends PageController { private static $allowed_actions = ['Form']; - public function Form() { + public function Form() + { $fields = new FieldList( new TextField('Name'), new EmailField('Email'), @@ -75,10 +76,12 @@ Now that we have a contact form, we need some way of collecting the data submitt class ContactPageController extends PageController { private static $allowed_actions = ['Form']; - public function Form() { + public function Form() + { // ... } - public function submit($data, $form) { + public function submit($data, $form) + { $email = new Email(); $email->setTo('siteowner@mysite.com'); @@ -122,7 +125,8 @@ The framework comes with a predefined validator called [RequiredFields](api:Silv ```php - public function Form() { + public function Form() + { // ... $validator = new RequiredFields('Name', 'Message'); return new Form($this, 'Form', $fields, $actions, $validator); diff --git a/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md b/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md index 33dacf3d3..2bb190f27 100644 --- a/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md +++ b/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md @@ -47,7 +47,8 @@ To extend the options available in the panel, define your own fields via a [Data 'FooterContent' => 'HTMLText' ]; - public function updateCMSFields(FieldList $fields) { + public function updateCMSFields(FieldList $fields) + { $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content") ); diff --git a/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md b/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md index 7247e2817..6487fe11e 100644 --- a/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md +++ b/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md @@ -26,7 +26,8 @@ and `RequestHandler`. You can still apply extensions to descendants of these cla 'DateOfBirth' => 'SS_Datetime' ]; - public function SayHi() { + public function SayHi() + { // $this->owner refers to the original instance. In this case a `Member`. return "Hi " . $this->owner->Name; } @@ -90,7 +91,8 @@ $has_one etc. 'Image' => 'Image', ]; - public function SayHi() { + public function SayHi() + { // $this->owner refers to the original instance. In this case a `Member`. return "Hi " . $this->owner->Name; } @@ -140,7 +142,8 @@ through the [Object::extend()](api:Object::extend()) method. ```php - public function getValidator() { + public function getValidator() + { // .. $this->extend('updateValidator', $validator); @@ -163,7 +166,8 @@ validator by defining the `updateValidator` method. // .. - public function updateValidator($validator) { + public function updateValidator($validator) + { // we want to make date of birth required for each member $validator->addRequiredField('DateOfBirth'); } @@ -190,7 +194,8 @@ extension. The `CMS` provides a `updateCMSFields` Extension Hook to tie into. 'Image' => 'Image', ]; - public function updateCMSFields(FieldList $fields) { + public function updateCMSFields(FieldList $fields) + { $fields->push(new TextField('Position')); $fields->push($upload = new UploadField('Image', 'Profile Image')); $upload->setAllowedFileCategories('image/supported'); @@ -206,7 +211,8 @@ which allows an Extension to modify the results. ```php - public function Foo() { + public function Foo() + { $foo = // .. $this->extend('updateFoo', $foo); @@ -228,7 +234,8 @@ In your [Extension](api:SilverStripe\Core\Extension) class you can only refer to class MyMemberExtension extends DataExtension { - public function updateFoo($foo) { + public function updateFoo($foo) + { // outputs the original class var_dump($this->owner); } @@ -288,7 +295,8 @@ This method is preferred to disabling, enabling, and calling field extensions ma ```php - public function getCMSFields() { + public function getCMSFields() + { $this->beforeUpdateCMSFields(function($fields) { // Include field which must be present when updateCMSFields is called on extensions diff --git a/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md b/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md index af89deff1..c443d23aa 100644 --- a/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md +++ b/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md @@ -57,7 +57,8 @@ First we need to define a callback for the shortcode. 'MyShortCodeMethod' => 'HTMLText' ]; - public static function MyShortCodeMethod($arguments, $content = null, $parser = null, $tagName) { + public static function MyShortCodeMethod($arguments, $content = null, $parser = null, $tagName) + { return "" . $tagName . " " . $content . "; " . count($arguments) . " arguments."; } } @@ -197,7 +198,8 @@ When the location attribute is "leftAlone" or "center" then the DOM is split aro Here is a summary of the callback parameter values based on some example shortcodes. ```php - public function MyCustomShortCode($arguments, $content = null, $parser = null, $tagName) { + public function MyCustomShortCode($arguments, $content = null, $parser = null, $tagName) + { // .. } diff --git a/docs/en/02_Developer_Guides/05_Extending/05_Injector.md b/docs/en/02_Developer_Guides/05_Extending/05_Injector.md index 53bd26f76..48e61c82a 100644 --- a/docs/en/02_Developer_Guides/05_Extending/05_Injector.md +++ b/docs/en/02_Developer_Guides/05_Extending/05_Injector.md @@ -179,7 +179,8 @@ An example using the `MyFactory` service to create instances of the `MyService` class MyFactory implements SilverStripe\Core\Injector\Factory { - public function create($service, array $params = []) { + public function create($service, array $params = []) + { return new MyServiceImplementation(); } } @@ -216,7 +217,8 @@ Assuming a class structure such as { private $database; - public function setDatabase($d) { + public function setDatabase($d) + { $this->database = $d; } } @@ -225,7 +227,8 @@ Assuming a class structure such as private $username; private $password; - public function __construct($username, $password) { + public function __construct($username, $password) + { $this->username = $username; $this->password = $password; } diff --git a/docs/en/02_Developer_Guides/05_Extending/06_Aspects.md b/docs/en/02_Developer_Guides/05_Extending/06_Aspects.md index bf37ba0cf..d413d68d8 100644 --- a/docs/en/02_Developer_Guides/05_Extending/06_Aspects.md +++ b/docs/en/02_Developer_Guides/05_Extending/06_Aspects.md @@ -59,7 +59,8 @@ used. 'insert','update','delete','replace' ]; - public function beforeCall($proxied, $method, $args, &$alternateReturn) { + public function beforeCall($proxied, $method, $args, &$alternateReturn) + { if (isset($args[0])) { $sql = $args[0]; $code = isset($args[1]) ? $args[1] : E_USER_ERROR; diff --git a/docs/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md b/docs/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md index bddb6cc7b..846fc6a4c 100644 --- a/docs/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md +++ b/docs/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md @@ -18,22 +18,26 @@ explicitly logging in or by invoking the "remember me" functionality. 'NumVisit' => 'Int', ]; - public function memberLoggedIn() { + public function memberLoggedIn() + { $this->logVisit(); } - public function memberAutoLoggedIn() { + public function memberAutoLoggedIn() + { $this->logVisit(); } - public function updateCMSFields(FieldList $fields) { + public function updateCMSFields(FieldList $fields) + { $fields->addFieldsToTab('Root.Main', [ ReadonlyField::create('LastVisited', 'Last visited'), ReadonlyField::create('NumVisit', 'Number of visits') ]); } - protected function logVisit() { + protected function logVisit() + { if(!Security::database_is_ready()) return; DB::query(sprintf( diff --git a/docs/en/02_Developer_Guides/06_Testing/How_Tos/01_Write_a_FunctionalTest.md b/docs/en/02_Developer_Guides/06_Testing/How_Tos/01_Write_a_FunctionalTest.md index 53db45eef..9be96c57e 100644 --- a/docs/en/02_Developer_Guides/06_Testing/How_Tos/01_Write_a_FunctionalTest.md +++ b/docs/en/02_Developer_Guides/06_Testing/How_Tos/01_Write_a_FunctionalTest.md @@ -17,7 +17,8 @@ response and modify the session within a test. /** * Test generation of the view */ - public function testViewHomePage() { + public function testViewHomePage() + { $page = $this->get('home/'); // Home page should load.. diff --git a/docs/en/02_Developer_Guides/06_Testing/How_Tos/03_Testing_Email.md b/docs/en/02_Developer_Guides/06_Testing/How_Tos/03_Testing_Email.md index aa804a4d4..24651a926 100644 --- a/docs/en/02_Developer_Guides/06_Testing/How_Tos/03_Testing_Email.md +++ b/docs/en/02_Developer_Guides/06_Testing/How_Tos/03_Testing_Email.md @@ -8,7 +8,8 @@ email was sent using this method. ```php - public function MyMethod() { + public function MyMethod() + { $e = new Email(); $e->To = "someone@example.com"; $e->Subject = "Hi there"; diff --git a/docs/en/02_Developer_Guides/08_Performance/00_Partial_Caching.md b/docs/en/02_Developer_Guides/08_Performance/00_Partial_Caching.md index 6b5708a29..08bb32e0f 100644 --- a/docs/en/02_Developer_Guides/08_Performance/00_Partial_Caching.md +++ b/docs/en/02_Developer_Guides/08_Performance/00_Partial_Caching.md @@ -98,7 +98,8 @@ For example, a block that shows a collection of rotating slides needs to update ```php - public function SliderCacheKey() { + public function SliderCacheKey() + { $fragments = [ 'Page-Slides', $this->ID, @@ -146,7 +147,8 @@ configurable only on a site-wide basis), you could add a special function to you ```php - public function BlogStatisticsCounter() { + public function BlogStatisticsCounter() + { return (int)(time() / 60 / 5); // Returns a new number every five minutes } ``` diff --git a/docs/en/02_Developer_Guides/08_Performance/05_Resource_Usage.md b/docs/en/02_Developer_Guides/08_Performance/05_Resource_Usage.md index 9c6ede631..6cf4bd59c 100644 --- a/docs/en/02_Developer_Guides/08_Performance/05_Resource_Usage.md +++ b/docs/en/02_Developer_Guides/08_Performance/05_Resource_Usage.md @@ -24,7 +24,8 @@ SilverStripe can request more resources through `Environment::increaseMemoryLimi
```php - public function myBigFunction() { + public function myBigFunction() + { Environment::increaseTimeLimitTo(400); } ``` \ No newline at end of file diff --git a/docs/en/02_Developer_Guides/09_Security/00_Member.md b/docs/en/02_Developer_Guides/09_Security/00_Member.md index 7fd7a424b..9eee8a3d1 100644 --- a/docs/en/02_Developer_Guides/09_Security/00_Member.md +++ b/docs/en/02_Developer_Guides/09_Security/00_Member.md @@ -77,7 +77,8 @@ parent::getCMSFields() and manipulate the [FieldList](api:SilverStripe\Forms\Fie ```php - public function getCMSFields() { + public function getCMSFields() + { $fields = parent::getCMSFields(); $fields->insertBefore("HTMLEmail", new TextField("Age")); $fields->removeByName("JobTitle"); @@ -121,7 +122,8 @@ things, you should add appropriate [Permission::checkMember()](api:SilverStripe\ * Modify the field set to be displayed in the CMS detail pop-up */ - public function updateCMSFields(FieldList $currentFields) { + public function updateCMSFields(FieldList $currentFields) + { // Only show the additional fields on an appropriate kind of use if(Permission::checkMember($this->owner->ID, "VIEW_FORUM")) { // Edit the FieldList passed, adding or removing fields as necessary @@ -135,7 +137,8 @@ things, you should add appropriate [Permission::checkMember()](api:SilverStripe\ private static $many_many = []; private static $belongs_many_many = []; - public function somethingElse() { + public function somethingElse() + { // You can add any other methods you like, which you can call directly on the member object. } } diff --git a/docs/en/02_Developer_Guides/09_Security/04_Secure_Coding.md b/docs/en/02_Developer_Guides/09_Security/04_Secure_Coding.md index 565f3167f..465f5056c 100644 --- a/docs/en/02_Developer_Guides/09_Security/04_Secure_Coding.md +++ b/docs/en/02_Developer_Guides/09_Security/04_Secure_Coding.md @@ -116,7 +116,8 @@ Example: ```php class MyForm extends Form { - public function save($RAW_data, $form) { + public function save($RAW_data, $form) + { // Pass true as the second parameter of raw2sql to quote the value safely $SQL_data = Convert::raw2sql($RAW_data, true); // works recursively on an array $objs = Player::get()->where("Name = " . $SQL_data['name']); @@ -136,7 +137,8 @@ Example: class MyController extends Controller { private static $allowed_actions = ['myurlaction']; - public function myurlaction($RAW_urlParams) { + public function myurlaction($RAW_urlParams) + { // Pass true as the second parameter of raw2sql to quote the value safely $SQL_urlParams = Convert::raw2sql($RAW_urlParams, true); // works recursively on an array $objs = Player::get()->where("Name = " . $SQL_data['OtherID']); @@ -157,12 +159,14 @@ passing data through, escaping should happen at the end of the chain. /** * @param array $RAW_data All names in an indexed array (not SQL-safe) */ - public function saveAllNames($RAW_data) { + public function saveAllNames($RAW_data) + { // $SQL_data = Convert::raw2sql($RAW_data); // premature escaping foreach($RAW_data as $item) $this->saveName($item); } - public function saveName($RAW_name) { + public function saveName($RAW_name) + { $SQL_name = Convert::raw2sql($RAW_name, true); DB::query("UPDATE Player SET Name = {$SQL_name}"); } @@ -293,7 +297,8 @@ PHP: 'TitleWithHTMLSuffix' => 'HTMLText' // optional, as HTMLText is the default casting ]; - public function TitleWithHTMLSuffix($suffix) { + public function TitleWithHTMLSuffix($suffix) + { // $this->Title is not casted in PHP return $this->Title . '(' . $suffix. ')'; } @@ -330,7 +335,8 @@ PHP: class MyController extends Controller { private static $allowed_actions = ['search']; - public function search($request) { + public function search($request) + { $htmlTitle = '

Your results for:' . Convert::raw2xml($request->getVar('Query')) . '

'; return $this->customise([ 'Query' => Text::create($request->getVar('Query')), @@ -364,7 +370,8 @@ PHP: class MyController extends Controller { private static $allowed_actions = ['search']; - public function search($request) { + public function search($request) + { $rssRelativeLink = "/rss?Query=" . urlencode($_REQUEST['query']) . "&sortOrder=asc"; $rssLink = Controller::join_links($this->Link(), $rssRelativeLink); return $this->customise([ @@ -428,7 +435,8 @@ Below is an example with different ways you would use this casting technique: ```php - public function CaseStudies() { + public function CaseStudies() + { // cast an ID from URL parameters e.g. (mysite.com/home/action/ID) $anotherID = (int)Director::urlParam['ID']; @@ -557,7 +565,8 @@ controller's `init()` method: ```php class MyController extends Controller { - public function init() { + public function init() + { parent::init(); $this->getResponse()->addHeader('X-Frame-Options', 'SAMEORIGIN'); } @@ -698,7 +707,8 @@ unauthorised local persons. SilverStripe adds the current date for every request class MySecureController extends Controller { - public function init() { + public function init() + { parent::init(); // Add cache headers to ensure sensitive content isn't cached. diff --git a/docs/en/02_Developer_Guides/11_Integration/00_CSV_Import.md b/docs/en/02_Developer_Guides/11_Integration/00_CSV_Import.md index a7d2c5bc8..57e14dc31 100644 --- a/docs/en/02_Developer_Guides/11_Integration/00_CSV_Import.md +++ b/docs/en/02_Developer_Guides/11_Integration/00_CSV_Import.md @@ -82,11 +82,13 @@ You'll need to add a route to your controller to make it accessible via URL protected $template = "BlankPage"; - public function Link($action = null) { + public function Link($action = null) + { return Controller::join_links('MyController', $action); } - public function Form() { + public function Form() + { $form = new Form( $this, 'Form', @@ -101,7 +103,8 @@ You'll need to add a route to your controller to make it accessible via URL return $form; } - public function doUpload($data, $form) { + public function doUpload($data, $form) + { $loader = new CsvBulkLoader('MyDataObject'); $results = $loader->load($_FILES['CsvFile']['tmp_name']); $messages = []; @@ -193,13 +196,15 @@ Sample implementation of a custom loader. Assumes a CSV-file in a certain format 'callback' => 'getTeamByTitle' ] ]; - public static function importFirstAndLastName(&$obj, $val, $record) { + public static function importFirstAndLastName(&$obj, $val, $record) + { $parts = explode(' ', $val); if(count($parts) != 2) return false; $obj->FirstName = $parts[0]; $obj->LastName = $parts[1]; } - public static function getTeamByTitle(&$obj, $val, $record) { + public static function getTeamByTitle(&$obj, $val, $record) + { return FootballTeam::get()->filter('Title', $val)->First(); } } diff --git a/docs/en/02_Developer_Guides/11_Integration/01_RestfulService.md b/docs/en/02_Developer_Guides/11_Integration/01_RestfulService.md index 63d581b39..97ade2269 100644 --- a/docs/en/02_Developer_Guides/11_Integration/01_RestfulService.md +++ b/docs/en/02_Developer_Guides/11_Integration/01_RestfulService.md @@ -21,7 +21,8 @@ in the template. ```php - public function getWellingtonWeather() { + public function getWellingtonWeather() + { $fetch = new RestfulService( 'https://query.yahooapis.com/v1/public/yql' ); @@ -163,7 +164,8 @@ If the web service returned an error (for example, API key not available or inad class MyRestfulService extends RestfulService { - public function errorCatch($response) { + public function errorCatch($response) + { $err_msg = $response; if(strpos($err_msg, '<') === false) { @@ -182,7 +184,8 @@ If you want to bypass error handling, define `checkErrors` in the constructor fo class MyRestfulService extends RestfulService { - public function __construct($expiry = NULL) { + public function __construct($expiry = NULL) + { parent::__construct('http://www.flickr.com/services/rest/', $expiry); $this->checkErrors = false; diff --git a/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md b/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md index b34ba1ee3..9178ea31c 100644 --- a/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md +++ b/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md @@ -65,13 +65,15 @@ You can use [RSSFeed](api:SilverStripe\Control\RSS\RSSFeed) to easily create a f 'rss' ]; - public function init() { + public function init() + { parent::init(); RSSFeed::linkToFeed($this->Link() . "rss", "10 Most Recently Updated Pages"); } - public function rss() { + public function rss() + { $rss = new RSSFeed( $this->LatestUpdates(), $this->Link(), @@ -82,7 +84,8 @@ You can use [RSSFeed](api:SilverStripe\Control\RSS\RSSFeed) to easily create a f return $rss->outputToBrowser(); } - public function LatestUpdates() { + public function LatestUpdates() + { return Page::get()->sort("LastEdited", "DESC")->limit(10); } } @@ -106,7 +109,8 @@ method is defined and returns a string to the full website URL. class Player extends DataObject { - public function AbsoluteLink() { + public function AbsoluteLink() + { // assumes players can be accessed at yoursite.com/players/2 return Controller::join_links( @@ -129,13 +133,15 @@ Then in our controller, we add a new action which returns a the XML list of `Pla 'players' ]; - public function init() { + public function init() + { parent::init(); RSSFeed::linkToFeed($this->Link("players"), "Players"); } - public function players() { + public function players() + { $rss = new RSSFeed( Player::get(), $this->Link("players"), @@ -184,7 +190,8 @@ Say from that last example we want to include the Players Team in the XML feed w ```php - public function players() { + public function players() + { $rss = new RSSFeed( Player::get(), $this->Link("players"), diff --git a/docs/en/02_Developer_Guides/11_Integration/How_Tos/Import_CSV_through_a_Controller.md b/docs/en/02_Developer_Guides/11_Integration/How_Tos/Import_CSV_through_a_Controller.md index 561c1cc20..0549a4538 100644 --- a/docs/en/02_Developer_Guides/11_Integration/How_Tos/Import_CSV_through_a_Controller.md +++ b/docs/en/02_Developer_Guides/11_Integration/How_Tos/Import_CSV_through_a_Controller.md @@ -17,11 +17,13 @@ form (which is used for `MyDataObject` instances). You can access it through protected $template = "BlankPage"; - public function Link($action = null) { + public function Link($action = null) + { return Controller::join_links('MyController', $action); } - public function Form() { + public function Form() + { $form = new Form( $this, 'Form', @@ -36,7 +38,8 @@ form (which is used for `MyDataObject` instances). You can access it through return $form; } - public function doUpload($data, $form) { + public function doUpload($data, $form) + { $loader = new CsvBulkLoader('MyDataObject'); $results = $loader->load($_FILES['CsvFile']['tmp_name']); $messages = []; diff --git a/docs/en/02_Developer_Guides/11_Integration/How_Tos/custom_csvbulkloader.md b/docs/en/02_Developer_Guides/11_Integration/How_Tos/custom_csvbulkloader.md index d6b45c92d..cd0cb483a 100644 --- a/docs/en/02_Developer_Guides/11_Integration/How_Tos/custom_csvbulkloader.md +++ b/docs/en/02_Developer_Guides/11_Integration/How_Tos/custom_csvbulkloader.md @@ -89,14 +89,16 @@ Our final import looks like this. ] ]; - public static function importFirstAndLastName(&$obj, $val, $record) { + public static function importFirstAndLastName(&$obj, $val, $record) + { $parts = explode(' ', $val); if(count($parts) != 2) return false; $obj->FirstName = $parts[0]; $obj->LastName = $parts[1]; } - public static function getTeamByTitle(&$obj, $val, $record) { + public static function getTeamByTitle(&$obj, $val, $record) + { return FootballTeam::get()->filter('Title', $val)->First(); } } diff --git a/docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md b/docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md index 8bf673800..4dee06f42 100644 --- a/docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md +++ b/docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md @@ -11,7 +11,8 @@ First, we write the code to query the API feed. ```php - public function getWellingtonWeather() { + public function getWellingtonWeather() + { $fetch = new RestfulService( 'https://query.yahooapis.com/v1/public/yql' ); diff --git a/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md b/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md index 1ddc6ee76..99ae9581e 100644 --- a/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md +++ b/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md @@ -48,7 +48,8 @@ and `MyDate`. The attribute `HiddenProperty` should not be searchable, and `MyDa 'MyDate' => 'Date' ]; - public function getDefaultSearchContext() { + public function getDefaultSearchContext() + { $fields = $this->scaffoldSearchFields([ 'restrictFields' => ['PublicProperty','MyDate'] ]); @@ -87,7 +88,8 @@ the `$fields` constructor parameter. class PageController extends ContentController { - public function SearchForm() { + public function SearchForm() + { $context = singleton('MyDataObject')->getCustomSearchContext(); $fields = $context->getSearchFields(); @@ -101,7 +103,8 @@ the `$fields` constructor parameter. return $form; } - public function doSearch($data, $form) { + public function doSearch($data, $form) + { $context = singleton('MyDataObject')->getCustomSearchContext(); $results = $context->getResults($data); @@ -122,7 +125,8 @@ in order to read page limit information. It is also passed the current ```php - public function getResults($searchCriteria = []) { + public function getResults($searchCriteria = []) + { $start = ($this->getRequest()->getVar('start')) ? (int)$this->getRequest()->getVar('start') : 0; $limit = 10; @@ -146,7 +150,8 @@ notice that if you want to use this getResults function, you need to change the ```php - public function doSearch($data, $form) { + public function doSearch($data, $form) + { $context = singleton('MyDataObject')->getCustomSearchContext(); $results = $this->getResults($data); return $this->customise([ diff --git a/docs/en/02_Developer_Guides/14_Files/03_File_Security.md b/docs/en/02_Developer_Guides/14_Files/03_File_Security.md index 3f408aeef..f4aa35bed 100644 --- a/docs/en/02_Developer_Guides/14_Files/03_File_Security.md +++ b/docs/en/02_Developer_Guides/14_Files/03_File_Security.md @@ -67,7 +67,8 @@ authorised users, the following should be considered: ```php class PageController extends ContentController { - public function init() { + public function init() + { parent::init(); // Whitelist any protected files on this page for the current user foreach($this->Files() as $file) { @@ -99,7 +100,8 @@ authorised users, the following should be considered: ```php class PageController extends ContentController { - public function init() { + public function init() + { parent::init(); // Whitelist any protected files on this page for the current user foreach($this->Files() as $file) { diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md index 84655ac6e..ef7c079f7 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md @@ -107,19 +107,23 @@ permissions by default. For most cases, less restrictive checks make sense, e.g. class Category extends DataObject { // ... - public function canView($member = null) { + public function canView($member = null) + { return Permission::check('CMS_ACCESS_MyAdmin', 'any', $member); } - public function canEdit($member = null) { + public function canEdit($member = null) + { return Permission::check('CMS_ACCESS_MyAdmin', 'any', $member); } - public function canDelete($member = null) { + public function canDelete($member = null) + { return Permission::check('CMS_ACCESS_MyAdmin', 'any', $member); } - public function canCreate($member = null) { + public function canCreate($member = null) + { return Permission::check('CMS_ACCESS_MyAdmin', 'any', $member); } ``` @@ -191,7 +195,8 @@ For example, we might want to exclude all products without prices in our sample class MyAdmin extends ModelAdmin { - public function getList() { + public function getList() + { $list = parent::getList(); // Always limit by model class, in case you're managing multiple @@ -214,7 +219,8 @@ checkbox which limits search results to expensive products (over $100). class MyAdmin extends ModelAdmin { - public function getSearchContext() { + public function getSearchContext() + { $context = parent::getSearchContext(); if($this->modelClass == 'Product') { @@ -224,7 +230,8 @@ checkbox which limits search results to expensive products (over $100). return $context; } - public function getList() { + public function getList() + { $list = parent::getList(); $params = $this->getRequest()->requestVar('q'); // use this to access search parameters @@ -254,7 +261,8 @@ example, to add a new component. ]; // ... - public function getEditForm($id = null, $fields = null) { + public function getEditForm($id = null, $fields = null) + { $form = parent::getEditForm($id, $fields); // $gridFieldName is generated from the ModelClass, eg if the Class 'Product' @@ -287,7 +295,8 @@ to only one specific `GridField`: 'Category' ]; - public function getEditForm($id = null, $fields = null) { + public function getEditForm($id = null, $fields = null) + { $form = parent::getEditForm($id, $fields); $gridFieldName = 'Product'; @@ -325,7 +334,8 @@ To customize the exported columns, create a new method called `getExportFields` { // ... - public function getExportFields() { + public function getExportFields() + { return [ 'Name' => 'Name', 'ProductCode' => 'Product Code', diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/02_CMS_Architecture.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/02_CMS_Architecture.md index 676687d89..9972c42a4 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/02_CMS_Architecture.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/02_CMS_Architecture.md @@ -295,7 +295,8 @@ Firstly, `reactRouter` must be passed as a boolean flag to indicate that this se controlled by the react section, and thus should suppress registration of a page.js route for this section. ```php - public function getClientConfig() { + public function getClientConfig() + { return array_merge(parent::getClientConfig(), [ 'reactRouter' => true ]); @@ -366,7 +367,8 @@ in a single Ajax request. class MyAdmin extends LeftAndMain { private static $url_segment = 'myadmin'; - public function getResponseNegotiator() { + public function getResponseNegotiator() + { $negotiator = parent::getResponseNegotiator(); $controller = $this; // Register a new callback @@ -375,7 +377,8 @@ in a single Ajax request. }); return $negotiator; } - public function MyRecordInfo() { + public function MyRecordInfo() + { return $this->renderWith('MyRecordInfo'); } } @@ -550,7 +553,8 @@ which is picked up by the menu: ```php - public function mycontrollermethod() { + public function mycontrollermethod() + { // .. logic here $this->getResponse()->addHeader('X-Controller', 'AssetAdmin'); return 'my response'; diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/06_Javascript_Development.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/06_Javascript_Development.md index df8fd567c..e71c46a1d 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/06_Javascript_Development.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/06_Javascript_Development.md @@ -423,7 +423,8 @@ PHP: ```php class MyController { - public function autocomplete($request) { + public function autocomplete($request) + { $results = Page::get()->filter("Title", $request->getVar('title')); if(!$results) return new HTTPResponse("Not found", 404); diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Alternating_Button.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Alternating_Button.md index 3d722fdc8..6911357fc 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Alternating_Button.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Alternating_Button.md @@ -28,7 +28,8 @@ Here is the configuration code for the button: ```php - public function getCMSActions() { + public function getCMSActions() + { $fields = parent::getCMSActions(); $fields->fieldByName('MajorActions')->push( @@ -54,7 +55,8 @@ Here we initialise the button based on the backend check, and assume that the bu ```php - public function getCMSActions() { + public function getCMSActions() + { // ... if ($this->needsCleaning()) { // Will initialise the button into alternate state. diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Menu.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Menu.md index 47d4e8444..189fef643 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Menu.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Menu.md @@ -65,7 +65,8 @@ button configuration. class CustomLeftAndMain extends LeftAndMainExtension { - public function init() { + public function init() + { // unique identifier for this item. Will have an ID of Menu-$ID $id = 'LinkToGoogle'; diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Tree.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Tree.md index 2ced54bce..e101e8125 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Tree.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Tree.md @@ -68,11 +68,13 @@ __Example: using a subclass__ ```php class Page extends SiteTree { - public function getScheduledToPublish(){ + public function getScheduledToPublish() + { // return either true or false } - public function getStatusFlags($cached = true) { + public function getStatusFlags($cached = true) + { $flags = parent::getStatusFlags($cached); $flags['scheduledtopublish'] = "Scheduled To Publish"; return $flags; diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_Site_Reports.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_Site_Reports.md index d35a36c6a..90dde8641 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_Site_Reports.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_Site_Reports.md @@ -38,17 +38,20 @@ The following example will create a report to list every page on the current sit { // the name of the report - public function title() { + public function title() + { return 'All Pages'; } // what we want the report to return - public function sourceRecords($params = null) { + public function sourceRecords($params = null) + { return Page::get()->sort('Title'); } // which fields on that object we want to show - public function columns() { + public function columns() + { $fields = [ 'Title' => 'Title' ]; diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md index 693d76864..66285985b 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md @@ -87,7 +87,8 @@ and insert the following code. 'IsBookmarked' => 'Boolean' ]; - public function updateCMSFields(FieldList $fields) { + public function updateCMSFields(FieldList $fields) + { $fields->addFieldToTab('Root.Main', new CheckboxField('IsBookmarked', "Show in CMS bookmarks?") ); @@ -123,7 +124,8 @@ Add the following code to a new file `mysite/code/BookmarkedLeftAndMainExtension class BookmarkedPagesLeftAndMainExtension extends LeftAndMainExtension { - public function BookmarkedPages() { + public function BookmarkedPages() + { return Page::get()->filter("IsBookmarked", 1); } } diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extending_An_Existing_ModelAdmin.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extending_An_Existing_ModelAdmin.md index 32db46fce..585f170fd 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extending_An_Existing_ModelAdmin.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extending_An_Existing_ModelAdmin.md @@ -8,7 +8,8 @@ also another tool at your disposal: The [Extension](api:SilverStripe\Core\Extens class MyAdminExtension extends Extension { // ... - public function updateEditForm(&$form) { + public function updateEditForm(&$form) + { $form->Fields()->push(/* ... */) } } diff --git a/docs/en/02_Developer_Guides/16_Execution_Pipeline/01_Flushable.md b/docs/en/02_Developer_Guides/16_Execution_Pipeline/01_Flushable.md index 07b9c2d1a..478560f57 100644 --- a/docs/en/02_Developer_Guides/16_Execution_Pipeline/01_Flushable.md +++ b/docs/en/02_Developer_Guides/16_Execution_Pipeline/01_Flushable.md @@ -23,11 +23,13 @@ This example uses [Cache](api:Cache) in some custom code, and the same cache is class MyClass extends DataObject implements Flushable { - public static function flush() { + public static function flush() + { Cache::factory('mycache')->clean(Zend_Cache::CLEANING_MODE_ALL); } - public function MyCachedContent() { + public function MyCachedContent() + { $cache = Cache::factory('mycache') $something = $cache->load('mykey'); if(!$something) { @@ -50,7 +52,8 @@ flush so they are re-created on demand. class MyClass extends DataObject implements Flushable { - public static function flush() { + public static function flush() + { foreach(glob(ASSETS_PATH . '/_tempfiles/*.jpg') as $file) { unlink($file); } diff --git a/docs/en/04_Changelogs/3.0.0.md b/docs/en/04_Changelogs/3.0.0.md index cd193a33a..60e87dc71 100644 --- a/docs/en/04_Changelogs/3.0.0.md +++ b/docs/en/04_Changelogs/3.0.0.md @@ -163,7 +163,8 @@ you can use `add_to_class()` as a replacement to `extraStatics()`. ); // advanced syntax - static function add_to_class($class, $extensionClass, $args = null) { + static function add_to_class($class, $extensionClass, $args = null) + { if($class == 'MyClass') { Config::inst()->update($class, 'db', array( 'Title' => 'Varchar' diff --git a/docs/en/04_Changelogs/3.0.9.md b/docs/en/04_Changelogs/3.0.9.md index 4e82a163e..0c1060e47 100644 --- a/docs/en/04_Changelogs/3.0.9.md +++ b/docs/en/04_Changelogs/3.0.9.md @@ -24,7 +24,8 @@ please use `DataObject->canView()` to determine permissions. class MyController extends Controller { private static $allowed_actions = array('showpage'); - public function showpage($request) { + public function showpage($request) + { $page = Page::get()->byID($request->param('ID')); if(!$page->canView()) return $this->httpError(401); // continue with authenticated logic... diff --git a/docs/en/04_Changelogs/3.1.0.md b/docs/en/04_Changelogs/3.1.0.md index 95b046cd5..66fedaae5 100644 --- a/docs/en/04_Changelogs/3.1.0.md +++ b/docs/en/04_Changelogs/3.1.0.md @@ -250,7 +250,8 @@ on your own `Controller` subclasses if they contain any actions accessible throu class MyController extends Controller { // This action is now denied because no $allowed_actions are specified - public function myaction($request) {} + public function myaction($request) + {} } You can overwrite the default behaviour on undefined `$allowed_actions` to allow all actions, @@ -273,9 +274,11 @@ you'll need to specificy each accessible action individually. { public static $allowed_actions = array('*' => 'ADMIN'); // Always denied because not explicitly listed in $allowed_actions - public function myaction($request) {} + public function myaction($request) + {} // Always denied because not explicitly listed in $allowed_actions - public function myotheraction($request) {} + public function myotheraction($request) + {} } Please review all rules governing allowed actions in the @@ -291,7 +294,8 @@ Overriding inherited access definitions is no longer possible. class MyController extends Controller { public static $allowed_actions = array('myaction' => 'ADMIN'); - public function myaction($request) {} + public function myaction($request) + {} } class MySubController extends MyController { @@ -309,7 +313,8 @@ New approach with the [Config API](/developer_guides/configuration/configuration :::php class MySubController extends MyController { - public function init() { + public function init() + { parent::init(); Config::inst()->update('MyController', 'allowed_actions', @@ -376,16 +381,20 @@ Since `GridField` is used in `ModelAdmin`, this change will affect both classes. :::php class MyModel extends DataObject { - public function canView($member = null) { + public function canView($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canEdit($member = null) { + public function canEdit($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canDelete($member = null) { + public function canDelete($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } - public function canCreate($member = null) { + public function canCreate($member = null) + { return Permission::check('CMS_ACCESS_CMSMain', 'any', $member); } diff --git a/docs/en/04_Changelogs/3.1.11.md b/docs/en/04_Changelogs/3.1.11.md index e10b439c1..33e607c42 100644 --- a/docs/en/04_Changelogs/3.1.11.md +++ b/docs/en/04_Changelogs/3.1.11.md @@ -35,7 +35,8 @@ E.g. count()) return false; $context = func_num_args() > 1 ? func_get_arg(1) : array(); diff --git a/docs/en/04_Changelogs/3.1.16.md b/docs/en/04_Changelogs/3.1.16.md index ebaa2215c..47d717a9b 100644 --- a/docs/en/04_Changelogs/3.1.16.md +++ b/docs/en/04_Changelogs/3.1.16.md @@ -15,7 +15,8 @@ For example: :::php class MyCustomValidator extends Validator { - public function php($data) { + public function php($data) + { $this->validationError( 'EmailAddress', DBField::create_field('HTMLText', "Invalid email. Please sign up at this page") diff --git a/docs/en/04_Changelogs/3.1.2.md b/docs/en/04_Changelogs/3.1.2.md index c5b1395e7..e3f142793 100644 --- a/docs/en/04_Changelogs/3.1.2.md +++ b/docs/en/04_Changelogs/3.1.2.md @@ -34,7 +34,8 @@ please use `DataObject->canView()` to determine permissions. class MyController extends Controller { private static $allowed_actions = array('showpage'); - public function showpage($request) { + public function showpage($request) + { $page = Page::get()->byID($request->param('ID')); if(!$page->canView()) return $this->httpError(401); // continue with authenticated logic... diff --git a/docs/en/04_Changelogs/3.1.9.md b/docs/en/04_Changelogs/3.1.9.md index d7ada580a..dfcf5068f 100644 --- a/docs/en/04_Changelogs/3.1.9.md +++ b/docs/en/04_Changelogs/3.1.9.md @@ -17,7 +17,8 @@ E.g. getWhere(); // Will be flattened (unsafe 3.1 compatible format) $expression = $query->toAppropriateExpression(); // Either SQLSelect or SQLDelete $expression->getWhere(); // Will be parameterised (preferred 3.2 compatible format) @@ -732,7 +734,8 @@ Before: :::php - public function filtersOnColumn($query, $column) { + public function filtersOnColumn($query, $column) + { $regexp = '/^(.*\.)?("|`)?' . $column . ' ("|`)?\s?=/'; foreach($this->getWhere() as $predicate) { if(preg_match($regexp, $predicate)) return true; @@ -745,7 +748,8 @@ After: :::php - public function filtersOnColumn($query, $column) { + public function filtersOnColumn($query, $column) + { $regexp = '/^(.*\.)?("|`)?' . $column . ' ("|`)?\s?=/'; foreach($this->getWhereParameterised($parameters) as $predicate) { if(preg_match($regexp, $predicate)) return true; diff --git a/docs/en/04_Changelogs/3.2.1.md b/docs/en/04_Changelogs/3.2.1.md index 729d58a57..1dc663dec 100644 --- a/docs/en/04_Changelogs/3.2.1.md +++ b/docs/en/04_Changelogs/3.2.1.md @@ -15,7 +15,8 @@ For example: :::php class MyCustomValidator extends Validator { - public function php($data) { + public function php($data) + { $this->validationError( 'EmailAddress', DBField::create_field('HTMLText', "Invalid email. Please sign up at this page") diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md index 207f45351..aceabbed8 100644 --- a/docs/en/04_Changelogs/4.0.0.md +++ b/docs/en/04_Changelogs/4.0.0.md @@ -1001,7 +1001,8 @@ class MyShortcodeUser extends Object private $content; - public function Content($arguments, $parser, $shortcode) { + public function Content($arguments, $parser, $shortcode) + { return File::handle_shortcode($arguments, $this->content, $parser, $shortcode); } } @@ -1020,7 +1021,8 @@ class MyShortcodeUser extends Object private $content; - public function Content($arguments, $parser, $shortcode) { + public function Content($arguments, $parser, $shortcode) + { return FileShortcodeProvider::handle_shortcode($arguments, $this->content, $parser, $shortcode); } } diff --git a/docs/en/04_Changelogs/alpha/4.0.0-alpha1.md b/docs/en/04_Changelogs/alpha/4.0.0-alpha1.md index ba4cbb321..2356f9df3 100644 --- a/docs/en/04_Changelogs/alpha/4.0.0-alpha1.md +++ b/docs/en/04_Changelogs/alpha/4.0.0-alpha1.md @@ -454,10 +454,12 @@ Before: // in MyImageExtension.php class MyImageExtension extends DataExtension { - public function GalleryThumbnail($height) { + public function GalleryThumbnail($height) + { return $this->getFormattedImage('GalleryThumbnail', $height); } - public function generateGalleryThumbnail(Image_Backend $backend, $height) { + public function generateGalleryThumbnail(Image_Backend $backend, $height) + { return $backend->paddedResize(300, $height); } } @@ -475,7 +477,8 @@ After: // in MyImageExtension.php class MyImageExtension extends Extension { - public function GalleryThumbnail($height) { + public function GalleryThumbnail($height) + { // Generates the manipulation key $variant = $this->owner->variantName(__FUNCTION__, $height); @@ -522,7 +525,8 @@ The below describes the minimum amount of effort required to implement a composi 'Country' => 'Varchar(100)' ); - public function scaffoldFormField($title = null) { + public function scaffoldFormField($title = null) + { new AddressFormField($this->getName(), $title); } } @@ -613,7 +617,8 @@ E.g. :::php class MyErrorPageExtension extends SiteTreeExtension { - public function updateErrorFilename(&$name, &$statuscode) { + public function updateErrorFilename(&$name, &$statuscode) + { if($this->owner->exists()) { $locale = $this->Locale; } else { @@ -801,7 +806,8 @@ For example: * @param Int $val * @return Varchar */ - public function TextNumber() { + public function TextNumber() + { return new Varchar('TextNumber', 'Number is ' . $this->Number); } } @@ -820,7 +826,8 @@ Will become: * @param Int $val * @return Varchar */ - public function TextNumber() { + public function TextNumber() + { return new DBVarchar('TextNumber', 'Number is ' . $this->Number); } } diff --git a/docs/en/04_Changelogs/beta/3.2.0-beta1.md b/docs/en/04_Changelogs/beta/3.2.0-beta1.md index c992d16d5..feabc1943 100644 --- a/docs/en/04_Changelogs/beta/3.2.0-beta1.md +++ b/docs/en/04_Changelogs/beta/3.2.0-beta1.md @@ -279,7 +279,8 @@ simply use the provided page URLs. class MyController extends Controller { static $allowed_actions = array('myaction'); - public function myaction($request) { + public function myaction($request) + { // ... } } @@ -469,7 +470,8 @@ of strings. This format is inherently unsafe, and should be avoided where possib :::php getWhere(); // Will be flattened (unsafe 3.1 compatible format) $expression = $query->toAppropriateExpression(); // Either SQLSelect or SQLDelete $expression->getWhere(); // Will be parameterised (preferred 3.2 compatible format) @@ -700,7 +702,8 @@ Before: :::php - public function filtersOnColumn($query, $column) { + public function filtersOnColumn($query, $column) + { $regexp = '/^(.*\.)?("|`)?' . $column . ' ("|`)?\s?=/'; foreach($this->getWhere() as $predicate) { if(preg_match($regexp, $predicate)) return true; @@ -713,7 +716,8 @@ After: :::php - public function filtersOnColumn($query, $column) { + public function filtersOnColumn($query, $column) + { $regexp = '/^(.*\.)?("|`)?' . $column . ' ("|`)?\s?=/'; foreach($this->getWhereParameterised($parameters) as $predicate) { if(preg_match($regexp, $predicate)) return true; diff --git a/docs/en/04_Changelogs/rc/3.1.2-rc1.md b/docs/en/04_Changelogs/rc/3.1.2-rc1.md index cfa614117..5e06c1b98 100644 --- a/docs/en/04_Changelogs/rc/3.1.2-rc1.md +++ b/docs/en/04_Changelogs/rc/3.1.2-rc1.md @@ -34,7 +34,8 @@ please use `DataObject->canView()` to determine permissions. class MyController extends Controller { private static $allowed_actions = array('showpage'); - public function showpage($request) { + public function showpage($request) + { $page = Page::get()->byID($request->param('ID')); if(!$page->canView()) return $this->httpError(401); // continue with authenticated logic... diff --git a/docs/en/05_Contributing/04_Release_Process.md b/docs/en/05_Contributing/04_Release_Process.md index fa36c05e3..419b9e4b6 100644 --- a/docs/en/05_Contributing/04_Release_Process.md +++ b/docs/en/05_Contributing/04_Release_Process.md @@ -67,7 +67,8 @@ Here's an example for replacing `Director::isDev()` with a (theoretical) `Env::i * Returns true if your are in development mode * @deprecated 4.0 Use {@link Env::is_dev()} instead. */ - public function isDev() { + public function isDev() + { Deprecation::notice('4.0', 'Use Env::is_dev() instead'); return Env::is_dev(); } diff --git a/docs/en/05_Contributing/14_PHP_Coding_Conventions.md b/docs/en/05_Contributing/14_PHP_Coding_Conventions.md index da8b26659..cb6a7c129 100644 --- a/docs/en/05_Contributing/14_PHP_Coding_Conventions.md +++ b/docs/en/05_Contributing/14_PHP_Coding_Conventions.md @@ -58,7 +58,8 @@ Try to avoid using PHP's ability to mix HTML into the code. ```php // PHP code - public function getTitle() { + public function getTitle() + { return "

Bad Example

"; } @@ -71,7 +72,8 @@ Better: Keep HTML in template files: ```php // PHP code - public function getTitle() { + public function getTitle() + { return "Better Example"; }