|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / View / Layout / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/View/Layout/BuilderFactory.php |
Size | 2.05 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 07-Jan-2021 21:08 |
Last accessed | 24-Aug-2025 01:22 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Layout;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View;
/**
* Class BuilderFactory
*/
class BuilderFactory
{
/**#@+
* Allowed builder types
*/
const TYPE_LAYOUT = 'layout';
const TYPE_PAGE = 'page';
/**#@-*/
/**#@-*/
protected $typeMap = [
self::TYPE_LAYOUT => \Magento\Framework\View\Layout\Builder::class,
self::TYPE_PAGE => \Magento\Framework\View\Page\Builder::class,
];
/**
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* Constructor
*
* @param ObjectManagerInterface $objectManager
* @param array $typeMap
*/
public function __construct(
ObjectManagerInterface $objectManager,
array $typeMap = []
) {
$this->objectManager = $objectManager;
$this->mergeTypes($typeMap);
}
/**
* Add or override builder types
*
* @param array $typeMap
* @return void
*/
protected function mergeTypes(array $typeMap)
{
foreach ($typeMap as $typeInfo) {
if (isset($typeInfo['type']) && isset($typeInfo['class'])) {
$this->typeMap[$typeInfo['type']] = $typeInfo['class'];
}
}
}
/**
* Create builder instance
*
* @param string $type
* @param array $arguments
* @throws \InvalidArgumentException
* @return BuilderInterface
*/
public function create($type, array $arguments)
{
if (empty($this->typeMap[$type])) {
throw new \InvalidArgumentException('"' . $type . ': isn\'t allowed');
}
$builderInstance = $this->objectManager->create($this->typeMap[$type], $arguments);
if (!$builderInstance instanceof BuilderInterface) {
throw new \InvalidArgumentException(get_class($builderInstance) . ' isn\'t instance of BuilderInterface');
}
return $builderInstance;
}
}
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Layout;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View;
/**
* Class BuilderFactory
*/
class BuilderFactory
{
/**#@+
* Allowed builder types
*/
const TYPE_LAYOUT = 'layout';
const TYPE_PAGE = 'page';
/**#@-*/
/**#@-*/
protected $typeMap = [
self::TYPE_LAYOUT => \Magento\Framework\View\Layout\Builder::class,
self::TYPE_PAGE => \Magento\Framework\View\Page\Builder::class,
];
/**
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* Constructor
*
* @param ObjectManagerInterface $objectManager
* @param array $typeMap
*/
public function __construct(
ObjectManagerInterface $objectManager,
array $typeMap = []
) {
$this->objectManager = $objectManager;
$this->mergeTypes($typeMap);
}
/**
* Add or override builder types
*
* @param array $typeMap
* @return void
*/
protected function mergeTypes(array $typeMap)
{
foreach ($typeMap as $typeInfo) {
if (isset($typeInfo['type']) && isset($typeInfo['class'])) {
$this->typeMap[$typeInfo['type']] = $typeInfo['class'];
}
}
}
/**
* Create builder instance
*
* @param string $type
* @param array $arguments
* @throws \InvalidArgumentException
* @return BuilderInterface
*/
public function create($type, array $arguments)
{
if (empty($this->typeMap[$type])) {
throw new \InvalidArgumentException('"' . $type . ': isn\'t allowed');
}
$builderInstance = $this->objectManager->create($this->typeMap[$type], $arguments);
if (!$builderInstance instanceof BuilderInterface) {
throw new \InvalidArgumentException(get_class($builderInstance) . ' isn\'t instance of BuilderInterface');
}
return $builderInstance;
}
}