コード例 #1
0
 /**
  * Interpret the $resource and retrieve from it parameters witch the implementation is interested in.
  *
  * @param ResourceInterface $resource
  * @return void
  */
 public function interpret(ResourceInterface $resource)
 {
     $url = $resource->getUrl();
     $query = parse_url($url, PHP_URL_QUERY);
     if (!$query) {
         return;
     }
     // Do the magick
     parse_str($query, $data);
     foreach ((array) $data as $name => $value) {
         $param = new GenericParam();
         $param->setName($name);
         $param->setValue($value);
         $this->set($param);
     }
 }
コード例 #2
0
 /**
  * Interpret the $resource and retrieve from it parameters witch the implementation is interested in.
  *
  * @param ResourceInterface $resource
  * @return void
  */
 public function interpret(ResourceInterface $resource)
 {
     $url = $resource->getUrl();
     $path = parse_url($url, PHP_URL_PATH);
     if (!$path) {
         // TODO: Should throw exception ?
         return;
     }
     $self = $this;
     preg_replace_callback(self::PARAM_REGEXP, function ($matches) use($self) {
         $param = new GenericParam();
         $param->setName($matches['name']);
         $self->set($param);
         // make cleaner param
         return '<' . $param->getName() . '>';
     }, $path);
 }
コード例 #3
0
 protected function parseGeneral($general)
 {
     if (!is_array($general)) {
         return;
     }
     $general = array_intersect_key($general, $this->allowedGeneralKeys);
     foreach ($general as $namespace => $data) {
         switch ($namespace) {
             case 'params':
                 foreach ((array) $data as $name => $options) {
                     $param = new GenericParam();
                     $param->setName($name);
                     $param->setOptions($options);
                     $this->generalParams->set($param);
                 }
                 break;
         }
     }
 }