Skip to content

Instantly share code, notes, and snippets.

@inri13666
Created September 21, 2016 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inri13666/fcdcf58a6678d07f0c47c5f707c782c5 to your computer and use it in GitHub Desktop.
Save inri13666/fcdcf58a6678d07f0c47c5f707c782c5 to your computer and use it in GitHub Desktop.
<?php
namespace HomeNest\Bundle\ThemeBundle\Security\Authorization\Voter;
use ED\BlogBundle\Security\Authorization\Voter\ArticleVoter as EdArticleVoter;
class OverriddenArticleVoter extends EdArticleVoter
{
public function supportsClass($class)
{
try {
return parent::supportsClass($class);
} catch (\Error $e) {
return false;
}
}
}
<?php
namespace HomeNest\Bundle\ThemeBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OverrideServiceCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if($container->hasDefinition('ed_blog.authorization_voter.article_voter')) {
$definition = $container->getDefinition('ed_blog.authorization_voter.article_voter');
$definition->setClass('HomeNest\Bundle\ThemeBundle\Security\Authorization\Voter\OverriddenArticleVoter');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment