<?php
namespace App\Listener;
use App\Services\DTV\YamlConfig\YamlReader;
use Exception;
use ReflectionClass;
use ReflectionException;
use RuntimeException;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
/**
* @deprecated
*/
class AclAnnotationListener
{
private YamlReader $yamlReader;
/**
* @throws Exception
*/
public function __construct(
YamlReader $yamlReader
)
{
$this->yamlReader = $yamlReader;
}
/**
* @param ControllerEvent $event
*
* @return void
*/
public function onKernelController( ControllerEvent $event ): void
{
if ( !$event->isMainRequest() ) {
return;
}
$controllers = $event->getController();
if ( !is_array( $controllers ) ) {
return;
}
$this->handleAnnotation( $controllers );
}
/**
* @param iterable $controllers
*
* @return void
*
*/
private function handleAnnotation( iterable $controllers ): void
{
[ $controller, $method ] = $controllers;
try {
$controller = new ReflectionClass( $controller );
}
catch ( ReflectionException $e ) {
throw new RuntimeException( 'Failed to read annotation!' );
}
$this->handleMethodAnnotation( $controller, $method );
}
/**
* @param ReflectionClass $controller
* @param string $method
*
* @return void
*
*/
private function handleMethodAnnotation( ReflectionClass $controller, string $method ): void
{
// Pour éviter les conflits entre l'ancien système et le nouveau
$community = $this->yamlReader->getCommunity();
}
}