From e3fff3ac3362df5da1d14e4d2f853d709094021d Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 3 Dec 2024 11:18:03 +1300 Subject: [PATCH] API Rename validator classes --- src/DataObjects/WorkflowAction.php | 4 ++-- src/DataObjects/WorkflowTransition.php | 6 +++--- src/Extensions/WorkflowEmbargoExpiryExtension.php | 6 +++--- ...redFields.php => AWRequiredFieldsValidator.php} | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) rename src/Forms/{AWRequiredFields.php => AWRequiredFieldsValidator.php} (87%) diff --git a/src/DataObjects/WorkflowAction.php b/src/DataObjects/WorkflowAction.php index d9471f14..3997bc2d 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\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..4a79d49b 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,13 +430,13 @@ 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 + * 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 diff --git a/src/Forms/AWRequiredFields.php b/src/Forms/AWRequiredFieldsValidator.php similarity index 87% rename from src/Forms/AWRequiredFields.php rename to src/Forms/AWRequiredFieldsValidator.php index 903a8ad1..909e840e 100644 --- a/src/Forms/AWRequiredFields.php +++ b/src/Forms/AWRequiredFieldsValidator.php @@ -2,17 +2,17 @@ namespace Symbiote\AdvancedWorkflow\Forms; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\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? * * @author Russell Michell russell@silverstripe.com * @package advancedworkflow */ -class AWRequiredFields extends RequiredFields +class AWRequiredFieldsValidator extends RequiredFieldsValidator { protected $data = array(); protected static $caller; @@ -50,12 +50,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) @@ -105,11 +105,11 @@ protected function getData() public function setCaller($caller) { - AWRequiredFields::$caller = $caller; + AWRequiredFieldsValidator::$caller = $caller; } public function getCaller() { - return AWRequiredFields::$caller; + return AWRequiredFieldsValidator::$caller; } }