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


PHP Pool::getAdminByAdminCode方法代码示例

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


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

示例1: onKernelRequest

 /**
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  * @throws \RuntimeException
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request) {
         return;
     }
     if (!$request->hasSession()) {
         return;
     }
     $adminCode = $request->get('_sonata_admin');
     if (!is_null($adminCode)) {
         $this->admin = $this->adminPool->getAdminByAdminCode($adminCode);
         if (!$this->admin) {
             throw new \RuntimeException(sprintf('Unable to find the admin class related to the current controller (%s)', get_class($this)));
         }
         if (method_exists($this->admin, 'getTrackedActions')) {
             foreach ($this->admin->getTrackedActions() as $trackedAction) {
                 // if an action which is flagged as 'to be tracked' is matching the end of the route: add info to session
                 if (preg_match('#' . $trackedAction . '$#', $request->get('_route'), $matches)) {
                     $this->updateTrackedInfo($request->getSession(), '_networking_initcms_admin_tracker', array('url' => $request->getRequestUri(), 'controller' => $this->admin->getBaseControllerName(), 'action' => $trackedAction));
                 }
             }
         }
     }
 }
开发者ID:networking,项目名称:init-cms-bundle,代码行数:29,代码来源:AdminTrackerListener.php

示例2: testGetAdminByAdminCodeForChildClass

 public function testGetAdminByAdminCodeForChildClass()
 {
     $adminMock = $this->getMockBuilder('Sonata\\AdminBundle\\Admin\\AdminInterface')->disableOriginalConstructor()->getMock();
     $adminMock->expects($this->any())->method('hasChild')->will($this->returnValue(true));
     $adminMock->expects($this->once())->method('getChild')->with($this->equalTo('sonata.news.admin.comment'))->will($this->returnValue('commentAdminClass'));
     $containerMock = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $containerMock->expects($this->any())->method('get')->will($this->returnValue($adminMock));
     $this->pool = new Pool($containerMock, 'Sonata', '/path/to/logo.png');
     $this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
 }
开发者ID:natxet,项目名称:SonataAdminBundle,代码行数:10,代码来源:PoolTest.php

示例3: getAdmin

 /**
  * @param ComponentInterface $component
  *
  * @return AdminInterface
  */
 protected function getAdmin(ComponentInterface $component, ActionInterface $action = null)
 {
     if ($action && ($adminComponent = $action->getComponent('admin_code'))) {
         return $this->pool->getAdminByAdminCode($adminComponent);
     }
     try {
         return $this->pool->getAdminByClass($component->getModel());
     } catch (\RuntimeException $e) {
     }
     return false;
 }
开发者ID:sagikazarmark,项目名称:SonataTimelineBundle,代码行数:16,代码来源:SonataTimelineExtension.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('code'));
     $datagrid = $admin->getDatagrid();
     $filters = $blockContext->getSetting('filters');
     if (!isset($filters['_per_page'])) {
         $filters['_per_page'] = array('value' => $blockContext->getSetting('limit'));
     }
     foreach ($filters as $name => $data) {
         $datagrid->setValue($name, isset($data['type']) ? $data['type'] : null, $data['value']);
     }
     $datagrid->buildPager();
     return $this->renderPrivateResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'admin_pool' => $this->pool, 'admin' => $admin, 'pager' => $datagrid->getPager(), 'datagrid' => $datagrid), $response);
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:17,代码来源:AdminStatsBlockService.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     try {
         $admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('admin_code'));
     } catch (ServiceNotFoundException $e) {
         throw new \RuntimeException('Unable to find the Admin instance', $e->getCode(), $e);
     }
     if (!$admin instanceof AdminInterface) {
         throw new \RuntimeException('The requested service is not an Admin instance');
     }
     if (!$admin->isGranted('LIST')) {
         throw new AccessDeniedException();
     }
     $pager = $this->searchHandler->search($admin, $blockContext->getSetting('query'), $blockContext->getSetting('page'), $blockContext->getSetting('per_page'));
     return $this->renderPrivateResponse($admin->getTemplate('search_result_block'), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'admin_pool' => $this->pool, 'pager' => $pager, 'admin' => $admin), $response);
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:19,代码来源:AdminSearchBlockService.php


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