/** * Use inner type to convert each array's value * * @param mixed $value * @param Property $property * @param string $method * * @return array */ protected function convert($value, Property $property, $method) { if (!$property->hasOption('inner_type')) { throw new IncompletePropertyDefinitionException(sprintf('An inner type must be defined for the property "%s"', $property->getName())); } $value = (array) $value; $type = Types::getType($property->getOption('inner_type')); if ($type instanceof self) { throw new \LogicException('Array imbrication is not allowed'); } foreach ($value as &$val) { $val = $type->{$method}($val, $property); } return $value; }
/** * Find the nodes related to the relationship * * @param Property $property * @param array $info * * @return object */ protected function getRelationshipNode(Property $property, array $info) { $nodeClass = $this->map->getClass($property->getOption('node')); foreach ($this->entities as $entity) { if (!$entity instanceof $nodeClass) { continue; } $nodeInfo = $this->entities->getInfo($entity); if ($nodeInfo['realId'] === $info[$property->getType()]) { return $entity; } } $query = new Query(sprintf('MATCH (n:%s) WHERE id(n) = {where}.id RETURN n;', $nodeClass)); $query->addVariable('n', $nodeClass); $query->addParameters('where', ['id' => $info[$property->getType()]]); return $this->uow->execute($query)->current(); }
/** * {@inheritdoc} */ public function convertToPHPValue($value, Property $property) { return json_decode($value, $property->hasOption('associative') ? (bool) $property->getOption('associative') : false); }