-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from creative-commoners/pulls/7/valid
API Rename validator classes
- Loading branch information
Showing
4 changed files
with
16 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,31 +2,21 @@ | |
|
||
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? | ||
* | ||
* @author Russell Michell [email protected] | ||
* @package advancedworkflow | ||
* | ||
* @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; | ||
|
||
public function __construct() | ||
{ | ||
$message = 'Will be renamed to Symbiote\\AdvancedWorkflow\\Forms\\AWRequiredFieldsValidator'; | ||
Deprecation::noticeWithNoReplacment('5.4.0', $message, Deprecation::SCOPE_CLASS); | ||
parent::__construct(...func_get_args()); | ||
} | ||
|
||
public function php($data) | ||
{ | ||
$valid = parent::php($data); | ||
|
@@ -60,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) | ||
|
@@ -115,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; | ||
} | ||
} |