本文整理汇总了PHP中Magento\Framework\App\Bootstrap::createObjectManagerFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::createObjectManagerFactory方法的具体用法?PHP Bootstrap::createObjectManagerFactory怎么用?PHP Bootstrap::createObjectManagerFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::createObjectManagerFactory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initObjectManager
/**
* Initialize Magento ObjectManager.
*
* @return void
*/
protected function initObjectManager()
{
if (!$this->magentoObjectManager) {
$objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
$this->magentoObjectManager = $objectManagerFactory->create($_SERVER);
}
}
示例2: getObjectManagerFactory
/**
* Returns ObjectManagerFactory
*
* @param array $initParams
* @return \Magento\Framework\App\ObjectManagerFactory
*/
public function getObjectManagerFactory($initParams = [])
{
return Bootstrap::createObjectManagerFactory(
BP,
$initParams
);
}
示例3: tearDown
protected function tearDown()
{
unset($this->model);
$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
$objectManager = $magentoObjectManagerFactory->create($_SERVER);
\Magento\Framework\App\ObjectManager::setInstance($objectManager);
}
示例4: createProcessor
/**
* Create Processor
*
* @return Processor
*/
public function createProcessor()
{
$objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
$objectManager = $objectManagerFactory->create($_SERVER);
$response = $objectManager->create('Magento\\Framework\\App\\Response\\Http');
return new Processor($response);
}
示例5: get
/**
* Retrieve object manager.
*
* @return \Magento\Framework\ObjectManagerInterface
* @throws \Magento\Setup\Exception
*/
public function get()
{
if (null === $this->objectManager) {
$initParams = $this->serviceLocator->get(InitParamListener::BOOTSTRAP_PARAM);
$factory = Bootstrap::createObjectManagerFactory(BP, $initParams);
$this->objectManager = $factory->create($initParams);
}
return $this->objectManager;
}
示例6: setUp
public function setUp()
{
$this->mockViewFilesystem = $this->getMockBuilder('\\Magento\\Framework\\View\\FileSystem')->disableOriginalConstructor()->getMock();
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$objectManagerMock->expects($this->once())->method('get')->with('Magento\\Email\\Model\\Resource\\Template')->will($this->returnValue($objectManagerHelper->getObject('Magento\\Email\\Model\\Resource\\Template')));
try {
$this->objectManagerBackup = \Magento\Framework\App\ObjectManager::getInstance();
} catch (\RuntimeException $e) {
$this->objectManagerBackup = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER)->create($_SERVER);
}
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
$this->template = $objectManagerHelper->getObject('Magento\\Sales\\Model\\Email\\Template', ['viewFileSystem' => $this->mockViewFilesystem]);
}
示例7: setUp
protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
$this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn(['test' => 1]);
$this->structureMock = $this->getMock('Magento\\Config\\Model\\Config\\Structure', [], [], '', false);
$this->structureMock->expects($this->any())->method('getFieldPathsByAttribute')->willReturn(['path' => 'test']);
$this->resourceModelMock = $this->getMock('Magento\\Email\\Model\\Resource\\Template', [], [], '', false);
$this->resourceModelMock->expects($this->any())->method('getSystemConfigByPathsAndTemplateId')->willReturn(['test_config' => 2015]);
$objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$objectManagerMock->expects($this->any())->method('get')->with('Magento\\Email\\Model\\Resource\\Template')->will($this->returnValue($this->resourceModelMock));
try {
$this->objectManagerBackup = \Magento\Framework\App\ObjectManager::getInstance();
} catch (\RuntimeException $e) {
$this->objectManagerBackup = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER)->create($_SERVER);
}
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
$this->model = $helper->getObject('Magento\\Email\\Model\\BackendTemplate', ['scopeConfig' => $this->scopeConfigMock, 'structure' => $this->structureMock]);
}
示例8: setUp
protected function setUp()
{
$this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactoryInterface');
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
$this->managerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
$this->connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$this->resourceMock = $this->getMock('Magento\\Framework\\Flag\\Resource', [], [], '', false);
$this->resourceMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($this->connectionMock));
$this->selectMock = $this->getMock('Zend_Db_Select', ['getPart', 'setPart', 'from', 'columns'], [$this->connectionMock]);
$this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->selectMock));
$this->objectManagerMock = $this->getMock('Magento\\Framework\\App\\ObjectManager', [], [], '', false);
try {
$this->objectManagerBackup = \Magento\Framework\App\ObjectManager::getInstance();
} catch (\RuntimeException $e) {
$this->objectManagerBackup = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER)->create($_SERVER);
}
\Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->uut = $this->getUut();
}
示例9: foreach
$files['additional'] = [$opt->getOption('extra-classes-file')];
$entities = [];
$repositoryScanner = new Scanner\RepositoryScanner();
$repositories = $repositoryScanner->collectEntities($files['di']);
$scanner = new Scanner\CompositeScanner();
$scanner->addChild(new Scanner\PhpScanner($log), 'php');
$scanner->addChild(new Scanner\XmlScanner($log), 'di');
$scanner->addChild(new Scanner\ArrayScanner(), 'additional');
$entities = $scanner->collectEntities($files);
$interceptorScanner = new Scanner\XmlInterceptorScanner();
$entities['interceptors'] = $interceptorScanner->collectEntities($files['di']);
// 1.2 Generation of Factory and Additional Classes
$generatorIo = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), $generationDir);
$generator = new \Magento\Framework\Code\Generator($generatorIo, [Interceptor::ENTITY_TYPE => 'Magento\\Framework\\Interception\\Code\\Generator\\Interceptor', Proxy::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Proxy', Factory::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Factory', Mapper::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\Mapper', Persistor::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Persistor', Repository::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Repository', Converter::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Converter', SearchResults::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\SearchResults', ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\ExtensionAttributesInterfaceGenerator', ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\ExtensionAttributesGenerator']);
/** Initialize object manager for code generation based on configs */
$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
$objectManager = $magentoObjectManagerFactory->create($_SERVER);
$generator->setObjectManager($objectManager);
$generatorAutoloader = new \Magento\Framework\Code\Generator\Autoloader($generator);
spl_autoload_register([$generatorAutoloader, 'load']);
foreach ($repositories as $entityName) {
switch ($generator->generateClass($entityName)) {
case \Magento\Framework\Code\Generator::GENERATION_SUCCESS:
$log->add(Log::GENERATION_SUCCESS, $entityName);
break;
case \Magento\Framework\Code\Generator::GENERATION_ERROR:
$log->add(Log::GENERATION_ERROR, $entityName);
break;
case \Magento\Framework\Code\Generator::GENERATION_SKIP:
default:
//no log
示例10: testCreateObjectManagerFactory
public function testCreateObjectManagerFactory()
{
$result = Bootstrap::createObjectManagerFactory('test', []);
$this->assertInstanceOf('Magento\\Framework\\App\\ObjectManagerFactory', $result);
}
示例11: testCreateObjectManagerFactoryCouldBeOverridden
/**
* @expectedException \BadMethodCallException
* @expectedExceptionMessage Magento\Framework\App\Test\Unit\ObjectManager\FactoryStub::__construct
*/
public function testCreateObjectManagerFactoryCouldBeOverridden()
{
$rootPath = __DIR__ . '/_files/';
$factory = Bootstrap::createObjectManagerFactory($rootPath, []);
$factory->create([], false);
}
示例12: exit
if (!preg_match('/^[a-z]{2}_[A-Z]{2}$/', $lang)) {
echo USAGE;
exit(1);
}
}
}
$isDryRun = isset($options['dry-run']);
$verbosity = \Magento\Tools\View\Deployer\Log::ERROR;
if (isset($options['verbose'])) {
$verbosity = 0 === (int) $options['verbose'] ? \Magento\Tools\View\Deployer\Log::SILENT : \Magento\Tools\View\Deployer\Log::ERROR | \Magento\Tools\View\Deployer\Log::DEBUG;
}
$logger = new \Magento\Tools\View\Deployer\Log($verbosity);
try {
// run the deployment logic
$filesUtil = new \Magento\Framework\App\Utility\Files(BP);
$omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []);
$objectManager = $omFactory->create([\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT]);
/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */
$deploymentConfig = $objectManager->get('Magento\\Framework\\App\\DeploymentConfig');
$isAppInstalled = $deploymentConfig->isAvailable();
if (!$isAppInstalled) {
throw new \Exception('You need to install the Magento application before running this utility.');
}
/** @var \Magento\Tools\View\Deployer $deployer */
$deployer = $objectManager->create('Magento\\Tools\\View\\Deployer', ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun]);
$deployer->deploy($omFactory, $langs);
} catch (\Exception $e) {
$logger->logError($e->getMessage());
$logger->logDebug($e->getTraceAsString());
exit(1);
}
示例13: getObjectManager
/**
* Get object manager
*
* @return \Magento\Framework\ObjectManagerInterface
*/
public function getObjectManager()
{
if (!$this->objectManager) {
$objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $this->initArguments);
$this->objectManager = $objectManagerFactory->create($this->initArguments);
$this->objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(self::AREA_CODE);
}
return $this->objectManager;
}
示例14: getObjectManager
/**
* Get object manager for Magento application
*
* @return \Magento\Framework\ObjectManagerInterface
*/
private function getObjectManager()
{
if (null === $this->objectManager) {
$this->assertDeploymentConfigExists();
$factory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $this->initParams);
$this->objectManager = $factory->create($this->initParams);
}
return $this->objectManager;
}