ExpressionLanguage.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Security\Core\Authorization;
  11. use Psr\Cache\CacheItemPoolInterface;
  12. use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
  13. // Help opcache.preload discover always-needed symbols
  14. class_exists(ExpressionLanguageProvider::class);
  15. if (!class_exists(BaseExpressionLanguage::class)) {
  16. throw new \LogicException(sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
  17. } else {
  18. /**
  19. * Adds some function to the default ExpressionLanguage.
  20. *
  21. * @author Fabien Potencier <fabien@symfony.com>
  22. *
  23. * @see ExpressionLanguageProvider
  24. */
  25. class ExpressionLanguage extends BaseExpressionLanguage
  26. {
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function __construct(CacheItemPoolInterface $cache = null, array $providers = [])
  31. {
  32. // prepend the default provider to let users override it easily
  33. array_unshift($providers, new ExpressionLanguageProvider());
  34. parent::__construct($cache, $providers);
  35. }
  36. }
  37. }