ConditionFactory.php 987 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Layout\Condition;
  7. use Magento\Framework\ObjectManagerInterface;
  8. /**
  9. * Factory for composite.
  10. */
  11. class ConditionFactory
  12. {
  13. /**
  14. * @var ObjectManagerInterface
  15. */
  16. private $objectManager;
  17. /**
  18. * @param ObjectManagerInterface $objectManager
  19. */
  20. public function __construct(ObjectManagerInterface $objectManager)
  21. {
  22. $this->objectManager = $objectManager;
  23. }
  24. /**
  25. * @param array $elementVisibilityConditions
  26. *
  27. * @return Condition
  28. */
  29. public function create(array $elementVisibilityConditions)
  30. {
  31. $conditions = [];
  32. foreach ($elementVisibilityConditions as $condition) {
  33. $conditions[] = $this->objectManager->create($condition['name']);
  34. }
  35. return $this->objectManager->create(Condition::class, ['conditions' => $conditions]);
  36. }
  37. }