Skip to content

Commit 5917947

Browse files
committed
DOC Update syntax for callout blocks
1 parent 8a5df02 commit 5917947

File tree

116 files changed

+1895
-2383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1895
-2383
lines changed

en/00_Getting_Started/02_Composer.md

+32-38
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ installed globally. You should now be able to run the command:
2222
composer help
2323
```
2424

25-
[info]
26-
If you already have Composer installed, make sure it is composer 2 by running `composer --version`. If you're running Composer 1, run [`composer self-update`](https://getcomposer.org/doc/03-cli.md#self-update-selfupdate). You may also want to check out the [upgrade guide for Composer 1.x to 2.0](https://getcomposer.org/upgrade/UPGRADE-2.0.md).
27-
[/info]
25+
> [!NOTE]
26+
> If you already have Composer installed, make sure it is composer 2 by running `composer --version`. If you're running Composer 1, run [`composer self-update`](https://getcomposer.org/doc/03-cli.md#self-update-selfupdate). You may also want to check out the [upgrade guide for Composer 1.x to 2.0](https://getcomposer.org/upgrade/UPGRADE-2.0.md).
2827
2928
## Create a new site
3029

@@ -35,14 +34,13 @@ version:
3534
composer create-project silverstripe/installer my-project
3635
```
3736

38-
[hint]
39-
With the above command, `my-project` is the path (relative to your current working directory) where Composer will create the project.
40-
41-
For example, on OSX, you might want to create a project as a sub-directory of `~/Sites`. You could do that by running `cd ~/Sites` before
42-
the above command.
43-
44-
If that directory doesn't exist, Composer will create it for you.
45-
[/hint]
37+
> [!TIP]
38+
> With the above command, `my-project` is the path (relative to your current working directory) where Composer will create the project.
39+
>
40+
> For example, on OSX, you might want to create a project as a sub-directory of `~/Sites`. You could do that by running `cd ~/Sites` before
41+
> the above command.
42+
>
43+
> If that directory doesn't exist, Composer will create it for you.
4644
4745
If you want to get additional fixtures for testing, such as behat and phpunit configuration, an
4846
example `.env.example` file, and all documentation, then it's recommended to use the `--prefer-source` option
@@ -87,11 +85,10 @@ a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-
8785
composer require silverstripe/blog ^2
8886
```
8987

90-
[warning]
91-
**Version constraints:** `master` or `main` is not a legal version string - it's a branch name. These are different things. The
92-
version string that would get you the branch is `dev-main`. The version string that would get you a numeric branch is
93-
a little different. The version string for the `5` branch is `5.x-dev`.
94-
[/warning]
88+
> [!WARNING]
89+
> **Version constraints:** `master` or `main` is not a legal version string - it's a branch name. These are different things. The
90+
> version string that would get you the branch is `dev-main`. The version string that would get you a numeric branch is
91+
> a little different. The version string for the `5` branch is `5.x-dev`.
9592
9693
## Updating dependencies
9794

@@ -107,14 +104,13 @@ composer update
107104
Updates to the required modules will be installed, and the `composer.lock` file will get updated with the specific
108105
commits and version constraints for each of them.
109106

110-
[hint]
111-
The update command can also be used to *downgrade* dependencies - if you edit your `composer.json` file and set a version
112-
constraint that will require a lower version to be installed, running `composer update` will "update" your installed
113-
dependencies to match your constraints, which in this case would install lower versions than what you had previously.
114-
115-
You may occasionally need to use the `--with-all-dependencies` option when downgrading dependencies to avoid conflicting
116-
version constraints.
117-
[/hint]
107+
> [!TIP]
108+
> The update command can also be used to *downgrade* dependencies - if you edit your `composer.json` file and set a version
109+
> constraint that will require a lower version to be installed, running `composer update` will "update" your installed
110+
> dependencies to match your constraints, which in this case would install lower versions than what you had previously.
111+
>
112+
> You may occasionally need to use the `--with-all-dependencies` option when downgrading dependencies to avoid conflicting
113+
> version constraints.
118114
119115
## Deploying projects with Composer
120116

@@ -229,10 +225,9 @@ file. It will appear in your project root, and by default, it will look somethin
229225
To add modules, you should add more entries into the `"require"` section. For example, we might add the blog and forum
230226
modules.
231227

232-
[notice]
233-
Be careful with the commas at the end of the lines! You can run `composer validate` to be sure your `composer.json`
234-
file is formatted correctly.
235-
[/notice]
228+
> [!WARNING]
229+
> Be careful with the commas at the end of the lines! You can run `composer validate` to be sure your `composer.json`
230+
> file is formatted correctly.
236231
237232
Save your file, and then run the following command to update the installed packages:
238233

@@ -303,16 +298,15 @@ This is how you do it:
303298
composer require silverstripe/cms
304299
```
305300

