/** * Occurs before Entity persistence * * @ORM\PreUpdate * * @param AgentCriterionValue $agentCriterionValue * @param LifecycleEventArgs $event */ public function preUpdate(AgentCriterionValue $agentCriterionValue, LifecycleEventArgs $event) { $input = false; $fValue = null; $criterion = $agentCriterionValue->getCriterion(); if ($criterion) { $relationship = $criterion->getRelationship(); if ($relationship) { $input = $relationship->getInput(); } } if ($input) { $method = 'get' . ucwords($input); if (method_exists($agentCriterionValue, $method)) { switch ($input) { case 'boolean': case 'string': case 'daterange': case 'range': $fValue = $agentCriterionValue->{$method}(); break; case 'location': case 'multiple': $fValue = is_array($agentCriterionValue->{$method}()) ? serialize($agentCriterionValue->{$method}()) : $agentCriterionValue->{$method}(); break; } $agentCriterionValue->setValue($fValue); } } }
/** * * @param AgentCriterionValue $value * * @return AgentCriterion */ public function setValue($value) { $value->setCriterion($this); $this->value = $value; return $this; }