/**
  * @Given is resource with id :resource
  */
 public function isResourceWithId($resource)
 {
     $this->applicationCore->registerResourceFactory($this->securityName, function () use($resource) {
         return new \Dgafka\Fixtures\IBAC\ResourceFactory($resource);
     });
 }
Пример #2
0
ini_set('display_startup_errors', 1);
error_reporting(-1);
require __DIR__ . '/../../vendor/autoload.php';
use Dgafka\AuthorizationSecurity\Application\Core;
use Dgafka\AuthorizationSecurity\Application\CoreConfig;
use Dgafka\AuthorizationSecurity\UI\Annotation\AnnotationSecurity;
//Initialization
$core = new Core(new CoreConfig(array(__DIR__), __DIR__ . '/../cache', true));
$core->registerUserFactory('roleUserFactory', function () {
    return new \Dgafka\Fixtures\Factory\RoleUserFactory(1, ['test']);
});
$core->registerUserFactory('identityUserFactory', function () {
    return new \Dgafka\Fixtures\IBAC\IdentityUserFactory(10);
});
$core->registerResourceFactory('resourceFactory', function () {
    return new \Dgafka\Fixtures\IBAC\ExampleResourceFactory();
});
$core->registerSecurityType('ibac', function () {
    return new \Dgafka\Fixtures\IBAC\IBACSecurity(new \Dgafka\Fixtures\IBAC\SimpleACL(['10' => [10, 12]]));
});
$core->registerSecurityPolicy('isLocalHost', function () {
    return new \Dgafka\Fixtures\Policies\IsLocalHost();
});
$core->registerSecurityPolicy('isMonday', function () {
    return new \Dgafka\Fixtures\Policies\IsMonday();
});
$annotationSecurity = AnnotationSecurity::getInstance();
$annotationSecurity->init($core);
//Tests
echo "\nFirst Example:\n";
$example = new \Dgafka\Examples\BasicUsage();