[CORE][Controller] Add default handler for when using http methods
This commit is contained in:
parent
2f7fdf6ee4
commit
259d2da05a
|
@ -51,7 +51,7 @@ class OEmbed extends Controller
|
|||
/**
|
||||
* Handle OEmbed server requests
|
||||
*/
|
||||
protected function handle(Request $request)
|
||||
public function handle(Request $request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// $url = $this->trimmed('url');
|
||||
|
|
|
@ -81,9 +81,9 @@ abstract class Controller extends AbstractController implements EventSubscriberI
|
|||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$class = static::class;
|
||||
$method = 'on' . ucfirst(mb_strtolower($request->getMethod()));
|
||||
$attributes = array_diff_key($request->attributes->get('_route_params'), array_flip(['_format', '_fragment', '_locale', 'template', 'accept', 'is_system_path']));
|
||||
$class = static::class;
|
||||
$method = 'on' . ucfirst(mb_strtolower($request->getMethod()));
|
||||
$attributes = array_diff_key($request->attributes->get('_route_params'), array_flip(['_format', '_fragment', '_locale', 'template', 'accept', 'is_system_path']));
|
||||
if (method_exists($class, $method)) {
|
||||
return $this->{$method}($request, ...$attributes);
|
||||
}
|
||||
|
@ -91,6 +91,18 @@ abstract class Controller extends AbstractController implements EventSubscriberI
|
|||
return $this->handle($request, ...$attributes);
|
||||
}
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$class = static::class;
|
||||
$method = 'on' . ucfirst(mb_strtolower($request->getMethod()));
|
||||
if (method_exists($class, $method)) {
|
||||
return $this->{$method}($request);
|
||||
}
|
||||
|
||||
$attributes = array_diff_key($request->attributes->get('_route_params'), array_flip(['_format', '_fragment', '_locale', 'template', 'accept', 'is_system_path']));
|
||||
return $this->handle($request, ...$attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Symfony event when it's searching for which controller to use
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user