예제 #1
0
 public function register(Application $app)
 {
     parent::register($app);
     $config = $app['config'];
     $app['handlebars'] = $app->share(function ($app) use($config) {
         $templatePathConfigPath = 'template.handlebars.path';
         if (!Arr::path($config, $templatePathConfigPath)) {
             Arr::setPath($config, $templatePathConfigPath, APP_PATH . '/templates');
         }
         return new Handlebars(['loader' => new FilesystemLoader(Arr::path($config, $templatePathConfigPath), ['extension' => '.hbs']), 'partials_loader' => new FilesystemLoader(Arr::path($config, $templatePathConfigPath), ['prefix' => '_'])]);
     });
     $app['config'] = $config;
 }
예제 #2
0
파일: Arr.php 프로젝트: apitude/apitude
 /**
  * Convert a multi-dimensional array into a single-dimensional array.
  *
  *     $array = array('set' => array('one' => 'something'), 'two' => 'other');
  *
  *     // Flatten the array
  *     $array = Arr::flatten($array);
  *
  *     // The array will now be
  *     array('one' => 'something', 'two' => 'other');
  *
  * [!!] The keys of array values will be discarded.
  *
  * @param  array $array array to flatten
  * @return array
  *                     @since   3.0.6
  */
 public static function flatten($array)
 {
     $is_assoc = Arr::isAssoc($array);
     $flat = [];
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $flat = array_merge($flat, Arr::flatten($value));
         } else {
             if ($is_assoc) {
                 $flat[$key] = $value;
             } else {
                 $flat[] = $value;
             }
         }
     }
     return $flat;
 }