src/View/Requirements_Backend.php
public function javascript($file, $options = array())
    {
        $file = ModuleResourceLoader::singleton()->resolvePath($file);

        // Get type
        $type = null;
        if (isset($this->javascript[$file]['type'])) {
            $type = $this->javascript[$file]['type'];
        }
        if (isset($options['type'])) {
            $type = $options['type'];
        }

        // make sure that async/defer is set if it is set once even if file is included multiple times
        $async = (
            isset($options['async']) && isset($options['async']) == true
            || (
                isset($this->javascript[$file])
                && isset($this->javascript[$file]['async'])
                && $this->javascript[$file]['async'] == true
            )
        );
        $defer = (
            isset($options['defer']) && isset($options['defer']) == true
            || (
                isset($this->javascript[$file])
                && isset($this->javascript[$file]['defer'])
                && $this->javascript[$file]['defer'] == true
            )
        );
        $this->javascript[$file] = array(
            'async' => $async,
            'defer' => $defer,
            'type' => $type,
        );

        // Record scripts included in this file
        if (isset($options['provides'])) {
            $this->providedJavascript[$file] = array_values($options['provides']);
        }
    }
public function javascript($file, $options = array())
    {
        $file = ModuleResourceLoader::singleton()->resolvePath($file);

        // Get type
        $type = null;
        if (isset($this->javascript[$file]['type'])) {
            $type = $this->javascript[$file]['type'];
        }
        if (isset($options['type'])) {
            $type = $options['type'];
        }

        // make sure that async/defer is set if it is set once even if file is included multiple times
        $async = (
            isset($options['async']) && isset($options['async']) == true
            || (
                isset($this->javascript[$file])
                && isset($this->javascript[$file]['async'])
                && $this->javascript[$file]['async'] == true
            )
        );
        $defer = (
            isset($options['defer']) && isset($options['defer']) == true
            || (
                isset($this->javascript[$file])
                && isset($this->javascript[$file]['defer'])
                && $this->javascript[$file]['defer'] == true
            )
        );
        $this->javascript[$file] = array(
            'async' => $async,
            'defer' => $defer,
            'type' => $type,
        );

        // Record scripts included in this file
        if (isset($options['provides'])) {
            $this->providedJavascript[$file] = array_values($options['provides']);
        }
    }
public function javascript ( $ file , $ options = array ( ) ) { $ file = ModuleResourceLoader :: singleton ( ) -> resolvePath ( $ file ) ; // Get type $ type = null ; if ( isset ( $ this -> javascript [ $ file ] [ 'type' ] ) ) { $ type = $ this -> javascript [ $ file ] [ 'type' ] ; } if ( isset ( $ options [ 'type' ] ) ) { $ type = $ options [ 'type' ] ; } // make sure that async/defer is set if it is set once even if file is included multiple times $ async = ( isset ( $ options [ 'async' ] ) && isset ( $ options [ 'async' ] ) == true || ( isset ( $ this -> javascript [ $ file ] ) && isset ( $ this -> javascript [ $ file ] [ 'async' ] ) && $ this -> javascript [ $ file ] [ 'async' ] == true ) ) ; $ defer = ( isset ( $ options [ 'defer' ] ) && isset ( $ options [ 'defer' ] ) == true || ( isset ( $ this -> javascript [ $ file ] ) && isset ( $ this -> javascript [ $ file ] [ 'defer' ] ) && $ this -> javascript [ $ file ] [ 'defer' ] == true ) ) ; $ this -> javascript [ $ file ] = array ( 'async' => $ async , 'defer' => $ defer , 'type' => $ type , ) ; // Record scripts included in this file if ( isset ( $ options [ 'provides' ] ) ) { $ this -> providedJavascript [ $ file ] = array_values ( $ options [ 'provides' ] ) ; } }
Register the given JavaScript file as required.

@param string $file Either relative to docroot or in the form "vendor/package:resource"
@param array $options List of options. Available options include:
- 'provides' : List of scripts files included in this file
- 'async' : Boolean value to set async attribute to script tag
- 'defer' : Boolean value to set defer attribute to script tag
- 'type' : Override script type= value.
Register the given JavaScript file as required .