|
19 | 19 |
|
20 | 20 | namespace Civi\Funding\Api4\Action\Remote\FundingCase;
|
21 | 21 |
|
22 |
| -use Civi\Api4\Generic\Result; |
23 |
| -use Civi\Core\CiviEventDispatcherInterface; |
| 22 | +use Civi\Api4\RemoteFundingCase; |
| 23 | +use Civi\Funding\Api4\Action\Remote\AbstractRemoteFundingAction; |
24 | 24 | use Civi\Funding\Api4\Action\Traits\FundingCaseTypeIdParameterTrait;
|
25 | 25 | use Civi\Funding\Api4\Action\Traits\FundingProgramIdParameterTrait;
|
26 |
| -use Civi\Funding\Event\Remote\FundingCase\ValidateNewApplicationFormEvent; |
27 |
| -use Civi\Funding\Exception\FundingException; |
28 |
| -use Civi\Funding\FundingProgram\FundingCaseTypeManager; |
29 |
| -use Civi\Funding\FundingProgram\FundingCaseTypeProgramRelationChecker; |
30 |
| -use Civi\Funding\FundingProgram\FundingProgramManager; |
31 | 26 | use Civi\RemoteTools\Api4\Action\Traits\DataParameterTrait;
|
32 | 27 |
|
33 |
| -/** |
34 |
| - * @method $this setData(array $data) |
35 |
| - */ |
36 |
| -class ValidateNewApplicationFormAction extends AbstractNewApplicationFormAction { |
| 28 | +class ValidateNewApplicationFormAction extends AbstractRemoteFundingAction { |
37 | 29 |
|
38 | 30 | use DataParameterTrait;
|
39 | 31 |
|
40 | 32 | use FundingCaseTypeIdParameterTrait;
|
41 | 33 |
|
42 | 34 | use FundingProgramIdParameterTrait;
|
43 | 35 |
|
44 |
| - public function __construct( |
45 |
| - FundingCaseTypeManager $fundingCaseTypeManager, |
46 |
| - FundingProgramManager $fundingProgramManager, |
47 |
| - CiviEventDispatcherInterface $eventDispatcher, |
48 |
| - FundingCaseTypeProgramRelationChecker $relationChecker |
49 |
| - ) { |
50 |
| - parent::__construct( |
51 |
| - 'validateNewApplicationForm', |
52 |
| - $fundingCaseTypeManager, |
53 |
| - $fundingProgramManager, |
54 |
| - $eventDispatcher, |
55 |
| - $relationChecker, |
56 |
| - ); |
57 |
| - } |
58 |
| - |
59 |
| - /** |
60 |
| - * @inheritDoc |
61 |
| - * |
62 |
| - * @throws \CRM_Core_Exception |
63 |
| - */ |
64 |
| - public function _run(Result $result): void { |
65 |
| - $this->assertFundingCaseTypeAndProgramRelated($this->getFundingCaseTypeId(), $this->getFundingProgramId()); |
66 |
| - $event = $this->createEvent(); |
67 |
| - $this->dispatchEvent($event); |
68 |
| - |
69 |
| - $result->debug['event'] = $event->getDebugOutput(); |
70 |
| - |
71 |
| - if (NULL === $event->isValid()) { |
72 |
| - throw new FundingException('Form not validated'); |
73 |
| - } |
74 |
| - |
75 |
| - $result->rowCount = 1; |
76 |
| - $result->exchangeArray([ |
77 |
| - 'valid' => $event->isValid(), |
78 |
| - 'errors' => $event->getErrors(), |
79 |
| - ]); |
80 |
| - } |
81 |
| - |
82 |
| - /** |
83 |
| - * @throws \CRM_Core_Exception |
84 |
| - */ |
85 |
| - private function createEvent(): ValidateNewApplicationFormEvent { |
86 |
| - return ValidateNewApplicationFormEvent::fromApiRequest( |
87 |
| - $this, |
88 |
| - $this->createEventParams($this->getFundingCaseTypeId(), $this->getFundingProgramId()), |
89 |
| - ); |
| 36 | + public function __construct() { |
| 37 | + parent::__construct(RemoteFundingCase::getEntityName(), 'validateNewApplicationForm'); |
90 | 38 | }
|
91 | 39 |
|
92 | 40 | }
|
0 commit comments