@param array  $defaultValuesMap Default values map to filter
@param object $entity           Entity
@param string $entityClass      Entity class

@throws \Darvin\Utils\DefaultValue\DefaultValueException
11267
private function filterDefaultValuesMap(array &$defaultValuesMap, $entity, $entityClass)
    {
        foreach ($defaultValuesMap as $targetProperty => $sourcePropertyPath) {
            if (!$this->propertyAccessor->isReadable($entity, $targetProperty)) {
                throw $this->createPropertyNotReadableException($entityClass, $targetProperty);
            }

            $value = $this->propertyAccessor->getValue($entity, $targetProperty);

            if (null !== $value) {
                unset($defaultValuesMap[$targetProperty]);
            }
        }
    }
233025
private function loadFilterValues()
    {
        $session = new Session();
        $this->filterValues = $session->get($this->getStorageNamespace());
        // Because entities saved into the session are not currently managed,
        // we retrieve the reference id previously set by the storeFilterValues function
        // to load the expected entity
        foreach($this->filters as $datagridFilter) {
            if ($datagridFilter->getType() instanceof DatagridFilterTypeEntity) {
                if (!empty($this->filterValues[$datagridFilter->getName()])) {
                    $filterOptions = $datagridFilter->getOptions();
                    $this->filterValues[$datagridFilter->getName()] = $this->entityManager->getReference(
                        $filterOptions['class'],
                        $this->filterValues[$datagridFilter->getName()]
                    );
                }
            }
        }
    }
814177
protected function extractDefault($defaultValue)
	{
		if($defaultValue==='true')
			$this->defaultValue=true;
		elseif($defaultValue==='false')
			$this->defaultValue=false;
		elseif(strpos($defaultValue,'nextval')===0)
			$this->defaultValue=null;
		elseif(preg_match('/^\'(.*)\'::/',$defaultValue,$matches))
			$this->defaultValue=$this->typecast(str_replace("''","'",$matches[1]));
		elseif(preg_match('/^(-?\d+(\.\d*)?)(::.*)?$/',$defaultValue,$matches))
			$this->defaultValue=$this->typecast($matches[1]);
		// else is null
	}
14268
public function setDefaultValue($defaultValue)
    {
        if (!is_string($defaultValue)) {
            throw new \InvalidArgumentException('The attribute defaultValue on the class Attribute has to be string (' . gettype($defaultValue) . ('object' === gettype($defaultValue) ? ' ' . get_class($defaultValue) : '') . ' given).');
        }

        $this->defaultValue = $defaultValue;

        return $this;
    }
1263708
public static String updateTable(Class<?> entityClass, String defaultTableName) {
        return updateTable(entityClass, defaultTableName, null);
    }
1249674
protected function initializeDefaultValues()
    {
        $defaults = [];

        $filters = $this->getFilterInformation();

        foreach (array_keys($filters) as $key) {
            $defaults[ $key ] = null;
        }

        $this->defaults = $defaults;

        return $this;
    }
269972
public static void initDefaultParameterValues(QueryParameter param,
                                                  List<Serializable> defValues, Map<String, Object> parameterValues) throws QueryException {

        if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
            parameterValues.put(param.getName(), defValues.get(0));
        } else {
            Object[] val = new Object[defValues.size()];
            for (int k = 0, size = defValues.size(); k < size; k++) {
                val[k] = defValues.get(k);
            }
            parameterValues.put(param.getName(), val);
        }
    }
265573
public function setValue($entity, $columnDescriptorId, $value, AutoTablesConfiguration $config) {
        Ensure::isNotNull($entity, 'entity musst not be null');
        $columnDescriptor = $this->getColumnDescriptor($entity, $columnDescriptorId, $config);
        if ($columnDescriptor->getType() == 'datetime') {
            $format = $this->translator->trans('php.date.format', array(), $config->getTransScope());
            $date = \DateTime::createFromFormat($format, $value);
            $columnDescriptor->setValue($entity, $date);
        } else {
            $columnDescriptor->setValue($entity, $value);
        }
    }
