<?phpnamespace App\Twig;use App\Services\Core\Core;use App\Services\Core\Tools;use App\Services\Core\Users;use App\Services\Cvs;use App\Services\Cvs\AppStoreLinksService;use App\Tools\Core\StatusSearchTool;use App\Tools\Cvs\AvailabilityTool;use Twig\Extension\AbstractExtension;use Twig\TwigFilter;use Twig\TwigFunction;class CvsExtension extends AbstractExtension{ private $core; private $tool; private $users; private $cvs; private $appStoreLinks; public function __construct(Core $coreService, Tools $toolService, Users $usersService, Cvs $cvsService, AppStoreLinksService $appStoreLinksService ){ $this->core = $coreService; $this->tool = $toolService; $this->users = $usersService; $this->cvs = $cvsService; $this->appStoreLinks = $appStoreLinksService; } public function getFunctions(): array { return [ new TwigFunction('getCvsCandidateUser', [$this, 'getCvsCandidateUser']), new TwigFunction('getCvsAvailabilityTool', [$this, 'getCvsAvailabilityTool']), new TwigFunction('getCvsStatusSearchTool', [$this, 'getCvsStatusSearchTool']), new TwigFunction('getCvsCompanyUser', [$this, 'getCvsCompanyUser']), new TwigFunction('getCvsMobilesUser', [$this, 'getCvsMobilesUser']), // Nouvelles fonctions liens stores new TwigFunction('getAppStoreCountries', [$this, 'getAppStoreCountries']), new TwigFunction('getAppStorePrimaryCountry', [$this, 'getAppStorePrimaryCountry']), ]; } public function getFilters() { return []; } public function getCvsMobilesUser($userID) { return $this->cvs->getCvsMobilesUser($userID); } public function getCvsCompanyUser($userID) { return $this->cvs->getCvsCompanyUser($userID); } public function getCvsCandidateUser($candidateID) { return $this->cvs->getCvsCandidateUser($candidateID); } public function getCvsAvailabilityTool($chain) { return AvailabilityTool::getStatus($chain); } public function getCvsStatusSearchTool($chain) { return StatusSearchTool::getStatus($chain); } /** * Retourne tous les pays App Store / Play Store affichables. * Format : ['primary' => [...], 'others' => [...]] */ public function getAppStoreCountries(): array { return $this->appStoreLinks->getAppStoreCountries(); } /** * Retourne le pays "primary" pour un countryCode donné. * Utilisé sur la version FR pour afficher un seul lien direct. */ public function getAppStorePrimaryCountry(string $preferredCountryCode = 'US'): ?array { return $this->appStoreLinks->getPrimaryCountry($preferredCountryCode); }}