mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 16:44:11 +03:00
Make *Processor handles Symfony requests
This commit is contained in:
parent
8b1b38dddc
commit
730dd2f2df
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 "<eventPrefix>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);
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user