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


PHP Admin\AdminInterface类代码示例

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


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

示例1: configureTabMenu

 /**
  * @throws InvalidConfigurationException
  */
 public function configureTabMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
 {
     if (!($subject = $admin->getSubject())) {
         return;
     }
     if (!$subject instanceof RouteReferrersReadInterface && !$subject instanceof Route) {
         throw new InvalidConfigurationException(sprintf('%s can only be used on subjects which implement Symfony\\Cmf\\Component\\Routing\\RouteReferrersReadInterface or Symfony\\Component\\Routing\\Route.', __CLASS__));
     }
     if ($subject instanceof PrefixInterface && !is_string($subject->getId())) {
         // we have an unpersisted dynamic route
         return;
     }
     $defaults = array();
     if ($subject instanceof TranslatableInterface) {
         if ($locale = $subject->getLocale()) {
             $defaults['_locale'] = $locale;
         }
     }
     try {
         $uri = $this->router->generate($subject, $defaults);
     } catch (RoutingExceptionInterface $e) {
         // we have no valid route
         return;
     }
     $menu->addChild($this->translator->trans('admin.menu_frontend_link_caption', array(), 'CmfRoutingBundle'), array('uri' => $uri, 'attributes' => array('class' => 'sonata-admin-menu-item', 'role' => 'menuitem'), 'linkAttributes' => array('class' => 'sonata-admin-frontend-link', 'role' => 'button', 'target' => '_blank', 'title' => $this->translator->trans('admin.menu_frontend_link_title', array(), 'CmfRoutingBundle'))));
 }
开发者ID:symfony-cmf,项目名称:routing-bundle,代码行数:29,代码来源:FrontendLinkExtension.php

示例2: setUp

 public function setUp()
 {
     $this->admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface', array('hasRoute', 'isGranted', 'generateObjectUrl', 'generateUrl', 'toString'));
     $this->pool = $this->getMock('Sonata\\AdminBundle\\Admin\\Pool', array('getAdminByClass'));
     $this->pool->expects($this->any())->method('getAdminByClass')->with($this->equalTo('Acme\\DemoBundle\\Model\\Demo'))->will($this->returnValue($this->admin));
     $this->twigExtension = new SonataTimelineExtension($this->pool);
 }
开发者ID:OskarStark,项目名称:SonataTimelineBundle,代码行数:7,代码来源:SonataTimelineExtensionTest.php

示例3: configureAcls

 /**
  * Configure the object ACL for the passed object identities
  *
  * @param OutputInterface      $output
  * @param AdminInterface       $admin
  * @param array                $oids an array of ObjectIdentityInterface implementations
  * @param UserSecurityIdentity $securityIdentity
  *
  * @throws \Exception
  *
  * @return array [countAdded, countUpdated]
  */
 public function configureAcls(OutputInterface $output, AdminInterface $admin, array $oids, UserSecurityIdentity $securityIdentity = null)
 {
     $countAdded = 0;
     $countUpdated = 0;
     $securityHandler = $admin->getSecurityHandler();
     if (!$securityHandler instanceof AclSecurityHandlerInterface) {
         $output->writeln(sprintf('Admin `%s` is not configured to use ACL : <info>ignoring</info>', $admin->getCode()));
         return array(0, 0);
     }
     $acls = $securityHandler->findObjectAcls($oids);
     foreach ($oids as $oid) {
         if ($acls->contains($oid)) {
             $acl = $acls->offsetGet($oid);
             $countUpdated++;
         } else {
             $acl = $securityHandler->createAcl($oid);
             $countAdded++;
         }
         if (!is_null($securityIdentity)) {
             // add object owner
             $securityHandler->addObjectOwner($acl, $securityIdentity);
         }
         $securityHandler->addObjectClassAces($acl, $securityHandler->buildSecurityInformation($admin));
         try {
             $securityHandler->updateAcl($acl);
         } catch (\Exception $e) {
             $output->writeln(sprintf('Error saving ObjectIdentity (%s, %s) ACL : %s <info>ignoring</info>', $oid->getIdentifier(), $oid->getType(), $e->getMessage()));
         }
     }
     return array($countAdded, $countUpdated);
 }
开发者ID:natxet,项目名称:SonataAdminBundle,代码行数:43,代码来源:ObjectAclManipulator.php

示例4: getBaseDatagrid

 /**
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @param array $values
  * @return \Sonata\AdminBundle\Datagrid\DatagridInterface
  */
 public function getBaseDatagrid(AdminInterface $admin, array $values = array())
 {
     $pager = new Pager();
     $pager->setCountColumn($admin->getModelManager()->getIdentifierFieldNames($admin->getClass()));
     $formBuilder = $this->formFactory->createNamedBuilder('form', 'filter', array(), array('csrf_protection' => false));
     return new Datagrid($admin->createQuery(), $admin->getList(), $pager, $formBuilder, $values);
 }
开发者ID:hunter1271,项目名称:IphpTreeBundle,代码行数:12,代码来源:DatagridBuilder.php

示例5: alterNewInstance

 /**
  * {@inheritdoc}
  */
 public function alterNewInstance(AdminInterface $admin, $object)
 {
     if ($object->getParent() == null) {
         $reflectionClass = $admin->getClass();
         $parent = $this->container->get('doctrine')->getRepository($reflectionClass)->findOneById($this->getRequest()->query->get('parent'));
         $object->setParent($parent);
     }
 }
开发者ID:endroid,项目名称:EndroidBehaviorBundle,代码行数:11,代码来源:TraversableAdminExtension.php

示例6: buildSecurityInformation

 /**
  * {@inheritDoc}
  */
 public function buildSecurityInformation(AdminInterface $admin)
 {
     $baseRole = 'ROLE_' . str_replace('.', '_', strtoupper($admin->getCode())) . '_%s';
     $results = array();
     foreach ($admin->getSecurityInformation() as $name => $permissions) {
         $results[sprintf($baseRole, $name)] = $permissions;
     }
     return $results;
 }
开发者ID:helmer,项目名称:SonataAdminBundle,代码行数:12,代码来源:AclSecurityHandler.php

示例7: fixFieldDescription

 /**
  * {@inheritdoc}
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     $fieldDescription->setTemplate('YnloAdminBundle::CRUD/list_enum.html.twig');
     /** @var ModelManager $modelManager */
     $modelManager = $admin->getModelManager();
     if (null === $fieldDescription->getOption('enum_type') && $modelManager->hasMetadata($admin->getClass())) {
         $mapping = $modelManager->getMetadata($admin->getClass())->getFieldMapping($fieldDescription->getName());
         $fieldDescription->setOption('enum_type', $mapping['type']);
     }
 }
开发者ID:ynloultratech,项目名称:framework,代码行数:13,代码来源:ListEnumFieldBuilder.php

示例8: getFormAdminType

 /**
  * @param FormMapper     $formMapper
  * @param AdminInterface $admin
  * @param string         $formField
  * @param string         $field
  * @param array          $fieldOptions
  * @param array          $adminOptions
  *
  * @return FormBuilder
  */
 protected final function getFormAdminType(FormMapper $formMapper, AdminInterface $admin, $formField, $field, $fieldOptions = array(), $adminOptions = array())
 {
     $adminOptions = array_merge(array('edit' => 'list', 'translation_domain' => 'SonataClassificationBundle'), $adminOptions);
     $fieldDescription = $admin->getModelManager()->getNewFieldDescriptionInstance($admin->getClass(), $field, $adminOptions);
     $fieldDescription->setAssociationAdmin($admin);
     $fieldDescription->setAdmin($formMapper->getAdmin());
     $fieldDescription->setAssociationMapping(array('fieldName' => $field, 'type' => ClassMetadataInfo::MANY_TO_ONE));
     $fieldOptions = array_merge(array('sonata_field_description' => $fieldDescription, 'class' => $admin->getClass(), 'model_manager' => $admin->getModelManager(), 'required' => false), $fieldOptions);
     return $formMapper->create($formField, 'sonata_type_model_list', $fieldOptions);
 }
