public function testIsPredefined() { $name = 'Predefined role'; $role = new AccountUserRole($name); $this->assertTrue($role->isPredefined()); $role->setAccount(new Account()); $this->assertFalse($role->isPredefined()); }
/** * @return bool * @return int */ protected function getFrontendPermissionForDelete() { if ($this->object->isPredefined()) { return self::ACCESS_DENIED; } return $this->isGrantedDeleteAccountUserRole($this->object) ? self::ACCESS_GRANTED : self::ACCESS_DENIED; }
/** * @param AccountUserRole $role * @return array|RedirectResponse */ protected function update(AccountUserRole $role) { $handler = $this->get('orob2b_account.form.handler.update_account_user_role_frontend'); if ($role->isPredefined()) { $newRole = $this->createNewRole($role); } else { $newRole = $role; } $form = $handler->createForm($newRole); return $this->get('oro_form.model.update_handler')->handleUpdate($role, $form, function () use($newRole) { return ['route' => 'orob2b_account_frontend_account_user_role_update', 'parameters' => ['id' => $newRole->getId()]]; }, function () use($newRole) { return ['route' => 'orob2b_account_frontend_account_user_role_view', 'parameters' => ['id' => $newRole->getId()]]; }, $this->get('translator')->trans('orob2b.account.controller.accountuserrole.saved.message'), $handler); }