{@inheritDoc}
@ODM\PreUpdate
@ODM\PrePersist
436582
public function recalculateRatings()
    {
        // Compute rating value.
        // @todo Need to know weather comments has changed or not.
        // Unfortunately, persistent collection gets no dirty flag,
        // if existing entries are changed....
        // We limit recalculates to the cases where comments gets loaded from
        // the database (which still does not neccessarly mean, there are changes...

        $comments = $this->getComments();
        if ($comments instanceof ArrayCollection // new Comments
            || $comments->isInitialized() // Comments were loaded and eventually changed (we do not know)
            || $comments->isDirty() // new Comments added w/o initializing
        ) {
            $this->getRating(/*recalculate*/ true);
        }
    }
1178738
public function beforeCompile()
	{
		$builder = $this->getContainerBuilder();

		$this->validateConfig($this->defaults);
		$config = $this->getConfig($this->defaults);

		foreach ($builder->findByType('Nette\Mail\IMailer') as $name => $def) {
			$builder->removeDefinition($name);
		}

		if ($config['debugger'] && interface_exists('Tracy\IBarPanel')) {
			$builder->addDefinition($this->prefix('panel'))
				->setClass('RM\MailPanel')
				->addSetup('$newMessageTime', [$config['newMessageTime']])
				->addSetup('$show', [array_unique($config['show'])])
				->addSetup('$autoremove', [$config['autoremove']])
				->addSetup('$hideEmpty', [$config['hideEmpty']]);
		}

		$builder->addDefinition($this->prefix('mailer'))
			->setClass('RM\FileMailer', [Helpers::expand($config['tempDir'], $builder->parameters)])
			->addSetup('@RM\MailPanel::setFileMailer', ['@self'])
			->addSetup('@Tracy\Bar::addPanel', [$this->prefix('@panel')]);
	}
502954
public function prePersist(LifecycleEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();
        $entity = $eventArgs->getEntity();

        $classMetadata = $em->getClassMetadata(get_class($entity));
        if ($this->isBlameable($classMetadata)) {
            if (!$entity->getCreatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setCreatedBy($user);

                    $uow->propertyChanged($entity, 'createdBy', null, $user);
                    $uow->scheduleExtraUpdate($entity, [
                        'createdBy' => [null,  $user],
                    ]);
                }
            }
            if (!$entity->getUpdatedBy()) {
                $user = $this->getUser();
                if ($this->isValidUser($user)) {
                    $entity->setUpdatedBy($user);
                    $uow->propertyChanged($entity, 'updatedBy', null, $user);

                    $uow->scheduleExtraUpdate($entity, [
                        'updatedBy' => [null, $user],
                    ]);
                }
            }
        }
    }
278536
public function beforeUpdate(array &$args) {
        $data = &$args[1];
        $data[$this->_fields['modifiedField']] = date(self::DATE_FORMAT);
    }
828381
public function beforeUpdate($event = null)
    {
        foreach (['child', 'parent'] as $role) {
            $primaryField = $this->getPrimaryField($role);
            $this->wasPrimary[$role] = !empty($this->owner->{$primaryField});
            if (!$this->owner->isActive) {
                $this->owner->{$primaryField} = 0;
            }
        }

        return true;
    }
980665
public function prePersist()
    {
        $this->createdAt = $this->updatedAt = new \DateTime('now');

        if (!$this->metaTitle) {
            $this->setMetaTitle($this->pageName);
        }
    }
375759
protected function prependRecipient($recipients)
    {
        $recipients = static::formatRecipient($recipients);
        $this->recipients = array_merge($recipients, $this->recipients);
    }
554647
public function preSave()
    {
        $this->originalData = $this->original;
        $this->updatedData = $this->attributes;
        
        // Disregard all object based items, like DateTime
        foreach ($this->updatedData as $key => $val) {
            if (gettype($val) == 'object' && !method_exists($val, '__toString')) {
                unset($this->originalData[$key]);
                unset($this->updatedData[$key]);
            }
        }
        
        $this->dirtyData = $this->getDirty();
        $this->updating = $this->exists;
    }
