Skip to content

Commit

Permalink
API Rename validator classes
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Dec 3, 2024
1 parent 5db879d commit e3fff3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/DataObjects/WorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -273,7 +273,7 @@ public function getCMSFields()

public function getValidator()
{
return new RequiredFields('Title');
return new RequiredFieldsValidator('Title');
}

public function summaryFields()
Expand Down
6 changes: 3 additions & 3 deletions src/DataObjects/WorkflowTransition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public function getAssignedMembers()
*
* @param array $data
* @return array
* @see {@link AWRequiredFields}
* @see {@link AWRequiredFieldsValidator}
*/
public function extendedRequiredFieldsNotSame($data = null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/WorkflowEmbargoExpiryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}

0 comments on commit e3fff3a

Please sign in to comment.