开发者ID:kazak,项目名称:forum,代码行数:20,代码来源:AbstractClassificationBlockService.php

示例9: buildField

 /**
  * {@inheritdoc}
  */
 public function buildField($type = null, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
 {
     if ($type == null) {
         $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
         $fieldDescription->setType($guessType->getType());
     } else {
         $fieldDescription->setType($type);
     }
     $this->fixFieldDescription($admin, $fieldDescription);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:13,代码来源:ListBuilder.php

示例10: alterNewInstance

 /**
  * Sanity check and default locale to request locale.
  *
  * {@inheritdoc}
  */
 public function alterNewInstance(AdminInterface $admin, $object)
 {
     if (!$object instanceof TranslatableInterface) {
         throw new \InvalidArgumentException('Expected TranslatableInterface, got ' . get_class($object));
     }
     if ($admin->hasRequest()) {
         $currentLocale = $admin->getRequest()->getLocale();
         if (in_array($currentLocale, $this->locales)) {
             $object->setLocale($currentLocale);
         }
     }
 }
开发者ID:frogriotcom,项目名称:CoreBundle,代码行数:17,代码来源:TranslatableExtension.php

示例11: getTranslatableLocale

 /**
  * Return current translatable locale
  * ie: the locale used to load object translations != current request locale.
  *
  * @return string
  */
 public function getTranslatableLocale(AdminInterface $admin)
 {
     if ($this->translatableLocale == null) {
         if ($admin->getRequest()) {
             $this->translatableLocale = $admin->getRequest()->get(self::TRANSLATABLE_LOCALE_PARAMETER);
         }
         if ($this->translatableLocale == null) {
             $this->translatableLocale = $this->getDefaultTranslationLocale($admin);
         }
     }
     return $this->translatableLocale;
 }
开发者ID:jorrit,项目名称:SonataTranslationBundle,代码行数:18,代码来源:AbstractTranslatableAdminExtension.php

示例12: addField

 /**
  * Adds a field to the Field description collection and sets its type.
  * If not type provided, will try to guess it.
  *
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionCollection $list
  * @param string|null $type
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @return FieldDescriptionCollection
  */
 public function addField(FieldDescriptionCollection $list, $type = null, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
 {
     if ($type == null) {
         $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName());
         $fieldDescription->setType($guessType->getType());
     } else {
         $fieldDescription->setType($type);
     }
     $this->fixFieldDescription($admin, $fieldDescription);
     $admin->addListFieldDescription($fieldDescription->getName(), $fieldDescription);
     return $list->add($fieldDescription);
 }
开发者ID:nzzdev,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:22,代码来源:ListBuilder.php

示例13: build

 /**
  * RouteBuilder that allowes slashes in the ids.
  *
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @param \Sonata\AdminBundle\Route\RouteCollection $collection
  */
 function build(AdminInterface $admin, RouteCollection $collection)
 {
     $collection->add('list');
     $collection->add('create');
     $collection->add('batch');
     $collection->add('edit', $admin->getRouterIdParameter() . '/edit', array(), array('id' => '.+'));
     $collection->add('delete', $admin->getRouterIdParameter() . '/delete', array(), array('id' => '.+'));
     $collection->add('show', $admin->getRouterIdParameter(), array(), array('id' => '.+', '_method' => 'GET'));
     // add children urls
     foreach ($admin->getChildren() as $children) {
         $collection->addCollection($children->getRoutes());
     }
 }
开发者ID:nzzdev,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:19,代码来源:PathInfoBuilderSlashes.php

示例14: preUpdate

 /**
  * {@inheritdoc}
  */
 public function preUpdate(AdminInterface $admin, $object)
 {
     if (!$admin->hasRequest() || !($data = $admin->getRequest()->get($admin->getUniqid()))) {
         return;
     }
     if (!isset($data[$this->fieldName])) {
         return;
     }
     $modelManager = $admin->getModelManager();
     if (!$modelManager instanceof LockInterface) {
         return;
     }
     $modelManager->lock($object, $data[$this->fieldName]);
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:17,代码来源:LockExtension.php

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


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