@param $metadata

@throws MessageFailureException
341851
public function onFailure($metadata)
    {
        $this->completed = true;
        $e = new MessageFailureException($metadata->getElements()['message']);
        $e->setStatusCode($metadata->getElements()['code']);

        throw $e;
    }
1365767
private function validateSchemata(EntityMetadata $metadata)
    {
        $persistence = $metadata->persistence;
        foreach ($persistence->schemata as $k => $schema) {
            if (!isset($schema['keys']) || empty($schema['keys'])) {
                throw MetadataException::invalidMetadata($metadata->type, 'At least one key must be specified to define an index.');
            }
            $persistence->schemata[$k]['options']['name'] = sprintf('modlr_%s', md5(json_encode($schema)));
        }
    }
559430
final protected function addFailureMessage(string $messageKey) : void
    {
        $messages = $this->getPossibleMessages();

        if (! isset($messages[$messageKey])) {
            throw new \RuntimeException('Unknown message key: ' . $messageKey);
        }

        $this->failureMessages[$messageKey] = $messages[$messageKey];
    }
882005
protected function onMetaReceived($metaData)
    {
        if (is_array($this->params)) {
            foreach ($this->params as $columnName => $columnInfo) {
                if (isset($metaData["columns"][$columnName])) {
                    $newColumnName = Utility::get($columnInfo, "name");
                    $currentColumnInfo = $metaData["columns"][$columnName];
                    if ($newColumnName) {
                        unset($columnInfo["name"]);
                        unset($metaData["columns"][$columnName]);
                    }

                    if ($this->override) {
                        $metaData["columns"][($newColumnName) ? $newColumnName : $columnName] = $columnInfo;
                    } else {
                        $metaData["columns"][($newColumnName) ? $newColumnName : $columnName] = array_merge($currentColumnInfo, $columnInfo);
                    }
                }
            }
        } else if (is_callable($this->params)) {
            $func = $this->params;
            $columns = $metaData['columns'];
            $pos = 0;
            foreach ($columns as $c => $cMeta) {
                $newMeta = $func($c, $cMeta, $pos);
                if (isset($newMeta['name'])) {
                    $newName = $newMeta['name'];
                    $this->nameMap[$c] = $newName;
                    // unset($columns[$c]);
                    unset($newMeta['name']);
                    $columns[$newName] = $newMeta;
                } else {
                    $columns[$c] = $newMeta;
                }
                $pos++;
            }
            $metaData['columns'] = $columns;
        }
        return $metaData;
    }
1100239
public function start($data, array $metadata = [], array $options = [])
    {
        $message_array = ['message' => $this->_serializeMessage($data)];
        if (array_key_exists('flags', $options)) {
            $message_array['flags'] = $options['flags'];
        }
        $this->call->startBatch([
            OP_SEND_INITIAL_METADATA => $metadata,
            OP_SEND_MESSAGE => $message_array,
            OP_SEND_CLOSE_FROM_CLIENT => true,
        ]);
    }
97935
private function wrapReflectionGetFileName(StreamMetaData $metadata): void
    {
        $methodCallFinder = new NodeFinderVisitor([MethodCall::class]);
        $traverser        = new NodeTraverser();
        $traverser->addVisitor($methodCallFinder);
        $traverser->traverse($metadata->syntaxTree);

        /** @var MethodCall[] $methodCalls */
        $methodCalls = $methodCallFinder->getFoundNodes();
        foreach ($methodCalls as $methodCallNode) {
            if (($methodCallNode->name instanceof Identifier) && ($methodCallNode->name->toString() === 'getFileName')) {
                $startPosition    = $methodCallNode->getAttribute('startTokenPos');
                $endPosition      = $methodCallNode->getAttribute('endTokenPos');
                $expressionPrefix = '\\' . __CLASS__ . '::resolveFileName(';

                $metadata->tokenStream[$startPosition][1] = $expressionPrefix . $metadata->tokenStream[$startPosition][1];
                $metadata->tokenStream[$endPosition][1] .= ')';
            }

        }
    }
148105
public function handleException(\Exception $exception, Metadata $metadata = null)
	{
		$metadata = $this->getMetadata($metadata, $exception);

		if (false === $this->shouldHandle($metadata))
		{
			return $this;
		}

		$categories = $metadata->getCategories();

		foreach ($this->handlerManager->all($categories) as $handler)
		{
			$handler->handleException($exception, $metadata);
		}

		$this->stats->addException();

		return $this;
	}
277760
public function messageConsumptionFailed(MessageConsumptionFailed $event)
    {
        $this->logger->log(
            $this->logLevel,
            $this->logMessage,
            [
                'exception' => $event->exception(),
                'message' => $event->message()
            ]
        );
    }
215691
private function throwBadRequest($message, $metadata = [], array $headers = [])
    {
        throw new HttpResponseException($this->badRequestResponse($message, $metadata, $headers));
    }
592809
protected function loadParentMetadata(ClassMetadataInterface $metadata)
    {
        $parent = $metadata->getReflectionClass()->getParentClass();

        if ($parent) {
            $metadata->mergeRules($this->getClassMetadata($parent->getName()));
        }
    }
938577
public function removeMetadata(\TechPromux\DynamicQueryBundle\Entity\Metadata $metadata)
    {
        $this->metadatas->removeElement($metadata);
    }
75372
private function serialize(EntityMetadata $metadata)
    {
        switch ($this->serializer) {
            case self::SERIALIZER_PHP:
                return serialize($metadata);
            case self::SERIALIZER_IGBINARY:
                return igbinary_serialize($metadata);
            default:
                throw new RuntimeException('Unable to handle serialization of the metadata object');
        }
    }
403733
private function createFailure($userMessage, $model = null){
        $typeIdentifier = is_null($model) ? 'unknown type' : $model->getTypeIdentifier();
        $message = 'The portable element cannot be registered "'.$typeIdentifier.'", reason: '.$userMessage;
        \common_Logger::w($message);
        return Report::createFailure($message);
    }
744362
public function setMetadata(string $metadata): self
    {
        $this->isValidString($metadata, 1000);

        $this->metadata = $metadata;

        return $this;
    }
865048
private function dispatchMetadataEvent($eventName, EntityMetadata $metadata)
    {
        $metadataArgs = new Events\MetadataArguments($metadata);
        $this->dispatcher->dispatch($eventName, $metadataArgs);
    }
1316872
protected function onMetaReceived($metaData)
    {
        foreach ($this->params as $cName => $cParams) {
            $metaData["columns"][$cName] = array(
                "type" => "string",
            );
        }
        return $metaData;
    }
38183
private function mapTranslatable(ClassMetadata $metadata): void
    {
        $className = $metadata->name;

        try {
            $resourceMetadata = $this->resourceMetadataRegistry->getByClass($className);
        } catch (\InvalidArgumentException $exception) {
            return;
        }

        if (!$resourceMetadata->hasParameter('translation')) {
            return;
        }

        /** @var MetadataInterface $translationResourceMetadata */
        $translationResourceMetadata = $this->resourceMetadataRegistry->get($resourceMetadata->getAlias() . '_translation');

        if (!$metadata->hasAssociation('translations')) {
            $metadata->mapOneToMany([
                'fieldName' => 'translations',
                'targetEntity' => $translationResourceMetadata->getClass('model'),
                'mappedBy' => 'translatable',
                'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY,
                'indexBy' => 'locale',
                'cascade' => ['persist', 'merge', 'remove'],
                'orphanRemoval' => true,
            ]);
        }
    }