vendor/symfony/routing/Exception/MissingMandatoryParametersException.php line 20

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Routing\Exception;
  11. /**
  12.  * Exception thrown when a route cannot be generated because of missing
  13.  * mandatory parameters.
  14.  *
  15.  * @author Alexandre Salomé <alexandre.salome@gmail.com>
  16.  */
  17. class MissingMandatoryParametersException extends \InvalidArgumentException implements ExceptionInterface
  18. {
  19.     private string $routeName '';
  20.     private array $missingParameters = [];
  21.     /**
  22.      * @param string[] $missingParameters
  23.      * @param int      $code
  24.      */
  25.     public function __construct(string $routeName ''$missingParameters null$code 0\Throwable $previous null)
  26.     {
  27.         if (\is_array($missingParameters)) {
  28.             $this->routeName $routeName;
  29.             $this->missingParameters $missingParameters;
  30.             $message sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".'implode('", "'$missingParameters), $routeName);
  31.         } else {
  32.             trigger_deprecation('symfony/routing''6.1''Construction of "%s" with an exception message is deprecated, provide the route name and an array of missing parameters instead.'__CLASS__);
  33.             $message $routeName;
  34.             $previous $code instanceof \Throwable $code null;
  35.             $code = (int) $missingParameters;
  36.         }
  37.         parent::__construct($message$code$previous);
  38.     }
  39.     /**
  40.      * @return string[]
  41.      */
  42.     public function getMissingParameters(): array
  43.     {
  44.         return $this->missingParameters;
  45.     }
  46.     public function getRouteName(): string
  47.     {
  48.         return $this->routeName;
  49.     }
  50. }