diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessage.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessage.php index 46e996395a..867a39bdac 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessage.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessage.php @@ -2,6 +2,8 @@ namespace Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane; +use Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; /** @@ -23,7 +25,7 @@ class CompletionMessage extends CheckoutPaneBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, \Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface $checkout_flow, \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, CheckoutFlowInterface $checkout_flow, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $checkout_flow, $entity_type_manager); $this->completionMessags = new CompletionMessages(); } diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessages.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessages.php index e5a9c91998..51af9655a4 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessages.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/CompletionMessages.php @@ -3,7 +3,6 @@ namespace Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane; use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\Core\TypedData\TranslatableInterface; /** * Acts as a container to collect all completion messages. @@ -13,7 +12,7 @@ class CompletionMessages implements \Iterator, \Countable { /** - * @var \Drupal\Core\TypedData\TranslatableInterface[] + * @var \Drupal\Core\StringTranslation\TranslatableMarkup[] */ private $messages; @@ -30,81 +29,58 @@ public function __construct() { } /** - * Return the current element + * Adds a message to the array. + * + * @param \Drupal\Core\StringTranslation\TranslatableMarkup $message + * The message to add. + */ + public function addMessage(TranslatableMarkup $message) { + $this->messages[] = $message; + } + + /** + * Gets the current message. * - * @link http://php.net/manual/en/iterator.current.php - * @return mixed Can return any type. - * @since 5.0.0 + * @return \Drupal\Core\StringTranslation\TranslatableMarkup + * The current message. */ public function current() { return $this->messages[$this->position]; } /** - * Move forward to next element - * - * @link http://php.net/manual/en/iterator.next.php - * @return void Any returned value is ignored. - * @since 5.0.0 + * {@inheritdoc} */ public function next() { ++$this->position; } /** - * Return the key of the current element - * - * @link http://php.net/manual/en/iterator.key.php - * @return mixed scalar on success, or null on failure. - * @since 5.0.0 + * {@inheritdoc} */ public function key() { return $this->position; } /** - * Checks if current position is valid - * - * @link http://php.net/manual/en/iterator.valid.php - * @return boolean The return value will be casted to boolean and then - * evaluated. Returns true on success or false on failure. - * @since 5.0.0 + * {@inheritdoc} */ public function valid() { return isset($this->messages[$this->position]); } /** - * Rewind the Iterator to the first element - * - * @link http://php.net/manual/en/iterator.rewind.php - * @return void Any returned value is ignored. - * @since 5.0.0 + * {@inheritdoc} */ public function rewind() { $this->position = 0; } /** - * Adds a message to the array. - * - * @param \Drupal\Core\StringTranslation\TranslatableMarkup $message - */ - public function addMessage(TranslatableMarkup $message) { - $this->messages[] = $message; - } - - /** - * Count elements of an object - * - * @link http://php.net/manual/en/countable.count.php - * @return int The custom count as an integer. - *

- *

- * The return value is cast to an integer. - * @since 5.1.0 + * {@inheritdoc} */ public function count() { return count($this->messages); } -} \ No newline at end of file + +} diff --git a/modules/checkout/templates/commerce-checkout-completion-message.html.twig b/modules/checkout/templates/commerce-checkout-completion-message.html.twig index 5e6bfc8b6d..2b6fb3e9c0 100644 --- a/modules/checkout/templates/commerce-checkout-completion-message.html.twig +++ b/modules/checkout/templates/commerce-checkout-completion-message.html.twig @@ -12,7 +12,7 @@ #}

{% for message in completion_messages %} - {{ message }} + {{ message }}
{% endfor %} {{ 'Your order number is @number.'|t({'@number': order_entity.getOrderNumber}) }}
diff --git a/modules/checkout/tests/src/Kernel/CompletionMessagesTest.php b/modules/checkout/tests/src/Kernel/CompletionMessagesTest.php index ba42f4704b..6ad9f65221 100644 --- a/modules/checkout/tests/src/Kernel/CompletionMessagesTest.php +++ b/modules/checkout/tests/src/Kernel/CompletionMessagesTest.php @@ -1,10 +1,4 @@ completionMessages = new CompletionMessages(); } + /** + * Tests add message method. + */ public function testAddMessage() { $this->completionMessages->addMessage(t('Message 1')); $this->completionMessages->addMessage(t('Message 2')); @@ -35,6 +37,9 @@ public function testAddMessage() { $this->assertCount(2, $this->completionMessages); } + /** + * Tests the messages iterator. + */ public function testMessagesIterator() { $this->completionMessages->addMessage(t('Message 1')); $this->completionMessages->addMessage(t('Message 2')); @@ -44,4 +49,4 @@ public function testMessagesIterator() { $this->assertEquals('Message 2', $this->completionMessages->current()->render()); } -} \ No newline at end of file +}