Skip to content

Commit

Permalink
Execute delete and submit actions in database transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Jul 30, 2024
1 parent fef1cef commit 025dd8f
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,35 @@ public function submitCreateForm(RemoteSubmitCreateFormAction $action
throw $validationResult->toException();
}

$entityValues = $formSpec->getDataTransformer()->toEntityValues(
ReadOnlyFieldsRemover::removeReadOnlyFields($formSpec, $action->getData()),
NULL,
$action->getResolvedContactId()
);

$this->profile->onPreCreate(

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().

Check failure on line 226 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreCreate().
$action->getArguments(),
$entityValues,
$entityFields,
$formSpec,
$action->getResolvedContactId()
);

$createdValues = $this->api4->createEntity(
$this->profile->getEntityName(),
$formSpec->getDataTransformer()->toEntityValues(
ReadOnlyFieldsRemover::removeReadOnlyFields($formSpec, $action->getData()),
NULL,
$action->getResolvedContactId()
),
$entityValues,
['checkPermissions' => $this->profile->isCheckApiPermissions($action->getResolvedContactId())],
)->single();
// Custom field values might not be part of $createdValues, so we add $entityValues
$createdValues += $entityValues;

$this->profile->onPostCreate(

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().

Check failure on line 242 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostCreate().
$action->getArguments(),
$createdValues,
$entityFields,
$formSpec,
$action->getResolvedContactId()
);

