Twig/RecommendationTwigExtension.php
public function showRecommendations(
        Twig_Environment $twigEnvironment,
        $contentId,
        $scenario,
        $limit,
        $contentType,
        $template,
        array $fields,
        array $params = array()
    ) {
        if (empty($fields)) {
            throw new InvalidArgumentException('Missing recommendation fields, at least one field is required');
        }

        $filters = '';
        if (isset($params['filters'])) {
            foreach ($params['filters'] as $key => $filter) {
                $filter = is_array($filter) ? implode(',', $filter) : $filter;
                $filters .= sprintf('&%s=%s', $key, $filter);
            }
        }

        return $twigEnvironment->render(
            sprintf('EzSystemsRecommendationBundle::%s.html.twig', $template),
            array(
                'contentId' => $contentId,
                'language' => $this->getCurrentLanguage(),
                'scenario' => $scenario,
                'limit' => $limit,
                'templateId' => uniqid(),
                'fields' => $fields,
                'filters' => $filters,
                'endpointUrl' => $this->getEndPointUrl(),
                'feedbackUrl' => $this->getFeedbackUrl($this->getContentTypeId($contentType)),
                'contentType' => $this->getContentTypeId($this->getContentIdentifier($contentId)),
                'outputTypeId' => $this->getContentTypeId($contentType),
                'categoryPath' => $this->getLocationPathString($contentId),
            )
        );
    }
public function showRecommendations(
        Twig_Environment $twigEnvironment,
        $contentId,
        $scenario,
        $limit,
        $contentType,
        $template,
        array $fields,
        array $params = array()
    ) {
        if (empty($fields)) {
            throw new InvalidArgumentException('Missing recommendation fields, at least one field is required');
        }

        $filters = '';
        if (isset($params['filters'])) {
            foreach ($params['filters'] as $key => $filter) {
                $filter = is_array($filter) ? implode(',', $filter) : $filter;
                $filters .= sprintf('&%s=%s', $key, $filter);
            }
        }

        return $twigEnvironment->render(
            sprintf('EzSystemsRecommendationBundle::%s.html.twig', $template),
            array(
                'contentId' => $contentId,
                'language' => $this->getCurrentLanguage(),
                'scenario' => $scenario,
                'limit' => $limit,
                'templateId' => uniqid(),
                'fields' => $fields,
                'filters' => $filters,
                'endpointUrl' => $this->getEndPointUrl(),
                'feedbackUrl' => $this->getFeedbackUrl($this->getContentTypeId($contentType)),
                'contentType' => $this->getContentTypeId($this->getContentIdentifier($contentId)),
                'outputTypeId' => $this->getContentTypeId($contentType),
                'categoryPath' => $this->getLocationPathString($contentId),
            )
        );
    }
public function showRecommendations ( Twig_Environment $ twigEnvironment , $ contentId , $ scenario , $ limit , $ contentType , $ template , array $ fields , array $ params = array ( ) ) { if ( empty ( $ fields ) ) { throw new InvalidArgumentException ( 'Missing recommendation fields, at least one field is required' ) ; } $ filters = '' ; if ( isset ( $ params [ 'filters' ] ) ) { foreach ( $ params [ 'filters' ] as $ key => $ filter ) { $ filter = is_array ( $ filter ) ? implode ( ',' , $ filter ) : $ filter ; $ filters .= sprintf ( '&%s=%s' , $ key , $ filter ) ; } } return $ twigEnvironment -> render ( sprintf ( 'EzSystemsRecommendationBundle::%s.html.twig' , $ template ) , array ( 'contentId' => $ contentId , 'language' => $ this -> getCurrentLanguage ( ) , 'scenario' => $ scenario , 'limit' => $ limit , 'templateId' => uniqid ( ) , 'fields' => $ fields , 'filters' => $ filters , 'endpointUrl' => $ this -> getEndPointUrl ( ) , 'feedbackUrl' => $ this -> getFeedbackUrl ( $ this -> getContentTypeId ( $ contentType ) ) , 'contentType' => $ this -> getContentTypeId ( $ this -> getContentIdentifier ( $ contentId ) ) , 'outputTypeId' => $ this -> getContentTypeId ( $ contentType ) , 'categoryPath' => $ this -> getLocationPathString ( $ contentId ) , ) ) ; }
Renders recommendations snippet code.

@param \Twig_Environment $twigEnvironment
@param int|mixed $contentId
@param string $scenario
@param int $limit
@param string $contentType
@param string $template
@param array $fields
@param array $params

@return string

@throws \EzSystems\RecommendationBundle\Exception\InvalidArgumentException when attributes are missing
Renders recommendations snippet code .