1269104
public function mapValue(Entity\Reflection\Property $property, $value)
    {
        // Call adapter's mapping if needed
        if (!$property->getReflection()->hasAdapter()) {
            throw new Exception\InvalidArgumentException(
                "Entity " . $property->getReflection()->getClassName()
                . " has no adapter defined!"
            );
        }
        if (isset($this->adapterMappings[$property->getReflection()->getAdapterName()])) {
            $value = $this->adapterMappings[$property->getReflection()->getAdapterName()]
                ->mapValue($property, $value);
        }

        if ($property->hasOption(Reflection\Property\Option\Map::KEY)) {

            $mapOption = $property->getOption(Reflection\Property\Option\Map::KEY);
            if (!$mapOption) {
                throw new Exception\InvalidArgumentException(
                    "Mapping disabled on property " . $property->getName() . "!"
                );
            }

            // Call map filter from property option
            $filterIn = $mapOption->getFilterIn();
            if ($filterIn) {
                $value = call_user_func($filterIn, $value);
            }
        }

        if ($value === null || $value === "") {
            return null;
        }

        if ($property->isScalarType($property->getType())
            || $property->getType() === Entity\Reflection\Property::TYPE_ARRAY
        ) {
            // Scalar & array

            if ($property->getType() === Reflection\Property::TYPE_BOOLEAN
                && in_array($value, ["false", "true"], true)
            ) {
                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
            }

            if (Validator::isTraversable($value)
                && $property->getType() !== Entity\Reflection\Property::TYPE_ARRAY
            ) {
                throw new Exception\InvalidArgumentException(
                    "Traversable value can not be mapped to scalar!",
                    $value
                );
            }

            if (settype($value, $property->getType())) {
                return $value;
            }
        } elseif ($property->getType() === Entity\Reflection\Property::TYPE_COLLECTION) {
            // Collection

            return $this->mapCollection($property->getTypeOption(), $value);
        } elseif ($property->getType() === Entity\Reflection\Property::TYPE_ENTITY) {
            // Entity

            if ($value instanceof Entity && $property->hasOption(Entity\Reflection\Property::OPTION_MAP_FILTER)) {
                // if value is entity created by filter don't map it again
                return $value;
            }
            return $this->mapEntity($property->getTypeOption(), $value);
        } elseif ($property->getType() === Entity\Reflection\Property::TYPE_DATETIME
            || $property->getType() === Entity\Reflection\Property::TYPE_DATE
        ) {
            // DateTime & Date

            if ($value instanceof \DateTime) {
                return $value;
            } elseif (is_array($value) && isset($value["date"])) {
                $date = $value["date"];
            } elseif (is_object($value) && isset($value->date)) {
                $date = $value->date;
            } else {
                $date = $value;
            }

            if (isset($date)) {

                try {
                    return new \DateTime($date);
                } catch (\Exception $e) {
                    throw new Exception\InvalidArgumentException(
                        "Can not map value to DateTime automatically! "
                        . $e->getMessage(),
                        $value
                    );
                }
            }
        }

        // Unexpected value type
        throw new Exception\InvalidArgumentException(
            "Value can not be mapped automatically!",
            $value
        );
    }
1328080
private function setDefaultValuesOnMetadata(MetadataInterface $metadata, array $defaultValues)
    {
        foreach ($defaultValues as $propertyPath => $value) {
            if (null !== $this->propertyAccessor->getValue($metadata, $propertyPath)) {
                continue;
            }

            $this->propertyAccessor->setValue($metadata, $propertyPath, $value);
        }
    }
491242
protected void setResultType(MappedStatement ms, Class<?> entityClass) {
        EntityTable entityTable = EntityHelper.getEntityTable(entityClass);
        List<ResultMap> resultMaps = new ArrayList<ResultMap>();
        resultMaps.add(entityTable.getResultMap(ms.getConfiguration()));
        MetaObject metaObject = MetaObjectUtil.forObject(ms);
        metaObject.setValue("resultMaps", Collections.unmodifiableList(resultMaps));
    }
723647
public function data_preprocessing(&$defaultvalues) {
        if (isset($defaultvalues['conditions'])) {
            $conditions = unserialize($defaultvalues['conditions']);
            $defaultvalues['timespent'] = $conditions->timespent;
            $defaultvalues['completed'] = $conditions->completed;
            $defaultvalues['gradebetterthan'] = $conditions->gradebetterthan;
        }

        // Set up the completion checkbox which is not part of standard data.
        $defaultvalues['completiontimespentenabled'] =
            !empty($defaultvalues['completiontimespent']) ? 1 : 0;

        if ($this->current->instance) {
            // Editing existing instance - copy existing files into draft area.
            $draftitemid = file_get_submitted_draft_itemid('mediafile');
            file_prepare_draft_area($draftitemid, $this->context->id, 'mod_lesson', 'mediafile', 0, array('subdirs'=>0, 'maxbytes' => $this->course->maxbytes, 'maxfiles' => 1));
            $defaultvalues['mediafile'] = $draftitemid;
        }
    }
