示例#1
0
 /**
  * @param array           $response
  * @param ResultInterface $result
  *
  * @return ResultInterface
  */
 public function map(array $response, ResultInterface $result)
 {
     foreach ($result->getFields() as $field) {
         $this->mapField($field, $response, $result);
     }
     return $result;
 }
示例#2
0
 private function translateValueObject(ValueObject $meta, ResultInterface $result, RelationshipInterface $relationship) : CollectionInterface
 {
     $node = $result->nodes()->get($relationship->startNode()->value());
     $data = new Collection([]);
     $meta->properties()->foreach(function (string $name, Property $property) use(&$data, $node) {
         if ($property->type()->isNullable() && !$node->properties()->hasKey($name)) {
             return;
         }
         $data = $data->set($name, $node->properties()->get($name));
     });
     return $data;
 }
示例#3
0
 /**
  * Translate a raw dbal result into formated data usable for entity factories
  *
  * @param ResultInterface $result
  * @param MapInterface<string, EntityInterface> $variables Association between query variables and entity definitions
  *
  * @return MapInterface<string, CollectionInterface>
  */
 public function translate(ResultInterface $result, MapInterface $variables) : MapInterface
 {
     $mapped = new Map('string', CollectionInterface::class);
     $variables->foreach(function (string $variable, EntityInterface $meta) use(&$mapped, $result) {
         $forVariable = $result->rows()->filter(function (RowInterface $row) use($variable) {
             return $row->column() === $variable;
         });
         if ($forVariable->count() === 0) {
             return;
         }
         $translator = $this->translators->get(get_class($meta));
         $mapped = $mapped->put($variable, $translator->translate($variable, $meta, $result));
     });
     return $mapped;
 }
 private function translateRelationship($identity, EntityInterface $meta, ResultInterface $result) : CollectionInterface
 {
     $relationship = $result->relationships()->filter(function (RelationshipInterface $relationship) use($identity, $meta) {
         $id = $meta->identity()->property();
         $properties = $relationship->properties();
         return $properties->hasKey($id) && $properties->get($id) === $identity;
     })->first();
     $data = (new Collection([]))->set($meta->identity()->property(), $relationship->properties()->get($meta->identity()->property()))->set($meta->startNode()->property(), $result->nodes()->get($relationship->startNode()->value())->properties()->get($meta->startNode()->target()))->set($meta->endNode()->property(), $result->nodes()->get($relationship->endNode()->value())->properties()->get($meta->endNode()->target()));
     $meta->properties()->foreach(function (string $name, Property $property) use(&$data, $relationship) {
         if ($property->type()->isNullable() && !$relationship->properties()->hasKey($name)) {
             return;
         }
         $data = $data->set($name, $relationship->properties()->get($name));
     });
     return $data;
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function merge(ResultInterface $resultInterface, $fieldPrefix = '')
 {
     foreach ($resultInterface->getErrors() as $key => $error) {
         $this->errors[$fieldPrefix . $key] = $error;
     }
     foreach ($resultInterface->getFailedRules() as $key => $rules) {
         $this->failedRules[$fieldPrefix . $key] = $rules;
     }
     foreach ($resultInterface->getValidated() as $name) {
         $this->validated[] = $fieldPrefix . $name;
     }
     if (!$resultInterface->isValid()) {
         $this->result = false;
     }
     return $this;
 }
 /**
  * @inheritdoc
  * 
  * @return string
  */
 public function getBrowser()
 {
     return $this->uaParsedData->getBrowser()->getFamily() . " " . $this->uaParsedData->getBrowser()->getVersionString();
 }