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


PHP Admin\FieldDescriptionInterface类代码示例

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


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

示例1: addFilter

 /**
  * @param \Sonata\AdminBundle\Datagrid\DatagridInterface      $datagrid
  * @param null                                                $type
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @param \Sonata\AdminBundle\Admin\AdminInterface            $admin
  */
 public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
 {
     if ($type == null) {
         $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
         $type = $guessType->getType();
         $fieldDescription->setType($type);
         $options = $guessType->getOptions();
         foreach ($options as $name => $value) {
             if (is_array($value)) {
                 $fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, array())));
             } else {
                 $fieldDescription->setOption($name, $fieldDescription->getOption($name, $value));
             }
         }
     } else {
         $fieldDescription->setType($type);
     }
     $this->fixFieldDescription($admin, $fieldDescription);
     $admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);
     $fieldDescription->mergeOption('field_options', array('required' => false));
     $filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());
     if (false !== $filter->getLabel() && !$filter->getLabel()) {
         $filter->setLabel($admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'filter', 'label'));
     }
     $datagrid->addFilter($filter);
 }
开发者ID:zajca,项目名称:SonataDoctrineMongoDBAdminBundle,代码行数:32,代码来源:DatagridBuilder.php

示例2: fixFieldDescription

 /**
  * The method defines the correct default settings for the provided FieldDescription.
  *
  * {@inheritdoc}
  *
  * @throws \RuntimeException if the $fieldDescription does not have a type.
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     $fieldDescription->setAdmin($admin);
     if ($admin->getModelManager()->hasMetadata($admin->getClass())) {
         $metadata = $admin->getModelManager()->getMetadata($admin->getClass());
         // set the default field mapping
         if (isset($metadata->fieldMappings[$fieldDescription->getName()])) {
             $fieldDescription->setFieldMapping($metadata->fieldMappings[$fieldDescription->getName()]);
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$fieldDescription->getName()])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$fieldDescription->getName()]);
         }
     }
     if (!$fieldDescription->getType()) {
         throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin)));
     }
     $fieldDescription->setOption('code', $fieldDescription->getOption('code', $fieldDescription->getName()));
     $fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));
     if (!$fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));
         if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_ONE) {
             $fieldDescription->setTemplate('SonataDoctrinePhpcrAdminBundle:CRUD:show_phpcr_many_to_one.html.twig');
         }
         if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_MANY) {
             $fieldDescription->setTemplate('SonataDoctrinePhpcrAdminBundle:CRUD:show_phpcr_many_to_many.html.twig');
         }
     }
     switch ($fieldDescription->getMappingType()) {
         case ClassMetadata::MANY_TO_ONE:
         case ClassMetadata::MANY_TO_MANY:
             $admin->attachAdminClass($fieldDescription);
             break;
     }
 }
开发者ID:jmontoyaa,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:42,代码来源:ShowBuilder.php

示例3: getDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
 {
     $options = array();
     $options['sonata_field_description'] = $fieldDescription;
     if ($type == 'sonata_type_model' || $type == 'sonata_type_model_list') {
         if ($fieldDescription->getOption('edit') == 'list') {
             throw new \LogicException('The ``sonata_type_model`` type does not accept an ``edit`` option anymore, please review the UPGRADE-2.1.md file from the SonataAdminBundle');
         }
         $options['class'] = $fieldDescription->getTargetEntity();
         $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
     } elseif ($type == 'sonata_type_admin') {
         if (!$fieldDescription->getAssociationAdmin()) {
             throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
         }
         $options['data_class'] = $fieldDescription->getAssociationAdmin()->getClass();
         $fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));
     } elseif ($type == 'sonata_type_collection') {
         if (!$fieldDescription->getAssociationAdmin()) {
             throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
         }
         $options['type'] = 'sonata_type_admin';
         $options['modifiable'] = true;
         $options['type_options'] = array('sonata_field_description' => $fieldDescription, 'data_class' => $fieldDescription->getAssociationAdmin()->getClass());
     }
     return $options;
 }
开发者ID:kamillo1888,项目名称:SonataDoctrineMongoDBAdminBundle,代码行数:29,代码来源:FormContractor.php

示例4: __construct

 public function __construct(FieldDescriptionInterface $fieldDescription)
 {
     $this->name               = $fieldDescription->getName();
     $this->fieldDescription   = $fieldDescription;
     $this->options            = array_replace(
         $this->getDefaultOptions(),
         $this->fieldDescription->getOption('filter_options', array())
     );
 }
开发者ID:nibsirahsieu,项目名称:AdminBundle,代码行数:9,代码来源:Filter.php

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

示例6: getTemplate

 /**
  * @param FieldDescriptionInterface $fieldDescription
  * @param string                    $defaultTemplate
  *
  * @return \Twig_TemplateInterface
  */
 protected function getTemplate(FieldDescriptionInterface $fieldDescription, $defaultTemplate)
 {
     $templateName = $fieldDescription->getTemplate() ?: $defaultTemplate;
     try {
         $template = $this->environment->loadTemplate($templateName);
     } catch (\Twig_Error_Loader $e) {
         $template = $this->environment->loadTemplate($defaultTemplate);
     }
     return $template;
 }
