Core/src/LongRunning/OperationResponseTrait.php
private function deserializeResult($operation, $type, $serializer, array $mappers)
    {
        $mappers = array_filter($mappers, function ($mapper) use ($type) {
            return $mapper['typeUrl'] === $type;
        });

        if (count($mappers) === 0) {
            throw new \RuntimeException(sprintf('No mapper exists for operation response type %s.', $type));
        }

        $mapper = current($mappers);
        $message = $mapper['message'];

        $response = new $message();
        $anyResponse = $operation->getLastProtoResponse()->getResponse();

        if (is_null($anyResponse)) {
            return null;
        }

        $response->mergeFromString($anyResponse->getValue());

        return $serializer->encodeMessage($response);
    }
private function deserializeResult($operation, $type, $serializer, array $mappers)
    {
        $mappers = array_filter($mappers, function ($mapper) use ($type) {
            return $mapper['typeUrl'] === $type;
        });

        if (count($mappers) === 0) {
            throw new \RuntimeException(sprintf('No mapper exists for operation response type %s.', $type));
        }

        $mapper = current($mappers);
        $message = $mapper['message'];

        $response = new $message();
        $anyResponse = $operation->getLastProtoResponse()->getResponse();

        if (is_null($anyResponse)) {
            return null;
        }

        $response->mergeFromString($anyResponse->getValue());

        return $serializer->encodeMessage($response);
    }
private function deserializeResult ( $ operation , $ type , $ serializer , array $ mappers ) { $ mappers = array_filter ( $ mappers , function ( $ mapper ) use ( $ type ) { return $ mapper [ 'typeUrl' ] === $ type ; } ) ; if ( count ( $ mappers ) === 0 ) { throw new \ RuntimeException ( sprintf ( 'No mapper exists for operation response type %s.' , $ type ) ) ; } $ mapper = current ( $ mappers ) ; $ message = $ mapper [ 'message' ] ; $ response = new $ message ( ) ; $ anyResponse = $ operation -> getLastProtoResponse ( ) -> getResponse ( ) ; if ( is_null ( $ anyResponse ) ) { return null ; } $ response -> mergeFromString ( $ anyResponse -> getValue ( ) ) ; return $ serializer -> encodeMessage ( $ response ) ; }
Convert an operation response to an array

@param OperationResponse|GaxOperationResponse $operation The operation to
serialize.
@param string $type The Operation type. The type should correspond to a
member of $mappers.typeUrl.
@param Serializer|GaxSerializer $serializer The gRPC serializer to use
for the deserialization.
@param array $mappers A list of mappers.
@return array|null
Convert an operation response to an array