/** * @param \Pimple $pimple */ public function setup(\Pimple $pimple) { $me = $this; $pimple['db'] = function () use($me) { $conn = Utils::getConnection(SW_PATH); return $conn; }; $pimple['filesystem.factory'] = function () use($me) { $updateConfig = $me->getParameter('update.config'); $ftp = isset($updateConfig['ftp_credentials']) ? $updateConfig['ftp_credentials'] : array(); return new FilesystemFactory(SW_PATH, $ftp); }; $pimple['path.builder'] = function () use($me) { $baseDir = SW_PATH; $updateDir = UPDATE_FILES_PATH; $backupDir = SW_PATH . '/files/backup'; return new PathBuilder($baseDir, $updateDir, $backupDir); }; $pimple['migration.manager'] = function () use($me) { $migrationPath = UPDATE_ASSET_PATH . '/migrations/'; $db = $me->get('db'); $migrationManger = new MigrationManager($db, $migrationPath); return $migrationManger; }; $pimple['dump'] = function () use($me) { $snippetsSql = UPDATE_ASSET_PATH . '/snippets.sql'; $snippetsSql = file_exists($snippetsSql) ? $snippetsSql : null; if (!$snippetsSql) { return null; } return new Dump($snippetsSql); }; $pimple['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; }; $pimple['controller.batch'] = function () use($me) { return new BatchController($me->get('slim.request'), $me->get('slim.response'), $me); }; }
/** * @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; }; }