306-
[notice]
307-
In most cases, you will probably have a specific branch of the fork you want to install. You should use the appropriate
308-
version constraint to install that branch. For example, to install a branch called `fix/issue-1990` your version constraint
309-
should be `dev-fix/issue-1990`.
310-
311-
Depending on what other installed modules have that package as a dependency, you may also need to declare an
312-
[inline alias](https://getcomposer.org/doc/articles/aliases.md#require-inline-alias).
313-
314-
See more about this in [Forks and branch names](#forks-and-branch-names) below.
315-
[/notice]
301+
> [!WARNING]
302+
> In most cases, you will probably have a specific branch of the fork you want to install. You should use the appropriate
303+
> version constraint to install that branch. For example, to install a branch called `fix/issue-1990` your version constraint
304+
> should be `dev-fix/issue-1990`.
305+
>
306+
> Depending on what other installed modules have that package as a dependency, you may also need to declare an
307+
> [inline alias](https://getcomposer.org/doc/articles/aliases.md#require-inline-alias).
308+
>
309+
> See more about this in [Forks and branch names](#forks-and-branch-names) below.
316310
317311
Composer will scan all of the repositories you list, collect meta-data about the packages within them, and use them in
318312
favour of the packages listed on packagist. To switch back to using the mainline version of the package, just remove

en/00_Getting_Started/03_Environment_Management.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ use SilverStripe\Core\Environment;
5454
Environment::getEnv('SS_DATABASE_CLASS');
5555
```
5656

57-
[hint]
58-
The `Environment::getEnv()` method will return `false` both if there was no value set for a variable or if
59-
the variable was explicitly set as `false`. You can determine whether a variable has been set by calling
60-
[`Environment::hasEnv()`](api:SilverStripe\Core\Environment::hasEnv()).
61-
[/hint]
57+
> [!TIP]
58+
> The `Environment::getEnv()` method will return `false` both if there was no value set for a variable or if
59+
> the variable was explicitly set as `false`. You can determine whether a variable has been set by calling
60+
> [`Environment::hasEnv()`](api:SilverStripe\Core\Environment::hasEnv()).
6261
6362
Individual settings can be assigned via [`Environment::setEnv()`](api:SilverStripe\Core\Environment::setEnv()) or [`Environment::putEnv()`](api:SilverStripe\Core\Environment::putEnv()) methods.
6463

@@ -67,9 +66,8 @@ use SilverStripe\Core\Environment;
6766
Environment::setEnv('API_KEY', 'AABBCCDDEEFF012345');
6867
```
6968

70-
[warning]
71-
`Environment::getEnv()` will return `false` whether the variable was explicitly set as `false` or simply wasn't set at all. You can use [`Environment::hasEnv()`](api:SilverStripe\Core\Environment::hasEnv()) to check whether an environment variable was set or not.
72-
[/warning]
69+
> [!WARNING]
70+
> `Environment::getEnv()` will return `false` whether the variable was explicitly set as `false` or simply wasn't set at all. You can use [`Environment::hasEnv()`](api:SilverStripe\Core\Environment::hasEnv()) to check whether an environment variable was set or not.
7371
7472
### Using environment variables in config
7573

@@ -91,9 +89,8 @@ $loader = new EnvironmentLoader();
9189
$loader->loadFile($env);
9290
```
9391

94-
[warning]
95-
Note that because `_config.php` is processed after YAML configuration, variables set in these extra `.env` files cannot be used inside YAML config.
96-
[/warning]
92+
> [!WARNING]
93+
> Note that because `_config.php` is processed after YAML configuration, variables set in these extra `.env` files cannot be used inside YAML config.
9794
9895
## Core environment variables
9996

en/00_Getting_Started/index.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ Within the newly created `my-project` folder, point your webserver at the `publi
2929

3030
Now create a `.env` file in your project root (not the `public/` folder).
3131

32-
[hint]
33-
If you used `silverstripe/installer` to create your project, you can rename the `.env.example` file to `.env`. It includes the minimum required [environment variables](environment_management).
34-
[/hint]
32+
> [!TIP]
33+
> If you used `silverstripe/installer` to create your project, you can rename the `.env.example` file to `.env`. It includes the minimum required [environment variables](environment_management).
3534
3635
Replace the placeholders as required:
3736

en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md

+35-48
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,19 @@ class Player extends DataObject
4343
This `Player` class definition will create a database table `Player` with columns for `PlayerNumber`, `FirstName` and
4444
so on. After writing this class, we need to regenerate the database schema.
4545

46-
[hint]
47-
You can technically omit the `table_name` property, and a default table name will be created based on the fully qualified class name - but this can result in table names that are too long for the database engine to handle. We recommend that you *always* explicitly declare a table name for your models.
48-
49-
See more in [Mapping classes to tables with `DataObjectSchema`](#mapping-classes-to-tables) below.
50-
[/hint]
46+
> [!TIP]
47+
> You can technically omit the `table_name` property, and a default table name will be created based on the fully qualified class name - but this can result in table names that are too long for the database engine to handle. We recommend that you *always* explicitly declare a table name for your models.
48+
>
49+
> See more in [Mapping classes to tables with `DataObjectSchema`](#mapping-classes-to-tables) below.
5150
5251
## Generating the database schema
5352

5453
After adding, modifying or removing `DataObject` subclasses, make sure to rebuild your Silverstripe CMS database. The
5554
database schema is generated automatically by visiting `/dev/build` (e.g. `https://www.example.com/dev/build`) in your browser
5655
while authenticated as an administrator, or by running `sake dev/build` on the command line (see [Command Line Interface](/developer_guides/cli/) to learn more about `sake`).
5756

58-
[info]
59-
In "dev" mode, you do not need to be authenticated to run `/dev/build`. See [Environment Types](/developer_guides/debugging/environment_types) for more information.
60-
[/info]
57+
> [!NOTE]
58+
> In "dev" mode, you do not need to be authenticated to run `/dev/build`. See [Environment Types](/developer_guides/debugging/environment_types) for more information.
6159
6260
This script will analyze the existing schema, compare it to what's required by your data classes, and alter the schema
6361
as required.
@@ -119,11 +117,10 @@ However, a better way is to use the `create()` method.
119117
$player = Player::create();
120118
```
121119

122-
[hint]
123-
Using the `create()` method provides chainability (known as a "fluent API" or "[fluent interface](https://en.wikipedia.org/wiki/Fluent_interface)"), which can add elegance and brevity to your code, e.g. `Player::create(['FirstName' => 'Sam'])->write()`.
124-
125-
More importantly, however, it will look up the class in the [`Injector`](api:SilverStripe\Core\Injector\Injector) so that the class can be overridden by [dependency injection](../extending/injector). For this reason, instantiating records using the `new` keyword is considered bad practice.
126-
[/hint]
120+
> [!TIP]
121+
> Using the `create()` method provides chainability (known as a "fluent API" or "[fluent interface](https://en.wikipedia.org/wiki/Fluent_interface)"), which can add elegance and brevity to your code, e.g. `Player::create(['FirstName' => 'Sam'])->write()`.
122+
>
123+
> More importantly, however, it will look up the class in the [`Injector`](api:SilverStripe\Core\Injector\Injector) so that the class can be overridden by [dependency injection](../extending/injector). For this reason, instantiating records using the `new` keyword is considered bad practice.
127124
128125
Database columns (aka fields) can be set as class properties on the object. The Silverstripe CMS ORM handles the saving
129126
of the values through a custom `__set()` method.
@@ -152,6 +149,9 @@ $id = $player->write();
152149
With the `Player` class defined we can query our data using the ORM. The ORM provides
153150
shortcuts and methods for fetching, sorting and filtering data from our database.
154151

152+
> [!TIP]
153+
> All of the below methods to get a single record will return `null` if there is no record to return.
154+
155155
```php
156156
// returns a `DataList` containing all the `Player` objects.
157157
$players = Player::get();
@@ -165,13 +165,8 @@ $player = Player::get()->byID(2);
165165
$player = Playet::get_by_id(2);
166166
```
167167

168-
[hint]
169-
All of the above methods to get a single record will return `null` if there is no record to return.
170-
[/hint]
171-
172-
[info]
173-
`DataObject::get()->byID()` and `DataObject::get_by_id()` achieve similar results, though the object returned by `DataObject::get_by_id()` is cached against a `static` property within `DataObject`.
174-
[/info]
168+
> [!NOTE]
169+
> `DataObject::get()->byID()` and `DataObject::get_by_id()` achieve similar results, though the object returned by `DataObject::get_by_id()` is cached against a `static` property within `DataObject`.
175170
176171
The ORM uses a "fluent" syntax, where you specify a query by chaining together different methods. Two common methods
177172
are `filter()` and `sort()`:
@@ -185,17 +180,15 @@ $members = Player::get()->filter([
185180

186181
There's a lot more to filtering and sorting, so make sure to keep reading.
187182

188-
[info]
189-
Values passed in to the `filter()` and `sort()` methods are automatically escaped and do not require any additional escaping. This makes it easy to safely filter/sort records by user input.
190-
[/info]
183+
> [!NOTE]
184+
> Values passed in to the `filter()` and `sort()` methods are automatically escaped and do not require any additional escaping. This makes it easy to safely filter/sort records by user input.
191185
192186
### Querying data when you have a record
193187

194188
When you have a `DataObject` record, it already has all of its database field data attached to it. You can get those values without triggering further database queries.
195189

196-
[notice]
197-
This does not apply to relations, which are always lazy loaded. See the [Relations between Records](relations) documentation for more information.
198-
[/notice]
190+
> [!WARNING]
191+
> This does not apply to relations, which are always lazy loaded. See the [Relations between Records](relations) documentation for more information.
199192
200193
```php
201194
$player = Player::get()->byID(2);
@@ -215,9 +208,8 @@ All database fields have a default value format which you can retrieve by treati
215208

216209
The ORM doesn't actually execute the [SQLSelect](api:SilverStripe\ORM\Queries\SQLSelect) query until you iterate on the result (e.g. with a `foreach()` or `<% loop %>`).
217210

218-
[hint]
219-
Some convenience methods (e.g. [`column()`](api:SilverStripe\ORM\DataList::column()) or aggregator methods like [`min()`](api:SilverStripe\ORM\DataList::min())) will also execute the query.
220-
[/hint]
211+
> [!TIP]
212+
> Some convenience methods (e.g. [`column()`](api:SilverStripe\ORM\DataList::column()) or aggregator methods like [`min()`](api:SilverStripe\ORM\DataList::min())) will also execute the query.
221213
222214
It's smart enough to generate a single efficient query at the last moment in time without needing to post-process the
223215
result set in PHP. In `MySQL` the query generated by the ORM may look something like this
@@ -267,9 +259,8 @@ if ($players->exists()) {
267259
}
268260
```
269261

270-
[hint]
271-
While you could use `if ($players->Count() > 0)` for this condition, the `exists()` method uses an `EXISTS` SQL query, which is more performant.
272-
[/hint]
262+
> [!TIP]
263+
> While you could use `if ($players->Count() > 0)` for this condition, the `exists()` method uses an `EXISTS` SQL query, which is more performant.
273264
274265
See the [Lists](lists) documentation for more information on dealing with [SS_List](api:SilverStripe\ORM\SS_List) instances.
275266

@@ -454,20 +445,18 @@ $teams = Team::get()->filter('Players.Avg(PointsScored):GreaterThan', 15);
454445
$teams = Team::get()->filter('Players.Sum(PointsScored):LessThan', 300);
455446
```
456447

457-
[hint]
458-
The above examples are using "dot notation" to get the aggregations of the `Players` relation on the `Teams` model. See [Relations between Records](relations) to learn more.
459-
[/hint]
448+
> [!TIP]
449+
> The above examples are using "dot notation" to get the aggregations of the `Players` relation on the `Teams` model. See [Relations between Records](relations) to learn more.
460450
461451
### `filterByCallback`
462452

463453
It is possible to filter by a PHP callback using the [`filterByCallback()`](api:SilverStripe\ORM\DataList::filterByCallback()) method. This will force the data model to fetch all records and loop them in
464454
PHP which will be much worse for performance, thus `filter()` or `filterAny()` are to be preferred over `filterByCallback()`.
465455

466-
[notice]
467-
Because `filterByCallback()` has to run in PHP, it has a significant performance tradeoff, and should not be used on large recordsets.
468-
469-
`filterByCallback()` will always return an `ArrayList`.
470-
[/notice]
456+
> [!WARNING]
457+
> Because `filterByCallback()` has to run in PHP, it has a significant performance tradeoff, and should not be used on large recordsets.
458+
>
459+
> `filterByCallback()` will always return an `ArrayList`.
471460
472461
The first parameter to the callback is the record, the second parameter is the list itself. The callback will run once
473462
for each record. The callback must return a boolean value. If the callback returns true, the current record will be included in the list of returned items.
@@ -683,11 +672,10 @@ $members = Member::get()
683672
->innerJoin('Group_Members', '"Rel"."MemberID" = "Member"."ID"', 'Rel');
684673
```
685674

686-
[alert]
687-
Using a join will *filter* results further by the JOINs performed against the foreign table. It will
688-
**not return** the additionally joined data. For the examples above, we're still only selecting values for the fields
689-
on the `Member` class table.
690-
[/alert]
675+
> [!CAUTION]
676+
> Using a join will *filter* results further by the JOINs performed against the foreign table. It will
677+
> **not return** the additionally joined data. For the examples above, we're still only selecting values for the fields
678+
> on the `Member` class table.
691679
692680
### Default values
693681

@@ -769,9 +757,8 @@ Product_Digital_Computer:
769757
IsPreBuilt: 'Boolean'
770758
```
771759
772-
[hint]
773-
Note that because `DigitalProduct` doesn't define any new fields it doesn't need its own table. We should still declare a `$table_name` though - who knows if this model might have its own table created in the future (e.g. if we add fields to it later on).
774-
[/hint]
760+
> [!TIP]
761+
> Note that because `DigitalProduct` doesn't define any new fields it doesn't need its own table. We should still declare a `$table_name` though - who knows if this model might have its own table created in the future (e.g. if we add fields to it later on).
775762

776763
Accessing the data is transparent to the developer.
777764

0 commit comments

Comments
 (0)