src/Admin/AdminHelper.php
public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
    {
        $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
        $mapping = $fieldDescription->getAssociationMapping();

        $method = sprintf('add%s', Inflector::classify($mapping['fieldName']));

        if (!method_exists($object, $method)) {
            $method = rtrim($method, 's');

            if (!method_exists($object, $method)) {
                $method = sprintf('add%s', Inflector::classify(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);
    }
public function addNewInstance($object, FieldDescriptionInterface $fieldDescription)
    {
        $instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
        $mapping = $fieldDescription->getAssociationMapping();

        $method = sprintf('add%s', Inflector::classify($mapping['fieldName']));

        if (!method_exists($object, $method)) {
            $method = rtrim($method, 's');

            if (!method_exists($object, $method)) {
                $method = sprintf('add%s', Inflector::classify(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);
    }
public function addNewInstance ( $ object , FieldDescriptionInterface $ fieldDescription ) { $ instance = $ fieldDescription -> getAssociationAdmin ( ) -> getNewInstance ( ) ; $ mapping = $ fieldDescription -> getAssociationMapping ( ) ; $ method = sprintf ( 'add%s' , Inflector :: classify ( $ mapping [ 'fieldName' ] ) ) ; if ( ! method_exists ( $ object , $ method ) ) { $ method = rtrim ( $ method , 's' ) ; if ( ! method_exists ( $ object , $ method ) ) { $ method = sprintf ( 'add%s' , Inflector :: classify ( 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 ) ; }
Add a new instance to the related FieldDescriptionInterface value.

@param object $object

@throws \RuntimeException
Add a new instance to the related FieldDescriptionInterface value .