updated to create syntax

This commit is contained in:
josephlewisnz 2022-02-17 13:10:44 +13:00
parent 07c97e45b2
commit 8e77095de0
2 changed files with 3 additions and 3 deletions

View File

@ -112,8 +112,7 @@ By default `GridFieldOrderableRows` will handle versioning but won't automatical
You can configure the list to automatically publish a record if the record is the latest version and is already published. This won't publish any records which have draft changes.
```php
$orderable = new GridFieldOrderableRows()
->setRepublishLiveRecords(true);
$orderable = GridFieldOrderableRows::create()->setRepublishLiveRecords(true);
```
There are caveats with both approaches so consideration should be made for which approach best suits the requirements.

View File

@ -101,6 +101,7 @@ class GridFieldOrderableRows extends RequestHandler implements
/**
* @param string $sortField
* @param boolean $republishLiveRecords
*/
public function __construct($sortField = 'Sort')
{
@ -689,7 +690,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$record = $currentSortList[$targetRecordID];
if ($record->$sortField != $newSortValue) {
$record->$sortField = $newSortValue;
// We need to do this before writing otherwith isLiveVersion() will always be false
$shouldRepublish = $this->getRepublishLiveRecords() && $record->isLiveVersion();