diff --git a/docs/en/01_Tutorials/03_Forms.md b/docs/en/01_Tutorials/03_Forms.md index 91f920ce6..9fba4d7e2 100644 --- a/docs/en/01_Tutorials/03_Forms.md +++ b/docs/en/01_Tutorials/03_Forms.md @@ -267,6 +267,9 @@ We can do this using a session variable. The [Session](api:SilverStripe\Control\ **mysite/code/HomePageController.php** ```php +use SilverStripe\Control\Session; +use PageController; + // ... class HomePageController extends PageController { @@ -286,6 +289,8 @@ Then we simply need to check if the session variable has been set in 'BrowserPol it is. ```php +use PageController; + // ... class HomePageController extends PageController { diff --git a/docs/en/01_Tutorials/04_Site_Search.md b/docs/en/01_Tutorials/04_Site_Search.md index 7bfc6005e..6dbf77a81 100644 --- a/docs/en/01_Tutorials/04_Site_Search.md +++ b/docs/en/01_Tutorials/04_Site_Search.md @@ -58,6 +58,8 @@ is applied via `FulltextSearchable::enable()` **cms/code/search/ContentControllerSearchExtension.php** ```php + use SilverStripe\Core\Extension; + class ContentControllerSearchExtension extends Extension { ... 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 602f06adf..68dcc240f 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 @@ -20,6 +20,8 @@ Let's look at a simple example: **mysite/code/Player.php** ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -77,6 +79,8 @@ system. Instead, it will generate a new `ID` by adding 1 to the current maximum **mysite/code/Player.php** ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -662,6 +666,8 @@ Define the default values for all the `$db` fields. This example sets the "Statu whenever a new object is created. ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -687,6 +693,9 @@ time. For example, suppose we have the following set of classes: ```php + use SilverStripe\CMS\Model\SiteTree; + use Page; + class Page extends SiteTree { 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 13f8fe384..64e1babf8 100644 --- a/docs/en/02_Developer_Guides/00_Model/02_Relations.md +++ b/docs/en/02_Developer_Guides/00_Model/02_Relations.md @@ -16,6 +16,8 @@ A 1-to-1 relation creates a database-column called "``ID", in "TeamID" on the "Player"-table. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { @@ -75,6 +77,8 @@ To specify that a has_one relation is polymorphic set the type to 'DataObject'. Ideally, the associated has_many (or belongs_to) should be specified with dot notation. ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { private static $has_many = [ @@ -118,6 +122,8 @@ available on both ends. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { @@ -159,6 +165,8 @@ you will get an instance of [HasManyList](api:SilverStripe\ORM\HasManyList) rath To specify multiple `$has_many` to the same object you can use dot notation to distinguish them like below: ```php + use SilverStripe\ORM\DataObject; + class Person extends DataObject { @@ -203,6 +211,8 @@ Similarly with `$has_many`, dot notation can be used to explicitly specify the ` This is not mandatory unless the relationship would be otherwise ambiguous. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { @@ -253,6 +263,8 @@ config to add extra columns. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { private static $many_many = [ @@ -296,6 +308,8 @@ or child record. The syntax for `belongs_many_many` is unchanged. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { private static $many_many = [ @@ -365,6 +379,8 @@ distinguish them like below: ```php + use SilverStripe\ORM\DataObject; + class Category extends DataObject { @@ -416,6 +432,8 @@ You can use the ORM to get a filtered result list without writing any SQL. For e See [DataObject::$has_many](api:SilverStripe\ORM\DataObject::$has_many) for more info on the described relations. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { 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 3302a939b..324b28287 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 @@ -14,6 +14,8 @@ In the `Player` example, we have four database columns each with a different dat **mysite/code/Player.php** ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -53,6 +55,8 @@ For complex default values for newly instantiated objects see [Dynamic Default V For simple values you can make use of the `$defaults` array. For example: ```php + use SilverStripe\ORM\DataObject; + class Car extends DataObject { @@ -84,6 +88,8 @@ For enum values, it's the second parameter. For example: ```php + use SilverStripe\ORM\DataObject; + class Car extends DataObject { @@ -107,6 +113,9 @@ object we can control the formatting and it allows us to call methods defined fr **mysite/code/Player.php** ```php + use SilverStripe\ORM\FieldType\DBField; + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -139,6 +148,8 @@ Then we can refer to a new `Name` column on our `Player` instances. In templates Rather than manually returning objects from your custom functions. You can use the `$casting` property. ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -178,6 +189,8 @@ Most objects in SilverStripe extend from [ViewableData](api:SilverStripe\View\Vi context. Through a `$casting` array, arbitrary properties and getters can be casted: ```php + use SilverStripe\View\ViewableData; + class MyObject extends ViewableData { @@ -218,6 +231,8 @@ The following example will use the result of `getStatus` instead of the 'Status' database column using `dbObject`. ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { 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 217fc6ba4..4745b0ae9 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 @@ -19,6 +19,9 @@ a `ModelAdmin` record. Example: Disallow creation of new players if the currently logged-in player is not a team-manager. ```php + use SilverStripe\Security\Security; + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -60,6 +63,10 @@ Example: Checking for a specific [permission](permissions) to delete this type o member is logged in who belongs to a group containing the permission "PLAYER_DELETE". ```php + use SilverStripe\Security\Permission; + use SilverStripe\Security\Security; + use SilverStripe\ORM\DataObject; + class Player extends DataObject { 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 8faf40615..bca9624d8 100644 --- a/docs/en/02_Developer_Guides/00_Model/07_Permissions.md +++ b/docs/en/02_Developer_Guides/00_Model/07_Permissions.md @@ -17,6 +17,9 @@ code. ```php + use SilverStripe\Security\Permission; + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { 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 4914f1d88..be3f3dc62 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 @@ -268,6 +268,8 @@ because of the custom SQL value transformation (`YEAR()`). An alternative approach would be a custom getter in the object definition. ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { private static $db = [ 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 2bf34ce4f..1d3be3ba3 100644 --- a/docs/en/02_Developer_Guides/00_Model/09_Validation.md +++ b/docs/en/02_Developer_Guides/00_Model/09_Validation.md @@ -22,6 +22,8 @@ write, and respond appropriately if it isn't. The return value of `validate()` is a [ValidationResult](api:SilverStripe\ORM\ValidationResult) object. ```php + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { 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 59cac04e5..1f42fd16b 100644 --- a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md +++ b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md @@ -21,6 +21,9 @@ also track versioned history. ```php + use SilverStripe\Versioned\Versioned; + use SilverStripe\ORM\DataObject; + class MyStagedModel extends DataObject { private static $extensions = [ @@ -34,6 +37,8 @@ can be specified by setting the constructor argument to "Versioned" ```php + use SilverStripe\ORM\DataObject; + class VersionedModel extends DataObject { private static $extensions = [ @@ -186,6 +191,10 @@ without requiring any custom code. ```php + use SilverStripe\Versioned\Versioned; + use SilverStripe\Assets\Image; + use Page; + class MyPage extends Page { private static $has_many = [ @@ -227,6 +236,9 @@ that can be used to traverse between each, and then by ensuring you configure bo E.g. ```php + use SilverStripe\Versioned\Versioned; + use SilverStripe\ORM\DataObject; + class MyParent extends DataObject { private static $extensions = [ @@ -298,6 +310,10 @@ Versioned object visibility can be customised in one of the following ways by ed E.g. ```php + use SilverStripe\Versioned\Versioned; + use SilverStripe\Security\Permission; + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { private static $extensions = [ @@ -332,6 +348,9 @@ only be invoked if the object is in a non-published state. E.g. ```php + use SilverStripe\Security\Permission; + use SilverStripe\ORM\DataExtension; + class MyObjectExtension extends DataExtension { public function canViewNonLive($member = null) @@ -347,6 +366,9 @@ permissions in the `TargetObject.non_live_permissions` config. E.g. ```php + use SilverStripe\Versioned\Versioned; + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { private static $extensions = [ 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 5483c88a8..a4373bff8 100644 --- a/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md +++ b/docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md @@ -13,6 +13,8 @@ customise those fields as required. An example is `DataObject`, SilverStripe will automatically create your CMS interface so you can modify what you need. ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -62,6 +64,8 @@ The `$searchable_fields` property uses a mixed array format that can be used to system. The default is a set of array values listing the fields. ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -78,6 +82,8 @@ default search filter assigned (usually an [ExactMatchFilter](api:SilverStripe\O additional information on `$searchable_fields`: ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -93,6 +99,8 @@ If you assign a single string value, you can set it to be either a [FormField](a both, you can assign an array: ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -114,6 +122,8 @@ both, you can assign an array: To include relations (`$has_one`, `$has_many` and `$many_many`) in your search, you can use a dot-notation. ```php + use SilverStripe\ORM\DataObject; + class Team extends DataObject { @@ -151,6 +161,8 @@ Summary fields can be used to show a quick overview of the data for a specific [ is their display as table columns, e.g. in the search results of a [ModelAdmin](api:SilverStripe\Admin\ModelAdmin) CMS interface. ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -171,6 +183,8 @@ is their display as table columns, e.g. in the search results of a [ModelAdmin]( To include relations or field manipulations in your summaries, you can use a dot-notation. ```php + use SilverStripe\ORM\DataObject; + class OtherObject extends DataObject { @@ -202,6 +216,8 @@ To include relations or field manipulations in your summaries, you can use a dot Non-textual elements (such as images and their manipulations) can also be used in summaries. ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { diff --git a/docs/en/02_Developer_Guides/00_Model/12_Indexes.md b/docs/en/02_Developer_Guides/00_Model/12_Indexes.md index 0d5f8efb8..3b55dc704 100644 --- a/docs/en/02_Developer_Guides/00_Model/12_Indexes.md +++ b/docs/en/02_Developer_Guides/00_Model/12_Indexes.md @@ -25,6 +25,8 @@ Indexes are represented on a `DataObject` through the `DataObject::$indexes` arr descriptor. There are several supported notations: ```php + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { @@ -53,6 +55,8 @@ support the following: **mysite/code/MyTestObject.php** ```php + use SilverStripe\ORM\DataObject; + class MyTestObject extends DataObject { 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 cd949e135..f87fd3822 100644 --- a/docs/en/02_Developer_Guides/01_Templates/09_Casting.md +++ b/docs/en/02_Developer_Guides/01_Templates/09_Casting.md @@ -48,6 +48,8 @@ provide default template for an object. **mysite/code/Page.php** ```php + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { @@ -72,6 +74,8 @@ content that method sends back, or, provide a type in the `$casting` array for t to a template, SilverStripe will ensure that the object is wrapped in the correct type and values are safely escaped. ```php + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { 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 31b813afe..b45cd83c8 100644 --- a/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md +++ b/docs/en/02_Developer_Guides/02_Controllers/01_Introduction.md @@ -9,6 +9,8 @@ subclass the base `Controller` class. **mysite/code/controllers/TeamController.php** ```php + use SilverStripe\Control\Controller; + class TeamController extends Controller { 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 e6d394a31..efe74745a 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 @@ -12,6 +12,8 @@ Any action you define on a controller must be defined in a `$allowed_actions` st directly calling methods that they shouldn't. ```php + use SilverStripe\Control\Controller; + class MyController extends Controller { @@ -46,6 +48,8 @@ An action named "index" is white listed by default, unless `allowed_actions` is is specifically restricted. ```php + use SilverStripe\Control\Controller; + ```php + use SilverStripe\Security\Permission; + use SilverStripe\Control\Controller; + class MyController extends Controller { 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 70eff180e..088cf9dd5 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 @@ -16,6 +16,9 @@ The following example will add a simple DateField to your Page, allowing you to ```php + use SilverStripe\Forms\DateField; + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { 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 188347638..c56e39cf1 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 @@ -17,6 +17,10 @@ functionality. It is usually added through the [DataObject::getCMSFields()](api: ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\HTMLEditor\HTMLEditorField; + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { @@ -47,6 +51,10 @@ This is particularly useful if you need different configurations for multiple [H ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\HTMLEditor\HTMLEditorField; + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { private static $db = [ @@ -246,6 +254,8 @@ Example: Remove field for "image captions" ```php + use SilverStripe\Core\Extension; + // File: mysite/code/MyToolbarExtension.php class MyToolbarExtension extends Extension { @@ -288,6 +298,9 @@ of the CMS you have to take care of instantiate yourself: ```php + use SilverStripe\Admin\ModalController; + use SilverStripe\Control\Controller; + // File: mysite/code/MyController.php class MyObjectController extends Controller { 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 c54e7ef85..2607d3593 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 @@ -29,6 +29,9 @@ actions such as deleting records. ```php + use SilverStripe\Forms\GridField\GridField; + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { @@ -62,6 +65,9 @@ the `getConfig()` method on `GridField`. ```php + use SilverStripe\Forms\GridField\GridField; + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { @@ -271,6 +277,11 @@ The namespace notation is `ManyMany[]`, so for example `Ma ```php + use SilverStripe\Forms\TextField; + use SilverStripe\Forms\GridField\GridField; + use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; + use SilverStripe\ORM\DataObject; + class Team extends DataObject { 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 2be887d5f..93b7dcd9e 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 @@ -11,6 +11,17 @@ code for a `Form` is to create it as a subclass to `Form`. Let's look at a examp ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\RequiredFields; + use SilverStripe\Forms\Form; + use SilverStripe\Forms\HeaderField; + use SilverStripe\Forms\OptionsetField; + use SilverStripe\Forms\CompositeField; + use SilverStripe\Forms\CheckboxSetField; + use SilverStripe\Forms\NumericField; + use SilverStripe\Forms\FormAction; + use SilverStripe\CMS\Controllers\ContentController; + class PageController extends ContentController { @@ -70,6 +81,16 @@ should be. Good practice would be to move this to a subclass and create a new in ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\RequiredFields; + use SilverStripe\Forms\HeaderField; + use SilverStripe\Forms\OptionsetField; + use SilverStripe\Forms\CompositeField; + use SilverStripe\Forms\CheckboxSetField; + use SilverStripe\Forms\NumericField; + use SilverStripe\Forms\FormAction; + use SilverStripe\Forms\Form; + class SearchForm extends Form { @@ -133,6 +154,9 @@ Our controller will now just have to create a new instance of this form object. ```php + use SearchForm; + use SilverStripe\CMS\Controllers\ContentController; + class PageController extends ContentController { 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 39ea34bfd..6932cf2b6 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 @@ -6,6 +6,15 @@ Let's start by defining a new `ContactPage` page type: ```php + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\TextField; + use SilverStripe\Forms\EmailField; + use SilverStripe\Forms\TextareaField; + use SilverStripe\Forms\FormAction; + use SilverStripe\Forms\Form; + use Page; + use PageController; + class ContactPage extends Page { } @@ -73,6 +82,9 @@ Now that we have a contact form, we need some way of collecting the data submitt ```php + use SilverStripe\Control\Email\Email; + use PageController; + class ContactPageController extends PageController { private static $allowed_actions = ['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 c5472b490..503838845 100644 --- a/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md +++ b/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md @@ -29,6 +29,8 @@ be marked `private static` and follow the `lower_case_with_underscores` structur ```php + use Page; + class MyClass extends Page { 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 2bb190f27..5132c272d 100644 --- a/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md +++ b/docs/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md @@ -40,6 +40,9 @@ To extend the options available in the panel, define your own fields via a [Data ```php + use SilverStripe\Forms\HTMLEditor\HTMLEditorField; + use SilverStripe\ORM\DataExtension; + class CustomSiteConfig extends DataExtension { 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 6487fe11e..d0883d7c8 100644 --- a/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md +++ b/docs/en/02_Developer_Guides/05_Extending/01_Extensions.md @@ -19,6 +19,8 @@ and `RequestHandler`. You can still apply extensions to descendants of these cla ```php + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { @@ -80,6 +82,8 @@ $has_one etc. ```php + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { @@ -161,6 +165,8 @@ validator by defining the `updateValidator` method. ```php + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { @@ -183,6 +189,10 @@ extension. The `CMS` provides a `updateCMSFields` Extension Hook to tie into. ```php + use SilverStripe\Forms\TextField; + use SilverStripe\AssetAdmin\Forms\UploadField; + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { @@ -231,6 +241,8 @@ In your [Extension](api:SilverStripe\Core\Extension) class you can only refer to ```php + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { 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 c443d23aa..1335f788f 100644 --- a/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md +++ b/docs/en/02_Developer_Guides/05_Extending/04_Shortcodes.md @@ -50,6 +50,8 @@ First we need to define a callback for the shortcode. ```php + use SilverStripe\CMS\Model\SiteTree; + class Page extends SiteTree { 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 48e61c82a..f81a1be48 100644 --- a/docs/en/02_Developer_Guides/05_Extending/05_Injector.md +++ b/docs/en/02_Developer_Guides/05_Extending/05_Injector.md @@ -69,6 +69,8 @@ The `Injector` API can be used to define the types of `$dependencies` that an ob ```php + use SilverStripe\Control\Controller; + class MyController extends Controller { 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 846fc6a4c..7acc71389 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 @@ -11,6 +11,11 @@ explicitly logging in or by invoking the "remember me" functionality. ```php + use SilverStripe\Forms\ReadonlyField; + use SilverStripe\Security\Security; + use SilverStripe\ORM\DB; + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { private static $db = [ 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 9be96c57e..4608c185a 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 @@ -11,6 +11,8 @@ response and modify the session within a test. ```php + use SilverStripe\Security\Member; + class HomePageTest extends FunctionalTest { 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 93f03ed05..aa8081379 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 @@ -10,6 +10,8 @@ with information that we need. ```php + use SilverStripe\Core\Injector\Injector; + class MyObjectTest extends SapphireTest { 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 d641cff8c..fc24cd0d9 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 @@ -59,6 +59,8 @@ approach is to use depedency injection to pass the logger in for you. The [Injec can help with this. The most straightforward is to specify a `dependencies` config setting, like this: ```php +use SilverStripe\Control\Controller; + class MyController extends Controller { private static $dependencies = [ 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 9eee8a3d1..51481f847 100644 --- a/docs/en/02_Developer_Guides/09_Security/00_Member.md +++ b/docs/en/02_Developer_Guides/09_Security/00_Member.md @@ -49,6 +49,8 @@ You can define subclasses of [Member](api:SilverStripe\Security\Member) to add e ```php + use SilverStripe\Security\Member; + class MyMember extends Member { private static $db = [ @@ -116,6 +118,9 @@ things, you should add appropriate [Permission::checkMember()](api:SilverStripe\ ```php + use SilverStripe\Security\Permission; + use SilverStripe\ORM\DataExtension; + class MyMemberExtension extends DataExtension { /** @@ -173,6 +178,11 @@ E.g. ```php + use SilverStripe\Control\Director; + use SilverStripe\Security\Security; + use SilverStripe\Security\Member; + use SilverStripe\Dev\BuildTask; + class CleanRecordsTask extends BuildTask { public function run($request) 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 465f5056c..33c4fb739 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 @@ -114,6 +114,9 @@ Example: ```php + use SilverStripe\Core\Convert; + use SilverStripe\Forms\Form; + class MyForm extends Form { public function save($RAW_data, $form) @@ -134,6 +137,9 @@ Example: ```php + use SilverStripe\Core\Convert; + use SilverStripe\Control\Controller; + class MyController extends Controller { private static $allowed_actions = ['myurlaction']; @@ -154,6 +160,10 @@ passing data through, escaping should happen at the end of the chain. ```php + use SilverStripe\Core\Convert; + use SilverStripe\ORM\DB; + use SilverStripe\Control\Controller; + class MyController extends Controller { /** @@ -238,6 +248,8 @@ PHP: ```php + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { private static $db = [ @@ -288,6 +300,8 @@ PHP: ```php + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject { public $Title = 'not bold'; // will be escaped due to Text casting @@ -332,6 +346,9 @@ PHP: ```php + use SilverStripe\Core\Convert; + use SilverStripe\Control\Controller; + class MyController extends Controller { private static $allowed_actions = ['search']; @@ -367,6 +384,8 @@ PHP: ```php + use SilverStripe\Control\Controller; + class MyController extends Controller { private static $allowed_actions = ['search']; @@ -563,6 +582,8 @@ controller's `init()` method: ```php + use SilverStripe\Control\Controller; + class MyController extends Controller { public function init() @@ -704,6 +725,9 @@ and `Date: ` will ensure that sensitive content is not stored loca unauthorised local persons. SilverStripe adds the current date for every request, and we can add the other cache headers to the request for our secure controllers: ```php + use SilverStripe\Control\HTTP; + use SilverStripe\Control\Controller; + class MySecureController extends Controller { 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 57e14dc31..a3489d674 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 @@ -49,6 +49,8 @@ The simplest way to use [CsvBulkLoader](api:SilverStripe\Dev\CsvBulkLoader) is t ```php + use SilverStripe\Admin\ModelAdmin; + class PlayerAdmin extends ModelAdmin { private static $managed_models = [ @@ -75,6 +77,14 @@ You'll need to add a route to your controller to make it accessible via URL ```php + use SilverStripe\Forms\Form; + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\FileField; + use SilverStripe\Forms\FormAction; + use SilverStripe\Forms\RequiredFields; + use SilverStripe\Dev\CsvBulkLoader; + use SilverStripe\Control\Controller; + class MyController extends Controller { @@ -139,6 +149,8 @@ Datamodel for Player ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { private static $db = [ @@ -159,6 +171,8 @@ Datamodel for FootballTeam: ```php + use SilverStripe\ORM\DataObject; + class FootballTeam extends DataObject { private static $db = [ @@ -179,6 +193,8 @@ Sample implementation of a custom loader. Assumes a CSV-file in a certain format * Avoids duplicate imports by a custom `$duplicateChecks` definition * Creates `Team` relations automatically based on the `Gruppe` column in the CSV data ```php + use SilverStripe\Dev\CsvBulkLoader; + class PlayerCsvBulkLoader extends CsvBulkLoader { public $columnMap = [ @@ -216,6 +232,8 @@ Building off of the ModelAdmin example up top, use a custom loader instead of th ```php + use SilverStripe\Admin\ModelAdmin; + class PlayerAdmin extends ModelAdmin { private static $managed_models = [ 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 9178ea31c..e2a59ab88 100644 --- a/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md +++ b/docs/en/02_Developer_Guides/11_Integration/02_RSSFeed.md @@ -56,6 +56,10 @@ You can use [RSSFeed](api:SilverStripe\Control\RSS\RSSFeed) to easily create a f ```php + use SilverStripe\Control\RSS\RSSFeed; + use Page; + use SilverStripe\CMS\Controllers\ContentController; + .. class PageController extends ContentController @@ -106,6 +110,10 @@ method is defined and returns a string to the full website URL. ```php + use SilverStripe\Control\Controller; + use SilverStripe\Control\Director; + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -126,6 +134,9 @@ Then in our controller, we add a new action which returns a the XML list of `Pla ```php + use SilverStripe\Control\RSS\RSSFeed; + use SilverStripe\CMS\Controllers\ContentController; + class PageController extends ContentController { 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 0549a4538..63db982d7 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 @@ -8,6 +8,14 @@ form (which is used for `MyDataObject` instances). You can access it through ```php + use SilverStripe\Forms\Form; + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\FileField; + use SilverStripe\Forms\FormAction; + use SilverStripe\Forms\RequiredFields; + use SilverStripe\Dev\CsvBulkLoader; + use SilverStripe\Control\Controller; + class MyController extends Controller { 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 cd0cb483a..c43940b7b 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 @@ -17,6 +17,8 @@ information about the individual player and a relation set up for managing the ` ```php + use SilverStripe\ORM\DataObject; + class Player extends DataObject { @@ -38,6 +40,8 @@ information about the individual player and a relation set up for managing the ` ```php + use SilverStripe\ORM\DataObject; + class FootballTeam extends DataObject { @@ -68,6 +72,8 @@ Our final import looks like this. ```php + use SilverStripe\Dev\CsvBulkLoader; + class PlayerCsvBulkLoader extends CsvBulkLoader { 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 99ae9581e..ae1bec24e 100644 --- a/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md +++ b/docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md @@ -20,6 +20,8 @@ Defining search-able fields on your DataObject. ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -39,6 +41,11 @@ and `MyDate`. The attribute `HiddenProperty` should not be searchable, and `MyDa ```php + use SilverStripe\ORM\Filters\PartialMatchFilter; + use SilverStripe\ORM\Filters\GreaterThanFilter; + use SilverStripe\ORM\Search\SearchContext; + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -83,6 +90,11 @@ the `$fields` constructor parameter. ```php + use SilverStripe\Forms\Form; + use SilverStripe\Forms\FieldList; + use SilverStripe\Forms\FormAction; + use SilverStripe\CMS\Controllers\ContentController; + // .. class PageController extends ContentController diff --git a/docs/en/02_Developer_Guides/12_Search/02_FulltextSearch.md b/docs/en/02_Developer_Guides/12_Search/02_FulltextSearch.md index 0a1c4aa03..cfc31d2b8 100644 --- a/docs/en/02_Developer_Guides/12_Search/02_FulltextSearch.md +++ b/docs/en/02_Developer_Guides/12_Search/02_FulltextSearch.md @@ -23,6 +23,8 @@ You can do so by adding this static variable to your class definition: ```php + use SilverStripe\ORM\DataObject; + class MyDataObject extends DataObject { @@ -50,6 +52,8 @@ Example DataObject: ```php + use SilverStripe\ORM\DataObject; + class SearchableDataObject extends DataObject { diff --git a/docs/en/02_Developer_Guides/13_i18n/index.md b/docs/en/02_Developer_Guides/13_i18n/index.md index 04cc98582..3622c4ff0 100644 --- a/docs/en/02_Developer_Guides/13_i18n/index.md +++ b/docs/en/02_Developer_Guides/13_i18n/index.md @@ -211,6 +211,8 @@ For instance, this is an example of how to correctly declare pluralisations for ```php + use SilverStripe\ORM\DataObject; + class MyObject extends DataObject, implements i18nEntityProvider { public function provideI18nEntities() 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 03ee4798a..2750d091f 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 @@ -52,6 +52,8 @@ within the assets folder). For example, to load a temporary file into a DataObject you could use the below: ```php + use SilverStripe\ORM\DataObject; +