开发者ID:pirasterize,项目名称:sonata-form-builder,代码行数:16,代码来源:FormBuilderExtension.php

示例7: getDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
 {
     $options = array();
     $options['sonata_field_description'] = $fieldDescription;
     if ($type == 'sonata_type_model' || $type == 'sonata_type_model_list' || $type == 'sonata_type_model_hidden') {
         if ($fieldDescription->getOption('edit') == 'list') {
             throw new \LogicException('The ``sonata_type_model`` type does not accept an ``edit`` option anymore, please review the UPGRADE-2.1.md file from the SonataAdminBundle');
         }
         $options['class'] = $fieldDescription->getTargetEntity();
         $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
     } elseif ($type == 'sonata_type_admin') {
         if (!$fieldDescription->getAssociationAdmin()) {
             throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
         }
         if (!in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE))) {
             throw new \RuntimeException(sprintf('You are trying to add `sonata_type_admin` field `%s` which is not One-To-One or  Many-To-One. Maybe you want `sonata_model_list` instead?', $fieldDescription->getName()));
         }
         $options['data_class'] = $fieldDescription->getAssociationAdmin()->getClass();
         $fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));
     } elseif ($type == 'sonata_type_collection') {
         if (!$fieldDescription->getAssociationAdmin()) {
             throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
         }
         $options['type'] = 'sonata_type_admin';
         $options['modifiable'] = true;
         $options['type_options'] = array('sonata_field_description' => $fieldDescription, 'data_class' => $fieldDescription->getAssociationAdmin()->getClass());
     }
     return $options;
 }
开发者ID:serialken,项目名称:BugTracker,代码行数:32,代码来源:FormContractor.php

示例8: fixFieldDescription

 /**
  * The method defines the correct default settings for the provided FieldDescription
  *
  * @param \Sonata\AdminBundle\Admin\AdminInterface            $admin
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  *
  * @return void
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     $fieldDescription->setAdmin($admin);
     if ($admin->getModelManager()->hasMetadata($admin->getClass())) {
         list($metadata, $lastPropertyName, $parentAssociationMappings) = $admin->getModelManager()->getParentMetadataForProperty($admin->getClass(), $fieldDescription->getName());
         $fieldDescription->setParentAssociationMappings($parentAssociationMappings);
         // set the default field mapping
         if (isset($metadata->fieldMappings[$lastPropertyName])) {
             $fieldDescription->setFieldMapping($metadata->fieldMappings[$lastPropertyName]);
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$lastPropertyName])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$lastPropertyName]);
         }
     }
     if (!$fieldDescription->getType()) {
         throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin)));
     }
     $fieldDescription->setOption('code', $fieldDescription->getOption('code', $fieldDescription->getName()));
     $fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));
     if (!$fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));
         if (!$fieldDescription->getTemplate()) {
             switch ($fieldDescription->getMappingType()) {
                 case ClassMetadataInfo::MANY_TO_ONE:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:show_orm_many_to_one.html.twig');
                     break;
                 case ClassMetadataInfo::ONE_TO_ONE:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:show_orm_one_to_one.html.twig');
                     break;
                 case ClassMetadataInfo::ONE_TO_MANY:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:show_orm_one_to_many.html.twig');
                     break;
                 case ClassMetadataInfo::MANY_TO_MANY:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:show_orm_many_to_many.html.twig');
                     break;
             }
         }
     }
     switch ($fieldDescription->getMappingType()) {
         case ClassMetadataInfo::MANY_TO_ONE:
         case ClassMetadataInfo::ONE_TO_ONE:
         case ClassMetadataInfo::ONE_TO_MANY:
         case ClassMetadataInfo::MANY_TO_MANY:
             $admin->attachAdminClass($fieldDescription);
             break;
     }
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:56,代码来源:ShowBuilder.php

示例9: addNewInstance

 /**
  * {@inheritdoc}
  */
 public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
 {
     $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
     foreach ($this->newLayoutBlockParameters as $attr => $value) {
         $method = sprintf('set%s', $this->camelize($attr));
         $instance->{$method}($value);
     }
     $mapping = $fieldDescription->getAssociationMapping();
     $method = sprintf('add%s', $this->camelize($mapping['fieldName']));
     if (!method_exists($object, $method)) {
         $method = rtrim($method, 's');
         if (!method_exists($object, $method)) {
             throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, get_class($object)));
         }
     }
     $object->{$method}($instance);
 }
