protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->_collections = $this->get('routes');
     $parents = array();
     foreach ($this->_collections as $collectionName => $collection) {
         $parents[$collectionName] = $collection->getParent();
     }
     $tree = Iterable::toTree($parents);
     $output->writeln('<info>Found ' . count($parents) . ' registered route collections.</info>');
     $output->writeln('');
     $output->writeln('<bold>ROOT</bold>');
     $this->_printTree($output, $tree);
     $output->writeln('');
 }
Example #2
0
 /**
  * Compile the configuration sets that have been set on this instance in the
  * order they were added, and return the compiled configuration set as an
  * instance of `Group`.
  *
  * @see _stack
  *
  * @return Group     The compiled configuration set
  *
  * @throws Exception If no data sets have been added to be compiled
  * @throws Exception If YAML parsing throws a ParseException
  * @throws Exception If YAML parsed result is not an array
  */
 public function compile()
 {
     if (empty($this->_dataSets)) {
         throw new Exception('Cannot compile configuration: there\'s nothing to compile');
     }
     $compiled = array();
     foreach ($this->_dataSets as $data) {
         try {
             $parsed = Yaml::parse($data, true);
         } catch (YamlParseException $e) {
             throw new Exception(sprintf('Cannot compile configuration: YAML parsing failed with message `%s`', $e->getMessage()), null, $e);
         }
         // Yaml::parse returns null if the file has nothing to parse in it
         // (e.g. empty file or just comments etc.)
         if (is_null($parsed)) {
             continue;
         }
         if (!is_array($parsed)) {
             throw new Exception(sprintf('Cannot compile configuration: parsed result was not an array for YAML `%s`', $data));
         }
         $compiled = $this->_stack($compiled, $parsed);
     }
     return Iterable::toObject($compiled, true, 'Message\\Cog\\Config\\Group');
 }
Example #3
0
 /**
  * Gets the parent collection names for each route collection.
  *
  * @return array An array where the key is the collection name and the
  *               value is an array of the parent collection names.
  */
 protected function _getCollectionHierarchy()
 {
     $parents = array();
     foreach ($this as $collectionName => $collection) {
         $parents[$collectionName] = $collection->getParent();
     }
     $tree = Iterable::toTree($parents);
     $keys = Iterable::arrayKeysMultidimensional($tree);
     $result = array();
     foreach ($keys as $key) {
         $result[$key] = array_merge((array) Iterable::getParentsFromKey($key, $tree), array($key));
     }
     return $result;
 }