Exemple #1
0
 /**
  * Run application
  *
  * @param string $applicationName
  * @param array $arguments
  * @return void
  */
 public function run($applicationName, array $arguments = array())
 {
     try {
         \Magento\Framework\Profiler::start('magento');
         if (!$this->_locator) {
             $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory();
             $this->_locator = $locatorFactory->create($this->_rootDir, $this->_parameters);
         }
         $application = $this->_locator->create($applicationName, $arguments);
         $response = $application->launch();
         \Magento\Framework\Profiler::stop('magento');
         $response->sendResponse();
     } catch (\Exception $exception) {
         if (isset($this->_parameters[State::PARAM_MODE]) && $this->_parameters[State::PARAM_MODE] == State::MODE_DEVELOPER) {
             echo $exception->getMessage() . "\n\n";
             echo $exception->getTraceAsString();
         } else {
             $message = "Error happened during application run.\n";
             try {
                 if (!$this->_locator) {
                     throw new \DomainException();
                 }
                 $this->_locator->get('Magento\\Framework\\Logger')->logException($exception);
             } catch (\Exception $e) {
                 $message .= "Could not write error message to log. Please use developer mode to see the message.\n";
             }
             echo $message;
         }
     }
 }
Exemple #2
0
 /**
  * Create Processor
  *
  * @return Processor
  */
 public function createProcessor()
 {
     $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory();
     $locator = $locatorFactory->create(BP, $_SERVER);
     $response = $locator->create('\\Magento\\Framework\\App\\Response\\Http');
     return new Processor($response);
 }
Exemple #3
0
 * 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)
 */
umask(0);
$mtfRoot = dirname(dirname(__FILE__));
$mtfRoot = str_replace('\\', '/', $mtfRoot);
define('MTF_BP', $mtfRoot);
define('MTF_TESTS_PATH', MTF_BP . '/tests/app/');
$path = get_include_path();
$path = rtrim($path, PATH_SEPARATOR);
$path .= PATH_SEPARATOR . MTF_BP . '/lib';
$path .= PATH_SEPARATOR . MTF_BP . '/vendor/magento/mtf';
$path .= PATH_SEPARATOR . MTF_BP . '/vendor/magento/mtf/lib';
set_include_path($path);
$appRoot = dirname(dirname(dirname(dirname(__DIR__))));
require $appRoot . '/app/bootstrap.php';
$objectManagerFactory = new \Magento\Framework\App\ObjectManagerFactory();
$arguments = $_SERVER;
$objectManager = $objectManagerFactory->create(BP, $arguments);
\Mtf\ObjectManagerFactory::configure($objectManager);
$autoloader = new \Magento\Framework\Autoload\IncludePath();
$autoloader->addIncludePath([BP . '/dev/tests/static/framework', realpath(__DIR__ . '/../../..')]);
// parse all options
if (isset($options['help'])) {
    echo USAGE;
    exit(0);
}
$langs = ['en_US'];
if (isset($options['langs'])) {
    $langs = explode(',', $options['langs']);
    foreach ($langs as $lang) {
        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;
}
// run the deployment logic
$filesUtil = new \Magento\TestFramework\Utility\Files(BP);
$omFactory = new \Magento\Framework\App\ObjectManagerFactory();
$objectManager = $omFactory->create(BP, [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT]);
$logger = new \Magento\Tools\View\Deployer\Log($verbosity);
/** @var \Magento\Tools\View\Deployer $deployer */
$deployer = $objectManager->create('Magento\\Tools\\View\\Deployer', ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun]);
$deployer->deploy(BP, $omFactory, $langs);
exit(0);
Exemple #5
0
 /**
  * Get object manager
  *
  * @return \Magento\Framework\ObjectManager\ObjectManager|null
  */
 protected function getObjectManager()
 {
     if (!$this->_objectManager) {
         $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory();
         $this->_objectManager = $locatorFactory->create(BP, $_SERVER);
     }
     return $this->_objectManager;
 }
Exemple #6
0
 /**
  * Get object manager
  *
  * @return \Magento\Framework\ObjectManager
  */
 public function getObjectManager()
 {
     if (!$this->_objectManager) {
         $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory();
         $this->_objectManager = $locatorFactory->create(BP, $_SERVER);
         $this->_objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(self::AREA_CODE);
     }
     return $this->_objectManager;
 }