Beispiel #1
0
 /**
  * Gets data from both POST and GET. When keys clash the value from POST will
  * be used.
  *
  * @param  string|null $key     Key to fetch, or null to return the full array
  * @param  mixed       $default Default value if the key does not exist
  *
  * @return mixed
  *
  * @since 2.0
  */
 public function input($key = null, $default = null)
 {
     $combined = Arr::merge($this->get, $this->post);
     if (is_null($key)) {
         return $combined;
     }
     return Arr::get($combined, $key, $default);
 }
Beispiel #2
0
 /**
  * @covers Fuel\Common\Arr::merge
  * @expectedException  \InvalidArgumentException
  * @group Common
  */
 public function testMergeException()
 {
     Arr::merge('not-an-array', 'not-an-array');
 }
Beispiel #3
0
 /**
  * Loads a config file
  *
  * @param string              $name
  * @param null|string|boolean $group
  *
  * @return array|null
  */
 public function load($name, $group = null)
 {
     if ($group === true) {
         $group = pathinfo($name, PATHINFO_FILENAME);
     }
     if ($group and $cached = $this->get($group)) {
         return $cached;
     }
     $name = $this->ensureDefaultFormat($name);
     $paths = $this->finder->findAllFiles($name);
     if (empty($paths)) {
         return false;
     }
     $config = array();
     foreach ($paths as $path) {
         $extension = pathinfo($path, PATHINFO_EXTENSION);
         $handler = $this->getHandler($extension);
         $config = Arr::merge($config, $handler->load($path));
     }
     if ($group) {
         $this->set($group, $config);
     } elseif ($group === null) {
         $this->merge($config);
     }
     return $config;
 }