public function apply(Request $request, ParamConverterConfiguration $configuration)
    {
        $supportedParameters = [
            'tagId' => 'tag',
            'parentId' => 'parentTag',
        ];

        foreach ($supportedParameters as $source => $destination) {
            if (!$request->attributes->has($source)) {
                continue;
            }

            if (empty($request->attributes->get($source))) {
                if ($configuration->isOptional()) {
                    continue;
                }

                throw new InvalidArgumentException(
                    sprintf('Required request attribute "%s" is empty.', $source)
                );
            }

            $request->attributes->set(
                $destination,
                $this->tagsService->loadTag(
                    $request->attributes->get($source)
                )
            );
        }

        return true;
    }
public function apply(Request $request, ParamConverterConfiguration $configuration)
    {
        $supportedParameters = [
            'tagId' => 'tag',
            'parentId' => 'parentTag',
        ];

        foreach ($supportedParameters as $source => $destination) {
            if (!$request->attributes->has($source)) {
                continue;
            }

            if (empty($request->attributes->get($source))) {
                if ($configuration->isOptional()) {
                    continue;
                }

                throw new InvalidArgumentException(
                    sprintf('Required request attribute "%s" is empty.', $source)
                );
            }

            $request->attributes->set(
                $destination,
                $this->tagsService->loadTag(
                    $request->attributes->get($source)
                )
            );
        }

        return true;
    }
public function apply ( Request $ request , ParamConverterConfiguration $ configuration ) { $ supportedParameters = [ 'tagId' => 'tag' , 'parentId' => 'parentTag' , ] ; foreach ( $ supportedParameters as $ source => $ destination ) { if ( ! $ request -> attributes -> has ( $ source ) ) { continue ; } if ( empty ( $ request -> attributes -> get ( $ source ) ) ) { if ( $ configuration -> isOptional ( ) ) { continue ; } throw new InvalidArgumentException ( sprintf ( 'Required request attribute "%s" is empty.' , $ source ) ) ; } $ request -> attributes -> set ( $ destination , $ this -> tagsService -> loadTag ( $ request -> attributes -> get ( $ source ) ) ) ; } return true ; }
For given tag ID in the request, it loads a tag and passes it as a parameter to called action method.

@param \Symfony\Component\HttpFoundation\Request $request The request
@param \Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter $configuration Contains the name, class and options of the object

@throws \Netgen\TagsBundle\Exception\InvalidArgumentException If the required argument is empty

@return bool True if the object has been successfully set, else false
For given tag ID in the request it loads a tag and passes it as a parameter to called action method .