Пример #1
0
 /**
  * Add one or multiple routes
  *
  * @param  string
  * @param  string|array|Route  either the translation for $path, an array for verb routing or an instance of Route
  * @param  bool                whether to prepend the route(s) to the routes array
  */
 public static function add($path, $options = null, $prepend = false, $case_sensitive = null)
 {
     if (is_array($path)) {
         // Reverse to keep correct order in prepending
         $prepend and $path = array_reverse($path, true);
         foreach ($path as $p => $t) {
             static::add($p, $t, $prepend);
         }
         return;
     } elseif ($options instanceof Route) {
         static::$routes[$path] = $options;
         return;
     }
     $name = $path;
     if (is_array($options) and array_key_exists('name', $options)) {
         $name = $options['name'];
         unset($options['name']);
         if (count($options) == 1 and !is_array($options[0])) {
             $options = $options[0];
         }
     }
     if ($prepend) {
         \Arr::prepend(static::$routes, $name, new \Route($path, $options, $case_sensitive));
         return;
     }
     static::$routes[$name] = new \Route($path, $options, $case_sensitive);
 }
Пример #2
0
 /**
  * Push an item onto the beginning of the collection.
  *
  * @param  mixed  $value
  * @param  mixed  $key
  * @return $this
  */
 public function prepend($value, $key = null)
 {
     $this->items = Arr::prepend($this->items, $value, $key);
     return $this;
 }
Пример #3
0
 /**
  * Tests Arr::prepend()
  *
  * @test
  */
 public function test_prepend_array()
 {
     $arr = array('two' => 2, 'three' => 3);
     $expected = array('one' => 1, 'two' => 2, 'three' => 3);
     Arr::prepend($arr, array('one' => 1));
     $this->assertEquals($expected, $arr);
 }
 /**
  * Prepend an user row.
  * 
  * @access public
  * @param mixed $title
  * @param mixed $callback
  * @return void
  */
 public function prepend($title, $callback, $ukey = null)
 {
     $this->prepare_insert($callback, $ukey);
     \Arr::prepend($this->properties, $ukey, $title);
     return $this;
 }