Additional actions after record deleted from DB
@param RecordValue $valueContainer
@param bool $deleteFiles
@return void
@throws \UnexpectedValueException
@throws \InvalidArgumentException
@throws \BadMethodCallException
197371
static public function valueDeleteExtender(RecordValue $valueContainer, $deleteFiles) {
        if ($deleteFiles) {
            /** @var FileColumn $column */
            $column = $valueContainer->getColumn();
            $fileConfig = $column->getConfiguration();
            $pkValue = $valueContainer->getRecord()->getPrimaryKeyValue();
            \File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
            if ($pkValue) {
                \File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
            }
        }
    }
658275
public function exportValue(&$submitvalues, $assoc = false) {
        $value =  $this->prepare_data($this->_findValue($submitvalues));
        return $this->_prepareValue($value, $assoc);
    }
183000
public function addValues(array $fieldValues)
    {
        foreach ($fieldValues as $fieldName => $values) {
            $values = Arr::cast($values);
            if (null === ($field = $this->getField($fieldName))) {
                $message = "unknown field";
                $len = count($values);
                if ($len !== 1) {
                    $message .= " (encountered $len values)";
                }
                $error = new Error($message);
                $error->setName($fieldName);
                $this->addError($error);
            }
            else {
                foreach ($values as $index => $value) {
                    $field->addValue($value, $index);
                }   
            }
        }
    }
719194
public function deleteValue(AttributeValueInterface $attributeValue)
    {
        /* @var \Concrete\Core\Entity\Attribute\Value\AbstractValue $attributeValue */

        $genericValue = $attributeValue->getGenericValue();
        if ($genericValue !== null) {
            $genericValues = $this->getAttributeValueRepository()->findBy(['generic_value' => $genericValue]);
            if (count($genericValues) == 1) {

                // Handle legacy attributes with these three lines.
                $controller = $attributeValue->getAttributeKey()->getController();
                $controller->setAttributeValue($attributeValue);
                $controller->deleteValue();

                $value = $attributeValue->getValueObject();
                if (is_object($value)) {
                    $this->entityManager->remove($value);
                    $this->entityManager->flush();
                }
                $this->entityManager->remove($genericValue);
            }
            $this->entityManager->remove($attributeValue);
        }

        $this->entityManager->flush();
    }
1106954
public function filterChangesOnly(array $oldValues, array &$newValues)
    {
        if ($newValues && $oldValues) {
            // \MUtil_Echo::track($newValues);
            // Remove up unchanged values
            foreach ($newValues as $name => $value) {
                if (array_key_exists($name, $oldValues)) {
                    /*
                     * Token->setValidFrom will convert to a string representation
                     * but values read from database will be Date objects. Make
                     * sure we compare string with strings
                     */
                    if ($value instanceof \Zend_Date) {
                        $value = $value->toString(\Gems_Tracker::DB_DATETIME_FORMAT);
                    }
                    if ($oldValues[$name] instanceof \Zend_Date) {
                        $oldValues[$name] = $oldValues[$name]->toString(\Gems_Tracker::DB_DATETIME_FORMAT);
                    }
                    // Extra condition for empty time in date values
                    if (($value === $oldValues[$name]) || ($value === $oldValues[$name] . ' 00:00:00')) {
                        unset($newValues[$name]);
                    }
                }
            }
        }

        return $newValues;
    }
382680
public function setSearchControlValues($controlValues = [], $rememberPrevious = false)
    {
        if ($rememberPrevious){
            $this->previousSearchValues = $this->model->searchValues;
        } else {
            if ($this->previousSearchValues)   {
                $this->model->searchValues = $this->previousSearchValues;
                $this->previousSearchValues = null;
                return;
            }
        }

        $controlValues = array_merge($this->defaultControlValues, $controlValues);

        foreach ($this->model->searchControls as $control) {
            $controlName = $control->getName();

            if (isset($controlValues[$controlName])) {
                $this->model->searchValues[$controlName] = $controlValues[$controlName];
            }
        }

        $this->reRender();

        $this->searchedEvent->raise();
    }
1367520
protected function loadEntityValues($valueClass, array $entitiesById)
    {
        foreach ($this->getValues($valueClass, $entitiesById) as $valueEntity) {
            $data = $valueEntity->getData();

            $refl = new \ReflectionClass($data);
            $valuesProperty = $refl->getProperty('values');
            $valuesProperty->setAccessible(true);
            $dataValues = $valuesProperty->getValue($data);
            if ($dataValues instanceof PersistentCollection) {
                $dataValues->setInitialized(true);
                $dataValues->add($valueEntity);
            } else {
                throw new \UnexpectedValueException('Data.values is not an instance of PersistentCollection');
            }
        }
    }
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;
        }
    }
928116
public function removedValueChangedListener(ValueChangedListenerInterface $listener)
    {
        if ($this->listeners->hasItem($listener)) {
            $this->listeners->removeItem($listener);
        }
    }
44697
protected function procPropValue($value, array &$validPropertyValues)
    {
        // If the value is not a nested item
        if (!($value instanceof ValueInterface)) {
            throw new InvalidArgumentException(
                sprintf(InvalidArgumentException::INVALID_PROPERTY_VALUE_STR, gettype($value)),
                InvalidArgumentException::INVALID_PROPERTY_VALUE
            );
        }

        // If the value isn't empty
        if (!$value->isEmpty()) {
            $validPropertyValues[] = $value;
        }
    }
