Ejemplo n.º 1
0
 public static function synthesize_dispatchers_config(array $fragments)
 {
     $config_array = [];
     foreach ($fragments as $fragment) {
         if (empty($fragment['dispatchers'])) {
             continue;
         }
         $config_array[] = $fragment['dispatchers'];
     }
     $config = call_user_func_array('array_merge', $config_array);
     #
     # Normalizing
     #
     array_walk($config, function (&$config) {
         if (is_string($config)) {
             $config = [DispatcherConfig::CONSTRUCTOR => $config];
         }
         $config += [DispatcherConfig::WEIGHT => 0];
     });
     #
     # Ordering
     #
     return \ICanBoogie\sort_by_weight($config, function ($config) {
         return $config[DispatcherConfig::WEIGHT];
     });
 }
Ejemplo n.º 2
0
 /**
  * Returns the collected assets as an array of URL.
  *
  * @return array
  */
 public function get()
 {
     $sorted = \ICanBoogie\sort_by_weight($this->collected, function ($v) {
         return $v;
     });
     return array_keys($sorted);
 }
Ejemplo n.º 3
0
 /**
  * Resolve group definitions into {@link Element} instances and sort them according to their
  * {@link WEIGHT}.
  *
  * @param array $groups
  *
  * @return Element[]
  */
 protected function resolve_groups(array $groups)
 {
     foreach ($groups as $group_id => &$group) {
         $group = $this->resolve_group($group);
         if ($group_id && !is_numeric($group_id)) {
             $group->add_class('group--' . \Brickrouge\normalize($group_id));
         }
     }
     return \ICanBoogie\sort_by_weight($groups, function ($v) {
         return $v[self::WEIGHT];
     });
 }
Ejemplo n.º 4
0
 /**
  * Synthesizes the `users_permission_resolver_list` config from `users` fragments.
  *
  * @param array $fragments
  *
  * @return array
  */
 public static function synthesize_config(array $fragments)
 {
     $list = [];
     $weight = [];
     foreach ($fragments as $fragment) {
         if (empty($fragment['permission_resolver_list'])) {
             continue;
         }
         foreach ($fragment['permission_resolver_list'] as $resolver_id => $resolver) {
             $resolver = (array) $resolver + ['weight' => 0];
             $list[$resolver_id] = $resolver[0];
             $weight[$resolver_id] = $resolver['weight'];
         }
     }
     return \ICanBoogie\sort_by_weight($list, function ($v, $k) use($weight) {
         return $weight[$k];
     });
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function getIterator()
 {
     if (!$this->dispatchers_order) {
         $weights = $this->dispatchers_weight;
         $this->dispatchers_order = \ICanBoogie\sort_by_weight($this->dispatchers, function ($v, $k) use($weights) {
             return $weights[$k];
         });
     }
     return new \ArrayIterator($this->dispatchers_order);
 }