Datastore/src/EntityMapper.php
public function responseToEntityProperties(array $entityData, $className = Entity::class)
    {
        if (!is_subclass_of($className, EntityInterface::class)) {
            throw new \InvalidArgumentException(sprintf(
                'Class %s must implement EntityInterface.',
                $className
            ));
        }

        $properties = [];
        $excludes = [];
        $meanings = [];

        $mappings = $className::mappings();
        foreach ($entityData as $key => $property) {
            $mapClassName = Entity::class;
            if (array_key_exists($key, $mappings)) {
                $mapClassName = $mappings[$key];
            }

            if ($mapClassName) {
                if (!is_subclass_of($mapClassName, EntityInterface::class)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Class %s must implement EntityInterface. (Found in mappings on %s)',
                        $mapClassName,
                        $className
                    ));
                }
            }

            $properties[$key] = $this->getPropertyValue($property, $mapClassName);

            if (isset($property['excludeFromIndexes']) && $property['excludeFromIndexes']) {
                $excludes[] = $key;
            }

            if (isset($property['meaning']) && $property['meaning']) {
                $meanings[$key] = $property['meaning'];
            }
        }

        return [
            'properties' => $properties,
            'excludes' => $excludes,
            'meanings' => $meanings
        ];
    }
public function responseToEntityProperties(array $entityData, $className = Entity::class)
    {
        if (!is_subclass_of($className, EntityInterface::class)) {
            throw new \InvalidArgumentException(sprintf(
                'Class %s must implement EntityInterface.',
                $className
            ));
        }

        $properties = [];
        $excludes = [];
        $meanings = [];

        $mappings = $className::mappings();
        foreach ($entityData as $key => $property) {
            $mapClassName = Entity::class;
            if (array_key_exists($key, $mappings)) {
                $mapClassName = $mappings[$key];
            }

            if ($mapClassName) {
                if (!is_subclass_of($mapClassName, EntityInterface::class)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Class %s must implement EntityInterface. (Found in mappings on %s)',
                        $mapClassName,
                        $className
                    ));
                }
            }

            $properties[$key] = $this->getPropertyValue($property, $mapClassName);

            if (isset($property['excludeFromIndexes']) && $property['excludeFromIndexes']) {
                $excludes[] = $key;
            }

            if (isset($property['meaning']) && $property['meaning']) {
                $meanings[$key] = $property['meaning'];
            }
        }

        return [
            'properties' => $properties,
            'excludes' => $excludes,
            'meanings' => $meanings
        ];
    }
public function responseToEntityProperties ( array $ entityData , $ className = Entity :: class ) { if ( ! is_subclass_of ( $ className , EntityInterface :: class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class %s must implement EntityInterface.' , $ className ) ) ; } $ properties = [ ] ; $ excludes = [ ] ; $ meanings = [ ] ; $ mappings = $ className :: mappings ( ) ; foreach ( $ entityData as $ key => $ property ) { $ mapClassName = Entity :: class ; if ( array_key_exists ( $ key , $ mappings ) ) { $ mapClassName = $ mappings [ $ key ] ; } if ( $ mapClassName ) { if ( ! is_subclass_of ( $ mapClassName , EntityInterface :: class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class %s must implement EntityInterface. (Found in mappings on %s)' , $ mapClassName , $ className ) ) ; } } $ properties [ $ key ] = $ this -> getPropertyValue ( $ property , $ mapClassName ) ; if ( isset ( $ property [ 'excludeFromIndexes' ] ) && $ property [ 'excludeFromIndexes' ] ) { $ excludes [ ] = $ key ; } if ( isset ( $ property [ 'meaning' ] ) && $ property [ 'meaning' ] ) { $ meanings [ $ key ] = $ property [ 'meaning' ] ; } } return [ 'properties' => $ properties , 'excludes' => $ excludes , 'meanings' => $ meanings ] ; }
Convert an entity response to properties, excludes and meanings.

@param array $entityData The incoming entity
@param string $className The name of a class to use as the entity. Must
implement {@see Google\Cloud\Datastore\EntityInterface}.
@return array
@throws \InvalidArgumentException If the value of $className does not
implement {@see Google\Cloud\Datastore\EntityInterface}.
@throws \InvalidArgumentException If the custom entity type containts invalid
mappings for embedded entities.
Convert an entity response to properties excludes and meanings .