示例#1
0
 /**
  * @param array $mappings
  * @param array $parent
  * @param       $value
  * @param       $propertyName
  * @param       $data
  */
 protected static function addRelationshipData(array &$mappings, array &$parent, &$value, &$propertyName, &$data)
 {
     if (\array_key_exists(Serializer::CLASS_IDENTIFIER_KEY, $value)) {
         $propertyName = DataAttributesHelper::transformToValidMemberName($propertyName);
         $type = $value[Serializer::CLASS_IDENTIFIER_KEY];
         self::relationshipLinksSelf($mappings, $parent, $propertyName, $type, $data, $value);
         self::relationshipLinksRelated($propertyName, $mappings, $parent, $data);
     }
 }
 /**
  * @param array  $mappings
  * @param array  $data
  * @param array  $value
  * @param string $type
  */
 protected static function addRelationshipsToIncludedResources(array &$mappings, array &$data, array &$value, $type)
 {
     foreach ($value as $propertyName => $attribute) {
         if (PropertyHelper::isAttributeProperty($mappings, $propertyName, $type)) {
             $propertyName = DataAttributesHelper::transformToValidMemberName($propertyName);
             if (\is_array($attribute) && \array_key_exists(Serializer::CLASS_IDENTIFIER_KEY, $attribute)) {
                 $data[$propertyName][JsonApiTransformer::DATA_KEY] = PropertyHelper::setResponseDataTypeAndId($mappings, $attribute);
                 continue;
             }
         }
     }
 }
 /**
  * @param \NilPortugues\Api\Mapping\Mapping $mapping
  *
  * @link http://jsonapi.org/format/#document-member-names-allowed-characters
  */
 protected function buildValidPropertyAlias($mapping)
 {
     $aliases = $mapping->getAliasedProperties();
     foreach ($aliases as &$alias) {
         $alias = DataAttributesHelper::transformToValidMemberName($alias);
     }
     $mapping->setPropertyNameAliases($aliases);
 }