Application\Admin\Controllers\RbacRoleController::createAction PHP Method

createAction() public method

public createAction ( )
    public function createAction()
    {
        if ($this->request->isAjax()) {
            $name = $this->request->get('name', 'trim');
            $description = $this->request->get('description', 'trim');
            if (RbacRole::exists(['role_name' => $name])) {
                return $this->response->setJsonContent(['code' => __LINE__, 'error' => 'role exists']);
            }
            $rbacRole = new RbacRole();
            $rbacRole->role_name = $name;
            $rbacRole->description = $description;
            $rbacRole->enabled = 1;
            $rbacRole->created_time = time();
            $rbacRole->create();
            return $this->response->setJsonContent(['code' => 0, 'error' => '']);
        }
    }
RbacRoleController