load() public method

Reads configuration from NEON file.
public load ( $file ) : array
return array
示例#1
0
 /**
  * @return mixed
  */
 protected function loadConfig()
 {
     $this->data = $this->adapter->load($this->fileName);
     $data = $this->data;
     foreach ($this->root as $item) {
         $data = isset($data[$item]) ? $data[$item] : array();
     }
     return $data;
 }
示例#2
0
 public function startup()
 {
     $this->template = $this->getTemplate();
     $this->template->setFile(dirname(__FILE__) . '/Classgen.latte');
     $this->template->phpTag = "<?php";
     $neon = new NeonAdapter();
     $this->data = $neon->load(dirname(__FILE__) . '/config.neon');
 }
示例#3
0
 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->validateConfig($this->defaults);
     // Add themes
     $params = [];
     $neon = new NeonAdapter();
     foreach (Finder::findFiles('theme.neon')->limitDepth(2)->from($config['themes']) as $file => $splfile) {
         // Parse config
         $expandConfig = ['themeDir' => dirname($splfile->getRealPath())];
         $themeConfig = Helpers::expand($neon->load($file), $expandConfig, TRUE);
         // Validate theme configs
         $this->validateConfig($this->themeDefaults, $themeConfig, 'themes');
         $this->validateConfig($this->themeDefaults['theme'], $themeConfig['theme'], 'theme');
         // Parse theme name
         $themeName = strtolower($themeConfig['theme']['name']);
         // Check duplicity
         if (array_key_exists($themeName, $params)) {
             throw new InvalidStateException('Theme "' . $themeName . '" is already defined.');
         }
         // Add to array
         $params[$themeName] = $themeConfig;
     }
     // Check if selected template is not null
     Validators::assertField($params, $config['theme'], NULL, 'template "%s"');
     $theme = $params[$config['theme']];
     // Add parameters to global parameters
     $builder->parameters['themes'] = [];
     $builder->parameters['themes']['theme'] = $theme['theme'];
     $builder->parameters['themes']['vars'] = $config['template'];
     $builder->parameters['themes']['output'] = $config['output'];
     // Add template model to container
     Compiler::parseServices($builder, ['services' => $theme['model']], $this->prefix('model'));
     // Add command manager (fake presenter)
     $builder->addDefinition($this->prefix('ui.manager'))->setClass('Generator\\UI\\CommandManager');
     // Add template factory
     $builder->addDefinition($this->prefix('latte.templateFactory'))->setClass('Generator\\Latte\\TemplateFactory')->setAutowired();
     // Add commands
     $builder->addDefinition($this->prefix('commands.info'))->setClass('Generator\\Commands\\InfoCommand')->setInject();
     $builder->addDefinition($this->prefix('commands.generate'))->setClass('Generator\\Commands\\GenerateCommand', [$builder->parameters['themes']])->setInject();
     $builder->addDefinition($this->prefix('commands.deploy'))->setClass('Generator\\Commands\\DeployCommand')->setInject();
     $builder->addDefinition($this->prefix('commands.error'))->setClass('Generator\\Commands\\ErrorCommand')->setInject();
 }
 /**
  * @param array $files
  * @throws InvalidStateException
  * @return array
  */
 protected function parsePosts($files)
 {
     $posts = [];
     $postsIds = [];
     $decoder = new NeonAdapter();
     foreach ($files as $file) {
         // Decode file
         $config = $decoder->load($file);
         // Merge
         $post = Config\Helpers::merge($config, $this->scheme);
         // Check unique post id
         if (in_array($post['id'], $postsIds)) {
             throw new InvalidStateException('Duplicate post.id "' . $post['id'] . '"');
         }
         // Expand post scheme
         $post = Helpers::expand($post, ['file' => dirname($file)], TRUE);
         // Unify
         $post['post'] = realpath($post['post']);
         $posts[] = $post;
         $postsIds[] = $post['id'];
     }
     return $posts;
 }
示例#5
0
 public function load()
 {
     $this->data = ArrayHash::from($this->adapter->load($this->fileName), true);
 }