コード例 #1
0
 /**
  * Retrieve an option (using dots separator for iterative search)
  * 
  * @example $this->getOption('parameters.config.captcha.apikey')
  *
  * @param  string $key
  * @param  mixed  $default
  * @return mixed
  */
 public function getOption($key, $default = null)
 {
     // Root search like parent class
     $key = explode('.', $key);
     $k = array_shift($key);
     $opt = parent::getOption($k);
     // Iterative search
     foreach ($key as $k) {
         if (!isset($opt[$k])) {
             return $default;
         }
         $opt = $opt[$k];
     }
     return $opt !== null ? $opt : $default;
 }