protected function setValue(
        EntityInterface $entity,
        AttributeInterface $attribute,
        $default_value,
        array $options = array()
    ) {
        $attribute_name = $attribute->getName();
        $attribute_options = array();

        if (!empty($options[self::OPTION_FIELD_VALUES])
            && is_array($options[self::OPTION_FIELD_VALUES])
        ) {
            $attribute_options = $options[self::OPTION_FIELD_VALUES];
        }

        if (empty($attribute_options[$attribute_name])) {
            $entity->setValue($attribute_name, $default_value);
        } else {
            $option = $attribute_options[$attribute_name];
            if (is_callable($option)) {
                $entity->setValue($attribute_name, call_user_func($option));
            } else {
                $entity->setValue($attribute_name, $option);
            }
        }
    }
protected function setValue(
        EntityInterface $entity,
        AttributeInterface $attribute,
        $default_value,
        array $options = array()
    ) {
        $attribute_name = $attribute->getName();
        $attribute_options = array();

        if (!empty($options[self::OPTION_FIELD_VALUES])
            && is_array($options[self::OPTION_FIELD_VALUES])
        ) {
            $attribute_options = $options[self::OPTION_FIELD_VALUES];
        }

        if (empty($attribute_options[$attribute_name])) {
            $entity->setValue($attribute_name, $default_value);
        } else {
            $option = $attribute_options[$attribute_name];
            if (is_callable($option)) {
                $entity->setValue($attribute_name, call_user_func($option));
            } else {
                $entity->setValue($attribute_name, $option);
            }
        }
    }
protected function setValue ( EntityInterface $ entity , AttributeInterface $ attribute , $ default_value , array $ options = array ( ) ) { $ attribute_name = $ attribute -> getName ( ) ; $ attribute_options = array ( ) ; if ( ! empty ( $ options [ self :: OPTION_FIELD_VALUES ] ) && is_array ( $ options [ self :: OPTION_FIELD_VALUES ] ) ) { $ attribute_options = $ options [ self :: OPTION_FIELD_VALUES ] ; } if ( empty ( $ attribute_options [ $ attribute_name ] ) ) { $ entity -> setValue ( $ attribute_name , $ default_value ) ; } else { $ option = $ attribute_options [ $ attribute_name ] ; if ( is_callable ( $ option ) ) { $ entity -> setValue ( $ attribute_name , call_user_func ( $ option ) ) ; } else { $ entity -> setValue ( $ attribute_name , $ option ) ; } } }
Sets either given default value or value from option to the given attribute.

@param EntityInterface $entity the entity to modify
@param AttributeInterface $attribute the attribute to set a value for
@param mixed $default_value Default value to set.
@param array $options Array containing a `attribute_name => $mixed` entry.
$mixed is set as value instead of $default_value.
If $mixed is a closure it will be called and used.
$mixed may also be another callable like an array
`array($class, "$methodName")` or a string like
`'Your\Namespace\Foo::getStaticTrololo'`.

@return void
Sets either given default value or value from option to the given attribute .