开发者ID:rapemer,项目名称:init-cms-bundle,代码行数:20,代码来源:PageAdminHelper.php

示例10: getDefaultOptions

 /**
  * @param $type
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @return array
  */
 public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
 {
     $options = array();
     $options['sonata_field_description'] = $fieldDescription;
     if ($type == 'doctrine_phpcr_type_tree_model') {
         $options['class'] = $fieldDescription->getTargetEntity();
         $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
     }
     if ($type == 'sonata_type_model') {
         $options['class'] = $fieldDescription->getTargetEntity();
         $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
         switch ($fieldDescription->getMappingType()) {
             case ClassMetadata::ONE_TO_MANY:
             case ClassMetadata::MANY_TO_MANY:
                 $options['multiple'] = true;
                 $options['parent'] = 'choice';
                 break;
             case ClassMetadata::MANY_TO_ONE:
             case ClassMetadata::ONE_TO_ONE:
                 break;
         }
         if ($fieldDescription->getOption('edit') == 'list') {
             $options['parent'] = 'text';
             if (!array_key_exists('required', $options)) {
                 $options['required'] = false;
             }
         }
     } else {
         if ($type == 'sonata_type_admin') {
             // nothing here ...
             $options['edit'] = 'inline';
         } else {
             if ($type == 'sonata_type_collection') {
                 $options['type'] = 'sonata_type_admin';
                 $options['modifiable'] = true;
                 $options['type_options'] = array('sonata_field_description' => $fieldDescription, 'data_class' => $fieldDescription->getAssociationAdmin()->getClass());
             }
         }
     }
     return $options;
 }
开发者ID:richardmiller,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:46,代码来源:FormContractor.php

示例11: fixFieldDescription

 /**
  * The method defines the correct default settings for the provided FieldDescription
  *
  * @param \Sonata\AdminBundle\Admin\AdminInterface            $admin
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  *
  * @return void
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     $fieldDescription->setAdmin($admin);
     if ($admin->getModelManager()->hasMetadata($admin->getClass())) {
         list($metadata, $lastPropertyName, $parentAssociationMappings) = $admin->getModelManager()->getParentMetadataForProperty($admin->getClass(), $fieldDescription->getName());
         $fieldDescription->setParentAssociationMappings($parentAssociationMappings);
         // set the default field mapping
         if (isset($metadata->fieldMappings[$lastPropertyName])) {
             $fieldDescription->setFieldMapping($metadata->fieldMappings[$lastPropertyName]);
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$lastPropertyName])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$lastPropertyName]);
         }
     }
     if (!$fieldDescription->getType()) {
         throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin)));
     }
     $fieldDescription->setOption('code', $fieldDescription->getOption('code', $fieldDescription->getName()));
     $fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));
     if (!$fieldDescription->getTemplate()) {
         if ($fieldDescription->getType() == 'id') {
             $fieldDescription->setType('string');
         }
         if ($fieldDescription->getType() == 'int') {
             $fieldDescription->setType('integer');
         }
         $template = $this->getTemplate($fieldDescription->getType());
         if ($template === null) {
             if ($fieldDescription->getMappingType() == ClassMetadataInfo::ONE) {
                 $template = 'SonataDoctrineMongoDBAdminBundle:CRUD:show_mongo_one.html.twig';
             } elseif ($fieldDescription->getMappingType() == ClassMetadataInfo::MANY) {
                 $template = 'SonataDoctrineMongoDBAdminBundle:CRUD:show_mongo_many.html.twig';
             }
         }
         $fieldDescription->setTemplate($template);
     }
     if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
         $admin->attachAdminClass($fieldDescription);
     }
 }
开发者ID:jdshao,项目名称:symfony_backstage,代码行数:49,代码来源:ShowBuilder.php

示例12: buildActionFieldDescription

 /**
  * @param FieldDescriptionInterface $fieldDescription
  *
  * @return FieldDescriptionInterface
  */
 public function buildActionFieldDescription(FieldDescriptionInterface $fieldDescription)
 {
     if (null === $fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list__action.html.twig');
     }
     if (null === $fieldDescription->getType()) {
         $fieldDescription->setType('action');
     }
     if (null === $fieldDescription->getOption('name')) {
         $fieldDescription->setOption('name', 'Action');
     }
     if (null === $fieldDescription->getOption('code')) {
         $fieldDescription->setOption('code', 'Action');
     }
     if (null !== $fieldDescription->getOption('actions')) {
         $actions = $fieldDescription->getOption('actions');
         foreach ($actions as $k => $action) {
             if (!isset($action['template'])) {
                 $actions[$k]['template'] = sprintf('SonataAdminBundle:CRUD:list__action_%s.html.twig', $k);
             }
         }
         $fieldDescription->setOption('actions', $actions);
     }
     return $fieldDescription;
 }
