Browse Source

Add direct reference to request instance in component.

Closes #6014
ADmad 11 years ago
parent
commit
fec1aacb03
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/Controller/Component.php

+ 12 - 1
src/Controller/Component.php

@@ -63,9 +63,16 @@ class Component implements EventListenerInterface
     use LogTrait;
 
     /**
+     * Request object
+     *
+     * @var \Cake\Network\Request
+     */
+    public $request;
+
+    /**
      * Component registry class used to lazy load components.
      *
-     * @var ComponentRegistry
+     * @var \Cake\Controller\ComponentRegistry
      */
     protected $_registry;
 
@@ -101,6 +108,10 @@ class Component implements EventListenerInterface
     public function __construct(ComponentRegistry $registry, array $config = [])
     {
         $this->_registry = $registry;
+        $controller = $registry->getController();
+        if ($controller) {
+            $this->request = $controller->request;
+        }
 
         $this->config($config);