예제 #1
0
 /**
  * Create array from object
  *
  * @param object $object
  *
  * @return mixed[]
  */
 private function setArray($object) : array
 {
     $data = [];
     $configurationObject = $this->configuration->getConfigurationObjectForClass(new ClassName(get_class($object)));
     $identifier = $configurationObject->getIdentifier();
     if ($identifier !== '') {
         $data[$this->configuration->getIdentifierAttribute()] = $identifier;
     }
     foreach ($configurationObject->getAttributes() as $attribute) {
         $type = $configurationObject->getTypeForAttribute($attribute);
         $data = $this->processSerializeForType($type, $object, $data, $attribute);
     }
     return $data;
 }
예제 #2
0
 /**
  * @param Type\Collection\IdentifiedObject $objectType
  * @param object $object
  * @param array $values
  *
  * @return Deserialize
  */
 private function processDeserializeTypeCollectionIdentifiedObject(Type\Collection\IdentifiedObject $objectType, $object, array $values) : self
 {
     $identifierAttribute = $this->configuration->getIdentifierAttribute();
     $objects = [];
     foreach ($values as $key => $objectFromValue) {
         if (isset($objectFromValue[$identifierAttribute]) === false) {
             continue;
         }
         $configurationObject = $this->configuration->getConfigurationObjectForIdentifier($objectFromValue[$identifierAttribute]);
         if ($configurationObject instanceof Blackhole) {
             continue;
         }
         $objects[$key] = $this->setObjectForClass($configurationObject->getClassName(), $objectFromValue);
     }
     $object->{$objectType->setter()}($objects);
     return $this;
 }