public static function start()
 {
     $kernel = new \Shopware\Kernel('testing', true);
     $kernel->boot();
     $container = $kernel->getContainer();
     $container->get('plugins')->Core()->ErrorHandler()->registerErrorHandler(E_ALL | E_STRICT);
     /** @var $repository \Shopware\Models\Shop\Repository */
     $repository = $container->get('models')->getRepository('Shopware\\Models\\Shop\\Shop');
     $shop = $repository->getActiveDefault();
     $shop->registerResources();
     if (!self::assertPlugin('SwagImportExport')) {
         throw new \Exception("Plugin ImportExport must be installed.");
     }
     Shopware()->Loader()->registerNamespace('SwagImportExport\\Tests', __DIR__ . '/../Tests/');
     Shopware()->Loader()->registerNamespace('Tests\\Helper', __DIR__ . '/Helper/');
     Shopware()->Loader()->registerNamespace('Tests\\Shopware\\ImportExport', __DIR__ . '/Shopware/ImportExport/');
     Shopware()->Loader()->registerNamespace('Shopware\\Setup\\SwagImportExport', __DIR__ . '/../Setup/SwagImportExport/');
     Shopware()->Loader()->registerNamespace('Shopware\\Components', __DIR__ . '/../Components/');
     Shopware()->Loader()->registerNamespace('Shopware\\CustomModels', __DIR__ . '/../Models/');
     self::registerResources();
 }
 /**
  * {@inheritdoc}
  */
 public function register(Container $container)
 {
     $container['config'] = $this->config;
     $container['shopware.version'] = function () {
         $version = trim(file_get_contents(__DIR__ . '/../data/version'));
         return $version;
     };
     $container['slim.app'] = function ($c) {
         $slimOptions = $c['config']['slim'];
         $slim = new \Slim\Slim($slimOptions);
         $slim->contentType('text/html; charset=utf-8');
         $c['slim.request'] = $slim->request();
         $c['slim.response'] = $slim->response();
         return $slim;
     };
     $container['system.locker'] = function ($c) {
         return new SystemLocker(SW_PATH . '/recovery/install/data/install.lock');
     };
     $container['translation.service'] = function ($c) {
         return new TranslationService($c['translations']);
     };
     // dump class contains state so we define it as factory here
     $container['database.dump_iterator'] = $container->factory(function ($c) {
         $dumpFile = __DIR__ . '/../data/sql/install.sql';
         return new DumpIterator($dumpFile);
     });
     // dump class contains state so we define it as factory here
     $container['database.dump_iterator_en_gb'] = $container->factory(function ($c) {
         $dumpFile = __DIR__ . '/../data/sql/en.sql';
         return new DumpIterator($dumpFile);
     });
     // dump class contains state so we define it as factory here
     $container['database.snippet_dump_iterator'] = $container->factory(function ($c) {
         $dumpFile = __DIR__ . '/../data/sql/snippets.sql';
         return new DumpIterator($dumpFile);
     });
     $container['shopware.container'] = function (Container $c) {
         require_once SW_PATH . '/autoload.php';
         $kernel = new \Shopware\Kernel('production', false);
         $kernel->boot();
         $container = $kernel->getContainer();
         $container->get('models')->generateAttributeModels();
         return $container;
     };
     $container['shopware.theme_installer'] = function ($c) {
         $shopwareContainer = $c['shopware.container'];
         /** @var $themeInstaller \Shopware\Components\Theme\Installer */
         $themeInstaller = $shopwareContainer->get('theme_installer');
         return $themeInstaller;
     };
     $container['http-client'] = function ($c) {
         return new CurlClient();
     };
     $container['theme.service'] = function ($c) {
         return new ThemeService($c['db'], $c['shopware.theme_installer']);
     };
     $container['install.requirements'] = function ($c) {
         return new Requirements(__DIR__ . '/../data/System.xml');
     };
     $container['install.requirementsPath'] = function ($c) {
         $check = new RequirementsPath(SW_PATH, SW_PATH . '/engine/Shopware/Components/Check/Data/Path.xml');
         $check->addFile('recovery/install/data');
         return $check;
     };
     $container['db'] = function ($c) {
         throw new \RuntimeException("Identifier DB not initialized yet");
     };
     $container['config.writer'] = function ($c) {
         return new ConfigWriter(SW_PATH . '/config.php');
     };
     $container['webserver.check'] = function ($c) {
         return new WebserverCheck($c['config']['check.ping_url'], $c['config']['check.check_url'], $c['config']['check.token.path'], $c['http-client']);
     };
     $container['database.service'] = function ($c) {
         return new DatabaseService($c['db']);
     };
     $container['license.service'] = function ($c) {
         return new LocalLicenseUnpackService();
     };
     $container['license.installer'] = function ($c) {
         return new LicenseInstaller($c['db']);
     };
     $container['menu.helper'] = function ($c) {
         $routes = $c['config']['menu.helper']['routes'];
         return new MenuHelper($c['slim.app'], $c['translation.service'], $routes);
     };
 }
