本文整理汇总了PHP中ACL::addResource方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::addResource方法的具体用法?PHP ACL::addResource怎么用?PHP ACL::addResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACL
的用法示例。
在下文中一共展示了ACL::addResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install()
{
if (!$this->input->is_cli_request()) {
return;
}
$this->load->dbforge();
// create acl table
$fields = array('key' => array('type' => 'VARCHAR', 'constraint' => '255'), 'value' => array('type' => 'TEXT'));
$this->dbforge->drop_table('acl');
$this->dbforge->add_field($fields);
$this->dbforge->add_key('key', true);
$this->dbforge->create_table('acl');
// create users table
$fields = array('id' => array('type' => 'INT', 'constraint' => 11, 'null' => false, 'auto_increment' => true), 'email' => array('type' => 'VARCHAR', 'constraint' => '255', 'null' => false), 'password' => array('type' => 'VARCHAR', 'constraint' => '255', 'null' => false));
$this->dbforge->drop_table('users');
$this->dbforge->add_field($fields);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('users');
// default resources to protect
$acl = new ACL();
$acl->addResource('administrator');
$acl->addResource('user');
$acl->addResource('role');
$acl->addResource('resource');
// create administrator role and grant all access
$acl->addRole('administrator');
$acl->addPermissions('administrator', 'administrator', 'read');
$acl->addPermissions('administrator', 'user', ['create', 'read', 'update', 'delete']);
$acl->addPermissions('administrator', 'role', ['create', 'read', 'update', 'delete']);
$acl->addPermissions('administrator', 'resource', ['create', 'read', 'update', 'delete']);
// custom resources
// ...
// ... add your custom resources to protect here
// ...
if (!defined('PHPUNIT_TEST')) {
echo "installed\r\n";
}
}
示例2: create
public function create($resource)
{
$acl = new ACL();
$acl->addResource($resource);
}