public function getControllerArguments(FilterControllerArgumentsEvent $event)
    {
        $namedArguments = $event->getRequest()->attributes->all();
        $argumentMetadatas = $this->argumentMetadataFactory->createArgumentMetadata($event->getController());
        $controllerArguments = $event->getArguments();

        foreach ($argumentMetadatas as $index => $argumentMetadata) {
            if ($argumentMetadata->isVariadic()) {
                // set the rest of the arguments as this arg's value
                $namedArguments[$argumentMetadata->getName()] = \array_slice($controllerArguments, $index);

                break;
            }

            if (!\array_key_exists($index, $controllerArguments)) {
                throw new \LogicException(sprintf('Could not find an argument value for argument %d of the controller.', $index));
            }

            $namedArguments[$argumentMetadata->getName()] = $controllerArguments[$index];
        }

        return $namedArguments;
    }