From 50c4e21adc188c73dd9c33fdae52639469c92257 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 25 Aug 2013 00:13:30 +0200 Subject: {auto} requests are added as objects --- include/extension.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'include/extension.h') 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 + * @copyright 2013 Copernica BV */ /** @@ -71,9 +74,68 @@ public: return true; } + /** + * 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; }; -- cgit v1.2.3