Example #3
0
 /**
  * @param \Pimple\Container $container
  */
 public function setup(\Pimple\Container $container)
 {
     $me = $this;
     $container['shopware.version'] = function () use($me) {
         $version = trim(file_get_contents(UPDATE_ASSET_PATH . '/version'));
         return $version;
     };
     $container['db'] = function () use($me) {
         $conn = Utils::getConnection(SW_PATH);
         return $conn;
     };
     $container['filesystem.factory'] = function () use($me) {
         $updateConfig = $me->getParameter('update.config');
         $ftp = isset($updateConfig['ftp_credentials']) ? $updateConfig['ftp_credentials'] : [];
         return new FilesystemFactory(SW_PATH, $ftp);
     };
     $container['path.builder'] = function () use($me) {
         $baseDir = SW_PATH;
         $updateDir = UPDATE_FILES_PATH;
         $backupDir = SW_PATH . '/files/backup';
         return new PathBuilder($baseDir, $updateDir, $backupDir);
     };
     $container['migration.manager'] = function () use($me) {
         $migrationPath = UPDATE_ASSET_PATH . '/migrations/';
         $db = $me->get('db');
         $migrationManger = new MigrationManager($db, $migrationPath);
         return $migrationManger;
     };
     $container['dump'] = function () use($me) {
         $snippetsSql = UPDATE_ASSET_PATH . '/snippets.sql';
         $snippetsSql = file_exists($snippetsSql) ? $snippetsSql : null;
         if (!$snippetsSql) {
             return null;
         }
         return new DumpIterator($snippetsSql);
     };
     $container['app'] = function () use($me) {
         $slimOptions = $me->getParameter('slim');
         $slim = new \Slim\Slim($slimOptions);
         $me->set('slim.request', $slim->request());
         $me->set('slim.response', $slim->response());
         return $slim;
     };
     $container['http-client'] = function () {
         return new CurlClient();
     };
     $container['store.api'] = function () use($me) {
         return new StoreApi($me->get('http-client'), $me->getParameter('storeapi.endpoint'));
     };
     $container['plugin.check'] = function () use($me) {
         return new PluginCheck($me->get('store.api'), $me->get('db'), $me->get('shopware.version'));
     };
     $container['dummy.plugin.finder'] = function () {
         return new DummyPluginFinder(SW_PATH);
     };
     $container['cleanup.files.finder'] = function () {
         return new CleanupFilesFinder(SW_PATH);
     };
     $container['system.locker'] = function () {
         return new SystemLocker(SW_PATH . '/recovery/install/data/install.lock');
     };
     $container['controller.batch'] = function () use($me) {
         return new BatchController($me->get('slim.request'), $me->get('slim.response'), $me);
     };
     $container['controller.requirements'] = function () use($me) {
         return new RequirementsController($me->get('slim.request'), $me->get('slim.response'), $me, $me->get('app'));
     };
     $container['controller.cleanup'] = function () use($me) {
         return new CleanupController($me->get('slim.request'), $me->get('slim.response'), $me->get('dummy.plugin.finder'), $me->get('cleanup.files.finder'), $me->get('app'), SW_PATH);
     };
     $container['shopware.container'] = function () use($me) {
         require_once SW_PATH . '/autoload.php';
         $kernel = new \Shopware\Kernel('production', false);
         $kernel->boot();
         $container = $kernel->getContainer();
         $container->get('models')->generateAttributeModels();
         return $container;
     };
     $container['shopware.theme_installer'] = function ($c) {
         $shopwareContainer = $c['shopware.container'];
         /** @var $themeInstaller \Shopware\Components\Theme\Installer */
         $themeInstaller = $shopwareContainer->get('theme_installer');
         return $themeInstaller;
     };
 }