909815
public function init($dbType, $defaultValue)
	{
		if ($defaultValue=='(NULL)')
		{
			$defaultValue=null;
		}
		parent::init($dbType, $defaultValue);
	}
1057733
protected function addMappingNode(
        string $nodeName,
        string $entityClass,
        string $entityMappingFile,
        string $entityManager,
        bool $entityEnabled
    ): NodeDefinition {
        $builder = new TreeBuilder();
        $node = $builder->root($nodeName);
        $node
            ->treatFalseLike([
                'enabled' => false,
            ])
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('class')
                    ->defaultValue($entityClass)
                    ->cannotBeEmpty()
                ->end()
                ->scalarNode('mapping_file')
                    ->defaultValue($entityMappingFile)
                    ->cannotBeEmpty()
                ->end()
                ->scalarNode('manager')
                    ->defaultValue($entityManager)
                    ->cannotBeEmpty()
                ->end()
                ->booleanNode('enabled')
                    ->defaultValue($entityEnabled)
                ->end()
            ->end()
        ->end();

        return $node;
    }
1063149
public function data_preprocessing(&$defaultvalues) {
        parent::data_preprocessing($defaultvalues);
        $defaultvalues['completionentriesenabled'] = !empty($defaultvalues['completionentries']) ? 1 : 0;
        if (empty($defaultvalues['completionentries'])) {
            $defaultvalues['completionentries'] = 1;
        }
    }
864668
protected function renderDefault($entity,$entityConfig,$type = self::TYPE_LINK_DEFAULT,array $parameters = array())
    {
        $route = $entityConfig['route'];
        $routeParameters = $entityConfig['routeParameters'];
        $labelMethod = $entityConfig['labelMethod'];
        
        if($labelMethod !== null){
            $label = call_user_func_array([$entity, $labelMethod],array());
        }else{
            $label = (string)$entity;
        }
        if($entityConfig["translation_domain"] !== null){
            $label = $this->trans($label,array(),$entityConfig["translation_domain"]);
        }
        $originalLabel = $label;
        $truncate = 0;
        $addTitle = false;
        if(isset($parameters['truncate'])){
            $truncate = (int) $parameters['truncate'];
            if(strlen($label) > $truncate){
                $label = mb_substr($label, 0, $truncate,'UTF-8').'...';
                $addTitle = true;
            }
        }
        
        if(isset($parameters['_onlyIcon']) && $parameters['_onlyIcon'] === true){
            return $entityConfig['icon'];
        }
        
        $icon = "";
        if($entityConfig['icon'] !== null){
            $icon = sprintf('<i class="%s"></i>',$entityConfig['icon']);
        }
        $buildUrl = $entityConfig["buildUrl"];
        if($buildUrl === null){
            $href = $this->buildUrl($entity, $entityConfig);
        }else{
            $href = $entityConfig["linkGeneratorItem"]->$buildUrl($entity, $entityConfig);
        }
        $entityConfig['url'] = $href;
        if(isset($parameters['_onlyUrl']) && $parameters['_onlyUrl'] === true){
            return $href;
        }
        if($href != ''){
            $extraParameters = '';
            if($addTitle === true){
                $extraParameters .= 'title = "'.$originalLabel.'"';
            }
            $color = $this->container->getParameter('tecnocreaciones_tools.service.link_generator.color');
            $link = sprintf('<a href="%s" style="color:%s" %s>%s&nbsp;%s</a>',$href,$color,$extraParameters,$icon,$label);
        }else{
            $link = sprintf('%s&nbsp;%s',$icon,$label);
        }
        
        if(isset($parameters['_onlyConf']) && $parameters['_onlyConf'] === true){
            return $entityConfig;
        }
        return $link;
    }
914686
public void populate(Entity entity) {
    stream(entity.getEntityType().getAllAttributes())
        .filter(Attribute::hasDefaultValue)
        .forEach(attr -> populateDefaultValues(entity, attr));
  }