597000
public function updateQuery(string $prependQuery = ' WHERE '): self
    {
        $whereCase = $this->getWhereClause($prependQuery);

        if ($whereCase !== '') {
            $this->query->setDQL($this->query->getDQL().$whereCase);
            $this->query->setHint(
                $this->conditionGenerator->getQueryHintName(),
                $this->getQueryHintValue()
            );
        }

        return $this;
    }
323808
public function prePersist($eventArgs)
    {
        $entity = $eventArgs->getEntity();

        foreach ($this->metadata->getManagedFields($entity) as $field) {
            $value = PropertyHelper::getValue($entity, $field);
            if (null !== $value) {
                $this->scheduleForUpload($value, $entity, $field);
            }
        }
    }
1043050
public function preUpdate(PHP5ObjectBuilder $builder)
    {
        if ($this->withUpdatedAt()) {
            return "if (\$this->isModified() && !\$this->isColumnModified(" . $this->getColumnConstant('update_column', $builder) . ")) {
    \$this->" . $this->getColumnSetter('update_column') . "(time());
}";
        }

        return '';
    }
567689
function compileUpdate()
    {
        $updateManager = new UpdateManager;
        $updateManager->table($this->nodes->source->getLeft());

        foreach ($this->nodes->restrictions as $expr) {
            $updateManager->where($expr);
        }

        foreach ($this->nodes->orders as $order) {
            $updateManager->order($order);
        }

        empty($this->nodes->limit) ?:
            $updateManager->take($this->nodes->limit->getExpression());

        empty($this->nodes->offset) ?:
            $updateManager->skip($this->nodes->offset->getExpression());

        return $updateManager;
    }
991692
public function addHandler(Handler $handler, $getsPrevious = true, $prepend = false)
    {
        foreach ($this->handlers as $level => $handlers) {
            if ($handler->accepts($level)) {
                if ($prepend) {
                    array_unshift($this->handlers[$level], $handler);
                } else {
                    array_push($this->handlers[$level], $handler);
                }
            }
        }
        if ($getsPrevious) {
            $records = array();
            foreach ($this->log as $record) {
                if ($handler->accepts($record['level'])) {
                    $records[] = $record;
                }
            }
            if (count($records)) {
                $handler->handleBatch($records);
            }
        }
    }
58332
public function withPreset(PresetInterface $preset)
	{
		$self = clone $this;
		$self->setOptions($preset->toArray());
		
		return $self;
	}
1333218
private function getPreparedInsertUpdate()
    {
        if (is_null($this->preparedInsertUpdate)) {
            $this->preparedInsertUpdate = $this->getServer()
                ->insert($this->tableName)
                ->set($this->keyColumnName, ':id')
                ->set($this->valueColumnName, ':value')
                ->set($this->expireColumnName, ':expire')
                ->onDuplicateKey($this->keyColumnName)
                ->set($this->valueColumnName, ':newValue')
                ->set($this->expireColumnName, ':newExpire');
        }

        return $this->preparedInsertUpdate;
    }
556528
public function prepValueForDB($value)
    {
        if ($value instanceof MultiValueField) {
            $value = $value->getValue();
        }
        if (is_object($value) || is_array($value)) {
            $value = json_encode($value);
        }

        return parent::prepValueForDB($value);
    }
436355
public function prePersist($object)
    {
        /** @var ContentInterface $contentObject */
        if ($contentObject = $object->getContent()) {
            try {
                $this->getModelManager()->create($contentObject);
                $object->setObjectId($contentObject->getId());
                $this->autoPageDraft($object->getPage());
            } catch (ModelManagerException $e) {
                throw new ModelManagerException($this->trans('Cannot create content, object is invalid', [], 'validators'));
            }
        }
    }