return $this->convertToSubmitFormActionResult(
$createdValues,
Expand Down Expand Up @@ -264,6 +284,15 @@ public function submitUpdateForm(RemoteSubmitUpdateFormAction $action
$entityValues,
$action->getResolvedContactId()
);

$this->profile->onPreUpdate(

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().

Check failure on line 288 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPreUpdate().
$newEntityValues,
$entityValues,
$entityFields,
$formSpec,
$action->getResolvedContactId()
);

$updatedValues = $this->api4->updateEntity(
$this->profile->getEntityName(),
$action->getId(),
Expand All @@ -274,6 +303,14 @@ public function submitUpdateForm(RemoteSubmitUpdateFormAction $action
// ones. Fields updated by triggers might be outdated, though.
$updatedValues += $entityValues;

$this->profile->onPostUpdate(

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().

Check failure on line 306 in Civi/RemoteTools/ActionHandler/AbstractProfileEntityActionsHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Call to an undefined method Civi\RemoteTools\EntityProfile\RemoteEntityProfileInterface::onPostUpdate().
$updatedValues,
$entityValues,
$entityFields,
$formSpec,
$action->getResolvedContactId()
);

return $this->convertToSubmitFormActionResult(
$updatedValues,
$entityValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
declare(strict_types = 1);

namespace Civi\RemoteTools\ActionHandler;

use Civi\RemoteTools\Api4\Action\RemoteDeleteAction;
use Civi\RemoteTools\Api4\Action\RemoteSubmitCreateFormAction;
use Civi\RemoteTools\Api4\Action\RemoteSubmitUpdateFormAction;
use Civi\RemoteTools\Database\TransactionFactory;

final class RemoteActionsHandlerTransactionDecorator extends AbstractRemoteEntityActionsHandlerDecorator {

private TransactionFactory $transactionFactory;

public function __construct(RemoteEntityActionsHandlerInterface $handler, TransactionFactory $transactionFactory) {
parent::__construct($handler);
$this->transactionFactory = $transactionFactory;
}

public function delete(RemoteDeleteAction $action): array {
$transaction = $this->transactionFactory->createTransaction();
try {
return parent::delete($action);
}
// @phpstan-ignore-next-line Dead catch clause.
catch (\Throwable $e) {
$transaction->rollback();

throw $e;
}
finally {
$transaction->commit();
}
}

public function submitCreateForm(RemoteSubmitCreateFormAction $action): array {
$transaction = $this->transactionFactory->createTransaction();
try {
return parent::submitCreateForm($action);
}
// @phpstan-ignore-next-line Dead catch clause.
catch (\Throwable $e) {
$transaction->rollback();

throw $e;
}
finally {
$transaction->commit();
}
}

public function submitUpdateForm(RemoteSubmitUpdateFormAction $action): array {
$transaction = $this->transactionFactory->createTransaction();
try {
return parent::submitUpdateForm($action);
}
// @phpstan-ignore-next-line Dead catch clause.
catch (\Throwable $e) {
$transaction->rollback();

throw $e;
}
finally {
$transaction->commit();
}
}

}
31 changes: 31 additions & 0 deletions Civi/RemoteTools/Database/TransactionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
* Copyright (C) 2022 SYSTOPIA GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation in version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types = 1);

namespace Civi\RemoteTools\Database;

/**
* @codeCoverageIgnore
*/
class TransactionFactory {

public function createTransaction(): \CRM_Core_Transaction {
return \CRM_Core_Transaction::create();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use Civi\Api4\Generic\AbstractAction;
use Civi\RemoteTools\ActionHandler\ActionHandlerInterface;
use Civi\RemoteTools\ActionHandler\ActionHandlerProvider;
use Civi\RemoteTools\ActionHandler\RemoteActionsHandlerTransactionDecorator;
use Civi\RemoteTools\DependencyInjection\Compiler\Traits\DecorateServiceTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -33,6 +35,8 @@
*/
final class ActionHandlerPass implements CompilerPassInterface {

use DecorateServiceTrait;

public static function buildHandlerKey(string $entityName, string $actionName, ?string $profileName): string {
if (NULL === $profileName) {
return $entityName . '.' . $actionName;
Expand Down Expand Up @@ -79,6 +83,15 @@ public function process(ContainerBuilder $container): void {
}
}

foreach ($handlerServices as $handlerKey => $handlerService) {
$this->decorateService(
$container,
$handlerService->__toString(),
RemoteActionsHandlerTransactionDecorator::class,
$handlerKey
);
}

$container->getDefinition(ActionHandlerProvider::class)
->addArgument(ServiceLocatorTagPass::register($container, $handlerServices));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
declare(strict_types = 1);

namespace Civi\RemoteTools\DependencyInjection\Compiler\Traits;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

trait DecorateServiceTrait {

/**
* @phpstan-param class-string $decoratorClass
* @param int|string $argumentKey
*/
protected function decorateService(
ContainerBuilder $container,
string $id,
string $decoratorClass,
string $serviceIdPostfix,
$argumentKey = 0
): void {
$decoratorId = $decoratorClass . ':' . $serviceIdPostfix;
$container->autowire($decoratorId, $decoratorClass)
->setDecoratedService($id)
->setArgument($argumentKey, new Reference($decoratorId . '.inner'));
}

}
49 changes: 49 additions & 0 deletions Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Civi\RemoteTools\Api4\Query\Comparison;
use Civi\RemoteTools\Api4\Query\ConditionInterface;
use Civi\RemoteTools\EntityProfile\Authorization\GrantResult;
use Civi\RemoteTools\Form\FormSpec\FormSpec;
use CRM_Remotetools_ExtensionUtil as E;

/**
Expand Down Expand Up @@ -118,4 +119,52 @@ public function getSaveSuccessMessage(
return E::ts('Saved successfully');
}

/**
* @inheritDoc
*/
public function onPreCreate(

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 125 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPreCreate() has parameter $entityValues with no value type specified in iterable type array.
array $arguments,
array &$entityValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
}

/**
* @inheritDoc
*/
public function onPostCreate(

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.0 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 7.4 prefer-lowest

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $arguments with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityFields with no value type specified in iterable type array.

Check failure on line 137 in Civi/RemoteTools/EntityProfile/AbstractRemoteEntityProfile.php

View workflow job for this annotation

GitHub Actions / PHPStan with PHP 8.3 prefer-stable

Method Civi\RemoteTools\EntityProfile\AbstractRemoteEntityProfile::onPostCreate() has parameter $entityValues with no value type specified in iterable type array.
array $arguments,
array $entityValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
}

/**
* @inheritDoc
*/
public function onPreUpdate(
array &$newValues,
array $oldValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
}

/**
* @inheritDoc
*/
public function onPostUpdate(
array $newValues,
array $oldValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,56 @@ public function getSaveSuccessMessage(
return $this->profile->getSaveSuccessMessage($newValues, $oldValues, $formData, $contactId);
}

/**
* @inheritDoc
*/
public function onPreCreate(
array $arguments,
array &$entityValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
$this->profile->onPreCreate($arguments, $entityValues, $entityFields, $formSpec, $contactId);
}

/**
* @inheritDoc
*/
public function onPostCreate(
array $arguments,
array $entityValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
$this->profile->onPostCreate($arguments, $entityValues, $entityFields, $formSpec, $contactId);
}

/**
* @inheritDoc
*/
public function onPreUpdate(
array &$newValues,
array $oldValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
$this->profile->onPreUpdate($newValues, $oldValues, $entityFields, $formSpec, $contactId);
}

/**
* @inheritDoc
*/
public function onPostUpdate(
array $newValues,
array $oldValues,
array $entityFields,
FormSpec $formSpec,
?int $contactId
): void {
$this->profile->onPostUpdate($newValues, $oldValues, $entityFields, $formSpec, $contactId);
}

}
3 changes: 3 additions & 0 deletions services/remote-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Civi\RemoteTools\Contact\RemoteContactIdResolverInterface;
use Civi\RemoteTools\Contact\RemoteContactIdResolverProvider;
use Civi\RemoteTools\Contact\RemoteContactIdResolverProviderInterface;
use Civi\RemoteTools\Database\TransactionFactory;
use Civi\RemoteTools\DependencyInjection\Compiler\ActionHandlerPass;
use Civi\RemoteTools\DependencyInjection\Compiler\RemoteEntityProfilePass;
use Civi\RemoteTools\EntityProfile\Helper\ProfileEntityDeleter;
Expand All @@ -58,6 +59,8 @@
$container->autowire(RequestContextInterface::class, RequestContext::class)
->setPublic(TRUE);

$container->autowire(TransactionFactory::class);

$container->autowire(ActionHandlerProviderInterface::class, ActionHandlerProviderCollection::class)
->addArgument(new TaggedIteratorArgument(ActionHandlerProviderInterface::SERVICE_TAG));

Expand Down
Loading

0 comments on commit 025dd8f

Please sign in to comment.