src/Twig/Extension/AdvertisingGeneric.php
/**
     * Displays scripts for a specific network or for all networks.
     */
Displays scripts for a specific network or for all networks.
Displays scripts for a specific network or for all networks .
public function showScripts(?string $network = null): string
    {
        $event = new EventTwig();
        $event->setNetwork($network ?: '');
        $this->dispatcher->dispatch($event, EventTwig::TWIG_GENERIC_SHOW_SCRIPTS_PRE);
        $scripts = $event->getScripts();
        if (empty($scripts))
        {
            $scripts = $this->networks->getScriptUrl();
            if (isset($scripts[$network]))
            {
                $scripts = [$scripts[$network]];
            }
        }
        $event->setScripts($scripts);
        $this->dispatcher->dispatch($event, EventTwig::TWIG_GENERIC_SHOW_SCRIPTS_POST);
        $scripts = $event->getScripts();
        if (empty($scripts))
        {
            return '';
        }
        return '<script async src="'.implode('"></script><script async src="', $scripts).'"></script>';
    }
public function showScripts ( ? string $ network = null ) : string { $ event = new EventTwig ( ) ; $ event -> setNetwork ( $ network ? : '' ) ; $ this -> dispatcher -> dispatch ( $ event , EventTwig :: TWIG_GENERIC_SHOW_SCRIPTS_PRE ) ; $ scripts = $ event -> getScripts ( ) ; if ( empty ( $ scripts ) ) { $ scripts = $ this -> networks -> getScriptUrl ( ) ; if ( isset ( $ scripts [ $ network ] ) ) { $ scripts = [ $ scripts [ $ network ] ] ; } } $ event -> setScripts ( $ scripts ) ; $ this -> dispatcher -> dispatch ( $ event , EventTwig :: TWIG_GENERIC_SHOW_SCRIPTS_POST ) ; $ scripts = $ event -> getScripts ( ) ; if ( empty ( $ scripts ) ) { return '' ; } return '<script async src="' . implode ( '"></script><script async src="' , $ scripts ) . '"></script>' ; }
Displays scripts for a specific network or for all networks.
Displays scripts for a specific network or for all networks .