PHP code example of optimeconsulting / acl_bundle
1. Go to this page and download the library: Download optimeconsulting/acl_bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
optimeconsulting / acl_bundle example snippets
return [
...
Optime\Acl\Bundle\OptimeAclBundle::class => ['all' => true],
];
# Controlador:
public function edit() {
# Por el nombre de un recurso
if (!$this->isGranted("resource", "user edit")) {
die("No tiene acceso");
}
// Por el nombre de una ruta
if (!$this->isGranted("resource_route", "ruta_usuario_editar")) {
die("No tiene acceso");
}
}
# Atributo en controlador:
#[IsGranted("resource", "user")]
public function edit() {
# ...
}