From e3b591a2268848a3fa9c910f0ada64640bc44a57 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 5 Dec 2024 17:31:20 +1300 Subject: [PATCH] API Rename validator classes --- src/DataObjects/WorkflowAction.php | 4 ++-- src/DataObjects/WorkflowTransition.php | 6 +++--- src/Extensions/WorkflowEmbargoExpiryExtension.php | 8 ++++---- ...redFields.php => AWRequiredFieldsValidator.php} | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) rename src/Forms/{AWRequiredFields.php => AWRequiredFieldsValidator.php} (88%) diff --git a/src/DataObjects/WorkflowAction.php b/src/DataObjects/WorkflowAction.php index d9471f14..d22ebd37 100644 --- a/src/DataObjects/WorkflowAction.php +++ b/src/DataObjects/WorkflowAction.php @@ -7,7 +7,7 @@ use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\ReadonlyField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\TabSet; use SilverStripe\Forms\TextField; use SilverStripe\ORM\DataObject; @@ -273,7 +273,7 @@ public function getCMSFields() public function getValidator() { - return new RequiredFields('Title'); + return new RequiredFieldsValidator('Title'); } public function summaryFields() diff --git a/src/DataObjects/WorkflowTransition.php b/src/DataObjects/WorkflowTransition.php index a0aa6db1..5c91715e 100644 --- a/src/DataObjects/WorkflowTransition.php +++ b/src/DataObjects/WorkflowTransition.php @@ -16,7 +16,7 @@ use SilverStripe\Security\Member; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; -use Symbiote\AdvancedWorkflow\Forms\AWRequiredFields; +use Symbiote\AdvancedWorkflow\Forms\AWRequiredFieldsValidator; /** * A workflow transition. @@ -177,7 +177,7 @@ public function fieldLabels($includerelations = true) public function getValidator() { - $required = new AWRequiredFields('Title', 'ActionID', 'NextActionID'); + $required = new AWRequiredFieldsValidator('Title', 'ActionID', 'NextActionID'); $required->setCaller($this); return $required; } @@ -275,7 +275,7 @@ public function getAssignedMembers() * * @param array $data * @return array - * @see {@link AWRequiredFields} + * @see {@link AWRequiredFieldsValidator} */ public function extendedRequiredFieldsNotSame($data = null) { diff --git a/src/Extensions/WorkflowEmbargoExpiryExtension.php b/src/Extensions/WorkflowEmbargoExpiryExtension.php index d64d10e8..1b246a92 100644 --- a/src/Extensions/WorkflowEmbargoExpiryExtension.php +++ b/src/Extensions/WorkflowEmbargoExpiryExtension.php @@ -19,7 +19,7 @@ use SilverStripe\Security\Permission; use SilverStripe\View\Requirements; use SilverStripe\Versioned\Versioned; -use Symbiote\AdvancedWorkflow\Forms\AWRequiredFields; +use Symbiote\AdvancedWorkflow\Forms\AWRequiredFieldsValidator; use Symbiote\AdvancedWorkflow\Jobs\WorkflowPublishTargetJob; use Symbiote\AdvancedWorkflow\Services\WorkflowService; use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor; @@ -430,14 +430,14 @@ public function getIntroMessage($key) */ public function getCMSValidator() { - $required = new AWRequiredFields(); + $required = new AWRequiredFieldsValidator(); $required->setCaller($this); return $required; } /** - * This is called in the AWRequiredFields class, this validates whether an Embargo and Expiry are not equal and that - * Embargo is before Expiry, returning the appropriate message when it fails. + * This is called in the AWRequiredFieldsValidator class, this validates whether an Embargo and Expiry are + * not equal and that Embargo is before Expiry, returning the appropriate message when it fails. * * @param $data * @return array diff --git a/src/Forms/AWRequiredFields.php b/src/Forms/AWRequiredFieldsValidator.php similarity index 88% rename from src/Forms/AWRequiredFields.php rename to src/Forms/AWRequiredFieldsValidator.php index 5a2c53db..9219ea3c 100644 --- a/src/Forms/AWRequiredFields.php +++ b/src/Forms/AWRequiredFieldsValidator.php @@ -2,11 +2,11 @@ namespace Symbiote\AdvancedWorkflow\Forms; -use SilverStripe\Forms\RequiredFields; use SilverStripe\Dev\Deprecation; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; /** - * Extends RequiredFields so we can prevent DO writes in AW's controller(s) without needing to catch Exceptions + * Extends RequiredFieldsValidator so we can prevent DO writes in AW's controller(s) without needing to catch Exceptions * from DO->validate() all over the place. * Note specifically $this->getExtendedValidationRoutines() - anti-pattern anyone? * @@ -15,7 +15,7 @@ * * @deprecated 5.4.0 Will be renamed to Symbiote\AdvancedWorkflow\Forms\AWRequiredFieldsValidator */ -class AWRequiredFields extends RequiredFields +class AWRequiredFieldsValidator extends RequiredFieldsValidator { protected $data = array(); protected static $caller; @@ -60,12 +60,12 @@ public function php($data) /** * Allows for the addition of an arbitrary no. additional, dedicated and "extended" validation methods on classes - * that call AWRequiredFields. + * that call AWRequiredFieldsValidator. * To add specific validation methods to a caller: * * 1). Write each checking method using this naming prototype: public function extendedRequiredFieldsXXX(). All * methods so named will be called. - * 2). Call AWRequiredFields->setCaller($this) + * 2). Call AWRequiredFieldsValidator->setCaller($this) * * Each extended method thus called, should return an array of a specific format. (See: static * $extendedMethodReturn on the caller) @@ -115,11 +115,11 @@ protected function getData() public function setCaller($caller) { - AWRequiredFields::$caller = $caller; + AWRequiredFieldsValidator::$caller = $caller; } public function getCaller() { - return AWRequiredFields::$caller; + return AWRequiredFieldsValidator::$caller; } }