Skip to content

Commit 408a77d

Browse files
committed
Update code example
1 parent cd9d5b0 commit 408a77d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,22 +368,24 @@ You may need to add custom logic to your API which can do with using the followi
368368

369369
For example the following implementation of the `onEditBeforeWrite()` hook will update the `Content` field of a DataObject updated via a `PATCH` request before saving, even though the `Content` field is not exposed in the API.
370370

371+
Note to run this code example you need to be logged in to the CMS to use and pass an `X-CSRF-TOKEN` header when making requests.
372+
371373
**src/MySiteTreeEndpoint.php**
372374

373375
```php
374376
<?php
375377

376-
use emteknetnz\RestApi\RestApiEndpoint;
378+
use emteknetnz\RestApi\Controllers\RestApiEndpoint;
377379
use SilverStripe\CMS\Model\SiteTree;
378380
use SilverStripe\ORM\DataObject;
379381

380382
class MySiteTreeEndpoint extends RestApiEndpoint
381383
{
382384
private static array $api_config = [
383-
RestApiEndpoint::PATH = 'api/pages';
385+
RestApiEndpoint::PATH => 'api/pages',
384386
RestApiEndpoint::DATA_CLASS => SiteTree::class,
385387
RestApiEndpoint::ACCESS => RestApiEndpoint::LOGGED_IN,
386-
RestApiEndpoint::ALLOWED_OPERATIONS => RestApiEndpoint::VIEW_CREATE_EDIT_DELETE,
388+
RestApiEndpoint::ALLOWED_OPERATIONS => RestApiEndpoint::VIEW_CREATE_EDIT_DELETE_ACTION,
387389
RestApiEndpoint::FIELDS => [
388390
'title' => 'Title',
389391
],

0 commit comments

Comments
 (0)