diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-08-25 00:13:30 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-08-25 00:13:30 +0200 |
commit | 50c4e21adc188c73dd9c33fdae52639469c92257 (patch) | |
tree | 9f1c87d67578ef3b007a2efdc163a9949140231c /include | |
parent | b8a14d96c06d5a8910cb28d28870f0036ae6a461 (diff) |
{auto} requests are added as objects
Diffstat (limited to 'include')
-rw-r--r-- | include/extension.h | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/include/extension.h b/include/extension.h index 3a852ac..eb7eb4c 100644 --- a/include/extension.h +++ b/include/extension.h @@ -10,6 +10,9 @@ * request is handled by an extension instance, but for others (when PHP runs * as module in a webserver) many requests are handled by the same extension * instance. + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2013 Copernica BV */ /** @@ -72,8 +75,67 @@ public: } /** + * Create a new request + * + * You can override this method if you've created your own request class, + * and you'd like to use an instance of that class instead. The returned + * object must have been created on the heap. + * + * @return Request* + */ + virtual Request *request() + { + return new Request(this); + } + + /** + * Start a request + * + * This method is called when the zend engine is about to start a new + * request. Internally, it calls the request() method to instantiate + * a new request object, and after that it initializes the request. + * + * @return boolean + */ + bool startRequest() + { + // failure if we already have a request + if (_request) return false; + + // create the request + _request = request(); + + // and initialize it + return _request->initialize(); + } + + /** + * End a request + * + * This method is called when the Zend engine is ready with a request. + * Internally, it destructs the request + * + * @return boolean + */ + bool endRequest() + { + // request must exist + if (!_request) return false; + + // finalize the request + bool result = _request->finalize(); + + // destruct the request object + delete _request; + + // done + return result; + } + + /** * Internal method to get access to the entry * @return zend_module_entry + * @internal */ _zend_module_entry *entry(); @@ -96,7 +158,11 @@ private: */ _zend_module_entry *_entry; - + /** + * The current request being processed + * @var Request + */ + Request *_request; }; |