Esempio n. 1
0
 /**
  * Collects views defined by modules.
  *
  * After the views defined by modules have been collected {@link Collection\CollectEvent} is
  * fired.
  *
  * @param Core $app
  *
  * @return array[string]array
  *
  * @throws \UnexpectedValueException when the {@link ViewOptions::TITLE},
  * {@link ViewOptions::TYPE}, {@link ViewOptions::MODULE} or {@link ViewOptions::RENDERS}
  * properties are empty.
  */
 protected function collect(Core $app)
 {
     static $required = [ViewOptions::TITLE, ViewOptions::TYPE, ViewOptions::MODULE, ViewOptions::RENDERS];
     $collection = $app->configs['views'];
     new Collection\CollectEvent($this, $collection);
     foreach ($collection as $id => &$definition) {
         $definition = ViewOptions::normalize($definition);
         foreach ($required as $property) {
             if (empty($definition[$property])) {
                 throw new \UnexpectedValueException(\ICanBoogie\format('%property is empty for the view %id.', ['property' => $property, 'id' => $id]));
             }
         }
     }
     return $collection;
 }
 /**
  * Unwind modules into views.
  *
  * @param array $modules
  *
  * @return array
  */
 protected function unwind_views(array $modules)
 {
     $views = [];
     foreach ($modules as $module_id => $module) {
         foreach ($module as $view_id => $options) {
             $views["{$module_id}/{$view_id}"] = Options::normalize($options + [Options::MODULE => $module_id, Options::TYPE => $view_id]);
         }
     }
     return $views;
 }