Skip to content

Instantly share code, notes, and snippets.

@mishak87
Created June 17, 2014 23:01
Show Gist options
  • Save mishak87/13ea6be081e217de06bb to your computer and use it in GitHub Desktop.
Save mishak87/13ea6be081e217de06bb to your computer and use it in GitHub Desktop.
<?php
namespace App;
use Nette;
class ProviderCollector extends Nette\Object
{
/** @var string[] */
private $providers;
/**
* @param string[] $providers
*/
public function __construct($providers)
{
$this->providers = $providers;
}
}
<?php
namespace App;
use Kdyby\Aop;
use Kdyby\Aop\JoinPoint\BeforeMethod;
use Nette;
class ProviderCollectorAspect extends Nette\Object
{
public $blacklist = ['A', 'B'];
/**
* @Aop\Before("method(App\ProviderCollector->__construct)")
*/
public function construct(BeforeMethod $joinPoint)
{
$joinPoint->setArgument(0, array_filter($joinPoint->getArguments()[0], function ($provider) {
return !in_array($provider, $this->blacklist, TRUE);
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment