CakeRequest::query PHP Méthode

query() public méthode

Provides a read accessor for $this->query. Allows you to use a syntax similar to CakeSession for reading URL query data.
public query ( string $name ) : mixed
$name string Query string variable name
Résultat mixed The value being read
    public function query($name)
    {
        return Hash::get($this->query, $name);
    }

Usage Example

Exemple #1
0
 /**
  * Set output of book content.
  *
  * @access private
  * @return void
  */
 private function setVisibleContent()
 {
     $book = $this->epub;
     $component = $this->cakeRequest->query('comp');
     $callback = function ($m) use($book, $component) {
         $method = $m[1];
         $path = $m[2];
         $end = '';
         if (preg_match('/^src\\s*:/', $method)) {
             $end = ')';
         }
         if (preg_match('/^#/', $path)) {
             return $method . '\'' . $path . '\'' . $end;
         }
         $hash = '';
         if (preg_match('/^(.+)#(.+)$/', $path, $matches)) {
             $path = $matches[1];
             $hash = '#' . $matches[2];
         }
         $comp = $book->getComponentName($component, $path);
         if (!$comp) {
             return $method . '\'#\'' . $end;
         }
         $out = $method . '\'?comp=' . $comp . $hash . '\'' . $end;
         return $end ? $out : str_replace('&', '&', $out);
     };
     $content = preg_replace_callback(array('/(src\\s*:\\s*url\\()(.*?)\\)/', '/(\\@import\\s+)["\'](.*?)["\'];/', '/(href=)["\']([^:]*?)["\']/', '/(src=)["\']([^:]*?)["\']/'), $callback, $book->component($component));
     header('Pragma: public');
     header('Cache-Control: maxage=' . 1209600);
     header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 1209600) . ' GMT');
     header('Content-Type: ' . $book->componentContentType($component));
     print $content;
     exit;
 }
All Usage Examples Of CakeRequest::query