From e7274b0ee454872fb8c2612e056340258f830c50 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Thu, 26 Oct 2017 13:22:02 +1300 Subject: [PATCH] Add namespaces --- .../00_Model/01_Data_Model_and_ORM.md | 11 +++- .../00_Model/02_Relations.md | 2 + .../02_Developer_Guides/00_Model/03_Lists.md | 2 + .../00_Model/04_Data_Types_and_Casting.md | 2 + .../00_Model/06_SearchFilters.md | 2 +- .../00_Model/08_SQL_Select.md | 26 ++++++-- .../00_Model/10_Versioning.md | 2 + .../01_Templates/03_Requirements.md | 2 + .../01_Templates/How_Tos/02_Pagination.md | 4 ++ .../How_Tos/03_Disable_Anchor_Links.md | 4 +- .../03_Forms/00_Introduction.md | 3 + .../03_Forms/04_Form_Security.md | 2 + .../03_Forms/05_Form_Transformations.md | 7 ++ .../Field_types/03_HTMLEditorField.md | 4 ++ .../03_Forms/Field_types/04_GridField.md | 19 ++++++ .../04_Create_a_GridField_ActionProvider.md | 5 ++ .../How_Tos/05_Simple_Contact_Form.md | 8 +++ .../04_Configuration/00_Configuration.md | 8 +-- .../05_Extending/01_Extensions.md | 6 +- .../05_Extending/04_Shortcodes.md | 2 + .../05_Extending/05_Injector.md | 10 +-- .../How_Tos/01_Publish_a_Module.md | 2 + .../02_Create_a_Google_Maps_Shortcode.md | 4 +- .../How_Tos/03_Track_member_logins.md | 2 +- .../06_Testing/04_Fixtures.md | 6 ++ .../06_Testing/How_Tos/02_FixtureFactories.md | 4 +- .../06_Testing/How_Tos/03_Testing_Email.md | 2 + .../07_Debugging/00_Environment_Types.md | 2 + .../07_Debugging/01_Error_Handling.md | 2 + .../07_Debugging/03_Template_debugging.md | 2 +- .../02_Developer_Guides/07_Debugging/index.md | 3 + .../08_Performance/01_Caching.md | 22 +++++-- .../08_Performance/02_HTTP_Cache_Headers.md | 4 +- .../08_Performance/05_Resource_Usage.md | 2 + .../09_Security/00_Member.md | 6 ++ .../09_Security/04_Secure_Coding.md | 17 ++++- docs/en/02_Developer_Guides/10_Email/index.md | 4 ++ .../11_Integration/00_CSV_Import.md | 2 + .../11_Integration/02_RSSFeed.md | 4 ++ .../11_Integration/How_Tos/embed_rss.md | 64 ------------------- .../12_Search/01_Searchcontext.md | 2 + docs/en/02_Developer_Guides/13_i18n/index.md | 14 +++- .../14_Files/01_File_Management.md | 2 + .../14_Files/03_File_Security.md | 2 + .../02_CMS_Architecture.md | 4 +- .../04_Preview.md | 2 +- .../05_Typography.md | 2 + .../06_Javascript_Development.md | 3 + .../How_Tos/CMS_Formfield_Help_Text.md | 2 + .../How_Tos/Customise_CMS_Pages_List.md | 2 +- .../How_Tos/Extend_CMS_Interface.md | 8 +-- .../03_App_Object_and_Kernel.md | 3 + .../18_Cookies_And_Sessions/01_Cookies.md | 8 ++- .../18_Cookies_And_Sessions/02_Sessions.md | 2 + 54 files changed, 235 insertions(+), 106 deletions(-) delete mode 100644 docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md 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 72b10b983..b5ccc89ea 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 @@ -547,6 +547,7 @@ when you want to find all the members that does not exist in a Group. ```php // ... Finding all members that does not belong to $group. + use SilverStripe\Security\Member; $otherMembers = Member::get()->subtract($group->Members()); ``` @@ -555,6 +556,7 @@ when you want to find all the members that does not exist in a Group. You can limit the amount of records returned in a DataList by using the `limit()` method. ```php + use SilverStripe\Security\Member; $members = Member::get()->limit(5); ``` @@ -582,6 +584,8 @@ For instance, the below model will be stored in the table name `BannerImage` ```php namespace SilverStripe\BannerManager; + use SilverStripe\ORM\DataObject; + class BannerImage extends \DataObject { private static $table_name = 'BannerImage'; @@ -616,6 +620,9 @@ table and column. ```php + use SilverStripe\ORM\Queries\SQLSelect; + use SilverStripe\ORM\DataObject; + public function countDuplicates($model, $fieldToCheck) { $table = DataObject::getSchema()->tableForField($model, $field); @@ -642,7 +649,7 @@ you need it to, you may also consider extending the ORM with new data types or f You can specify a WHERE clause fragment (that will be combined with other filters using AND) with the `where()` method: -```php +```php $members = Member::get()->where("\"FirstName\" = 'Sam'") ``` @@ -722,7 +729,7 @@ The data for the following classes would be stored across the following tables: ```yml - SiteTree: + SilverStripe\CMS\Model\SiteTree: - ID: Int - ClassName: Enum('SiteTree', 'Page', 'NewsPage') - Created: Datetime 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 7d7e573f4..9c70e1f56 100644 --- a/docs/en/02_Developer_Guides/00_Model/02_Relations.md +++ b/docs/en/02_Developer_Guides/00_Model/02_Relations.md @@ -412,6 +412,8 @@ Relationships between objects can cause cascading deletions, if necessary, throu `cascade_deletes` config on the parent class. ```php +use SilverStripe\ORM\DataObject; + class ParentObject extends DataObject { private static $has_one = [ 'Child' => ChildObject::class, diff --git a/docs/en/02_Developer_Guides/00_Model/03_Lists.md b/docs/en/02_Developer_Guides/00_Model/03_Lists.md index 369bea6c5..3462bb1d6 100644 --- a/docs/en/02_Developer_Guides/00_Model/03_Lists.md +++ b/docs/en/02_Developer_Guides/00_Model/03_Lists.md @@ -12,6 +12,8 @@ modify. [SS_List](api:SilverStripe\ORM\SS_List) implements `IteratorAggregate`, allowing you to loop over the instance. ```php + use SilverStripe\Security\Member; + $members = Member::get(); foreach($members as $member) { 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 e7faf71f5..05b3066e2 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 @@ -173,6 +173,7 @@ On the most basic level, the class can be used as simple conversion class from o number. ```php + use SilverStripe\ORM\FieldType\DBField; DBField::create_field('Double', 1.23456)->Round(2); // results in 1.23 ``` @@ -180,6 +181,7 @@ Of course that's much more verbose than the equivalent PHP call. The power of [D sophisticated helpers, like showing the time difference to the current date: ```php + use SilverStripe\ORM\FieldType\DBField; DBField::create_field('Date', '1982-01-01')->TimeDiff(); // shows "30 years ago" ``` diff --git a/docs/en/02_Developer_Guides/00_Model/06_SearchFilters.md b/docs/en/02_Developer_Guides/00_Model/06_SearchFilters.md index 6babd8259..53ab2a6bf 100644 --- a/docs/en/02_Developer_Guides/00_Model/06_SearchFilters.md +++ b/docs/en/02_Developer_Guides/00_Model/06_SearchFilters.md @@ -47,7 +47,7 @@ config: SilverStripe\Core\Injector\Injector: DataListFilter.CustomMatch: - class: MyVendor/Search/CustomMatchFilter + class: MyVendor\Search\CustomMatchFilter ``` The following is a query which will return everyone whose first name starts with "S", either lowercase or uppercase: diff --git a/docs/en/02_Developer_Guides/00_Model/08_SQL_Select.md b/docs/en/02_Developer_Guides/00_Model/08_SQL_Select.md index b4dad61bd..7e2be7e0c 100644 --- a/docs/en/02_Developer_Guides/00_Model/08_SQL_Select.md +++ b/docs/en/02_Developer_Guides/00_Model/08_SQL_Select.md @@ -19,6 +19,10 @@ For example, if you want to run a simple `COUNT` SQL statement, the following three statements are functionally equivalent: ```php + use SilverStripe\ORM\DB; + use SilverStripe\ORM\Queries\SQLSelect; + use SilverStripe\Security\Member; + // Through raw SQL. $count = DB::query('SELECT COUNT(*) FROM "Member"')->value(); @@ -96,7 +100,8 @@ object instead. For example, creating a `SQLDelete` object ```php - + use SilverStripe\ORM\Queries\SQLDelete; + $query = SQLDelete::create() ->setFrom('"SiteTree"') ->setWhere(['"SiteTree"."ShowInMenus"' => 0]); @@ -107,7 +112,8 @@ For example, creating a `SQLDelete` object Alternatively, turning an existing `SQLSelect` into a delete ```php - + use SilverStripe\ORM\Queries\SQLSelect; + $query = SQLSelect::create() ->setFrom('"SiteTree"') ->setWhere(['"SiteTree"."ShowInMenus"' => 0]) @@ -119,7 +125,8 @@ Alternatively, turning an existing `SQLSelect` into a delete Directly querying the database ```php - + use SilverStripe\ORM\DB; + DB::prepared_query('DELETE FROM "SiteTree" WHERE "SiteTree"."ShowInMenus" = ?', [0]); ``` @@ -169,7 +176,9 @@ SQLInsert also includes the following api methods: E.g. ```php - $update = SQLUpdate::create('"SiteTree"')->addWhere(['ID' => 3]); + use SilverStripe\ORM\Queries\SQLUpdate; + + $update = SQLUpdate::create('"SiteTree"')->addWhere(['ID' => 3]); // assigning a list of items $update->addAssignments([ @@ -202,7 +211,9 @@ these are translated internally as multiple single row inserts. For example, ```php - $insert = SQLInsert::create('"SiteTree"'); + use SilverStripe\ORM\Queries\SQLInsert; + + $insert = SQLInsert::create('"SiteTree"'); // Add multiple rows in a single call. Note that column names do not need // to be symmetric @@ -232,6 +243,8 @@ e.g. when you want a single column rather than a full-blown object representatio Example: Get the count from a relationship. ```php + use SilverStripe\ORM\Queries\SQLSelect; + $sqlQuery = new SQLSelect(); $sqlQuery->setFrom('Player'); $sqlQuery->addSelect('COUNT("Player"."ID")'); @@ -255,6 +268,9 @@ This can be useful for creating dropdowns. Example: Show player names with their birth year, but set their birth dates as values. ```php + use SilverStripe\ORM\Queries\SQLSelect; + use SilverStripe\Forms\DropdownField; + $sqlQuery = new SQLSelect(); $sqlQuery->setFrom('Player'); $sqlQuery->setSelect('Birthdate'); 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 c822072a8..b55eb32bf 100644 --- a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md +++ b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md @@ -174,6 +174,8 @@ By default, all records are retrieved from the "Draft" stage (so the `MyRecord` explicitly request a certain stage through various getters on the `Versioned` class. ```php +use SilverStripe\Versioned\Versioned; + // Fetching multiple records $stageRecords = Versioned::get_by_stage('MyRecord', Versioned::DRAFT); $liveRecords = Versioned::get_by_stage('MyRecord', Versioned::LIVE); diff --git a/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md b/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md index f864305f5..7bde9ec2c 100644 --- a/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md +++ b/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md @@ -50,6 +50,8 @@ class MyCustomController extends Controller ### CSS Files ```php +use SilverStripe\View\Requirements; + Requirements::css($path, $media); ``` 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 d96eaac90..681a995c0 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 @@ -11,6 +11,8 @@ The `PaginatedList` will automatically set up query limits and read the request **mysite/code/Page.php** ```php + use SilverStripe\ORM\PaginatedList; + /** * Returns a paginated list of all pages in the site. */ @@ -79,6 +81,8 @@ will break the pagination. You can disable automatic limiting using the [Paginat when using custom lists. ```php + use SilverStripe\ORM\PaginatedList; + $myPreLimitedList = Page::get()->limit(10); $pages = new PaginatedList($myPreLimitedList, $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 c7716f203..54af5a052 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 @@ -33,13 +33,15 @@ situations, you can disable anchor link rewriting by setting the `SSViewer.rewri **mysite/_config/app.yml** ```yml -SSViewer: +SilverStripe\View\SSViewer: rewrite_hash_links: false ``` Or, a better way is to call this just for the rendering phase of this particular file: ```php + use SilverStripe\View\SSViewer; + public function RenderCustomTemplate() { SSViewer::setRewriteHashLinks(false); diff --git a/docs/en/02_Developer_Guides/03_Forms/00_Introduction.md b/docs/en/02_Developer_Guides/03_Forms/00_Introduction.md index c0bb0fd5c..3fcfbba03 100644 --- a/docs/en/02_Developer_Guides/03_Forms/00_Introduction.md +++ b/docs/en/02_Developer_Guides/03_Forms/00_Introduction.md @@ -16,6 +16,9 @@ Creating a [Form](api:SilverStripe\Forms\Form) has the following signature. ```php + use SilverStripe\Forms\Form; + use SilverStripe\Forms\FieldList; + $form = new Form( $controller, // the Controller to render this form on $name, // name of the method that returns this form on the controller diff --git a/docs/en/02_Developer_Guides/03_Forms/04_Form_Security.md b/docs/en/02_Developer_Guides/03_Forms/04_Form_Security.md index 73c3258aa..c9db584f2 100644 --- a/docs/en/02_Developer_Guides/03_Forms/04_Form_Security.md +++ b/docs/en/02_Developer_Guides/03_Forms/04_Form_Security.md @@ -22,6 +22,8 @@ The `SecurityToken` automatically added looks something like: ```php + use SilverStripe\Forms\Form; + $form = new Form(..); echo $form->getSecurityToken()->getValue(); diff --git a/docs/en/02_Developer_Guides/03_Forms/05_Form_Transformations.md b/docs/en/02_Developer_Guides/03_Forms/05_Form_Transformations.md index 1cf29a535..877cba550 100644 --- a/docs/en/02_Developer_Guides/03_Forms/05_Form_Transformations.md +++ b/docs/en/02_Developer_Guides/03_Forms/05_Form_Transformations.md @@ -11,6 +11,8 @@ To make an entire [Form](api:SilverStripe\Forms\Form) read-only. ```php + use SilverStripe\Forms\Form; + $form = new Form(..); $form->makeReadonly(); ``` @@ -19,6 +21,8 @@ To make all the fields within a [FieldList](api:SilverStripe\Forms\FieldList) re ```php + use SilverStripe\Forms\FieldList; + $fields = new FieldList(..); $fields = $fields->makeReadonly(); ``` @@ -27,6 +31,9 @@ To make a [FormField](api:SilverStripe\Forms\FormField) read-only you need to kn ```php + use SilverStripe\Forms\TextField; + use SilverStripe\Forms\FieldList; + $field = new TextField(..); $field = $field->performReadonlyTransformation(); 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 a27a2625d..31cbf61ba 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 @@ -103,6 +103,8 @@ transparently generate the relevant underlying TinyMCE code. **mysite/_config.php** ```php + use SilverStripe\Forms\HTMLEditor\HtmlEditorConfig; + HtmlEditorConfig::get('cms')->enablePlugins('media'); ``` @@ -270,6 +272,8 @@ Example: Remove field for "image captions" ```php // File: mysite/_config.php + use SilverStripe\Admin\ModalController; + ModalController::add_extension('MyToolbarExtension'); ``` 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 412d723cd..114155717 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 @@ -8,6 +8,8 @@ tabular data in a format that is easy to view and modify. It can be thought of a ```php + use SilverStripe\Forms\GridField\GridField; + $field = new GridField($name, $title, $list); ``` @@ -103,6 +105,9 @@ the `getConfig()` method on `GridField`. With the `GridFieldConfig` instance, we can modify the behavior of the `GridField`. ```php + use SilverStripe\Forms\GridField\GridFieldConfig; + use SilverStripe\Forms\GridField\GridFieldDataColumns; + // `GridFieldConfig::create()` will create an empty configuration (no components). $config = GridFieldConfig::create(); @@ -115,7 +120,10 @@ With the `GridFieldConfig` instance, we can modify the behavior of the `GridFiel `GridFieldConfig` provides a number of methods to make setting the configuration easier. We can insert a component before another component by passing the second parameter. + ```php + use SilverStripe\Forms\GridField\GridFieldFilterHeader; + $config->addComponent(new GridFieldFilterHeader(), 'GridFieldDataColumns'); ``` @@ -169,6 +177,8 @@ A simple read-only and paginated view of records with sortable and searchable he ```php + use SilverStripe\Forms\GridField\GridFieldConfig_Base; + $config = GridFieldConfig_Base::create(); $gridField->setConfig($config); @@ -199,6 +209,8 @@ this record. ```php + use SilverStripe\Forms\GridField\GridFieldConfig_RecordViewer; + $config = GridFieldConfig_RecordViewer::create(); $gridField->setConfig($config); @@ -354,6 +366,9 @@ bottom right of the table. ```php + use SilverStripe\Forms\GridField\GridFieldButtonRow; + use SilverStripe\Forms\GridField\GridFieldPrintButton; + $config->addComponent(new GridFieldButtonRow('after')); $config->addComponent(new GridFieldPrintButton('buttons-after-right')); ``` @@ -366,6 +381,8 @@ create an area rendered before the table wrapped in a simple `
`. ```php + use SilverStripe\Forms\GridField\GridField_HTMLProvider; + class MyAreaComponent implements GridField_HTMLProvider { @@ -389,6 +406,8 @@ Now you can add other components into this area by returning them as an array fr ```php + use SilverStripe\Forms\GridField\GridField_HTMLProvider; + class MyShareLinkComponent implements GridField_HTMLProvider { 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 fd2718896..48ae5504e 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 @@ -19,6 +19,11 @@ below: ```php + use SilverStripe\Forms\GridField\GridField_ColumnProvider; + use SilverStripe\Forms\GridField\GridField_ActionProvider; + use SilverStripe\Forms\GridField\GridField_FormAction; + use SilverStripe\Control\Controller; + class GridFieldCustomAction implements GridField_ColumnProvider, GridField_ActionProvider { 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 5344eb683..d192a35a5 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 @@ -43,6 +43,11 @@ There's quite a bit in this function, so we'll step through one piece at a time. ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\TextField; + use SilverStripe\Forms\EmailField; + use SilverStripe\Forms\TextareaField; + $fields = new FieldList( new TextField('Name'), new EmailField('Email'), @@ -137,6 +142,9 @@ The framework comes with a predefined validator called [RequiredFields](api:Silv ```php + use SilverStripe\Forms\Form; + use SilverStripe\Forms\RequiredFields; + public function Form() { // ... diff --git a/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md b/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md index ac0875014..7ee680275 100644 --- a/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md +++ b/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md @@ -210,9 +210,9 @@ The structure of each YAML file is a series of headers and values separated by Y - '#rootroutes' - '#coreroutes' --- - Director: + SilverStripe\Control\Director: rules: - 'admin': 'AdminRootController' + 'admin': 'SilverStripe\Admin\AdminRootController' --- ``` @@ -260,9 +260,9 @@ keys is a list of reference paths to other value sections. A basic example: - '#rootroutes' - '#coreroutes' --- - Director: + SilverStripe\Control\Director: rules: - 'admin': 'AdminRootController' + 'admin': 'SilverStripe\Admin\AdminRootController' --- ``` 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 e9e9eb5e5..16ba05e44 100644 --- a/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md +++ b/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md @@ -49,7 +49,7 @@ we want to add the `MyMemberExtension` too. To activate this extension, add the ```yml - Member: + SilverStripe\Security\Member: extensions: - MyMemberExtension ``` @@ -58,7 +58,7 @@ Alternatively, we can add extensions through PHP code (in the `_config.php` file ```php - Member::add_extension('MyMemberExtension'); + SilverStripe\Security\Member::add_extension('MyMemberExtension'); ``` This class now defines a `MyMemberExtension` that applies to all `Member` instances on the website. It will have @@ -130,6 +130,8 @@ we added a `SayHi` method which is unique to our extension. **mysite/code/Page.php** ```php + use SilverStripe\Security\Security; + $member = Security::getCurrentUser(); echo $member->SayHi; 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 c235133c5..2d6175d3f 100644 --- a/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md +++ b/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md @@ -38,6 +38,8 @@ Other fields can be manually parsed with shortcodes through the `parse` method. ```php + use SilverStripe\View\Parsers\ShortcodeParser; + $text = "My awesome [my_shortcode] is here."; ShortcodeParser::get_active()->parse($text); ``` 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 8dbca173b..0706237bd 100644 --- a/docs/en/02_Developer_Guides/05_Extending/05_Injector.md +++ b/docs/en/02_Developer_Guides/05_Extending/05_Injector.md @@ -20,6 +20,8 @@ The following sums up the simplest usage of the `Injector` it creates a new obje ```php + use SilverStripe\Core\Injector\Injector; + $object = Injector::inst()->create('MyClassName'); ``` @@ -30,7 +32,7 @@ The benefit of constructing objects through this syntax is `ClassName` can be sw ```yml - Injector: + SilverStripe\Core\Injector\Injector: MyClassName: class: MyBetterClassName ``` @@ -134,7 +136,7 @@ As well as properties, method calls can also be specified: ```yml - Injector: + SilverStripe\Core\Injector\Injector: Logger: class: Monolog\Logger calls: @@ -169,7 +171,7 @@ An example using the `MyFactory` service to create instances of the `MyService` ```yml - Injector: + SilverStripe\Core\Injector\Injector: MyService: factory: MyFactory ``` @@ -247,7 +249,7 @@ And the following configuration.. MyController: dependencies: permissions: %$PermissionService - Injector: + SilverStripe\Core\Injector\Injector: PermissionService: class: RestrictivePermissionService properties: diff --git a/docs/en/02_Developer_Guides/05_Extending/How_Tos/01_Publish_a_Module.md b/docs/en/02_Developer_Guides/05_Extending/How_Tos/01_Publish_a_Module.md index 569013ae5..8c73e4992 100644 --- a/docs/en/02_Developer_Guides/05_Extending/How_Tos/01_Publish_a_Module.md +++ b/docs/en/02_Developer_Guides/05_Extending/How_Tos/01_Publish_a_Module.md @@ -95,6 +95,8 @@ Linking to resources in vendor modules uses exactly the same syntax as non-vendo this is how you would require a script in this module: ```php +use SilverStripe\View\Requirements; + Requirements::javascript('tractorcow/test-vendor-module:client/js/script.js'); ``` diff --git a/docs/en/02_Developer_Guides/05_Extending/How_Tos/02_Create_a_Google_Maps_Shortcode.md b/docs/en/02_Developer_Guides/05_Extending/How_Tos/02_Create_a_Google_Maps_Shortcode.md index 5d22005c5..8982e48ab 100644 --- a/docs/en/02_Developer_Guides/05_Extending/How_Tos/02_Create_a_Google_Maps_Shortcode.md +++ b/docs/en/02_Developer_Guides/05_Extending/How_Tos/02_Create_a_Google_Maps_Shortcode.md @@ -15,7 +15,9 @@ We'll add defaults to those in our shortcode parser so they're optional. **mysite/_config.php** -```php +```php + use SilverStripe\View\Parsers\ShortcodeParser; + ShortcodeParser::get('default')->register('googlemap', function($arguments, $address, $parser, $shortcode) { $iframeUrl = sprintf( 'http://maps.google.com/maps?q=%s&hnear=%s&ie=UTF8&hq=&t=m&z=14&output=embed', 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 b415cbdb3..a694f2020 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 @@ -58,7 +58,7 @@ explicitly logging in or by invoking the "remember me" functionality. Now you just need to apply this extension through your config: ```yml - Member: + SilverStripe\Security\Member: extensions: - MyMemberExtension diff --git a/docs/en/02_Developer_Guides/06_Testing/04_Fixtures.md b/docs/en/02_Developer_Guides/06_Testing/04_Fixtures.md index 1a4853bf0..de436503b 100644 --- a/docs/en/02_Developer_Guides/06_Testing/04_Fixtures.md +++ b/docs/en/02_Developer_Guides/06_Testing/04_Fixtures.md @@ -16,6 +16,8 @@ To include your fixture file in your tests, you should define it as your `$fixtu ```php + use SilverStripe\Dev\SapphireTest; + class MyNewTest extends SapphireTest { @@ -31,6 +33,8 @@ You can also use an array of fixture files, if you want to use parts of multiple ```php + use SilverStripe\Dev\SapphireTest; + class MyNewTest extends SapphireTest { @@ -293,6 +297,8 @@ using them. ```php + use SilverStripe\Core\Injector\Injector; + $factory = Injector::inst()->create('FixtureFactory'); $obj = $factory->createObject('Team', 'hurricanes'); diff --git a/docs/en/02_Developer_Guides/06_Testing/How_Tos/02_FixtureFactories.md b/docs/en/02_Developer_Guides/06_Testing/How_Tos/02_FixtureFactories.md index 735a93741..fce9bd084 100644 --- a/docs/en/02_Developer_Guides/06_Testing/How_Tos/02_FixtureFactories.md +++ b/docs/en/02_Developer_Guides/06_Testing/How_Tos/02_FixtureFactories.md @@ -11,7 +11,9 @@ with information that we need. ```php use SilverStripe\Core\Injector\Injector; - + use SilverStripe\Dev\SapphireTest; + use SilverStripe\Core\Injector\Injector; + class MyObjectTest extends SapphireTest { 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 87f9cba46..c6ca30149 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,6 +8,8 @@ email was sent using this method. ```php + use SilverStripe\Control\Email\Email; + public function MyMethod() { $e = new Email(); diff --git a/docs/en/02_Developer_Guides/07_Debugging/00_Environment_Types.md b/docs/en/02_Developer_Guides/07_Debugging/00_Environment_Types.md index cd2c251a9..fd76d4410 100644 --- a/docs/en/02_Developer_Guides/07_Debugging/00_Environment_Types.md +++ b/docs/en/02_Developer_Guides/07_Debugging/00_Environment_Types.md @@ -69,6 +69,8 @@ You can check for the current environment type in [config files](../configuratio Checking for what environment you're running in can also be done in PHP. Your application code may disable or enable certain functionality depending on the environment type. ```php + use SilverStripe\Control\Director; + if (Director::isLive()) { // is in live } elseif (Director::isTest()) { diff --git a/docs/en/02_Developer_Guides/07_Debugging/01_Error_Handling.md b/docs/en/02_Developer_Guides/07_Debugging/01_Error_Handling.md index 4b9c3d253..943b5b19f 100644 --- a/docs/en/02_Developer_Guides/07_Debugging/01_Error_Handling.md +++ b/docs/en/02_Developer_Guides/07_Debugging/01_Error_Handling.md @@ -14,6 +14,8 @@ For informational and debug logs, you can use the Logger directly. The Logger is can be accessed via the `Injector`: ```php +use SilverStripe\Core\Injector\Injector; + Injector::inst()->get(LoggerInterface::class)->info('User has logged in: ID #' . Security::getCurrentUser()->ID); Injector::inst()->get(LoggerInterface::class)->debug('Query executed: ' . $sql); ``` diff --git a/docs/en/02_Developer_Guides/07_Debugging/03_Template_debugging.md b/docs/en/02_Developer_Guides/07_Debugging/03_Template_debugging.md index 5a4213b44..c032b1311 100644 --- a/docs/en/02_Developer_Guides/07_Debugging/03_Template_debugging.md +++ b/docs/en/02_Developer_Guides/07_Debugging/03_Template_debugging.md @@ -15,6 +15,6 @@ block of html on your page. Only: environment: 'dev' --- - SSViewer: + SilverStripe\View\SSViewer: source_file_comments: true ``` \ No newline at end of file diff --git a/docs/en/02_Developer_Guides/07_Debugging/index.md b/docs/en/02_Developer_Guides/07_Debugging/index.md index ea79c240f..884c5900b 100644 --- a/docs/en/02_Developer_Guides/07_Debugging/index.md +++ b/docs/en/02_Developer_Guides/07_Debugging/index.md @@ -18,6 +18,9 @@ bottle-necks and identify slow moving parts of your application chain. The [Debug](api:SilverStripe\Dev\Debug) class contains a number of static utility methods for more advanced debugging. ```php + use SilverStripe\Dev\Debug; + use SilverStripe\Dev\Backtrace; + Debug::show($myVariable); // similar to print_r($myVariable) but shows it in a more useful format. diff --git a/docs/en/02_Developer_Guides/08_Performance/01_Caching.md b/docs/en/02_Developer_Guides/08_Performance/01_Caching.md index 050e8bfa2..36773c715 100644 --- a/docs/en/02_Developer_Guides/08_Performance/01_Caching.md +++ b/docs/en/02_Developer_Guides/08_Performance/01_Caching.md @@ -47,6 +47,8 @@ This factory allows us you to globally define an adapter for all cache instances ```php use Psr\SimpleCache\CacheInterface + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); ``` @@ -65,7 +67,9 @@ Cache objects follow the [PSR-16](http://www.php-fig.org/psr/psr-16/) class inte ```php - use Psr\SimpleCache\CacheInterface + use Psr\SimpleCache\CacheInterface; + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); @@ -89,7 +93,9 @@ this will only affect a subset of cache keys ("myCache" in this example): ```php - use Psr\SimpleCache\CacheInterface + use Psr\SimpleCache\CacheInterface; + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); // remove all items in this (namespaced) cache @@ -101,7 +107,9 @@ You can also delete a single item based on it's cache key: ```php - use Psr\SimpleCache\CacheInterface + use Psr\SimpleCache\CacheInterface; + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); // remove the cache item @@ -112,7 +120,9 @@ Individual cache items can define a lifetime, after which the cached value is ma ```php - use Psr\SimpleCache\CacheInterface + use Psr\SimpleCache\CacheInterface; + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); // remove the cache item @@ -144,7 +154,9 @@ old cache keys will be garbage collected as the cache fills up. ```php - use Psr\SimpleCache\CacheInterface + use Psr\SimpleCache\CacheInterface; + use SilverStripe\Core\Injector\Injector; + $cache = Injector::inst()->get(CacheInterface::class . '.myCache'); // Automatically changes when any group is edited diff --git a/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md b/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md index 750d9d095..87beb5e00 100644 --- a/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md +++ b/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md @@ -18,6 +18,8 @@ headers: ### HTTP::set_cache_age ```php + use SilverStripe\Control\HTTP; + HTTP::set_cache_age(0); ``` @@ -46,7 +48,7 @@ Cookie, X-Forwarded-Protocol, User-Agent, Accept To change the value of the `Vary` header, you can change this value by specifying the header in configuration ```yml -HTTP: +SilverStripe\Control\HTTP: vary: "" ``` 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 5e6434f6f..3a1706f50 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,6 +24,8 @@ SilverStripe can request more resources through `Environment::increaseMemoryLimi
```php + use SilverStripe\Core\Environment; + public function myBigFunction() { Environment::increaseTimeLimitTo(400); 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 a70a05dd7..ca5cefaa4 100644 --- a/docs/en/02_Developer_Guides/09_Security/00_Member.md +++ b/docs/en/02_Developer_Guides/09_Security/00_Member.md @@ -15,6 +15,8 @@ The [api:Security] class comes with a static method for getting information abou Retrieves the current logged in member. Returns *null* if user is not logged in, otherwise, the Member object is returned. ```php + use SilverStripe\Security\Security; + if( $member = Security::getCurrentUser() ) { // Work with $member } else { @@ -32,6 +34,8 @@ This is the least desirable way of extending the [Member](api:SilverStripe\Secur You can define subclasses of [Member](api:SilverStripe\Security\Member) to add extra fields or functionality to the built-in membership system. ```php +use SilverStripe\Security\Member; + class MyMember extends Member { private static $db = array( "Age" => "Int", @@ -58,6 +62,8 @@ details in the newsletter system. This function returns a [FieldList](api:Silve parent::getCMSFields() and manipulate the [FieldList](api:SilverStripe\Forms\FieldList) from there. ```php + use SilverStripe\Forms\TextField; + public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertBefore("HTMLEmail", new TextField("Age")); 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 b55d1b042..5b77a3362 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 @@ -26,6 +26,10 @@ come from user input. Example: ```php + use SilverStripe\ORM\DB; + use SilverStripe\ORM\DataObject; + use SilverStripe\ORM\Queries\SQLSelect; + $records = DB::prepared_query('SELECT * FROM "MyClass" WHERE "ID" = ?', [3]); $records = MyClass::get()->where(['"ID" = ?' => 3]); $records = MyClass::get()->where(['"ID"' => 3]); @@ -40,6 +44,9 @@ Parameterised updates and inserts are also supported, but the syntax is a little ```php + use SilverStripe\ORM\Queries\SQLInsert; + use SilverStripe\ORM\DB; + SQLInsert::create('"MyClass"') ->assign('"Name"', 'Daniel') ->addAssignments([ @@ -80,6 +87,8 @@ handled via prepared statements. Example: ```php + use SilverStripe\Security\Member; + // automatically escaped/quoted $members = Member::get()->filter('Name', $_GET['name']); // automatically escaped/quoted @@ -555,6 +564,9 @@ a [PasswordValidator](api:SilverStripe\Security\PasswordValidator): ```php + use SilverStripe\Security\Member; + use SilverStripe\Security\PasswordValidator; + $validator = new PasswordValidator(); $validator->minLength(7); $validator->checkHistoricalPasswords(6); @@ -672,6 +684,8 @@ variable will be no longer necessary, thus it will be necessary to always set SilverStripe recommends the use of TLS(HTTPS) for your application, and you can easily force the use through the director function `forceSSL()` ```php + use SilverStripe\Control\Director; + if (!Director::isDev()) { Director::forceSSL(); } @@ -685,7 +699,7 @@ use a [secure session](https://docs.silverstripe.org/en/3/developer_guides/cooki To do this, you may set the `cookie_secure` parameter to `true` in your `config.yml` for `Session` ```yml - Session: + SilverStripe\Control\Session: cookie_secure: true ``` @@ -700,6 +714,7 @@ clear text and can be intercepted and stolen by an attacker who is listening on code. It is best practice to set this flag unless the application is known to use JavaScript to access these cookies as this prevents an attacker who achieves cross-site scripting from accessing these cookies. ```php + use SilverStripe\Control\Cookie; Cookie::set('cookie-name', 'chocolate-chip', $expiry = 30, $path = null, $domain = null, $secure = true, $httpOnly = false diff --git a/docs/en/02_Developer_Guides/10_Email/index.md b/docs/en/02_Developer_Guides/10_Email/index.md index 272bc6de3..a2e404eff 100644 --- a/docs/en/02_Developer_Guides/10_Email/index.md +++ b/docs/en/02_Developer_Guides/10_Email/index.md @@ -24,6 +24,8 @@ SilverStripe\Core\Injector\Injector: ```php + use SilverStripe\Control\Email\Email; + $email = new Email($from, $to, $subject, $body); $email->sendPlain(); ``` @@ -135,6 +137,8 @@ Configuration of those properties looks like the following: ```php + use SilverStripe\Control\Director; + use SilverStripe\Core\Config\Config; if(Director::isLive()) { Config::inst()->update('Email', 'bcc_all_emails_to', "client@example.com"); } else { 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 b2c28b0ad..19a552143 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 @@ -36,6 +36,8 @@ The loader would be triggered through the `load()` method: ```php + use SilverStripe\Dev\CsvBulkLoader; + $loader = new CsvBulkLoader('Member'); $result = $loader->load(''); ``` 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 f8c7531d0..1ab453ba2 100644 --- a/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md +++ b/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md @@ -24,6 +24,8 @@ An outline of step one looks like: ```php + use SilverStripe\Control\RSS\RSSFeed; + $feed = new RSSFeed( $list, $link, @@ -201,6 +203,8 @@ Say from that last example we want to include the Players Team in the XML feed w ```php + use SilverStripe\Control\RSS\RSSFeed; + public function players() { $rss = new RSSFeed( 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 deleted file mode 100644 index 2acd56b42..000000000 --- a/docs/en/02_Developer_Guides/11_Integration/How_Tos/embed_rss.md +++ /dev/null @@ -1,64 +0,0 @@ -title: Embed an RSS Feed - -# Embed an RSS Feed - -[RestfulService](api:RestfulService) can be used to easily embed an RSS feed from a site. In this How to we'll embed the latest -weather information from the Yahoo Weather API. - -First, we write the code to query the API feed. - -**mysite/code/Page.php** - - -```php - public function getWellingtonWeather() - { - $fetch = new RestfulService( - 'https://query.yahooapis.com/v1/public/yql' - ); - - $fetch->setQueryString([ - 'q' => 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="Wellington, NZ")' - ]); - - // perform the query - $conn = $fetch->request(); - - // parse the XML body - $msgs = $fetch->getValues($conn->getBody(), "results"); - - // generate an object our templates can read - $output = new ArrayList(); - - if($msgs) { - foreach($msgs as $msg) { - $output->push(new ArrayData([ - 'Description' => Convert::xml2raw($msg->channel_item_description) - ])); - } - } - - return $output; - } - -``` - -This will provide our `Page` template with a new `WellingtonWeather` variable (an [ArrayList](api:SilverStripe\ORM\ArrayList)). Each item has a -single field `Description`. - -**mysite/templates/Page.ss** - - -```ss - - <% if WellingtonWeather %> - <% loop WellingtonWeather %> - $Description - <% end_loop %> - <% end_if %> -``` - -## Related - -* [RestfulService Documentation](../restfulservice) -* [RestfulService](api:RestfulService) 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 4c9923c86..5aa28a925 100644 --- a/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md +++ b/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md @@ -137,6 +137,8 @@ in order to read page limit information. It is also passed the current ```php + use SilverStripe\ORM\PaginatedList; + public function getResults($searchCriteria = []) { $start = ($this->getRequest()->getVar('start')) ? (int)$this->getRequest()->getVar('start') : 0; diff --git a/docs/en/02_Developer_Guides/13_i18n/index.md b/docs/en/02_Developer_Guides/13_i18n/index.md index 3e2228682..4da8bbcdb 100644 --- a/docs/en/02_Developer_Guides/13_i18n/index.md +++ b/docs/en/02_Developer_Guides/13_i18n/index.md @@ -29,6 +29,8 @@ you want to set. ```php + use SilverStripe\i18n\i18n; + // mysite/_config.php i18n::set_locale('de_DE'); // Setting the locale to German (Germany) i18n::set_locale('ca_AD'); // Setting to Catalan (Andorra) @@ -82,6 +84,8 @@ You can use these settings for your own view logic. ```php + use SilverStripe\Core\Config\Config; + Config::inst()->update('i18n', 'date_format', 'dd.MM.yyyy'); Config::inst()->update('i18n', 'time_format', 'HH:mm'); ``` @@ -107,7 +111,7 @@ In order to add a value, add the following to your `config.yml`: ```yml - i18n: + SilverStripe\i18n\i18n: common_locales: de_CGN: name: German (Cologne) @@ -119,7 +123,7 @@ Similarly, to change an existing language label, you can overwrite one of these ```yml - i18n: + SilverStripe\i18n\i18n: common_locales: en_NZ: native: Niu Zillund @@ -155,6 +159,8 @@ followed by `setLocale()` or `setDateFormat()`/`setTimeFormat()`. ```php + use SilverStripe\Forms\DateField; + $field = new DateField(); $field->setLocale('de_AT'); // set Austrian/German locale, defaulting format to dd.MM.y $field->setDateFormat('d.M.y'); // set a more specific date format (single digit day/month) @@ -341,7 +347,7 @@ To create a custom module order, you need to specify a config fragment that inse Name: customi18n Before: 'defaulti18n' --- - i18n: + SilverStripe\i18n\i18n: module_priority: - module1 - module2 @@ -402,6 +408,8 @@ If using this on the frontend, it's also necessary to include the stand-alone i1 js file. ```php +use SilverStripe\View\Requirements; + Requirements::javascript('silverstripe/admin:client/dist/js/i18n.js'); Requirements::add_i18n_javascript('/javascript/lang'); ``` diff --git a/docs/en/02_Developer_Guides/14_Files/01_File_Management.md b/docs/en/02_Developer_Guides/14_Files/01_File_Management.md index 460d09a34..f9d209a58 100644 --- a/docs/en/02_Developer_Guides/14_Files/01_File_Management.md +++ b/docs/en/02_Developer_Guides/14_Files/01_File_Management.md @@ -130,6 +130,8 @@ to live until a publish is made (either on this object, or cascading from a pare When files are renamed using the ORM, all file variants are automatically renamed at the same time. ```php +use SilverStripe\Assets\File; + $file = File::get()->filter('Name', 'oldname.jpg')->first(); if ($file) { // The below will move 'oldname.jpg' and 'oldname__variant.jpg' 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 e49087457..69f9de238 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 @@ -190,6 +190,8 @@ will be moved to `assets/a870de278b/NewCompanyLogo.gif`, and will be served dire the web server, bypassing the need for additional PHP requests. ```php +use SilverStripe\Assets\Storage\AssetStore; + $store = singleton(AssetStore::class); $store->publish('NewCompanyLogo.gif', 'a870de278b475cb75f5d9f451439b2d378e13af1'); ``` 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 8c6e45229..90e3e312d 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 @@ -62,7 +62,7 @@ The CMS interface can be accessed by default through the `admin/` URL. You can c After: - '#adminroutes' --- - Director: + SilverStripe\Control\Director: rules: 'admin': '' 'newAdmin': 'AdminRootController' @@ -75,7 +75,7 @@ In PHP you should use: ```php - AdminRootController::admin_url() + SilverStripe\Admin\AdminRootController::admin_url() ``` When writing templates use: diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/04_Preview.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/04_Preview.md index f58029c39..7c8532a5e 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/04_Preview.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/04_Preview.md @@ -82,7 +82,7 @@ to the `LeftAndMain.extra_requirements_javascript` [configuration value](../conf ```yml - LeftAndMain: + SilverStripe\Admin\LeftAndMain: extra_requirements_javascript: - mysite/javascript/MyLeftAndMain.Preview.js ``` diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/05_Typography.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/05_Typography.md index c75a806ee..1497af63a 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/05_Typography.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/05_Typography.md @@ -8,6 +8,8 @@ SilverStripe lets you customise the style of content in the CMS. This is done by ```php + use SilverStripe\Forms\HTMLEditor\HtmlEditorConfig; + HtmlEditorConfig::get('cms')->setOption('content_css', project() . '/css/editor.css'); ``` 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 f473003f6..dc2b1277f 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 @@ -419,6 +419,9 @@ PHP: ```php + use SilverStripe\Control\HTTPResponse; + use SilverStripe\View\ViewableData; + class MyController { public function autocomplete($request) diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Formfield_Help_Text.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Formfield_Help_Text.md index 677fb7d37..7582f184a 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Formfield_Help_Text.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/CMS_Formfield_Help_Text.md @@ -11,6 +11,8 @@ at the last position within the field, and expects unescaped HTML content. ```php + use SilverStripe\Forms\TextField; + TextField::create('MyText', 'My Text Label') ->setDescription('More detailed help'); ``` diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md index cbcd5f0be..458d1271f 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md @@ -78,7 +78,7 @@ or across page types with common characteristics. Now you just need to enable the extension in your [configuration file](../../configuration). ```yml // mysite/_config/config.yml - LeftAndMain: + SilverStripe\Admin\LeftAndMain: extensions: - NewsPageHolderCMSMainExtension ``` 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 6f4805342..5389815cd 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 @@ -67,7 +67,7 @@ Load the new CSS file into the CMS, by setting the `LeftAndMain.extra_requiremen ```yml - LeftAndMain: + SilverStripe\Admin\LeftAndMain: extra_requirements_css: - mysite/css/BookmarkedPages.css ``` @@ -106,7 +106,7 @@ Enable the extension in your [configuration file](../../configuration) ```yml - SiteTree: + SilverStripe\CMS\Model\SiteTree: extensions: - BookmarkedPageExtension ``` @@ -143,7 +143,7 @@ Enable the extension in your [configuration file](../../configuration) ```yml - LeftAndMain: + SilverStripe\Admin\LeftAndMain: extensions: - BookmarkedPagesLeftAndMainExtension ``` @@ -268,7 +268,7 @@ The extension then needs to be registered: ```yaml - LeftAndMain: + SilverStripe\Admin\LeftAndMain: extensions: - CustomActionsExtension ``` diff --git a/docs/en/02_Developer_Guides/16_Execution_Pipeline/03_App_Object_and_Kernel.md b/docs/en/02_Developer_Guides/16_Execution_Pipeline/03_App_Object_and_Kernel.md index 1c1f785fe..8f5acafd2 100644 --- a/docs/en/02_Developer_Guides/16_Execution_Pipeline/03_App_Object_and_Kernel.md +++ b/docs/en/02_Developer_Guides/16_Execution_Pipeline/03_App_Object_and_Kernel.md @@ -10,6 +10,9 @@ This can be accessed in user code via Injector ```php + use SilverStripe\Core\Kernel; + use SilverStripe\Core\Injector\Injector; + $kernel = Injector::inst()->get(Kernel::class); echo "Current environment: " . $kernel->getEnvironment(); ``` diff --git a/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md b/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md index 7656d357e..2fc2b9107 100644 --- a/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md +++ b/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/01_Cookies.md @@ -15,6 +15,8 @@ Sets the value of cookie with configuration. ```php + use SilverStripe\Control\Cookie; + Cookie::set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false); // Cookie::set('MyApplicationPreference', 'Yes'); @@ -54,6 +56,10 @@ from the browser. ```php + use SilverStripe\Core\Injector\Injector; + use SilverStripe\Control\Cookie; + use SilverStripe\Control\CookieJar; + $myCookies = [ 'cookie1' => 'value1', ]; @@ -102,7 +108,7 @@ If you need to implement your own Cookie_Backend you can use the injector system Name: mycookie After: '#cookie' --- - Injector: + SilverStripe\Core\Injector\Injector: Cookie_Backend: class: MyCookieJar ``` diff --git a/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md b/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md index d47116da3..4aa094771 100644 --- a/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md +++ b/docs/en/02_Developer_Guides/18_Cookies_And_Sessions/02_Sessions.md @@ -29,6 +29,8 @@ class MyController extends Controller Otherwise, if you're not in a controller, get the request as a service. ```php +use SilverStripe\Control\HTTPRequest; + $request = Injector::inst()->get(HTTPRequest::class); $session = $request->getSession(); ```