class Controller extends AbstractController
{
public function index(
App\handler\upload\Handler $handler
): Response
{
$handler->handle();
}
}
namespace App\handler\upload;
class Handler
{
public function __construct(
private EntityManagerInterface $em,
private TestClassRepository $testClassRepository
)
{
}
public function handle()
{
}
}
class Controller extends AbstractController
{
public function index(
App\handler\create\Handler $handler
): Response
{
$handler->handle();
}
}
namespace App\handler\create;
class Handler
{
public function __construct(
private EntityManagerInterface $em,
private TestClass2Repository $testClass2Repository
)
{
}
public function handle()
{
}
}
class Controller extends AbstractController
{
public function index(
App\handler\action\Handler $handler
): Response
{
$handler->handle();
}
}
namespace App\handler\action;
class Handler
{
public function handle()
{
$config = [
'type1' => 'App\handler\create\Handler',
'type2' => 'App\handler\upload\Handler',
];
$handler = null;
if ($type === 'type1') {
$handler = $config['type1'];
}
if ($type === 'type2') {
$handler = $config['type2'];
}
if (null !== $handler) {
$handler = new $handler();
$handler->handle();
}
}
}