gollumsf/controller-action-extractor-bundle

Extract controller class and action method

v1.0.2 2022-04-04 00:34 UTC

This package is auto-updated.

Last update: 2024-11-29 23:18:08 UTC


README

Build Status Build Status Build Status

Coverage License Latest Stable Version Latest Unstable Version Discord

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
    
}