diff --git a/src/Plugin/Action/ValidateShareTransactionAction.php b/src/Plugin/Action/ValidateShareTransactionAction.php index 9fc0d4b366b08025495dbed1cb521997e37c5d17..00526c9d72d16a09d454d3ec8fe3c611158c5310 100644 --- a/src/Plugin/Action/ValidateShareTransactionAction.php +++ b/src/Plugin/Action/ValidateShareTransactionAction.php @@ -7,6 +7,9 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Utility\Error; + +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\shareholder_register\Exception\ShareholderRegisterException; @@ -29,12 +32,20 @@ class ValidateShareTransactionAction extends ViewsBulkOperationsActionBase imple */ protected $messenger; + /** + * The shareholder_register logger channel. + * + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MessengerInterface $messenger) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MessengerInterface $messenger, LoggerInterface $logger) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->messenger = $messenger; + $this->logger = $logger; } /** @@ -45,7 +56,8 @@ class ValidateShareTransactionAction extends ViewsBulkOperationsActionBase imple $configuration, $plugin_id, $plugin_definition, - $container->get('messenger') + $container->get('messenger'), + $container->get('logger.factory')->get('shareholder_register') ); } @@ -78,10 +90,16 @@ class ValidateShareTransactionAction extends ViewsBulkOperationsActionBase imple try { $entity->actionValidate($this->configuration['date']); } - catch (ShareholderRegisterException $e) { + catch (ShareholderRegisterException $exception) { + // D10: Error::logException($this->logger, $exception); + $this->logger->error( + Error::DEFAULT_ERROR_MESSAGE, + Error::decodeException($exception) + ); + $this->messenger()->addError( $this->t('Could not validate transation:') . ' ' . - $this->t($e->getMessage(), $e->getMsgPlaceholders())); + $this->t($exception->getMessage(), $exception->getMsgPlaceholders())); } }