From 8e77095de01e53419da27b7c7ec292279b5cda7a Mon Sep 17 00:00:00 2001 From: josephlewisnz Date: Thu, 17 Feb 2022 13:10:44 +1300 Subject: [PATCH] updated to create syntax --- docs/en/index.md | 3 +-- src/GridFieldOrderableRows.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/index.md b/docs/en/index.md index 3d7ab99..d649be2 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -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. diff --git a/src/GridFieldOrderableRows.php b/src/GridFieldOrderableRows.php index 8f4c603..7787d5c 100755 --- a/src/GridFieldOrderableRows.php +++ b/src/GridFieldOrderableRows.php @@ -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();