當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pool::getAdminByClass方法代碼示例

本文整理匯總了PHP中Sonata\AdminBundle\Admin\Pool::getAdminByClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pool::getAdminByClass方法的具體用法?PHP Pool::getAdminByClass怎麽用?PHP Pool::getAdminByClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sonata\AdminBundle\Admin\Pool的用法示例。


在下文中一共展示了Pool::getAdminByClass方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: getUrlsafeIdentifier

 /**
  * Get the identifiers as a string that is save to use in an url.
  *
  * @param object         $model
  * @param AdminInterface $admin
  *
  * @return string string representation of the id that is save to use in an url
  */
 public function getUrlsafeIdentifier($model, AdminInterface $admin = null)
 {
     if (is_null($admin)) {
         $admin = $this->pool->getAdminByClass(ClassUtils::getClass($model));
     }
     return $admin->getUrlsafeIdentifier($model);
 }
開發者ID:andrey1s,項目名稱:SonataAdminBundle,代碼行數:15,代碼來源:SonataAdminExtension.php

示例3: testGetAdminForClassWhenAdminClassIsSet

 public function testGetAdminForClassWhenAdminClassIsSet()
 {
     $this->pool->setAdminServiceIds(array('sonata.user.admin.group1'));
     $this->pool->setAdminClasses(array('someclass' => array('sonata.user.admin.group1')));
     $this->assertTrue($this->pool->hasAdminByClass('someclass'));
     $this->assertSame('adminUserClass', $this->pool->getAdminByClass('someclass'));
 }
開發者ID:clavier-souris,項目名稱:SonataAdminBundle,代碼行數:7,代碼來源:PoolTest.php

示例4: getAdminByClass

 /**
  * @param string $className
  *
  * @return AdminInterface
  */
 private function getAdminByClass($className)
 {
     if (!isset($this->admins[$className])) {
         // will return null if not defined
         $this->admins[$className] = $this->pool->getAdminByClass($className);
     }
     return $this->admins[$className];
 }
開發者ID:viral810,項目名稱:ngSimpleCMS,代碼行數:13,代碼來源:PhpcrOdmTree.php

示例5: enhance

 /**
  * {@inheritdoc}
  */
 public function enhance(array $data, Resource $resource)
 {
     $object = $resource->getPayload();
     // sonata has dependency on ClassUtils so this is fine.
     $class = ClassUtils::getClass($object);
     if (false === $this->pool->hasAdminByClass($class)) {
         return $data;
     }
     $admin = $this->pool->getAdminByClass($class);
     $links = array();
     $routeCollection = $admin->getRoutes();
     foreach ($routeCollection->getElements() as $code => $route) {
         $routeName = $route->getDefault('_sonata_name');
         $url = $this->urlGenerator->generate($routeName, array($admin->getIdParameter() => $admin->getUrlsafeIdentifier($object)), true);
         $routeRole = substr($code, strlen($admin->getCode()) + 1);
         $links[$routeRole] = $url;
     }
     $data['label'] = $admin->toString($object);
     $data['sonata_label'] = $admin->getLabel();
     $data['sonata_links'] = $links;
     return $data;
 }
開發者ID:frogriotcom,項目名稱:ResourceRestBundle,代碼行數:25,代碼來源:SonataAdminEnhancer.php

示例6: enhance

 /**
  * {@inheritdoc}
  */
 public function enhance(Description $description)
 {
     $object = $description->getResource()->getPayload();
     // sonata has dependency on ClassUtils so this is fine.
     $class = ClassUtils::getClass($object);
     $admin = $this->pool->getAdminByClass($class);
     $links = array();
     $routeCollection = $admin->getRoutes();
     foreach ($routeCollection->getElements() as $code => $route) {
         $routeName = $route->getDefault('_sonata_name');
         $url = $this->urlGenerator->generate($routeName, array($admin->getIdParameter() => $admin->getUrlsafeIdentifier($object)), true);
         $routeRole = substr($code, strlen($admin->getCode()) + 1);
         $links[$routeRole] = $url;
     }
     if (isset($links['list'])) {
         $description->set('list', $links['list']);
         unset($links['list']);
     }
     if (isset($links['create'])) {
         $description->set(Descriptor::LINK_CREATE_HTML, $links['create']);
         unset($links['create']);
     }
     if (isset($links['edit'])) {
         $description->set(Descriptor::LINK_EDIT_HTML, $links['edit']);
         unset($links['edit']);
     }
     if (isset($links['delete'])) {
         $description->set(Descriptor::LINK_REMOVE_HTML, $links['delete']);
         unset($links['delete']);
     }
     if (isset($links['show'])) {
         $description->set(Descriptor::LINK_SHOW_HTML, $links['show']);
         unset($links['show']);
     }
     $description->set(Descriptor::PAYLOAD_TITLE, $admin->toString($object));
     $description->set(Descriptor::TYPE_ALIAS, $admin->getLabel());
 }
開發者ID:symfony-cmf,項目名稱:resource,代碼行數:40,代碼來源:AdminEnhancer.php

示例7: getUrlsafeIdentifier

 /**
  * Get the identifiers as a string that is save to use in an url.
  *
  * @param object $model
  *
  * @return string string representation of the id that is save to use in an url
  */
 public function getUrlsafeIdentifier($model)
 {
     $admin = $this->pool->getAdminByClass(ClassUtils::getClass($model));
     return $admin->getUrlsafeIdentifier($model);
 }
開發者ID:LamaDelRay,項目名稱:test_symf,代碼行數:12,代碼來源:SonataAdminExtension.php


注:本文中的Sonata\AdminBundle\Admin\Pool::getAdminByClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。