开发者ID:kosolapovvp,项目名称:SonataPropelAdminBundle,代码行数:30,代码来源:ListBuilder.php

示例13: addFilter

 /**
  * @param \Sonata\AdminBundle\Datagrid\DatagridInterface $datagrid
  * @param null $type
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @return \Sonata\AdminBundle\Filter\FilterInterface
  */
 public function addFilter(DatagridInterface $datagrid, $type = null, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
 {
     if ($type == null) {
         $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName());
         $type = $guessType->getType();
         $fieldDescription->setType($type);
         $options = $guessType->getOptions();
         foreach ($options as $name => $value) {
             if (is_array($value)) {
                 $fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, array())));
             } else {
                 $fieldDescription->setOption($name, $fieldDescription->getOption($name, $value));
             }
         }
     } else {
         $fieldDescription->setType($type);
     }
     $this->fixFieldDescription($admin, $fieldDescription);
     $admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);
     $fieldDescription->mergeOption('field_options', array('required' => false));
     $filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());
     $datagrid->addFilter($filter);
     return $datagrid->addFilter($filter);
 }
开发者ID:helmer,项目名称:SonataAdminBundle,代码行数:31,代码来源:DatagridBuilder.php

示例14: fixFieldDescription

 /**
  * {@inheritdoc}
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     if (null === $fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list__action.html.twig');
     }
     if (null === $fieldDescription->getType()) {
         $fieldDescription->setType('action');
     }
     if (null === $fieldDescription->getOption('name')) {
         $fieldDescription->setOption('name', 'Action');
     }
     if (null === $fieldDescription->getOption('code')) {
         $fieldDescription->setOption('code', 'Action');
     }
     if (null === $fieldDescription->getOption('header_style') && $fieldDescription->getOption('dropdown')) {
         $fieldDescription->setOption('header_style', 'width:40px');
     }
     if (null !== $fieldDescription->getOption('actions')) {
         $actions = $fieldDescription->getOption('actions');
         foreach ($actions as $k => &$action) {
             //only set the template if really exists
             //set to default any template that not exists
             if (!isset($action['template'])) {
                 if ($fieldDescription->getOption('dropdown')) {
                     $template = sprintf('SonataAdminBundle:CRUD:list__action_dropdown_%s.html.twig', $k);
                 } else {
                     $template = sprintf('SonataAdminBundle:CRUD:list__action_%s.html.twig', $k);
                 }
                 try {
                     $this->twig->loadTemplate($template);
                 } catch (\Twig_Error_Loader $e) {
                     if ($fieldDescription->getOption('dropdown')) {
                         $template = 'YnloAdminBundle::CRUD/list__action_dropdown_default.html.twig';
                     } else {
                         $template = 'YnloAdminBundle::CRUD/list__action_default.html.twig';
                     }
                 }
                 $action['template'] = $template;
             }
             //set default role
             if (!isset($action['role'])) {
                 $role = strtoupper($k);
                 $action['role'] = $role === 'SHOW' ? 'VIEW' : $role;
             }
             //set default visibility
             if (!isset($action['visible'])) {
                 $action['visible'] = true;
             }
         }
         $fieldDescription->setOption('actions', $actions);
     }
     //hide default label
     if (in_array($fieldDescription->getOption('label'), ['_action', 'Action'])) {
         $fieldDescription->setOption('label', ' ');
     }
     return $fieldDescription;
 }
开发者ID:ynloultratech,项目名称:framework,代码行数:60,代码来源:ListActionFieldBuilder.php

示例15: getSortParameters

 /**
  * {@inheritdoc}
  */
 public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid)
 {
     $values = $datagrid->getValues();
     if ($fieldDescription->getName() == $values['_sort_by']->getName() || $values['_sort_by']->getName() === $fieldDescription->getOption('sortable')) {
         if ($values['_sort_order'] == 'ASC') {
             $values['_sort_order'] = 'DESC';
         } else {
             $values['_sort_order'] = 'ASC';
         }
     } else {
         $values['_sort_order'] = 'ASC';
     }
     $values['_sort_by'] = is_string($fieldDescription->getOption('sortable')) ? $fieldDescription->getOption('sortable') : $fieldDescription->getName();
     return array('filter' => $values);
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:18,代码来源:ModelManager.php


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