diff --git a/src/mibew/libs/classes/Mibew/Controller/Chat/ThreadController.php b/src/mibew/libs/classes/Mibew/Controller/Chat/ThreadController.php index 4833cbc1..f9311937 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Chat/ThreadController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Chat/ThreadController.php @@ -40,7 +40,7 @@ class ThreadController extends AbstractController // TODO: Remove bufferization after *Processor classes will be rewritten // to play nice with symfony request/response objects ob_start(); - $processor->receiveRequest($request->request->get('data')); + $processor->handleRequest($request); $content = ob_get_clean(); return $content; diff --git a/src/mibew/libs/classes/Mibew/Controller/UsersController.php b/src/mibew/libs/classes/Mibew/Controller/UsersController.php index 0c334d83..7fed5052 100644 --- a/src/mibew/libs/classes/Mibew/Controller/UsersController.php +++ b/src/mibew/libs/classes/Mibew/Controller/UsersController.php @@ -94,7 +94,7 @@ class UsersController extends AbstractController // TODO: Remove bufferization after *Processor classes will be rewritten // to play nice with symfony request/response objects ob_start(); - $processor->receiveRequest($request->request->get('data')); + $processor->handleRequest($request); $content = ob_get_clean(); return $content; diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/AbstractProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/AbstractProcessor.php index 01240dcf..75cb2ba5 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/AbstractProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/AbstractProcessor.php @@ -23,6 +23,7 @@ namespace Mibew\RequestProcessor; use Mibew\Database; use Mibew\EventDispatcher; use Mibew\RequestProcessor\Exception\AbstractProcessorException; +use Symfony\Component\HttpFoundation\Request; /** * Implements abstract class for request processing @@ -153,12 +154,13 @@ abstract class AbstractProcessor * On any error function returns only boolean false. To handle error add * listener to the "RequestError" event. * - * @param string $package Encoded package + * @param Request $request The request to handle. * @return boolean true if request processed succussfully or false on * failure */ - public function receiveRequest($package) + public function handleRequest($request) { + $package = $this->extractPackage($request); $dispatcher = EventDispatcher::getInstance(); // Try to handle request try { @@ -593,4 +595,12 @@ abstract class AbstractProcessor * @return \Mibew\API\API */ abstract protected function getMibewAPIInstance(); + + /** + * Extrats a package from an request. + * + * @param Request $request The request to extract package from. + * @return string Encoded package. + */ + abstract protected function extractPackage(Request $request); } diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/ClientSideProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/ClientSideProcessor.php index a7894a39..618010d0 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/ClientSideProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/ClientSideProcessor.php @@ -19,8 +19,8 @@ namespace Mibew\RequestProcessor; -// Import namespaces and classes of the core use Mibew\Database; +use Symfony\Component\HttpFoundation\Request; /** * Base class for all request processors that interact with JavaScript @@ -120,4 +120,15 @@ abstract class ClientSideProcessor extends AbstractProcessor return $result; } + + /** + * Extrats a package from an request. + * + * @param Request $request The request to extract package from. + * @return string Encoded package. + */ + protected function extractPackage(Request $request) + { + return $request->request->get('data'); + } }