src/Helper/PageHelper.php
public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
    {
        $setters = [];

        // prefer method name given in the code option
        if ($method) {
            $setters[] = $method;
        }

        $camelizedFieldName = self::camelize($fieldName);
        $setters[] = 'set'.$camelizedFieldName;

        foreach ($setters as $setter) {
            if (method_exists($object, $setter)) {
                call_user_func([&$object, $setter], $value);

                return $object;
            }
        }

        if ($object->getId()) {
            throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
        }

        return $object;
    }
public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
    {
        $setters = [];

        // prefer method name given in the code option
        if ($method) {
            $setters[] = $method;
        }

        $camelizedFieldName = self::camelize($fieldName);
        $setters[] = 'set'.$camelizedFieldName;

        foreach ($setters as $setter) {
            if (method_exists($object, $setter)) {
                call_user_func([&$object, $setter], $value);

                return $object;
            }
        }

        if ($object->getId()) {
            throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
        }

        return $object;
    }
public static function setFieldValue ( PageInterface $ object , $ fieldName , $ value , $ method = null ) { $ setters = [ ] ; // prefer method name given in the code option if ( $ method ) { $ setters [ ] = $ method ; } $ camelizedFieldName = self :: camelize ( $ fieldName ) ; $ setters [ ] = 'set' . $ camelizedFieldName ; foreach ( $ setters as $ setter ) { if ( method_exists ( $ object , $ setter ) ) { call_user_func ( [ & $ object , $ setter ] , $ value ) ; return $ object ; } } if ( $ object -> getId ( ) ) { throw new NoValueException ( sprintf ( 'Unable to set the value of `%s`' , $ camelizedFieldName ) ) ; } return $ object ; }
Set the variables to the given content type object.

@param PageInterface $object
@param $fieldName
@param $value
@param null $method

@return mixed

@throws \Sonata\AdminBundle\Exception\NoValueException
Set the variables to the given content type object .