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


PHP FieldDescriptionInterface::getAssociationMapping方法代码示例

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


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

示例1: addNewInstance

 /**
  * Add a new instance to the related FieldDescriptionInterface value.
  *
  * @param object                                              $object
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  *
  * @throws \RuntimeException
  */
 public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
 {
     $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
     $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)) {
             $method = sprintf('add%s', $this->camelize(Inflector::singularize($mapping['fieldName'])));
             if (!method_exists($object, $method)) {
                 throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, ClassUtils::getClass($object)));
             }
         }
     }
     $object->{$method}($instance);
 }
开发者ID:netounet,项目名称:SonataAdminBundle,代码行数:24,代码来源:AdminHelper.php

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

示例3: addNewInstance

    /**
     * Add a new instance to the related FieldDescriptionInterface value
     *
     * @param object $object
     * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
     * @return void
     */
    public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
    {
        $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
        $mapping  = $fieldDescription->getAssociationMapping();

        $method = sprintf('add%s', $this->camelize($mapping['fieldName']));

        $object->$method($instance);
    }
开发者ID:nibsirahsieu,项目名称:AdminBundle,代码行数:16,代码来源:AdminHelper.php

示例4: addField

 /**
  * Add a new field type into the provided FormBuilder
  *
  * @param \Symfony\Component\Form\FormBuilder $formBuilder
  * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  * @return void
  */
 public function addField(FormBuilder $formBuilder, FieldDescriptionInterface $fieldDescription)
 {
     // There is a bug in the GraphWalker, so for now we always load related associations
     // for more information : https://github.com/symfony/symfony/pull/1056
     if ($formBuilder->getData() && in_array($fieldDescription->getType(), array(ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY, ClassMetadataInfo::MANY_TO_ONE, ClassMetadataInfo::ONE_TO_ONE))) {
         $value = $fieldDescription->getValue($formBuilder->getData());
         $infos = $fieldDescription->getAssociationMapping();
         if ($value instanceof $infos['targetEntity'] && $value instanceof \Doctrine\ORM\Proxy\Proxy) {
             $relatedId = 'get' . current($fieldDescription->getAdmin()->getModelManager()->getIdentifierFieldNames($infos['targetEntity']));
             $value->{$relatedId}();
             // force to load the lazy loading method __load in the proxy methode
         }
     }
     switch ($fieldDescription->getType()) {
         case ClassMetadataInfo::ONE_TO_MANY:
             $this->getOneToManyField($formBuilder, $fieldDescription);
             break;
         case ClassMetadataInfo::MANY_TO_MANY:
             $this->defineManyToManyField($formBuilder, $fieldDescription);
             break;
         case ClassMetadataInfo::MANY_TO_ONE:
         case ClassMetadataInfo::ONE_TO_ONE:
             $this->defineOneToOneField($formBuilder, $fieldDescription);
             break;
         default:
             list($type, $default_options) = $this->getFormTypeName($fieldDescription);
             $formBuilder->add($fieldDescription->getFieldName(), $type, array_merge($default_options, $fieldDescription->getOption('form_field_options', array())));
     }
 }
开发者ID:renegare,项目名称:AdminBundle,代码行数:36,代码来源:FormContractor.php


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