X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/a532906fc0063a87cb16f9daa0b76adef5fb3e36..ca4cd083c302be4c5a1b50de9d3dcd70cf20b1d8:/Command/CalendarCommand.php diff --git a/Command/CalendarCommand.php b/Command/CalendarCommand.php index 525aa67..dca096b 100644 --- a/Command/CalendarCommand.php +++ b/Command/CalendarCommand.php @@ -1,10 +1,18 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Rapsys\AirBundle\Command; use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\Cache\Adapter\FilesystemAdapter; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -13,90 +21,32 @@ use Symfony\Component\Routing\RouterInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Twig\Extra\Markdown\DefaultMarkdown; +use Rapsys\AirBundle\Command; use Rapsys\AirBundle\Entity\Session; use Rapsys\PackBundle\Util\SluggerUtil; class CalendarCommand extends Command { - //Set failure constant - const FAILURE = 1; - - ///Set success constant - const SUCCESS = 0; - - /** - * Doctrine instance - * - * @var ManagerRegistry - */ - protected $doctrine; - - ///Locale - protected $locale; - - ///Slugger - protected $slugger; - - ///Translator instance - protected $translator; - - ///Lifetime string - protected $lifetime; - - ///Namespace string - protected $namespace; - - ///Path string - protected $path; - /** * Creates new calendar command * * @param ManagerRegistry $doctrine The doctrine instance + * @param string $locale The default locale * @param RouterInterface $router The router instance * @param SluggerUtil $slugger The slugger instance * @param TranslatorInterface $translator The translator instance * @param string $namespace The cache namespace * @param int $lifetime The cache lifetime * @param string $path The cache path - * @param string $locale The default locale */ - public function __construct(ManagerRegistry $doctrine, RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, string $namespace, int $lifetime, string $path, string $locale) { + public function __construct(protected ManagerRegistry $doctrine, protected string $locale, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $namespace, protected int $lifetime, protected string $path) { //Call parent constructor - parent::__construct(); - - //Store doctrine - $this->doctrine = $doctrine; - - //Set lifetime - $this->lifetime = $lifetime; - - //Set namespace - $this->namespace = $namespace; - - //Set path - $this->path = $path; - - //Store router - $this->router = $router; - - //Retrieve slugger - $this->slugger = $slugger; - - //Get router context - $context = $this->router->getContext(); - - //Set host - $context->setHost('airlibre.eu'); - - //Set scheme - $context->setScheme('https'); - - //Set the translator - $this->translator = $translator; + parent::__construct($this->doctrine, $this->locale, $this->router, $this->slugger, $this->translator); } - ///Configure attribute command + /** + * Configure attribute command + */ protected function configure() { //Configure the class $this @@ -108,8 +58,10 @@ class CalendarCommand extends Command { ->setHelp('This command synchronize sessions in google calendar'); } - ///Process the attribution - protected function execute(InputInterface $input, OutputInterface $output) { + /** + * Process the attribution + */ + protected function execute(InputInterface $input, OutputInterface $output): int { //Compute period $period = new \DatePeriod( //Start from last week @@ -312,7 +264,7 @@ class CalendarCommand extends Command { //Init source $source = [ 'title' => $this->translator->trans('%dance% %id% by %pseudonym%', ['%id%' => $sessionId, '%dance%' => $this->translator->trans($session['ad_name'].' '.lcfirst($session['ad_type'])), '%pseudonym%' => $session['au_pseudonym']]).' '.$this->translator->trans('at '.$session['l_title']), - 'url' => $this->router->generate('rapsys_air_session_view', ['id' => $sessionId, 'location' => $this->slugger->slug($this->translator->trans($session['l_title'])), 'dance' => $this->slugger->slug($this->translator->trans($session['ad_name'].' '.lcfirst($session['ad_type']))), 'user' => $this->slugger->slug($session['au_pseudonym'])], UrlGeneratorInterface::ABSOLUTE_URL) + 'url' => $this->router->generate('rapsysair_session_view', ['id' => $sessionId, 'location' => $this->slugger->slug($this->translator->trans($session['l_title'])), 'dance' => $this->slugger->slug($this->translator->trans($session['ad_name'].' '.lcfirst($session['ad_type']))), 'user' => $this->slugger->slug($session['au_pseudonym'])], UrlGeneratorInterface::ABSOLUTE_URL) ]; //Init location @@ -511,13 +463,4 @@ class CalendarCommand extends Command { //Return success return self::SUCCESS; } - - /** - * Return the bundle alias - * - * {@inheritdoc} - */ - public function getAlias(): string { - return 'rapsys_air'; - } }