本文整理汇总了PHP中Sonata\AdminBundle\Admin\AdminInterface::generateObjectUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminInterface::generateObjectUrl方法的具体用法?PHP AdminInterface::generateObjectUrl怎么用?PHP AdminInterface::generateObjectUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Admin\AdminInterface
的用法示例。
在下文中一共展示了AdminInterface::generateObjectUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aclAction
/**
* Returns the Response object associated to the acl action.
*
* @param int|string|null $id
*
* @return Response|RedirectResponse
*
* @throws AccessDeniedException If access is not granted.
* @throws NotFoundHttpException If the object does not exist or the ACL is not enabled
*/
public function aclAction($id = null)
{
if (!$this->admin->isAclEnabled()) {
throw new NotFoundHttpException('ACL are not enabled for this admin');
}
$id = $this->get('request')->get($this->admin->getIdParameter());
$object = $this->admin->getObject($id);
if (!$object) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
if (false === $this->admin->isGranted('MASTER', $object)) {
throw new AccessDeniedException();
}
$this->admin->setSubject($object);
$aclUsers = $this->getAclUsers();
$adminObjectAclManipulator = $this->get('sonata.admin.object.manipulator.acl.admin');
$adminObjectAclData = new AdminObjectAclData($this->admin, $object, $aclUsers, $adminObjectAclManipulator->getMaskBuilderClass());
$form = $adminObjectAclManipulator->createForm($adminObjectAclData);
$request = $this->getRequest();
if ($request->getMethod() === 'POST') {
$form->submit($request);
if ($form->isValid()) {
$adminObjectAclManipulator->updateAcl($adminObjectAclData);
$this->addFlash('sonata_flash_success', 'flash_acl_edit_success');
return new RedirectResponse($this->admin->generateObjectUrl('acl', $object));
}
}
return $this->render($this->admin->getTemplate('acl'), array('action' => 'acl', 'permissions' => $adminObjectAclData->getUserPermissions(), 'object' => $object, 'users' => $aclUsers, 'form' => $form->createView()));
}
示例2: redirectTo
/**
* Redirect the user depend on this choice.
*
* @param object $object
*
* @return RedirectResponse
*/
protected function redirectTo($object)
{
$request = $this->getRequest();
$url = false;
if (null !== $request->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list');
}
if (null !== $request->get('btn_create_and_list')) {
$url = $this->admin->generateUrl('list');
}
if (null !== $request->get('btn_create_and_create')) {
$params = array();
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $request->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if ($this->getRestMethod() === 'DELETE') {
$url = $this->admin->generateUrl('list');
}
if (!$url) {
foreach (array('edit', 'show') as $route) {
if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) {
$url = $this->admin->generateObjectUrl($route, $object);
break;
}
}
}
if (!$url) {
$url = $this->admin->generateUrl('list');
}
return new RedirectResponse($url);
}
示例3: redirectTo
/**
* redirect the user depend on this choice
*
* @param object $object
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function redirectTo($object)
{
$url = false;
if ($this->get('request')->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list');
}
if ($this->get('request')->get('btn_create_and_create')) {
$url = $this->admin->generateUrl('create');
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
}
示例4: redirectTo
/**
* redirect the user depend on this choice
*
* @param object $object
*
* @return Response
*/
public function redirectTo($object)
{
$url = false;
if ($this->get('request')->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list');
}
if ($this->get('request')->get('btn_create_and_create')) {
$params = array();
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $this->get('request')->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
}
示例5: aclAction
/**
* Returns the Response object associated to the acl action.
*
* @param int|string|null $id
* @param Request $request
*
* @return Response|RedirectResponse
*
* @throws AccessDeniedException If access is not granted.
* @throws NotFoundHttpException If the object does not exist or the ACL is not enabled
*/
public function aclAction($id = null)
{
$request = $this->getRequest();
if (!$this->admin->isAclEnabled()) {
throw $this->createNotFoundException('ACL are not enabled for this admin');
}
$id = $request->get($this->admin->getIdParameter());
$object = $this->admin->getObject($id);
if (!$object) {
throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));
}
$this->admin->checkAccess('acl', $object);
$this->admin->setSubject($object);
$aclUsers = $this->getAclUsers();
$aclRoles = $this->getAclRoles();
$adminObjectAclManipulator = $this->get('sonata.admin.object.manipulator.acl.admin');
$adminObjectAclData = new AdminObjectAclData($this->admin, $object, $aclUsers, $adminObjectAclManipulator->getMaskBuilderClass(), $aclRoles);
$aclUsersForm = $adminObjectAclManipulator->createAclUsersForm($adminObjectAclData);
$aclRolesForm = $adminObjectAclManipulator->createAclRolesForm($adminObjectAclData);
if ($request->getMethod() === 'POST') {
if ($request->request->has(AdminObjectAclManipulator::ACL_USERS_FORM_NAME)) {
$form = $aclUsersForm;
$updateMethod = 'updateAclUsers';
} elseif ($request->request->has(AdminObjectAclManipulator::ACL_ROLES_FORM_NAME)) {
$form = $aclRolesForm;
$updateMethod = 'updateAclRoles';
}
if (isset($form)) {
$form->handleRequest($request);
if ($form->isValid()) {
$adminObjectAclManipulator->{$updateMethod}($adminObjectAclData);
$this->addFlash('sonata_flash_success', 'flash_acl_edit_success');
return new RedirectResponse($this->admin->generateObjectUrl('acl', $object));
}
}
}
return $this->render($this->admin->getTemplate('acl'), array('action' => 'acl', 'permissions' => $adminObjectAclData->getUserPermissions(), 'object' => $object, 'users' => $aclUsers, 'roles' => $aclRoles, 'aclUsersForm' => $aclUsersForm->createView(), 'aclRolesForm' => $aclRolesForm->createView()), null, $request);
}