public function renderLocaleSwitcher(\Twig_Environment $twig, array $options = [])
    {
        if (!$this->localeSwitcher->hasResource()) {
            $this->localeSwitcher->setResource($this->getPage());
        }

        $options = array_replace([
            'dropdown' => true,
            'tag'      => 'div',
            'attr'     => [],
            'locales'  => [],
            'template' => $this->config['locale_switcher_template'],
        ], $options);

        if (empty($urls = $this->localeSwitcher->getUrls($options['locales']))) {
            return '';
        }

        $current = $this->localeProvider->getCurrentLocale();

        $entries = [];
        foreach ($urls as $locale => $url) {
            $entries[$locale] = $url;
        }

        if (!isset($options['attr']['id'])) {
            $options['attr']['id'] = 'locale-switcher';
        }
        if ($options['dropdown']) {
            $classes = isset($options['attr']['class']) ? $options['attr']['class'] : '';
            $classes = trim($classes . ' dropdown');
            $options['attr']['class'] = $classes;
        }

        return $twig->render($options['template'], [
            'tag'      => $options['tag'],
            'dropdown' => $options['dropdown'],
            'attr'     => $options['attr'],
            'current'  => $current,
            'locales'  => $entries,
        ]);
    }
public function renderLocaleSwitcher(\Twig_Environment $twig, array $options = [])
    {
        if (!$this->localeSwitcher->hasResource()) {
            $this->localeSwitcher->setResource($this->getPage());
        }

        $options = array_replace([
            'dropdown' => true,
            'tag'      => 'div',
            'attr'     => [],
            'locales'  => [],
            'template' => $this->config['locale_switcher_template'],
        ], $options);

        if (empty($urls = $this->localeSwitcher->getUrls($options['locales']))) {
            return '';
        }

        $current = $this->localeProvider->getCurrentLocale();

        $entries = [];
        foreach ($urls as $locale => $url) {
            $entries[$locale] = $url;
        }

        if (!isset($options['attr']['id'])) {
            $options['attr']['id'] = 'locale-switcher';
        }
        if ($options['dropdown']) {
            $classes = isset($options['attr']['class']) ? $options['attr']['class'] : '';
            $classes = trim($classes . ' dropdown');
            $options['attr']['class'] = $classes;
        }

        return $twig->render($options['template'], [
            'tag'      => $options['tag'],
            'dropdown' => $options['dropdown'],
            'attr'     => $options['attr'],
            'current'  => $current,
            'locales'  => $entries,
        ]);
    }
public function renderLocaleSwitcher ( \ Twig_Environment $ twig , array $ options = [ ] ) { if ( ! $ this -> localeSwitcher -> hasResource ( ) ) { $ this -> localeSwitcher -> setResource ( $ this -> getPage ( ) ) ; } $ options = array_replace ( [ 'dropdown' => true , 'tag' => 'div' , 'attr' => [ ] , 'locales' => [ ] , 'template' => $ this -> config [ 'locale_switcher_template' ] , ] , $ options ) ; if ( empty ( $ urls = $ this -> localeSwitcher -> getUrls ( $ options [ 'locales' ] ) ) ) { return '' ; } $ current = $ this -> localeProvider -> getCurrentLocale ( ) ; $ entries = [ ] ; foreach ( $ urls as $ locale => $ url ) { $ entries [ $ locale ] = $ url ; } if ( ! isset ( $ options [ 'attr' ] [ 'id' ] ) ) { $ options [ 'attr' ] [ 'id' ] = 'locale-switcher' ; } if ( $ options [ 'dropdown' ] ) { $ classes = isset ( $ options [ 'attr' ] [ 'class' ] ) ? $ options [ 'attr' ] [ 'class' ] : '' ; $ classes = trim ( $ classes . ' dropdown' ) ; $ options [ 'attr' ] [ 'class' ] = $ classes ; } return $ twig -> render ( $ options [ 'template' ] , [ 'tag' => $ options [ 'tag' ] , 'dropdown' => $ options [ 'dropdown' ] , 'attr' => $ options [ 'attr' ] , 'current' => $ current , 'locales' => $ entries , ] ) ; }
Renders the locale switcher.

@param \Twig_Environment $twig
@param array             $options

@return string
Renders the locale switcher .