DeprecateOldTemplateHook.php
5 years ago
HookCommandInterface.php
5 years ago
SetupFieldConfirmation.php
5 years ago
SetupFieldEmailTag.php
5 years ago
SetupFieldPersistance.php
5 years ago
SetupFieldReceipt.php
5 years ago
SetupFieldValidation.php
5 years ago
SetupNewTemplateHook.php
5 years ago
SetupPaymentDetailsDisplay.php
5 years ago
SetupFieldValidation.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer\Commands; |
| 4 | |
| 5 | use Give\Framework\FieldsAPI\FieldCollection; |
| 6 | |
| 7 | /** |
| 8 | * Setup field validation for custom fields on the required fields hook. |
| 9 | * |
| 10 | * @NOTE This is reducing on required fields, so it doesn't implement the shared interface. This is a special case. |
| 11 | * |
| 12 | * @since 2.10.2 |
| 13 | */ |
| 14 | class SetupFieldValidation { |
| 15 | |
| 16 | /** |
| 17 | * @since 2.10.2 |
| 18 | * |
| 19 | * @param int $formID |
| 20 | */ |
| 21 | public function __construct( $formID ) { |
| 22 | $this->formID = $formID; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @since 2.10.2 |
| 27 | * |
| 28 | * @param array $requiredFields |
| 29 | * @param string $hook |
| 30 | * |
| 31 | * @return array |
| 32 | */ |
| 33 | public function __invoke( $requiredFields, $hook ) { |
| 34 | $fieldCollection = new FieldCollection( 'root' ); |
| 35 | do_action( "give_fields_$hook", $fieldCollection, $this->formID ); |
| 36 | $fieldCollection->walk( |
| 37 | function( $field ) use ( &$requiredFields ) { |
| 38 | if ( $field->isRequired() ) { |
| 39 | $requiredFields[ $field->getName() ] = $field->getRequiredError(); |
| 40 | } |
| 41 | } |
| 42 | ); |
| 43 | return $requiredFields; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 |