192804
public static function createApplicationComponentFromPostValues($postValues)
    {
        if (isset($postValues['title'], $postValues['component'])) {
            $applicationComponent = new \stdClass();
            $applicationComponent->title = $postValues['title'];
            $applicationComponent->slug = StringUtil::slugify($postValues['title']);
            $applicationComponent->component = $postValues['component'];
            $applicationComponent->parameters = new \stdClass();
            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
                foreach ($postValues['parameterNames'] as $key => $value) {
                    $applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
                }
            }

            return $applicationComponent;
        } else {
            throw new \Exception('Trying to create application component with invalid data.');
        }
    }
456722
public function write( string $formatOrContents, ...$contextValues ) : void
	{
		fwrite(
			$this->getFileHandle(),
			sprintf( $formatOrContents, ...$contextValues )
		);
	}
607032
private function fileAddRow($fieldValues = [])
    {
        if ($fieldValues) {
            $this->getFileWriter()->write($fieldValues);
            if (0 === $this->count) {
                // Indicate to other processes that this file is being compiled.
                $this->file->setStatus(File::STATUS_BUILDING);
                $this->fileEntitySave();
            }
            ++$this->count;
        }

        return $this;
    }
110742
public function processFormData(array $valuelist)
    {
        if ($valuelist) {
            $date_str = implode(" ", $valuelist);
            try {
                $this->data = Carbon::createFromFormat($this->carbon_format, $date_str)->startOfDay();
            } catch (\Exception $e) {
                $this->data = null;
                // Do not create a process error if this is an optional field
                if (!empty($date_str) && !$this->flags->optional) {
                    throw new ValueError("Not a valid date value");
                }
            }
        }
    }
888368
public function exportValue(&$submitValues, $assoc = false) {
        $value = $this->_findValue($submitValues);
        if (null === $value) {
            $value = $this->getValue();
        } else if ($value) {
            $value = unformat_float($value, true);
        }
        return $this->_prepareValue($value, $assoc);
    }
706343
public function delete(EntityDefinition $definition, array $ids, WriteContext $writeContext): DeleteResult
    {
        $this->validateWriteInput($ids);

        $commandQueue = new WriteCommandQueue();

        $fields = $definition->getPrimaryKeys();

        $resolved = [];
        foreach ($ids as $raw) {
            $mapped = [];

            /** @var Field $field */
            foreach ($fields as $field) {
                if (!($field instanceof StorageAware)) {
                    continue;
                }

                if (array_key_exists($field->getPropertyName(), $raw)) {
                    $mapped[$field->getStorageName()] = $raw[$field->getPropertyName()];
                    continue;
                }

                if ($field instanceof ReferenceVersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                if ($field instanceof VersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                $fieldKeys = $fields
                    ->filter(function (Field $field) {
                        return !$field instanceof VersionField && !$field instanceof ReferenceVersionField;
                    })
                    ->map(function (Field $field) {
                        return $field->getPropertyName();
                    });

                throw new IncompletePrimaryKeyException($fieldKeys);
            }

            $resolved[] = $mapped;
        }

        if (!$definition instanceof MappingEntityDefinition) {
            $restrictions = $this->foreignKeyResolver->getAffectedDeleteRestrictions($definition, $resolved, $writeContext->getContext());

            if (!empty($restrictions)) {
                $restrictions = array_map(function ($restriction) {
                    return new RestrictDeleteViolation($restriction['pk'], $restriction['restrictions']);
                }, $restrictions);

                throw new RestrictDeleteViolationException($definition, $restrictions, $this->registry);
            }
        }

        $cascades = [];
        if (!$definition instanceof MappingEntityDefinition) {
            $cascadeDeletes = $this->foreignKeyResolver->getAffectedDeletes($definition, $resolved, $writeContext->getContext());

            $cascadeDeletes = array_column($cascadeDeletes, 'restrictions');
            foreach ($cascadeDeletes as $cascadeDelete) {
                $cascades = array_merge_recursive($cascades, $cascadeDelete);
            }

            foreach ($cascades as $affectedDefinitionClass => &$cascade) {
                $affectedDefinition = $this->registry->get($affectedDefinitionClass);

                $cascade = array_map(function ($key) use ($affectedDefinition) {
                    $payload = $key;

                    if (!\is_array($key)) {
                        $payload = ['id' => $key];
                    }

                    return new EntityWriteResult($key, $payload, $affectedDefinition, null);
                }, $cascade);
            }
        }

        $skipped = [];
        foreach ($resolved as $mapped) {
            $mappedBytes = array_map(function ($id) {
                return Uuid::fromHexToBytes($id);
            }, $mapped);

            $existence = $this->gateway->getExistence($definition, $mappedBytes, [], $commandQueue);

            if (!$existence->exists()) {
                $skipped[$definition->getClass()][] = new EntityWriteResult($mapped, $mapped, $definition, $existence);
                continue;
            }

            $commandQueue->add(
                $definition,
                new DeleteCommand(
                    $definition,
                    $mappedBytes,
                    $existence
                )
            );
        }

        $writeContext->setLanguages($this->languageLoader->loadLanguages());
        $identifiers = $this->getWriteResults($commandQueue);
        $this->gateway->execute($commandQueue->getCommandsInOrder(), $writeContext);

        return new DeleteResult(
            array_merge_recursive($identifiers, $cascades),
            $skipped
        );
    }
27961
public void setValueTypes(List<ValueType<?>> valueTypes) {
        Validate.noNullElements(valueTypes);
        this.sqlExecutor.setValueTypes(valueTypes);
        this.callExecutor.setValueTypes(valueTypes);
    }