Example #1
0
 function _parseConfigFile()
 {
     $config_file = $this->configFile();
     if ($config_file && file_exists($config_file)) {
         $this->yaml = Yaml::Parse(file_get_contents($config_file));
     }
 }
Example #2
0
 private function setConfig()
 {
     $all_configurations = Yaml::Parse(file_get_contents($_SERVER['DOCUMENT_ROOT'] . $this->contextData['bundleRoot'] . '/configuration.yml'));
     $this->configuration = $all_configurations[$this->editorName];
     $this->blockTypes = $this->configuration['block_types'];
     $this->customParams = $this->configuration['custom'];
     $this->formParams = $this->configuration['form'];
     $this->templatesDirectory = $this->configuration['templates']['directory'];
     $this->templatesFormat = $this->configuration['templates']['format'];
 }
Example #3
0
 public function enable(\Eccube\Entity\Plugin $plugin, $enable = true)
 {
     $pluginDir = $this->calcPluginDir($plugin->getCode());
     $em = $this->app['orm.em'];
     $plugin->setEnable($enable ? Constant::ENABLED : Constant::DISABLED);
     $em->persist($plugin);
     $em->flush();
     $this->callPluginManagerMethod(Yaml::Parse($pluginDir . '/' . self::CONFIG_YML), $enable ? 'enable' : 'disable');
     return true;
 }
Example #4
0
 public function loadPlugin()
 {
     // プラグインディレクトリを探索.
     $basePath = __DIR__ . '/../../app/Plugin';
     $finder = Finder::create()->in($basePath)->directories()->depth(0);
     $finder->sortByName();
     // ハンドラ優先順位をdbから持ってきてハッシュテーブルを作成
     $priorities = array();
     $handlers = $this['orm.em']->getRepository('Eccube\\Entity\\PluginEventHandler')->getHandlers();
     foreach ($handlers as $handler) {
         if ($handler->getPlugin()->getEnable() && !$handler->getPlugin()->getDelFlg()) {
             $priority = $handler->getPriority();
         } else {
             // Pluginがdisable、削除済みの場合、EventHandlerのPriorityを全て0とみなす
             $priority = \Eccube\Entity\PluginEventHandler::EVENT_PRIORITY_DISABLED;
         }
         $priorities[$handler->getPlugin()->getClassName()][$handler->getEvent()][$handler->getHandler()] = $priority;
     }
     // プラグインをロードする.
     // config.yml/event.ymlの定義に沿ってインスタンスの生成を行い, イベント設定を行う.
     foreach ($finder as $dir) {
         //config.ymlのないディレクトリは無視する
         if (!file_exists($dir->getRealPath() . '/config.yml')) {
             continue;
         }
         $config = Yaml::parse($dir->getRealPath() . '/config.yml');
         $plugin = $this['orm.em']->getRepository('Eccube\\Entity\\Plugin')->findOneBy(array('code' => $config['code']));
         // const
         if (isset($config['const'])) {
             $this['config'] = $this->share($this->extend('config', function ($eccubeConfig) use($config) {
                 $eccubeConfig[$config['code']] = array('const' => $config['const']);
                 return $eccubeConfig;
             }));
         }
         if ($plugin && $plugin->getEnable() == Constant::DISABLED) {
             // プラグインが無効化されていれば読み込まない
             continue;
         }
         // Type: Event
         if (isset($config['event'])) {
             $class = '\\Plugin\\' . $config['code'] . '\\' . $config['event'];
             $subscriber = new $class($this);
             if (file_exists($dir->getRealPath() . '/event.yml')) {
                 foreach (Yaml::Parse($dir->getRealPath() . '/event.yml') as $event => $handlers) {
                     foreach ($handlers as $handler) {
                         if (!isset($priorities[$config['event']][$event][$handler[0]])) {
                             // ハンドラテーブルに登録されていない(ソースにしか記述されていない)ハンドラは一番後ろにする
                             $priority = \Eccube\Entity\PluginEventHandler::EVENT_PRIORITY_LATEST;
                         } else {
                             $priority = $priorities[$config['event']][$event][$handler[0]];
                         }
                         // 優先度が0のプラグインは登録しない
                         if (\Eccube\Entity\PluginEventHandler::EVENT_PRIORITY_DISABLED != $priority) {
                             $this['eccube.event.dispatcher']->addListener($event, array($subscriber, $handler[0]), $priority);
                         }
                     }
                 }
             }
         }
         // Type: ServiceProvider
         if (isset($config['service'])) {
             foreach ($config['service'] as $service) {
                 $class = '\\Plugin\\' . $config['code'] . '\\ServiceProvider\\' . $service;
                 $this->register(new $class($this));
             }
         }
     }
 }
Example #5
0
 /**
  * @return mixed
  */
 protected function getYamlParameters()
 {
     $configFile = $this->getParametersPath();
     $parameters = Yaml::Parse(file_get_contents($configFile));
     return $parameters['parameters'];
 }
Example #6
0
 private function createConfigYamlFile($data)
 {
     $fs = new Filesystem();
     $config_file = $this->config_path . '/config.yml';
     if ($fs->exists($config_file)) {
         $fs->remove($config_file);
     }
     $auth_magic = Str::random(32);
     $allowHost = Str::convertLineFeed($data['admin_allow_hosts']);
     if (empty($allowHost)) {
         $adminAllowHosts = array();
     } else {
         $adminAllowHosts = explode("\n", $allowHost);
     }
     $target = array('${AUTH_MAGIC}', '${SHOP_NAME}', '${ECCUBE_INSTALL}', '${FORCE_SSL}');
     $replace = array($auth_magic, $data['shop_name'], '0', $data['admin_force_ssl']);
     $fs = new Filesystem();
     $content = str_replace($target, $replace, file_get_contents($this->dist_path . '/config.yml.dist'));
     $fs->dumpFile($config_file, $content);
     $config = Yaml::Parse($config_file);
     $config['admin_allow_host'] = $adminAllowHosts;
     $yml = Yaml::dump($config);
     file_put_contents($config_file, $yml);
     return $this;
 }
Example #7
0
 public function enable(\Eccube\Entity\Plugin $plugin, $enable = true)
 {
     $em = $this->app['orm.em'];
     try {
         $pluginDir = $this->calcPluginDir($plugin->getCode());
         $em->getConnection()->beginTransaction();
         $plugin->setEnable($enable ? Constant::ENABLED : Constant::DISABLED);
         $em->persist($plugin);
         $this->callPluginManagerMethod(Yaml::Parse($pluginDir . '/' . self::CONFIG_YML), $enable ? 'enable' : 'disable');
         $em->flush();
         $em->getConnection()->commit();
     } catch (\Exception $e) {
         $em->getConnection()->rollback();
         throw $e;
     }
     return true;
 }
Example #8
0
 public function readYml($yml)
 {
     return Yaml::Parse($yml);
 }