/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/View/Element/BlockFactory.php
57 строк
1 KB
Abhinav Pathak
Fix Static test failures
13 авг 2025, 16:53
Не верифицирован
13 авг 2025, 16:53
a66a530
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\View\Element; use Magento\Framework\ObjectManagerInterface; /** * Creates Blocks * * @api * @since 100.0.2 */ class BlockFactory { /** * @var ObjectManagerInterface */ protected $objectManager; /** * Constructor * * @param ObjectManagerInterface $objectManager */ public function __construct(ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; } /** * Create block * * @template T of BlockInterface * * @param class-string<T> $blockName * @param array $arguments * * @return T * * @throws \LogicException */ public function createBlock($blockName, array $arguments = []) { $blockName = ltrim($blockName, '\\'); $block = $this->objectManager->create($blockName, $arguments); if (!$block instanceof BlockInterface) { throw new \LogicException($blockName . ' does not implement BlockInterface'); } if ($block instanceof Template) { $block->setTemplateContext($block); } return $block; } }