Exemplo n.º 1
3
<?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, []);
Exemplo n.º 2
1
 /**
  * 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;
 }
Exemplo n.º 3
1
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * Returns ObjectManagerFactory
  *
  * @param array $initParams
  * @return \Magento\Framework\App\ObjectManagerFactory
  */
 public function getObjectManagerFactory($initParams = [])
 {
     return Bootstrap::createObjectManagerFactory(
         BP,
         $initParams
     );
 }
Exemplo n.º 5
0
 protected function tearDown()
 {
     unset($this->model);
     $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
     $objectManager = $magentoObjectManagerFactory->create($_SERVER);
     \Magento\Framework\App\ObjectManager::setInstance($objectManager);
 }
 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();
 }
 /**
  * Initialize Magento ObjectManager.
  *
  * @return void
  */
 protected function initObjectManager()
 {
     if (!$this->magentoObjectManager) {
         $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER);
         $this->magentoObjectManager = $objectManagerFactory->create($_SERVER);
     }
 }
Exemplo n.º 8
0
 /**
  * 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);
 }
Exemplo n.º 9
0
 /**
  * 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');
     }
 }
Exemplo n.º 10
0
 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'));
 }
 /**
  * Bootstraps Magento2
  */
 public function bootstrapMage2()
 {
     if (is_null($this->bootstrap)) {
         $bootstrap = Bootstrap::create(BP, $_SERVER);
         $bootstrap->getObjectManager();
         $this->bootstrap = true;
     }
 }
Exemplo n.º 12
0
 /**
  * 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();
 }
Exemplo n.º 13
0
 /**
  * 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;
 }
Exemplo n.º 14
0
 /**
  * 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;
 }
Exemplo n.º 15
0
 /**
  * @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());
 }
Exemplo n.º 16
0
 /**
  * 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;
 }
Exemplo n.º 17
0
 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]);
 }
 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());
 }
Exemplo n.º 19
0
 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]);
 }
Exemplo n.º 20
0
 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();
 }
 public function testUnitTestFilesPlacement()
 {
     $objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager();
     /** @var \Magento\Framework\Data\Collection\Filesystem $filesystem */
     $filesystem = $objectManager->get('Magento\\Framework\\Data\\Collection\\Filesystem');
     $filesystem->setCollectDirs(false)->setCollectFiles(true)->setCollectRecursively(true);
     $targetsExist = false;
     foreach ($this->scanList as $dir) {
         if (realpath($this->root . DIRECTORY_SEPARATOR . $dir)) {
             $filesystem->addTargetDir($this->root . DIRECTORY_SEPARATOR . $dir);
             $targetsExist = true;
         }
     }
     if ($targetsExist) {
         $files = $filesystem->load()->toArray();
         $fileList = [];
         foreach ($files['items'] as $file) {
             $fileList[] = $file['filename'];
         }
         $this->assertEquals(0, $files['totalRecords'], "The following files have been found in obsolete test directories: \n" . implode("\n", $fileList));
     }
 }
Exemplo n.º 22
0
        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);
}
Exemplo n.º 23
0
/**
 * Performance framework bootstrap script
 *
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$testsBaseDir = dirname(__DIR__);
require __DIR__ . '/../../../../app/bootstrap.php';
$appBootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
(new \Magento\Framework\Autoload\IncludePath())->addIncludePath($testsBaseDir . '/framework');
$bootstrap = new \Magento\TestFramework\Performance\Bootstrap($appBootstrap, $testsBaseDir);
$bootstrap->cleanupReports();
return $bootstrap;
Exemplo n.º 24
0
 * $bootstrap = new \Magento\Framework\App\Bootstrap(BP, $_SERVER, $extra);
 * $app = $bootstrap->createApplication('Magento\Framework\App\Http');
 * $bootstrap->run($app);
 * --------------------------------------------
 *
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER, null);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\\Framework\\App\\Http');
$bootstrap->run($app);
Exemplo n.º 25
0
<?php

/**
 * Public alias for the application entry point
 *
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Filesystem\DirectoryList;
try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
    <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
        <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
        Autoload error</h3>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}
$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']];
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Magento\\Framework\\App\\Http');
$bootstrap->run($app);
Exemplo n.º 26
0
 /**
  * Handle for any other errors
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleGenericReport(Bootstrap $bootstrap, \Exception $exception)
 {
     $reportData = array($exception->getMessage(), $exception->getTraceAsString());
     $params = $bootstrap->getParams();
     if (isset($params['REQUEST_URI'])) {
         $reportData['url'] = $params['REQUEST_URI'];
     }
     if (isset($params['SCRIPT_NAME'])) {
         $reportData['script_name'] = $params['SCRIPT_NAME'];
     }
     require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php';
     return true;
 }
Exemplo n.º 27
0
 $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
Exemplo n.º 28
0
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\State;
use Magento\Framework\Shell\ComplexParameter;
require_once __DIR__ . '/../../../../../app/bootstrap.php';
$usage = 'Usage: php -f install.php -- --admin_username= [--bootstrap=]
    --admin_username - store\'s admin username. Required for installation.
    [--bootstrap] - add or override parameters of the bootstrap' . PHP_EOL;
$data = getopt('', ['admin_username:'******'bootstrap::']);
if (!isset($data['admin_username']) || empty($data['admin_username'])) {
    echo $usage;
    exit(1);
}
$bootstrapParam = new ComplexParameter('bootstrap');
$params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
$params[State::PARAM_MODE] = State::MODE_DEVELOPER;
$bootstrap = Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\\Tools\\SampleData\\InstallerApp', ['data' => $data]);
$bootstrap->run($app);
Exemplo n.º 29
0
 /**
  * @expectedException \BadMethodCallException
  * @expectedExceptionMessage Magento\Framework\App\Test\Unit\ObjectManager\FactoryStub::__construct
  */
 public function testCreateObjectManagerFactoryCouldBeOverridden()
 {
     $rootPath = __DIR__ . '/_files/';
     $factory = Bootstrap::createObjectManagerFactory($rootPath, []);
     $factory->create([], false);
 }
Exemplo n.º 30
0
 /**
  * @return void
  */
 protected function _initMagento2()
 {
     require_once $this->getMagentoRootFolder() . '/app/bootstrap.php';
     $params = $_SERVER;
     $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'admin';
     $params[\Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM] = true;
     $params['entryPoint'] = basename(__FILE__);
     $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
     /** @var \Magento\Framework\App\Cron $app */
     $app = $bootstrap->createApplication('N98\\Magento\\Framework\\App\\Magerun', []);
     /* @var $app \N98\Magento\Framework\App\Magerun */
     $app->launch();
     $this->_objectManager = $app->getObjectManager();
 }