• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP App\Bootstrap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\App\Bootstrap的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap类的具体用法?PHP Bootstrap怎么用?PHP Bootstrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Bootstrap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, []);
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:autoload.php


示例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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:Cli.php


示例3: getObjectManagerFactory

 /**
  * Returns ObjectManagerFactory
  *
  * @param array $initParams
  * @return \Magento\Framework\App\ObjectManagerFactory
  */
 public function getObjectManagerFactory($initParams = [])
 {
     return Bootstrap::createObjectManagerFactory(
         BP,
         $initParams
     );
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:ObjectManagerProvider.php


示例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();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:ComposerTest.php


示例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);
 }
开发者ID:nja78,项目名称:magento2,代码行数:7,代码来源:HttpTest.php


示例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);
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:SequenceSorter.php


示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:Cli.php


示例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);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:processorFactory.php


示例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');
     }
 }
开发者ID:mage2pro,项目名称:core,代码行数:14,代码来源:TestCase.php


示例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'));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:8,代码来源:BootstrapTest.php


示例11: bootstrapMage2

 /**
  * Bootstraps Magento2
  */
 public function bootstrapMage2()
 {
     if (is_null($this->bootstrap)) {
         $bootstrap = Bootstrap::create(BP, $_SERVER);
         $bootstrap->getObjectManager();
         $this->bootstrap = true;
     }
 }
开发者ID:nagno,项目名称:phpspec-bootstrap-magento2,代码行数:11,代码来源:BootstrapMaintainer.php


示例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();
 }
开发者ID:yireo,项目名称:Yireo_GoogleTagManager2,代码行数:11,代码来源:Generic.php


示例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;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:15,代码来源:ObjectManagerProvider.php


示例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;
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:15,代码来源:Bootstrap.php


示例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());
 }
开发者ID:baisoo,项目名称:Yireo_NewRelic2,代码行数:15,代码来源:DataTest.php


示例16: 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);
         /** @var \Magento\Framework\App\Filesystem\DirectoryList $dirList */
         $dirList = $this->appBootstrap->getObjectManager()->get('Magento\\Framework\\App\\Filesystem\\DirectoryList');
         $this->config = new Config($configData, $this->testsBaseDir, $dirList->getRoot());
     }
     return $this->config;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:17,代码来源:Bootstrap.php


示例17: 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]);
 }
开发者ID:kid17,项目名称:magento2,代码行数:14,代码来源:TemplateTest.php


示例18: initMagento

 public function initMagento()
 {
     $bootstrapPath = $this->config->getMagentoBootstrapPath();
     if (!file_exists($bootstrapPath)) {
         throw new \RuntimeException(sprintf("Magento's bootstrap file was not found at path '%s'", $bootstrapPath));
     }
     include $bootstrapPath;
     $params = $_SERVER;
     $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload']];
     putenv('BEHAT_RUNNING=true');
     $bootstrap = Bootstrap::create(BP, $params);
     $app = $bootstrap->createApplication('Magento\\Framework\\App\\Http');
     $app->launch();
     ObjectManager::getInstance();
     $this->magentoConfigManager = new MagentoConfigManager();
     $this->magentoConfigManager->changeConfigs($this->config->getRequiredMagentoConfig());
 }
开发者ID:tkotosz,项目名称:behat-magento2-init,代码行数:17,代码来源:Magento2InitListener.php


示例19: 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]);
 }
开发者ID:nja78,项目名称:magento2,代码行数:19,代码来源:BackendTemplateTest.php


示例20: 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();
 }
开发者ID:nja78,项目名称:magento2,代码行数:21,代码来源:AbstractCollectionTest.php



注:本文中的Magento\Framework\App\Bootstrap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP App\CacheInterface类代码示例发布时间:2022-05-23
下一篇:
PHP App\ActionFlag类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap