ModifierComposite.php 729 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Url;
  7. /**
  8. * Composite URL modifier.
  9. */
  10. class ModifierComposite implements ModifierInterface
  11. {
  12. /**
  13. * @var ModifierInterface[]
  14. */
  15. private $modifiers;
  16. /**
  17. * @param ModifierInterface[] $modifiers
  18. */
  19. public function __construct(array $modifiers = [])
  20. {
  21. $this->modifiers = $modifiers;
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function execute($url, $mode = ModifierInterface::MODE_ENTIRE)
  27. {
  28. foreach ($this->modifiers as $modifier) {
  29. $url = $modifier->execute($url, $mode);
  30. }
  31. return $url;
  32. }
  33. }