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


PHP FieldDescriptionInterface::getName方法代码示例

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


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

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

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

示例3: 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)
    {
        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->setAdmin($admin);
        $fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'standard'));

        if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY, ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::ONE_TO_ONE ))) {
            $admin->attachAdminClass($fieldDescription);
        }
    }
开发者ID:nibsirahsieu,项目名称:AdminBundle,代码行数:34,代码来源:FormContractor.php

示例4: getDefaultOptions

 /**
  * @param string                                              $type
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  *
  * @return array
  */
 public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
 {
     $options = array('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:kosolapovvp,项目名称:SonataPropelAdminBundle,代码行数:31,代码来源:FormContractor.php

示例5: fixFieldDescription

 /**
  * @param \Sonata\AdminBundle\Admin\AdminInterface            $admin
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     $fieldDescription->setAdmin($admin);
     if (!$fieldDescription->getType()) {
         throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin)));
     }
     // define the template to use
     if (!$fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));
     }
     // define code and label
     $fieldDescription->setOption('code', $fieldDescription->getOption('code', $fieldDescription->getName()));
     $fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));
 }
开发者ID:kosolapovvp,项目名称:SonataPropelAdminBundle,代码行数:18,代码来源:ShowBuilder.php

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

示例7: fixFieldDescription

 /**
  * {@inheritdoc}
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     if ($fieldDescription->getName() == '_action') {
         $this->buildActionFieldDescription($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]);
             if ($fieldDescription->getOption('sortable') !== false) {
                 $fieldDescription->setOption('sortable', $fieldDescription->getOption('sortable', true));
                 $fieldDescription->setOption('sort_parent_association_mappings', $fieldDescription->getOption('sort_parent_association_mappings', $fieldDescription->getParentAssociationMappings()));
                 $fieldDescription->setOption('sort_field_mapping', $fieldDescription->getOption('sort_field_mapping', $fieldDescription->getFieldMapping()));
             }
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$lastPropertyName])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$lastPropertyName]);
         }
         $fieldDescription->setOption('_sort_order', $fieldDescription->getOption('_sort_order', 'ASC'));
     }
     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:list_orm_many_to_one.html.twig');
                     break;
                 case ClassMetadataInfo::ONE_TO_ONE:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:list_orm_one_to_one.html.twig');
                     break;
                 case ClassMetadataInfo::ONE_TO_MANY:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:list_orm_one_to_many.html.twig');
                     break;
                 case ClassMetadataInfo::MANY_TO_MANY:
                     $fieldDescription->setTemplate('SonataDoctrineORMAdminBundle:CRUD:list_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:saberyounis,项目名称:Sonata-Project,代码行数:60,代码来源:ListBuilder.php

示例8: __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

示例9: fixFieldDescription

 /**
  * {@inheritDoc}
  *
  * @throws \RuntimeException if the $fieldDescription does not have a type.
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     if ($fieldDescription->getName() == '_action') {
         $this->buildActionFieldDescription($fieldDescription);
     }
     $fieldDescription->setAdmin($admin);
     if ($admin->getModelManager()->hasMetadata($admin->getClass())) {
         $metadata = $admin->getModelManager()->getMetadata($admin->getClass());
         // TODO sort on parent associations or node name
         $defaultSortable = true;
         if ($metadata->hasAssociation($fieldDescription->getName()) || $metadata->nodename === $fieldDescription->getName()) {
             $defaultSortable = false;
         }
         // TODO get and set parent association mappings, see
         // https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/issues/106
         //$fieldDescription->setParentAssociationMappings($parentAssociationMappings);
         // set the default field mapping
         if (isset($metadata->mappings[$fieldDescription->getName()])) {
             $fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]);
             if ($fieldDescription->getOption('sortable') !== false) {
                 $fieldDescription->setOption('sortable', $fieldDescription->getOption('sortable', $defaultSortable));
                 $fieldDescription->setOption('sort_parent_association_mappings', $fieldDescription->getOption('sort_parent_association_mappings', $fieldDescription->getParentAssociationMappings()));
                 $fieldDescription->setOption('sort_field_mapping', $fieldDescription->getOption('sort_field_mapping', $fieldDescription->getFieldMapping()));
             }
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$fieldDescription->getName()])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$fieldDescription->getName()]);
         }
         $fieldDescription->setOption('_sort_order', $fieldDescription->getOption('_sort_order', 'ASC'));
     }
     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:list_phpcr_many_to_one.html.twig');
         }
         if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_MANY) {
             $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_many_to_many.html.twig');
         }
         if ($fieldDescription->getMappingType() == 'child' || $fieldDescription->getMappingType() == 'parent') {
             $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_one_to_one.html.twig');
         }
         if ($fieldDescription->getMappingType() == 'children' || $fieldDescription->getMappingType() == 'referrers') {
             $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_one_to_many.html.twig');
         }
     }
     $mappingTypes = array(ClassMetadata::MANY_TO_ONE, ClassMetadata::MANY_TO_MANY, 'children', 'child', 'parent', 'referrers');
     if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && in_array($fieldDescription->getMappingType(), $mappingTypes)) {
         $admin->attachAdminClass($fieldDescription);
     }
 }
开发者ID:Aaike,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:61,代码来源:ListBuilder.php

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

示例11: 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:kosolapovvp,项目名称:SonataPropelAdminBundle,代码行数:13,代码来源:ListBuilder.php

示例12: fixFieldDescription

 /**
  * The method define the correct default settings for the provided FieldDescription
  *
  * @param \Sonata\AdminBundle\Admin\FieldDescription $fieldDescription
  * @return void
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription, array $options = array())
 {
     if ($fieldDescription->getName() == '_action') {
         $this->buildActionFieldDescription($fieldDescription);
     }
     $fieldDescription->mergeOptions($options);
     $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()]);
             if ($fieldDescription->getOption('sortable') !== false) {
                 $fieldDescription->setOption('sortable', $fieldDescription->getOption('sortable', $fieldDescription->getName()));
             }
         }
         // set the default association mapping
         if (isset($metadata->associationMappings[$fieldDescription->getName()])) {
             $fieldDescription->setAssociationMapping($metadata->associationMappings[$fieldDescription->getName()]);
         }
         $fieldDescription->setOption('_sort_order', $fieldDescription->getOption('_sort_order', 'ASC'));
     }
     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(sprintf('SonataAdminBundle:CRUD:list_%s.html.twig', $fieldDescription->getType()));
         if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_ONE) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list_orm_many_to_one.html.twig');
         }
         if ($fieldDescription->getType() == ClassMetadataInfo::ONE_TO_ONE) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list_orm_one_to_one.html.twig');
         }
         if ($fieldDescription->getType() == ClassMetadataInfo::ONE_TO_MANY) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list_orm_one_to_many.html.twig');
         }
         if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_MANY) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list_orm_many_to_many.html.twig');
         }
     }
     if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_ONE) {
         $admin->attachAdminClass($fieldDescription);
     }
     if ($fieldDescription->getType() == ClassMetadataInfo::ONE_TO_ONE) {
         $admin->attachAdminClass($fieldDescription);
     }
     if ($fieldDescription->getType() == ClassMetadataInfo::ONE_TO_MANY) {
         $admin->attachAdminClass($fieldDescription);
     }
     if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_MANY) {
         $admin->attachAdminClass($fieldDescription);
     }
 }
开发者ID:renegare,项目名称:AdminBundle,代码行数:61,代码来源:ListBuilder.php

示例13: fixFieldDescription

 /**
  * The method defines the correct default settings for the provided FieldDescription.
  *
  * @param \Sonata\AdminBundle\Admin\AdminInterface            $admin
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  */
 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:zajca,项目名称:SonataDoctrineMongoDBAdminBundle,代码行数:47,代码来源:ShowBuilder.php

示例14: fixFieldDescription

 /**
  * @throws \RuntimeException
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @param \Sonata\AdminBundle\Admin\FieldDescription $fieldDescription
  * @return void
  */
 public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
 {
     // set default values
     $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()));
     $fieldDescription->setOption('filter_value', $fieldDescription->getOption('filter_value', null));
     $fieldDescription->setOption('filter_options', $fieldDescription->getOption('filter_options', null));
     $fieldDescription->setOption('filter_field_options', $fieldDescription->getOption('filter_field_options', null));
     $fieldDescription->setOption('name', $fieldDescription->getOption('name', $fieldDescription->getName()));
     // set the default type if none is set
     if (!$fieldDescription->getType()) {
         $fieldDescription->setType('string');
     }
     if (!$fieldDescription->getTemplate()) {
         $fieldDescription->setTemplate(sprintf('SonataAdminBundle:CRUD:filter_%s.html.twig', $fieldDescription->getType()));
         if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_ONE) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:filter_many_to_one.html.twig');
         }
         if ($fieldDescription->getType() == ClassMetadataInfo::MANY_TO_MANY) {
             $fieldDescription->setTemplate('SonataAdminBundle:CRUD:filter_many_to_many.html.twig');
         }
     }
 }
开发者ID:renegare,项目名称:AdminBundle,代码行数:44,代码来源:DatagridBuilder.php

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


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