当前位置: 首页>>代码示例>>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;未经允许,请勿转载。