当前位置: 首页>>代码示例>>PHP>>正文


PHP AdminInterface::getTemplate方法代码示例

本文整理汇总了PHP中Sonata\AdminBundle\Admin\AdminInterface::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminInterface::getTemplate方法的具体用法?PHP AdminInterface::getTemplate怎么用?PHP AdminInterface::getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\AdminBundle\Admin\AdminInterface的用法示例。


在下文中一共展示了AdminInterface::getTemplate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBaseTemplate

 /**
  * return the base template name
  *
  * @return string the template name
  */
 protected function getBaseTemplate()
 {
     if ($this->isXmlHttpRequest()) {
         return $this->admin->getTemplate('ajax');
     }
     return $this->admin->getTemplate('layout');
 }
开发者ID:symbio,项目名称:orangegate4-analytics-bundle,代码行数:12,代码来源:BaseController.php

示例2: 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()));
 }
开发者ID:stuckiest,项目名称:SymfonyBlog,代码行数:39,代码来源:CRUDController.php

示例3: historyAction

 /**
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException|\Symfony\Component\Security\Core\Exception\AccessDeniedException
  *
  * @param mixed $id
  *
  * @return Response
  */
 public function historyAction($id = null)
 {
     if (false === $this->admin->isGranted('EDIT')) {
         throw new AccessDeniedException();
     }
     $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));
     }
     $manager = $this->get('sonata.admin.audit.manager');
     if (!$manager->hasReader($this->admin->getClass())) {
         throw new NotFoundHttpException(sprintf('unable to find the audit reader for class : %s', $this->admin->getClass()));
     }
     $reader = $manager->getReader($this->admin->getClass());
     $revisions = $reader->findRevisions($this->admin->getClass(), $id);
     return $this->render($this->admin->getTemplate('history'), array('action' => 'history', 'object' => $object, 'revisions' => $revisions));
 }
开发者ID:novatex,项目名称:SonataAdminBundle,代码行数:25,代码来源:CRUDController.php

示例4: 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);
 }
开发者ID:lilocon,项目名称:SonataAdminBundle,代码行数:49,代码来源:CRUDController.php

示例5: historyViewRevisionAction

 /**
  * @param null    $id
  * @param string  $revision
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  *
  * @return Response
  */
 public function historyViewRevisionAction($id = null, $revision = null)
 {
     if (false === $this->admin->isGranted('EDIT')) {
         throw new AccessDeniedException();
     }
     $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));
     }
     $manager = $this->get('sonata.admin.audit.manager');
     if (!$manager->hasReader($this->admin->getClass())) {
         throw new NotFoundHttpException(sprintf('unable to find the audit reader for class : %s', $this->admin->getClass()));
     }
     $reader = $manager->getReader($this->admin->getClass());
     // retrieve the revisioned object
     $object = $reader->find($this->admin->getClass(), $id, $revision);
     if (!$object) {
         throw new NotFoundHttpException(sprintf('unable to find the targeted object `%s` from the revision `%s` with classname : `%s`', $id, $revision, $this->admin->getClass()));
     }
     $this->admin->setSubject($object);
     return $this->render($this->admin->getTemplate('show'), array('action' => 'show', 'object' => $object, 'elements' => $this->admin->getShow()));
 }
开发者ID:richhl,项目名称:SonataAdminBundle,代码行数:32,代码来源:CRUDController.php


注:本文中的Sonata\AdminBundle\Admin\AdminInterface::getTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。