當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。