本文整理汇总了PHP中RoleModel::create方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::create方法的具体用法?PHP RoleModel::create怎么用?PHP RoleModel::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
public function up()
{
$this->createTable('role', array('primary' => 'roleID'), array(array('roleID', 'integer'), array('roleDescription', 'string', array('limit' => 128, 'null' => true)), array('ACLstring', 'text', array('null' => true, 'limit' => '1M'))));
$this->createTable('assignment', array('primary' => 'assignmentID'), array(array('dbUserID', 'integer'), array('roleID', 'integer'), array('assignmentID', 'integer'), array('comments', 'text', array('null' => true))));
$this->createIndex('assignment', array('dbUserID', 'roleID'));
// reset db metadata cache
QFrame_Db_Table::scanDb();
// give the admin user full global rights
$adminRole = RoleModel::create(array('roleDescription' => 'Administrators'));
$adminRole->grant('view');
$adminRole->grant('edit');
$adminRole->grant('approve');
$adminRole->grant('administer');
$adminRole->save();
DbUserModel::findByUsername('admin')->addRole($adminRole)->save();
}
示例2: testSavePersistsNewRoles
public function testSavePersistsNewRoles()
{
$role = RoleModel::create(array('roleDescription' => 'SAMPLE'))->save();
$this->assertFalse(is_null($role->roleID));
$role = RoleModel::find($role->roleID);
$this->assertEquals($role->roleDescription, 'SAMPLE');
}
示例3: createAction
/**
* Create action. Creates a role and redirects back to the index action.
*/
public function createAction()
{
RoleModel::create(array('roleDescription' => $this->_getParam('roleDescription')))->save();
$this->flash('notice', 'Role successfully created');
$this->_redirector->gotoRoute(array('action' => 'index'));
}