ActiveVoter.php 764 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Menu\Matcher\Voter;
  11. use Knp\Menu\ItemInterface;
  12. use Knp\Menu\Matcher\Voter\VoterInterface;
  13. /**
  14. * Active menu voter bases in extra `active`.
  15. *
  16. * @author Samusev Andrey <andrey.simfi@ya.ru>
  17. */
  18. class ActiveVoter implements VoterInterface
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function matchItem(ItemInterface $item)
  24. {
  25. if (!$item->getExtra('sonata_admin', false)) {
  26. return;
  27. }
  28. return $item->getExtra('active', null);
  29. }
  30. }