/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Model/Description/Mixin/MixinFactory.php
76 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 11:23
22 окт 2025, 11:23
6c2f6e6
Код
Авторство
О чём код?
<?php /** * Copyright 2017 Adobe * All Rights Reserved. */ namespace Magento\Setup\Model\Description\Mixin; /** * Create mixin instance based on type */ class MixinFactory { /**#@+ * Constants for existing mixin types */ const SPAN_MIXIN = 'span'; const BOLD_MIXIN = 'b'; const BRAKE_MIXIN = 'br'; const PARAGRAPH_MIXIN = 'p'; const HEADER_MIXIN = 'h1'; const ITALIC_MIXIN = 'i'; /**#@-*/ /** * @var array */ private $typeClassMap = [ self::SPAN_MIXIN => SpanMixin::class, self::BOLD_MIXIN => BoldMixin::class, self::BRAKE_MIXIN => BrakeMixin::class, self::PARAGRAPH_MIXIN => ParagraphMixin::class, self::HEADER_MIXIN => HeaderMixin::class, self::ITALIC_MIXIN => ItalicMixin::class, ]; /** * @var \Magento\Framework\ObjectManagerInterface */ private $objectManager; /** * @param \Magento\Framework\ObjectManagerInterface $objectManager * @throws \Magento\Setup\Exception */ public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; } /** * Create mixin by type * * @param string $mixinType * @return \Magento\Setup\Model\Description\Mixin\DescriptionMixinInterface * @throws \InvalidArgumentException */ public function create($mixinType) { if (!isset($this->typeClassMap[$mixinType])) { throw new \InvalidArgumentException(sprintf('Undefined mixin type: %s.', $mixinType)); } $mixin = $this->objectManager->get($this->typeClassMap[$mixinType]); if (!$mixin instanceof \Magento\Setup\Model\Description\Mixin\DescriptionMixinInterface) { throw new \InvalidArgumentException( sprintf( 'Class "%s" must implement \Magento\Setup\Model\Description\Mixin\DescriptionMixinInterface.', get_class($mixin) ) ); } return $mixin; } }