/** * Convert internal value to specific format. * * @param Specification &$specification */ public function prepareSpecification(Specification &$specification) { $value = []; foreach ((array) $specification->getAttribute('value') as $defValueId) { if (Client::isValidMongoId($defValueId)) { $value[] = new ObjectID($defValueId); } } $specification->setAttribute('value', $value); $specification->setAttribute('unit_id', null); }
/** * @return ObjectID */ public function getUserId() { return $this->getAttribute('user_id') && Client::isValidMongoId($this->getAttribute('user_id')) ? new ObjectID($this->getAttribute('user_id')) : null; }
/** * Convert internal value to specific format. * * @param Specification &$specification */ public function prepareSpecification(Specification &$specification) { $value = $specification->getAttribute('value') !== null && Client::isValidMongoId($specification->getAttribute('value')) ? new ObjectID($specification->getAttribute('value')) : null; $specification->setAttribute('value', $value); $specification->setAttribute('unit_id', null); }