gollumsf / controller-action-extractor-bundle
Extract controller class and action method
Installs: 1 021
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.2
- symfony/http-foundation: ^4.4|^5|^6
- symfony/http-kernel: ^4.4|^5|^6
- symfony/routing: ^4.4|^5|^6
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-29 23:10:50 UTC
README
Extract controller class and action method from Request or Route
Installation:
composer require gollumsf/controller-action-extractor-bundle
config/bundles.php
return [ // [ ... ] GollumSF\RestBundle\ControllerActionExtractorBundle::class => ['all' => true], ];
Usage
use GollumSF\ControllerActionExtractorBundle\Extractor\ControllerActionExtractorInterface; public function (ControllerActionExtractorInterface $extractor) { // Inject service // Get $route from router $controllerAction = $extractor->extractFromRoute($route); // Get $request $controllerAction = $extractor->extractFromRequest($request); // Get $request $controllerAction = $extractor->extractFromString('Controller::action'); $controllerClass = $controllerAction->getControllerClass(); // Return controller class $actionMethod = $controllerAction->getActionMethod(); // Return action method }