mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
add use statements
This commit is contained in:
parent
84feab5a68
commit
e4fba5a7b1
@ -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
|
||||
{
|
||||
|
@ -58,6 +58,8 @@ is applied via `FulltextSearchable::enable()`
|
||||
**cms/code/search/ContentControllerSearchExtension.php**
|
||||
|
||||
```php
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class ContentControllerSearchExtension extends Extension
|
||||
{
|
||||
...
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -16,6 +16,8 @@ A 1-to-1 relation creates a database-column called "`<relationship-name>`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.
|
||||
</div>
|
||||
|
||||
```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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -17,6 +17,9 @@ code.
|
||||
</div>
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyDataObject extends DataObject
|
||||
{
|
||||
|
||||
|
@ -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 = [
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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 = [
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -9,6 +9,8 @@ subclass the base `Controller` class.
|
||||
**mysite/code/controllers/TeamController.php**
|
||||
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class TeamController extends Controller
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
class MyController extends Controller
|
||||
{
|
||||
@ -60,6 +64,8 @@ is specifically restricted.
|
||||
`$allowed_actions` can be defined on `Extension` classes applying to the controller.
|
||||
|
||||
```php
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class MyExtension extends Extension
|
||||
{
|
||||
|
||||
@ -73,6 +79,8 @@ is specifically restricted.
|
||||
Only public methods can be made accessible.
|
||||
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
@ -96,6 +104,8 @@ Only public methods can be made accessible.
|
||||
|
||||
If a method on a parent class is overwritten, access control for it has to be redefined as well.
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
@ -132,6 +142,9 @@ Access checks on parent classes need to be overwritten via the [Configuration AP
|
||||
Form action methods should **not** be included in `$allowed_actions`. However, the form method **should** be included
|
||||
as an `allowed_action`.
|
||||
```php
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
@ -158,6 +171,8 @@ Each method responding to a URL can also implement custom permission checks, e.g
|
||||
the passed request data.
|
||||
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
@ -192,6 +207,9 @@ execution. This behavior can be used to implement permission checks.
|
||||
`init` is called for any possible action on the controller and before any specific method such as `index`.
|
||||
</div>
|
||||
```php
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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[<extradata-field-name>]`, 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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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'];
|
||||
|
@ -29,6 +29,8 @@ be marked `private static` and follow the `lower_case_with_underscores` structur
|
||||
|
||||
|
||||
```php
|
||||
use Page;
|
||||
|
||||
class MyClass extends Page
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -50,6 +50,8 @@ First we need to define a callback for the shortcode.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
|
||||
class Page extends SiteTree
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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 = [
|
||||
|
@ -11,6 +11,8 @@ response and modify the session within a test.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
class HomePageTest extends FunctionalTest
|
||||
{
|
||||
|
||||
|
@ -10,6 +10,8 @@ with information that we need.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
|
||||
class MyObjectTest extends SapphireTest
|
||||
{
|
||||
|
||||
|
@ -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 = [
|
||||
|
@ -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)
|
||||
|
@ -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 = '<b>not bold</b>'; // 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: <current 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
|
||||
{
|
||||
|
||||
|
@ -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 = [
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
||||
<?
|
||||
class Banner extends DataObject
|
||||
{
|
||||
|
@ -65,6 +65,8 @@ authorised users, the following should be considered:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
|
||||
class PageController extends ContentController
|
||||
{
|
||||
public function init()
|
||||
@ -98,6 +100,8 @@ authorised users, the following should be considered:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
|
||||
class PageController extends ContentController
|
||||
{
|
||||
public function init()
|
||||
@ -313,6 +317,8 @@ the `Versioned` extension.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyVersiondObject extends DataObject
|
||||
{
|
||||
/** Ensure assets are archived along with the DataObject */
|
||||
|
@ -21,6 +21,8 @@ a category.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Product extends DataObject
|
||||
{
|
||||
|
||||
@ -41,6 +43,8 @@ a category.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Category extends DataObject
|
||||
{
|
||||
|
||||
@ -64,6 +68,8 @@ We'll name it `MyAdmin`, but the class name can be anything you want.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
|
||||
@ -104,6 +110,9 @@ permissions by default. For most cases, less restrictive checks make sense, e.g.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Category extends DataObject
|
||||
{
|
||||
// ...
|
||||
@ -142,6 +151,8 @@ class (see [SearchContext](../search/searchcontext) docs for details).
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Product extends DataObject
|
||||
{
|
||||
|
||||
@ -167,6 +178,8 @@ model class, where you can add or remove columns. To change the title, use [Data
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Product extends DataObject
|
||||
{
|
||||
|
||||
@ -192,6 +205,8 @@ For example, we might want to exclude all products without prices in our sample
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
|
||||
@ -216,6 +231,9 @@ checkbox which limits search results to expensive products (over $100).
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
|
||||
@ -252,6 +270,9 @@ example, to add a new component.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\GridField\GridFieldFilterHeader;
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
|
||||
@ -287,6 +308,9 @@ to only one specific `GridField`:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\GridField\GridFieldFilterHeader;
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
|
||||
@ -330,6 +354,8 @@ To customize the exported columns, create a new method called `getExportFields`
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class MyAdmin extends ModelAdmin
|
||||
{
|
||||
// ...
|
||||
|
@ -162,6 +162,12 @@ Basic example form in a CMS controller subclass:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
|
||||
class MyAdmin extends LeftAndMain
|
||||
{
|
||||
function getEditForm() {
|
||||
@ -363,6 +369,8 @@ in a single Ajax request.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
|
||||
// mysite/code/MyAdmin.php
|
||||
class MyAdmin extends LeftAndMain
|
||||
{
|
||||
@ -491,6 +499,8 @@ without affecting the response body.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
|
||||
class MyController extends LeftAndMain
|
||||
{
|
||||
class myaction()
|
||||
|
@ -22,6 +22,8 @@ black-and-transparent PNG graphics. In this case we'll place the icon in
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class ProductAdmin extends ModelAdmin
|
||||
{
|
||||
// ...
|
||||
@ -37,6 +39,8 @@ controller, removing the "Admin" bit at the end.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
|
||||
class ProductAdmin extends ModelAdmin
|
||||
{
|
||||
// ...
|
||||
@ -62,6 +66,9 @@ button configuration.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\CMSMenu;
|
||||
use SilverStripe\Admin\LeftAndMainExtension;
|
||||
|
||||
class CustomLeftAndMain extends LeftAndMainExtension
|
||||
{
|
||||
|
||||
|
@ -19,6 +19,8 @@ hypothetical `NewsPageHolder` type, which contains `NewsPage` children.
|
||||
|
||||
|
||||
```php
|
||||
use Page;
|
||||
|
||||
// mysite/code/NewsPageHolder.php
|
||||
class NewsPageHolder extends Page
|
||||
{
|
||||
@ -43,6 +45,9 @@ or across page types with common characteristics.
|
||||
|
||||
|
||||
```php
|
||||
use Page;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
// mysite/code/NewsPageHolderCMSMainExtension.php
|
||||
class NewsPageHolderCMSMainExtension extends Extension
|
||||
{
|
||||
|
@ -66,6 +66,8 @@ __Example: using a subclass__
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
|
||||
class Page extends SiteTree
|
||||
{
|
||||
public function getScheduledToPublish()
|
||||
|
@ -34,6 +34,8 @@ The following example will create a report to list every page on the current sit
|
||||
|
||||
###CustomSideReport.php
|
||||
```php
|
||||
use Page;
|
||||
|
||||
class CustomSideReport_NameOfReport extends SS_Report
|
||||
{
|
||||
|
||||
|
@ -80,6 +80,9 @@ and insert the following code.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
class BookmarkedPageExtension extends DataExtension
|
||||
{
|
||||
|
||||
@ -121,6 +124,9 @@ Add the following code to a new file `mysite/code/BookmarkedLeftAndMainExtension
|
||||
|
||||
|
||||
```php
|
||||
use Page;
|
||||
use SilverStripe\Admin\LeftAndMainExtension;
|
||||
|
||||
class BookmarkedPagesLeftAndMainExtension extends LeftAndMainExtension
|
||||
{
|
||||
|
||||
@ -238,6 +244,8 @@ applicable controller actions to it:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Admin\LeftAndMainExtension;
|
||||
|
||||
class CustomActionsExtension extends LeftAndMainExtension
|
||||
{
|
||||
|
||||
|
@ -5,6 +5,8 @@ also another tool at your disposal: The [Extension](api:SilverStripe\Core\Extens
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
class MyAdminExtension extends Extension
|
||||
{
|
||||
// ...
|
||||
|
@ -20,6 +20,8 @@ This example uses [Cache](api:Cache) in some custom code, and the same cache is
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyClass extends DataObject implements Flushable
|
||||
{
|
||||
|
||||
@ -49,6 +51,8 @@ useful in an example like `GD` or `Imagick` generating resampled images, but we
|
||||
flush so they are re-created on demand.
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyClass extends DataObject implements Flushable
|
||||
{
|
||||
|
||||
|
@ -93,6 +93,8 @@ This code provides a good template:
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
class MyProcess extends Controller
|
||||
{
|
||||
|
||||
|
@ -8,6 +8,8 @@ login forms or other changes. To re-enable this, you'll need to use the `Injecto
|
||||
Define a login form:
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
|
||||
|
||||
class CustomLoginForm extends MemberLoginForm
|
||||
{
|
||||
|
||||
|
@ -8,6 +8,8 @@ login forms or other changes. To re-enable this, you'll need to use the `Injecto
|
||||
Define a login form:
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
|
||||
|
||||
class CustomLoginForm extends MemberLoginForm
|
||||
{
|
||||
|
||||
|
@ -8,6 +8,8 @@ login forms or other changes. To re-enable this, you'll need to use the `Injecto
|
||||
Define a login form:
|
||||
|
||||
```php
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
|
||||
|
||||
class CustomLoginForm extends MemberLoginForm
|
||||
{
|
||||
|
||||
|
@ -650,6 +650,10 @@ Usages of UploadField will need to be upgraded as below.
|
||||
Before:
|
||||
|
||||
```php
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\AssetAdmin\Forms\UploadField;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyClass extends DataObject
|
||||
{
|
||||
public function getCMSFields()
|
||||
@ -707,6 +711,8 @@ including both plurals and cross-module localisations.
|
||||
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class MyObject extends DataObject, implements i18nEntityProvider
|
||||
{
|
||||
public function provideI18nEntities()
|
||||
@ -951,6 +957,8 @@ SilverStripe\Assets\Image::add_extension('MyImageExtension');
|
||||
Now image manipulations are implemented with a single method via a callback generator:
|
||||
|
||||
```php
|
||||
use SilverStripe\Assets\File;
|
||||
|
||||
// in MyImageExtension.php
|
||||
class MyImageExtension extends SilverStripe\Core\Extension
|
||||
{
|
||||
@ -1227,6 +1235,8 @@ parameter, which declares whether or not the model is versioned and has a draft
|
||||
if it only has versioning without staging.
|
||||
|
||||
```php
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
/**
|
||||
* This model has staging and versioning. Stages will be "Stage" and "Live"
|
||||
*/
|
||||
@ -1272,6 +1282,10 @@ For instance, on a products page which has a list of products, the products shou
|
||||
(`has_many`, `many_many`, etc.).
|
||||
|
||||
```php
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use Page;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class ProductPage extends Page
|
||||
{
|
||||
private static $has_many = [
|
||||
|
Loading…
Reference in New Issue
Block a user