From 9ec893b06146f4ea32d5c041f03d4225390e5908 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:32:04 +1200 Subject: [PATCH] DOC Document renamed classes (#584) --- .../00_Model/01_Data_Model_and_ORM.md | 2 +- en/02_Developer_Guides/00_Model/03_Lists.md | 20 +++++----- .../00_Model/04_Data_Types_and_Casting.md | 6 +-- .../00_Model/06_SearchFilters.md | 4 +- .../00_Model/09_Validation.md | 10 ++--- .../How_Tos/Grouping_DataObject_Sets.md | 16 ++++---- .../01_Templates/01_Syntax.md | 6 +-- .../01_Templates/02_Common_Variables.md | 4 +- .../01_Templates/04_Rendering_Templates.md | 16 ++++---- .../01_Templates/09_Casting.md | 12 +++--- .../11_Partial_Template_Caching.md | 2 +- .../01_Templates/How_Tos/02_Pagination.md | 20 +++++----- .../03_Forms/01_Validation.md | 8 ++-- .../07_Using_GridField_With_Arbitrary_Data.md | 28 ++++++------- .../Field_types/01_Common_Subclasses.md | 2 +- .../05_Extending/01_Extensions.md | 6 +-- .../11_Integration/02_RSSFeed.md | 2 +- .../12_Search/01_Searchcontext.md | 2 +- .../04_Preview.md | 2 +- .../06_Javascript_Development.md | 4 +- en/08_Changelogs/6.0.0.md | 40 +++++++++++++++++-- 21 files changed, 122 insertions(+), 90 deletions(-) diff --git a/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md b/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md index 450a70b33..0e1f4ba72 100644 --- a/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md +++ b/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md @@ -262,7 +262,7 @@ if ($players->exists()) { > [!TIP] > While you could use `if ($players->Count() > 0)` for this condition, the `exists()` method uses an `EXISTS` SQL query, which is more performant. -See the [Lists](lists) documentation for more information on dealing with [SS_List](api:SilverStripe\ORM\SS_List) instances. +See the [Lists](lists) documentation for more information on dealing with [SS_List](api:SilverStripe\Model\List\SS_List) instances. ## Sorting diff --git a/en/02_Developer_Guides/00_Model/03_Lists.md b/en/02_Developer_Guides/00_Model/03_Lists.md index eab272053..fbcb2d023 100644 --- a/en/02_Developer_Guides/00_Model/03_Lists.md +++ b/en/02_Developer_Guides/00_Model/03_Lists.md @@ -6,7 +6,7 @@ icon: list # Managing lists -Whenever using the ORM to fetch records or navigate relationships you will receive an [SS_List](api:SilverStripe\ORM\SS_List) instance commonly as +Whenever using the ORM to fetch records or navigate relationships you will receive an [SS_List](api:SilverStripe\Model\List\SS_List) instance commonly as either [DataList](api:SilverStripe\ORM\DataList) or [RelationList](api:SilverStripe\ORM\RelationList). This object gives you the ability to iterate over each of the results or modify. @@ -14,7 +14,7 @@ There's a lot more information about filtering and sorting lists in the [Introdu ## Iterating over the list -[`SS_List`](api:SilverStripe\ORM\SS_List) extends the [`IteratorAggregate`](https://www.php.net/manual/en/class.iteratoraggregate.php) interface, allowing you to loop over the instance. +[`SS_List`](api:SilverStripe\Model\List\SS_List) extends the [`IteratorAggregate`](https://www.php.net/manual/en/class.iteratoraggregate.php) interface, allowing you to loop over the instance. ```php use SilverStripe\Security\Member; @@ -37,7 +37,7 @@ Or in the template engine: ## Finding an item by value -You can use the [`find()`](api:SilverStripe\ORM\SS_List::find()) method to get a single item based on the value of one of its properties. +You can use the [`find()`](api:SilverStripe\Model\List\SS_List::find()) method to get a single item based on the value of one of its properties. ```php $members = Member::get(); @@ -48,7 +48,7 @@ echo $members->find('ID', 4)->FirstName; ## Maps -A map is like an array, where the indexes contain data as well as the values. You can build a map from any list by calling the [`map()](api:SilverStripe\ORM\SS_List::map()) method. +A map is like an array, where the indexes contain data as well as the values. You can build a map from any list by calling the [`map()](api:SilverStripe\Model\List\SS_List::map()) method. ```php $members = Member::get()->map('ID', 'FirstName'); @@ -58,7 +58,7 @@ foreach ($members as $id => $firstName) { } ``` -This functionality is provided by the [`Map`](api:SilverStripe\ORM\Map) class, which can be used to build a map from any `SS_List`. You can instantiate a new `Map` object using the `new` keyword as well. +This functionality is provided by the [`Map`](api:SilverStripe\Model\List\Map) class, which can be used to build a map from any `SS_List`. You can instantiate a new `Map` object using the `new` keyword as well. ```php $membersMap = new Map(Member::get(), 'ID', 'FirstName'); @@ -66,7 +66,7 @@ $membersMap = new Map(Member::get(), 'ID', 'FirstName'); ## Column -You can get all of the values for a single property by calling the [`column()`](api:SilverStripe\ORM\SS_List::column()) method. +You can get all of the values for a single property by calling the [`column()`](api:SilverStripe\Model\List\SS_List::column()) method. ```php // returns [ @@ -121,7 +121,7 @@ There are some limitations: ## ArrayList -[`ArrayList`](api:SilverStripe\ORM\ArrayList) exists to wrap a standard PHP array in the same API as a database backed list. +[`ArrayList`](api:SilverStripe\Model\List\ArrayList) exists to wrap a standard PHP array in the same API as a database backed list. ```php $sam = Member::get()->byId(5); @@ -137,8 +137,8 @@ $numItems = $list->Count(); ## API documentation -- [SS_List](api:SilverStripe\ORM\SS_List) +- [SS_List](api:SilverStripe\Model\List\SS_List) - [RelationList](api:SilverStripe\ORM\RelationList) - [DataList](api:SilverStripe\ORM\DataList) -- [ArrayList](api:SilverStripe\ORM\ArrayList) -- [Map](api:SilverStripe\ORM\Map) +- [ArrayList](api:SilverStripe\Model\List\ArrayList) +- [Map](api:SilverStripe\Model\List\Map) diff --git a/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md b/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md index 54c7680aa..f3101ac56 100644 --- a/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md +++ b/en/02_Developer_Guides/00_Model/04_Data_Types_and_Casting.md @@ -185,11 +185,11 @@ DBField::create_field('Date', '1982-01-01')->TimeDiff(); ## Casting -Most objects in Silverstripe CMS extend from [ViewableData](api:SilverStripe\View\ViewableData), which means they know how to present themselves in a view +Most objects in Silverstripe CMS extend from [ModelData](api:SilverStripe\Model\ModelData), which means they know how to present themselves in a view context. Rather than manually returning objects from your custom functions. You can use the `$casting` configuration property. This casting only happens when you get the values in a template, so calling the method in your PHP code will always return the raw value. > [!TIP] -> While these examples are using `DataObject` subclasses, you can use the `$casting` configuration property on *any* `ViewableData` subclass. +> While these examples are using `DataObject` subclasses, you can use the `$casting` configuration property on *any* `ModelData` subclass. ```php namespace App\Model; @@ -237,7 +237,7 @@ $name = $player->getName()->LimitCharacters(2); <% end_with %> ``` -You can get the casted `DBField` instance of these properties by calling the [`obj()`](api:SilverStripe\View\ViewableData::obj()) method: +You can get the casted `DBField` instance of these properties by calling the [`obj()`](api:SilverStripe\Model\ModelData::obj()) method: ```php $player = Player::get()->byId(1); diff --git a/en/02_Developer_Guides/00_Model/06_SearchFilters.md b/en/02_Developer_Guides/00_Model/06_SearchFilters.md index 709e21416..2af4248c1 100644 --- a/en/02_Developer_Guides/00_Model/06_SearchFilters.md +++ b/en/02_Developer_Guides/00_Model/06_SearchFilters.md @@ -6,7 +6,7 @@ icon: search # `SearchFilter` modifiers -The `filter()`, `exclude()`, and other related methods on [`DataList`](api:SilverStripe\ORM\DataList), [`ArrayList`](api:SilverStripe\ORM\ArrayList), and [`EagerLoadedList`](api:SilverStripe\ORM\EagerLoadedList) specify exact matches by default. However, when calling these methods, there are a number of suffixes that +The `filter()`, `exclude()`, and other related methods on [`DataList`](api:SilverStripe\ORM\DataList), [`ArrayList`](api:SilverStripe\Model\List\ArrayList), and [`EagerLoadedList`](api:SilverStripe\ORM\EagerLoadedList) specify exact matches by default. However, when calling these methods, there are a number of suffixes that you can put on field names to change this behavior. These are represented as `SearchFilter` subclasses and include: - [`ExactMatchFilter`](api:SilverStripe\ORM\Filters\ExactMatchFilter) @@ -58,7 +58,7 @@ Developers can define their own [SearchFilter](api:SilverStripe\ORM\Filters\Sear > Though note that for backwards compatibility reasons, `ArrayList` is explicitly case sensitive by default. To change that, you must set `ArrayList.default_case_sensitive` to false. > > ```yml -> SilverStripe\ORM\ArrayList: +> SilverStripe\Model\List\ArrayList: > default_case_sensitive: false > ``` diff --git a/en/02_Developer_Guides/00_Model/09_Validation.md b/en/02_Developer_Guides/00_Model/09_Validation.md index 4e821eab8..61f585efe 100644 --- a/en/02_Developer_Guides/00_Model/09_Validation.md +++ b/en/02_Developer_Guides/00_Model/09_Validation.md @@ -8,14 +8,14 @@ icon: check-square ## Validation using `symfony/validator` constraints {#symfony-validator} -The [`ConstraintValidator`](api:SilverStripe\Core\Validation\ConstraintValidator) class provides an abstraction around [`symfony/validator`](https://symfony.com/doc/current/components/validator.html), so you can easily validate values against symfony's validation constraints and get a [`ValidationResult`](api:SilverStripe\ORM\ValidationResult) object with the result. +The [`ConstraintValidator`](api:SilverStripe\Core\Validation\ConstraintValidator) class provides an abstraction around [`symfony/validator`](https://symfony.com/doc/current/components/validator.html), so you can easily validate values against symfony's validation constraints and get a [`ValidationResult`](api:SilverStripe\Core\Validation\ValidationResult) object with the result. ```php use SilverStripe\Core\Validation\ConstraintValidator; /** * @var \Symfony\Component\Validator\Constraint $constraint - * @var \SilverStripe\ORM\ValidationResult $result + * @var \SilverStripe\Core\Validation\ValidationResult $result */ $result = ConstraintValidator::validate($valueToValidate, $constraint); ``` @@ -44,12 +44,12 @@ called any time the `write()` method is called, before the `onBeforeWrite()` ext By default, there is no validation - objects are always valid! However, you can override this method in your `DataObject` sub-classes to specify custom validation, or use the `updateValidate()` extension hook through an [Extension](api:SilverStripe\Core\Extension). -Invalid objects won't be able to be written - a [`ValidationException`](api:SilverStripe\ORM\ValidationException) will be thrown and no write will occur. +Invalid objects won't be able to be written - a [`ValidationException`](api:SilverStripe\Core\Validation\ValidationException) will be thrown and no write will occur. Ideally you should call `validate()` in your own application to test that an object is valid before attempting a write, and respond appropriately if it isn't. -The return value of `validate()` is a [`ValidationResult`](api:SilverStripe\ORM\ValidationResult) object. +The return value of `validate()` is a [`ValidationResult`](api:SilverStripe\Core\Validation\ValidationResult) object. ```php namespace App\Model; @@ -85,4 +85,4 @@ class MyObject extends DataObject ## API documentation - [DataObject](api:SilverStripe\ORM\DataObject) -- [ValidationResult](api:SilverStripe\ORM\ValidationResult); +- [ValidationResult](api:SilverStripe\Core\Validation\ValidationResult); diff --git a/en/02_Developer_Guides/00_Model/How_Tos/Grouping_DataObject_Sets.md b/en/02_Developer_Guides/00_Model/How_Tos/Grouping_DataObject_Sets.md index 828ae5119..db1c8a3d7 100644 --- a/en/02_Developer_Guides/00_Model/How_Tos/Grouping_DataObject_Sets.md +++ b/en/02_Developer_Guides/00_Model/How_Tos/Grouping_DataObject_Sets.md @@ -5,14 +5,14 @@ summary: Learn how to split the results of a query into subgroups # Grouping lists of records -The [SS_List](api:SilverStripe\ORM\SS_List) class is designed to return a flat list of records. +The [SS_List](api:SilverStripe\Model\List\SS_List) class is designed to return a flat list of records. These lists can get quite long, and hard to present on a single list. [Pagination](/developer_guides/templates/how_tos/pagination) is one way to solve this problem, by splitting up the list into multiple pages. In this howto, we present an alternative to pagination: -grouping a list by various criteria, through the [`GroupedList`](api:SilverStripe\ORM\GroupedList) class. -This class is a [`ListDecorator`](api:SilverStripe\ORM\ListDecorator), which means it wraps around a list, +grouping a list by various criteria, through the [`GroupedList`](api:SilverStripe\Model\List\GroupedList) class. +This class is a [`ListDecorator`](api:SilverStripe\Model\List\ListDecorator), which means it wraps around a list, adding new functionality. It provides a `groupBy()` method, which takes a field name, and breaks up the managed list @@ -21,7 +21,7 @@ Similarly, the `GroupedBy()` method builds on this and returns the same data in ## Grouping sets by first letter -This example deals with breaking up a [`SS_List`](api:SilverStripe\ORM\SS_List) into sub-headings by the first letter. +This example deals with breaking up a [`SS_List`](api:SilverStripe\Model\List\SS_List) into sub-headings by the first letter. Let's say you have a set of Module objects, each representing a Silverstripe CMS module, and you want to output a list of these in alphabetical order, with each letter as a heading; something like the following list: @@ -71,7 +71,7 @@ namespace App\PageType; use App\Model\Module; use Page; -use SilverStripe\ORM\GroupedList; +use SilverStripe\Model\List\GroupedList; class ModulePage extends Page { @@ -111,7 +111,7 @@ In this case, the `getTitleFirstLetter()` method defined earlier is used to brea Grouping a set by month is a very similar process. The only difference would be to sort the records by month name, and then create a method on the DataObject that returns the month name, -and pass that to the [GroupedList::GroupedBy()](api:SilverStripe\ORM\GroupedList::GroupedBy()) call. +and pass that to the [GroupedList::GroupedBy()](api:SilverStripe\Model\List\GroupedList::GroupedBy()) call. We're reusing our example `Module` object, but grouping by its built-in `Created` property instead, @@ -144,7 +144,7 @@ namespace App\PageType; use App\Model\Module; use Page; -use SilverStripe\ORM\GroupedList; +use SilverStripe\Model\List\GroupedList; class ModulePage extends Page { @@ -159,7 +159,7 @@ class ModulePage extends Page } ``` -The final step is to render this into the template using the [GroupedList::GroupedBy()](api:SilverStripe\ORM\GroupedList::GroupedBy()) method. +The final step is to render this into the template using the [GroupedList::GroupedBy()](api:SilverStripe\Model\List\GroupedList::GroupedBy()) method. ```ss <%-- Modules list grouped by the Month Posted --%> diff --git a/en/02_Developer_Guides/01_Templates/01_Syntax.md b/en/02_Developer_Guides/01_Templates/01_Syntax.md index 82c791210..9125c308d 100644 --- a/en/02_Developer_Guides/01_Templates/01_Syntax.md +++ b/en/02_Developer_Guides/01_Templates/01_Syntax.md @@ -271,7 +271,7 @@ include. ## Looping over lists -The `<% loop %>` tag is used to iterate or loop over a collection of items such as a native PHP array, a [DataList](api:SilverStripe\ORM\DataList), or an [ArrayList](api:SilverStripe\ORM\ArrayList) +The `<% loop %>` tag is used to iterate or loop over a collection of items such as a native PHP array, a [DataList](api:SilverStripe\ORM\DataList), or an [ArrayList](api:SilverStripe\Model\List\ArrayList) collection. ```ss @@ -307,7 +307,7 @@ This can be particularly useful when you have collections within collections. ### Altering the list -`<% loop %>` statements often iterate over [`SS_List`](api:SilverStripe\ORM\SS_List) instances. As the template has access to the list object, +`<% loop %>` statements often iterate over [`SS_List`](api:SilverStripe\Model\List\SS_List) instances. As the template has access to the list object, templates can call its methods. Sorting the list by a given field. @@ -564,7 +564,7 @@ refer directly to properties and methods of the [`Member`](api:SilverStripe\Secu ### `fortemplate()` and `$Me` {#fortemplate} -If you reference some `ViewableData` object directly in a template, the `forTemplate()` method on that object will be called. +If you reference some `ModelData` object directly in a template, the `forTemplate()` method on that object will be called. This can be used to provide a default template for an object. ```php diff --git a/en/02_Developer_Guides/01_Templates/02_Common_Variables.md b/en/02_Developer_Guides/01_Templates/02_Common_Variables.md index 2dce5a672..f87d8196e 100644 --- a/en/02_Developer_Guides/01_Templates/02_Common_Variables.md +++ b/en/02_Developer_Guides/01_Templates/02_Common_Variables.md @@ -427,5 +427,5 @@ Placing it just below `$Content` is a good default. - [ContentController](api:SilverStripe\CMS\Controllers\ContentController): The main controller responsible for handling pages. - [Controller](api:SilverStripe\Control\Controller): Generic controller (not specific to pages.) -- [DataObject](api:SilverStripe\ORM\DataObject): Underlying model class for page objects. -- [ViewableData](api:SilverStripe\View\ViewableData): Underlying object class for pretty much anything displayable. +- [DataObject](api:SilverStripe\ORM\DataObject): Underlying model class for models which store their data in the database. +- [ModelData](api:SilverStripe\Model\ModelData): Underlying object class for pretty much anything which contains data. diff --git a/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md b/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md index 6c0171489..b0c0fd048 100644 --- a/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md +++ b/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md @@ -6,7 +6,7 @@ icon: code # Rendering data to a template -Templates do nothing on their own. Rather, they are used to generate markup - most typically they are used to generate HTML markup, using variables from some `ViewableData` object. +Templates do nothing on their own. Rather, they are used to generate markup - most typically they are used to generate HTML markup, using variables from some `ModelData` object. All of the `<% if %>`, `<% loop %>` and other variables are methods or parameters that are called on the current object in scope (see [scope](syntax#scope) in the syntax section). @@ -17,13 +17,13 @@ The following will render the given data into a template. Given the template: $Name is the $Role on our team. ``` -Our application code can render into that view using the [`renderWith()`](api:SilverStripe\View\ViewableData) method provided by `ViewableData`. Call this method on any instance of `ViewableData` or its subclasses, passing in a template name or an array of templates to render. +Our application code can render into that view using the [`renderWith()`](api:SilverStripe\Model\ModelData) method provided by `ModelData`. Call this method on any instance of `ModelData` or its subclasses, passing in a template name or an array of templates to render. ```php namespace App\Model; +use SilverStripe\Model\ArrayData; use SilverStripe\ORM\DataObject; -use SilverStripe\View\ArrayData; class MyModel extends DataObject { @@ -96,7 +96,7 @@ This will look for a global `templates/Coach_Message.ss` template, and if it doe See [template types and locations](template_inheritance/#template-types-and-locations) for more information. > [!NOTE] -> Most classes in Silverstripe CMS you want in your template extend `ViewableData` and allow you to call `renderWith`. This +> Most classes in Silverstripe CMS you want in your template extend `ModelData` and allow you to call `renderWith`. This > includes [Controller](api:SilverStripe\Control\Controller), [FormField](api:SilverStripe\Forms\FormField) and [DataObject](api:SilverStripe\ORM\DataObject) instances. > > ```php @@ -157,7 +157,7 @@ class MyPageController extends PageController ## Rendering arbitrary data in templates -Any data you want to render into the template that does not extend `ViewableData` should be wrapped in an object that +Any data you want to render into the template that does not extend `ModelData` should be wrapped in an object that does, such as `ArrayData` or `ArrayList`. ```php @@ -165,8 +165,8 @@ namespace App\PageType; use PageController; use SilverStripe\Control\Director; -use SilverStripe\ORM\ArrayList; -use SilverStripe\View\ArrayData; +use SilverStripe\Model\ArrayData; +use SilverStripe\Model\List\ArrayList; class MyPageController extends PageController { @@ -195,4 +195,4 @@ class MyPageController extends PageController ``` > [!WARNING] -> A common mistake is trying to loop over an array directly in a template - this won't work. You'll need to wrap the array in some `ViewableData` instance as mentioned above. +> A common mistake is trying to loop over an array directly in a template - this won't work. You'll need to wrap the array in some `ModelData` instance as mentioned above. diff --git a/en/02_Developer_Guides/01_Templates/09_Casting.md b/en/02_Developer_Guides/01_Templates/09_Casting.md index 5739c7ab9..d39604bd6 100644 --- a/en/02_Developer_Guides/01_Templates/09_Casting.md +++ b/en/02_Developer_Guides/01_Templates/09_Casting.md @@ -6,7 +6,7 @@ icon: code # Formatting, casting, and escaping variable content -All objects that are being rendered in a template should be a [ViewableData](api:SilverStripe\View\ViewableData) instance such as `DataObject`, +All objects that are being rendered in a template should be a [ModelData](api:SilverStripe\Model\ModelData) instance such as `DataObject`, `DBField` or `Controller`. From these objects, the template can include any method from the object in [scope](syntax#scope). ## Casting @@ -25,9 +25,9 @@ that class, and ensures and values are safely escaped. ```php namespace App\Data; -use SilverStripe\View\ViewableData; +use SilverStripe\Model\ModelData; -class MyTemplatedObject extends ViewableData +class MyTemplatedObject extends ModelData { private static $casting = [ 'Header' => 'HTMLText', @@ -48,7 +48,7 @@ For every field used in templates, a casting helper will be applied. This will f in case none are specified. > [!NOTE] -> By default, all content without a type explicitly defined in a `$casting` array will use the `ViewableData.default_cast` configuration. By default, +> By default, all content without a type explicitly defined in a `$casting` array will use the `ModelData.default_cast` configuration. By default, > that configuration is set to `Text`, so HTML characters are escaped. ### Common casting types @@ -86,7 +86,7 @@ $LastEdited.Format("d/m/Y") ``` Any public method from the object in scope can be called within the template. If that method returns another -`ViewableData` instance, you can chain the method calls. +`ModelData` instance, you can chain the method calls. ```ss <%-- prints the first paragraph of content for the first item in the list --%> @@ -127,7 +127,7 @@ All `DBField` instances share the following useful methods for formatting their The concept of escaping values in templates is ultimately just a combination of formatting and casting. Values are typically escaped (i.e. the special HTML characters are encoded) in templates by either not -declaring a casting type, or by defaulting to the `Text` casting type defined on `ViewableData`. +declaring a casting type, or by defaulting to the `Text` casting type defined on `ModelData`. See the [casting](#casting) section above for instructions on configuring your model to declare casting types for fields, and how some of the more common diff --git a/en/02_Developer_Guides/01_Templates/11_Partial_Template_Caching.md b/en/02_Developer_Guides/01_Templates/11_Partial_Template_Caching.md index 9b6777ec0..ad0bf924a 100644 --- a/en/02_Developer_Guides/01_Templates/11_Partial_Template_Caching.md +++ b/en/02_Developer_Guides/01_Templates/11_Partial_Template_Caching.md @@ -1,6 +1,6 @@ --- title: Partial Template Caching -summary: Cache a section of a template Reduce rendering time with cached templates and understand the limitations of the ViewableData object caching. +summary: Cache a section of a template Reduce rendering time with cached templates and understand the limitations of the ModelData object caching. icon: tags --- diff --git a/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md b/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md index a8123a85b..001eeccd8 100644 --- a/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md +++ b/en/02_Developer_Guides/01_Templates/How_Tos/02_Pagination.md @@ -5,8 +5,8 @@ summary: Break up the result of a database query into multiple pages # How to create a paginated list -In order to create a paginated list, create a method on your controller that first creates a [`SS_List`](api:SilverStripe\ORM\SS_List) that contains -all your records (e.g. [via the ORM](/developer_guides/model/data_model_and_orm/#querying-data)), then wraps it in a [`PaginatedList`](api:SilverStripe\ORM\PaginatedList) object. The `PaginatedList` constructor should also be passed the +In order to create a paginated list, create a method on your controller that first creates a [`SS_List`](api:SilverStripe\Model\List\SS_List) that contains +all your records (e.g. [via the ORM](/developer_guides/model/data_model_and_orm/#querying-data)), then wraps it in a [`PaginatedList`](api:SilverStripe\Model\List\PaginatedList) object. The `PaginatedList` constructor should also be passed the [`HTTPRequest`](api:SilverStripe\Control\HTTPRequest) object so it can read the current page information from the `?start=` GET var. The `PaginatedList` will automatically set up query limits and read the request for information. @@ -17,7 +17,7 @@ namespace App\PageType; use Page; use PageController; -use SilverStripe\ORM\PaginatedList; +use SilverStripe\Model\List\PaginatedList; class MyPageController extends PageController { @@ -39,8 +39,8 @@ class MyPageController extends PageController > Note that the concept of "pages" used in pagination does not necessarily mean that we're dealing with `Page` classes, > it's just a term to describe a sub-collection of the list. -There are two ways to generate pagination controls: [PaginatedList::Pages()](api:SilverStripe\ORM\PaginatedList::Pages()) and -[PaginatedList::PaginationSummary()](api:SilverStripe\ORM\PaginatedList::PaginationSummary()). In this example we will use `PaginationSummary()`. +There are two ways to generate pagination controls: [PaginatedList::Pages()](api:SilverStripe\Model\List\PaginatedList::Pages()) and +[PaginatedList::PaginationSummary()](api:SilverStripe\Model\List\PaginatedList::PaginationSummary()). In this example we will use `PaginationSummary()`. The first step is to simply list the objects in the template: @@ -85,12 +85,12 @@ If there is more than one page, this block will render a set of pagination contr ## Paginating custom lists In some situations where you are generating the list yourself, the underlying list will already contain only the items -that you wish to display on the current page. In this situation the automatic limiting done by [PaginatedList](api:SilverStripe\ORM\PaginatedList) -will break the pagination. You can disable automatic limiting using the [PaginatedList::setLimitItems()](api:SilverStripe\ORM\PaginatedList::setLimitItems()) method +that you wish to display on the current page. In this situation the automatic limiting done by [PaginatedList](api:SilverStripe\Model\List\PaginatedList) +will break the pagination. You can disable automatic limiting using the [PaginatedList::setLimitItems()](api:SilverStripe\Model\List\PaginatedList::setLimitItems()) method when using custom lists. ```php -use SilverStripe\ORM\PaginatedList; +use SilverStripe\Model\List\PaginatedList; $myPreLimitedList = Page::get()->limit(10, $somePageOffset); @@ -100,7 +100,7 @@ $pages->setLimitItems(false); ## Setting the number of items per page -By default, the `PaginatedList` includes 10 items per page. You can change this by calling [`setPageLength()`](api:SilverStripe\ORM\PaginatedList::setPageLength()). +By default, the `PaginatedList` includes 10 items per page. You can change this by calling [`setPageLength()`](api:SilverStripe\Model\List\PaginatedList::setPageLength()). ```php $pages = new PaginatedList(Page::get(), $this->getRequest()); @@ -133,4 +133,4 @@ Note that this is not an exhaustive list, as any public method on `PaginatedList ## API documentation -- [`PaginatedList`](api:SilverStripe\ORM\PaginatedList) +- [`PaginatedList`](api:SilverStripe\Model\List\PaginatedList) diff --git a/en/02_Developer_Guides/03_Forms/01_Validation.md b/en/02_Developer_Guides/03_Forms/01_Validation.md index 12f98dfbd..f817bf332 100644 --- a/en/02_Developer_Guides/03_Forms/01_Validation.md +++ b/en/02_Developer_Guides/03_Forms/01_Validation.md @@ -145,8 +145,8 @@ At times it's not possible for all validation or recoverable errors to be pre-de submission, such as those generated by the form [Validator](api:SilverStripe\Forms\Validator). Sometimes errors may occur within form action methods, and it is necessary to display errors on the form after initial validation has been performed. -In this case you may throw a [`ValidationException`](api:SilverStripe\ORM\ValidationException) within your handler, optionally passing it an -error message, or a [`ValidationResult`](api:SilverStripe\ORM\ValidationResult) containing the list of errors you wish to display. +In this case you may throw a [`ValidationException`](api:SilverStripe\Core\Validation\ValidationException) within your handler, optionally passing it an +error message, or a [`ValidationResult`](api:SilverStripe\Core\Validation\ValidationResult) containing the list of errors you wish to display. E.g. @@ -154,7 +154,7 @@ E.g. namespace App\Control; use SilverStripe\Control\Controller; -use SilverStripe\ORM\ValidationException; +use SilverStripe\Core\Validation\ValidationException; class MyController extends Controller { @@ -183,12 +183,12 @@ custom `FormField` classes or extensions. namespace App\PageType; use PageController; +use SilverStripe\Core\Validation\ValidationResult; use SilverStripe\Forms\EmailField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\TextField; -use SilverStripe\ORM\ValidationResult; use SilverStripe\Security\Member; class MyFormPageController extends PageController diff --git a/en/02_Developer_Guides/03_Forms/07_Using_GridField_With_Arbitrary_Data.md b/en/02_Developer_Guides/03_Forms/07_Using_GridField_With_Arbitrary_Data.md index af71908be..d673538f5 100644 --- a/en/02_Developer_Guides/03_Forms/07_Using_GridField_With_Arbitrary_Data.md +++ b/en/02_Developer_Guides/03_Forms/07_Using_GridField_With_Arbitrary_Data.md @@ -13,10 +13,10 @@ icon: table Data which isn't represented by `DataObject` records can come in two forms: -- truely arbitrary data wrapped in [`ArrayData`](api:SilverStripe\View\ArrayData) +- truely arbitrary data wrapped in [`ArrayData`](api:SilverStripe\Model\ArrayData) - data which has some specific class to represent it. -Both are supported by `GridField`, provided the class representing the data is some subclass of [`ViewableData`](api:SilverStripe\View\ViewableData). +Both are supported by `GridField`, provided the class representing the data is some subclass of [`ModelData`](api:SilverStripe\Model\ModelData). Some grid field components may require specific information, such as which columns to display or how to represent the data in a form. Depending on how you're representing your data, you might need to call specific methods on those components to pass that information in, or you might instead choose to implement methods in your data representation class which the components can call to get that information. @@ -30,8 +30,8 @@ Regardless of how you get your data, whether it's from a web API or some other s > See [viewing data in a form](#arraydata-view) for more information. ```php -use SilverStripe\ORM\ArrayList; -use SilverStripe\View\ArrayData; +use SilverStripe\Model\ArrayData; +use SilverStripe\Model\List\ArrayList; $list = ArrayList::create([ ArrayData::create([ @@ -137,7 +137,7 @@ $gridField->getConfig()->addComponents([ ## Representing data in your own class -As mentioned [in the preamble above](#using-gridfield-with-arbitrary-data), the class representing your data must be a subclass of `ViewableData` in order for it to be used in a `GridField`. +As mentioned [in the preamble above](#using-gridfield-with-arbitrary-data), the class representing your data must be a subclass of `ModelData` in order for it to be used in a `GridField`. Representing data in your own class adds some complexity, but empowers content authors to create, update and delete entries via the `GridField`. @@ -156,9 +156,9 @@ To represent your data as rows in a `GridField`, you can rely on the default `Gr ```php namespace App\Data; -use SilverStripe\View\ViewableData; +use SilverStripe\Model\ModelData; -class DataRepresentation extends ViewableData +class DataRepresentation extends ModelData { private int $id; @@ -194,7 +194,7 @@ class DataRepresentation extends ViewableData ```php use App\Data\DataRepresentation; use SilverStripe\Forms\GridField\GridField; -use SilverStripe\ORM\ArrayList; +use SilverStripe\Model\List\ArrayList; $list = ArrayList::create([ DataRepresentation::create(1, 'This is an item'), @@ -226,10 +226,10 @@ namespace App\Data; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\TextField; +use SilverStripe\Model\ModelData; use SilverStripe\ORM\Search\BasicSearchContext; -use SilverStripe\View\ViewableData; -class DataRepresentation extends ViewableData +class DataRepresentation extends ModelData { // ... @@ -285,9 +285,9 @@ namespace App\Data; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\TextField; -use SilverStripe\View\ViewableData; +use SilverStripe\Model\ModelData; -class DataRepresentation extends ViewableData +class DataRepresentation extends ModelData { // ... @@ -332,10 +332,10 @@ Records with no `ID` field or which have a non-numeric value for their `ID` fiel namespace App\Data; use LogicException; +use SilverStripe\Model\ModelData; use SilverStripe\ORM\DataObjectInterface; -use SilverStripe\View\ViewableData; -class DataRepresentation extends ViewableData implements DataObjectInterface +class DataRepresentation extends ModelData implements DataObjectInterface { // ... diff --git a/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md b/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md index 7536b98e1..eb1a22c47 100644 --- a/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md +++ b/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md @@ -57,7 +57,7 @@ doesn't necessarily have any visible styling. - [CheckboxSetField](api:SilverStripe\Forms\CheckboxSetField): Displays a set of checkboxes as a logical group. - [TreeDropdownField](api:SilverStripe\Forms\TreeDropdownField): Dropdown-like field that allows you to select an item from a hierarchical AJAX-expandable tree. - [TreeMultiselectField](api:SilverStripe\Forms\TreeMultiselectField): Represents many-many joins using a tree selector shown in a dropdown-like element. -- [GridField](api:SilverStripe\Forms\GridField\GridField): Displays a [SS_List](api:SilverStripe\ORM\SS_List) in a tabular format. Versatile base class which can be configured to allow editing, sorting, etc. +- [GridField](api:SilverStripe\Forms\GridField\GridField): Displays a [SS_List](api:SilverStripe\Model\List\SS_List) in a tabular format. Versatile base class which can be configured to allow editing, sorting, etc. - [ListboxField](api:SilverStripe\Forms\ListboxField): Multi-line listbox field, through `