本文整理汇总了PHP中Magento\Framework\App\Bootstrap类的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap类的具体用法?PHP Bootstrap怎么用?PHP Bootstrap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bootstrap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
<?php
/**
* Register basic autoloader that uses include path
*
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\Autoload\ClassLoaderWrapper;
/**
* Shortcut constant for the root directory
*/
define('BP', dirname(__DIR__));
$vendorDir = (require BP . '/app/etc/vendor_path.php');
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
/* 'composer install' validation */
if (file_exists($vendorAutoload)) {
$composerAutoloader = (include $vendorAutoload);
} else {
throw new \Exception('Vendor autoload is not found. Please run \'composer install\' under application root directory.');
}
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));
// Sets default autoload mappings, may be overridden in Bootstrap::create
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
示例2: getApplicationCommands
/**
* Gets application commands
*
* @return array
*/
protected function getApplicationCommands()
{
$commands = [];
try {
$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
/** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */
$omProvider = $this->serviceManager->get('Magento\\Setup\\Model\\ObjectManagerProvider');
$omProvider->setObjectManager($objectManager);
if (class_exists('Magento\\Setup\\Console\\CommandList')) {
$setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager);
$commands = array_merge($commands, $setupCommandList->getCommands());
}
if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
/** @var \Magento\Framework\Console\CommandList $commandList */
$commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList');
$commands = array_merge($commands, $commandList->getCommands());
}
$commands = array_merge($commands, $this->getVendorCommands($objectManager));
} catch (\Exception $e) {
$this->initException = $e;
}
return $commands;
}
示例3: getObjectManagerFactory
/**
* Returns ObjectManagerFactory
*
* @param array $initParams
* @return \Magento\Framework\App\ObjectManagerFactory
*/
public function getObjectManagerFactory($initParams = [])
{
return Bootstrap::createObjectManagerFactory(
BP,
$initParams
);
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
self::$root = BP;
self::$rootJson = json_decode(file_get_contents(self::$root . '/composer.json'), true);
self::$dependencies = [];
self::$objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager();
}
示例5: 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);
}
示例6: 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);
}
}
示例7: getApplicationCommands
/**
* Gets application commands
*
* @return array
*/
protected function getApplicationCommands()
{
$setupCommands = [];
$toolsCommands = [];
$modulesCommands = [];
$bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
if (class_exists('Magento\\Setup\\Console\\CommandList')) {
$serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
$setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager);
$setupCommands = $setupCommandList->getCommands();
}
if (class_exists('Magento\\Tools\\Console\\CommandList')) {
$toolsCommandList = new \Magento\Tools\Console\CommandList();
$toolsCommands = $toolsCommandList->getCommands();
}
if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
$commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList');
$modulesCommands = $commandList->getCommands();
}
$commandsList = array_merge($setupCommands, $toolsCommands, $modulesCommands);
return $commandsList;
}
示例8: 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);
}
示例9: setUp
/**
* 2016-11-03
* @override
* @see \PHPUnit\Framework\TestCase::setUp()
* @return void
*/
protected function setUp()
{
if (!self::$r) {
self::$r = true;
Bootstrap::create(BP, $_SERVER)->createApplication(Http::class);
df_app_state()->setAreaCode('frontend');
}
}
示例10: testCreateFilesystemDriverPool
public function testCreateFilesystemDriverPool()
{
$driverClass = get_class($this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\DriverInterface'));
$result = Bootstrap::createFilesystemDriverPool([Bootstrap::INIT_PARAM_FILESYSTEM_DRIVERS => ['custom' => $driverClass]]);
/** @var \Magento\Framework\Filesystem\DriverPool $result */
$this->assertInstanceOf('Magento\\Framework\\Filesystem\\DriverPool', $result);
$this->assertInstanceof($driverClass, $result->getDriver('custom'));
}
示例11: bootstrapMage2
/**
* Bootstraps Magento2
*/
public function bootstrapMage2()
{
if (is_null($this->bootstrap)) {
$bootstrap = Bootstrap::create(BP, $_SERVER);
$bootstrap->getObjectManager();
$this->bootstrap = true;
}
}
示例12: setUp
/**
* Setup method
*/
protected function setUp()
{
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('Magento\\Framework\\App\\Http');
$bootstrap->run($app);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->objectManager = ObjectManager::getInstance();
}
示例13: 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;
}
示例14: getConfig
/**
* Return configuration for the tests
*
* @return \Magento\TestFramework\Performance\Config
*/
public function getConfig()
{
if (null === $this->config) {
$configFile = "{$this->testsBaseDir}/config.php";
$configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist";
$configData = (require $configFile);
$this->config = new Config($configData, $this->testsBaseDir, $this->appBootstrap->getDirList()->getRoot());
}
return $this->config;
}
示例15: testIsAdmin
/**
* @test
* @covers \Yireo\NewRelic2\Helper\Data::isAdmin
*/
public function testIsAdmin()
{
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$bootstrap->createApplication('Magento\\Framework\\App\\Http');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$appState = $objectManager->get('Magento\\Framework\\App\\State');
$backendAreaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE;
$appState->setAreaCode($backendAreaCode);
$this->assertTrue($this->targetHelper->isAdmin());
}