Twig/IncludeLibraryCode.php
public function Code(Environment $environment, $name, $type, $version = 'latest', $params = null)
    {
        $type = strtolower($type);

        //Gets type for local file
        $local = false;
        if ('local' == $type) {
            $local = true;
            $type = strtolower(substr($name, strrpos($name, '.') + 1));
        }

        //Defines fragment to use
        $fragment = null;
        if ('css' == $type) {
            $fragment = '@c975LIncludeLibrary/fragments/css.html.twig';
        } elseif ('js' == $type || 'javascript' == $type || 'jscript' == $type || 'script' == $type) {
            $fragment = '@c975LIncludeLibrary/fragments/javascript.html.twig';
            $type = 'javascript';
        }

        //Gets data for local file
        if ($local) {
            $data = 'css' == $type ? array('href' => $name) : array('src' => $name);
        //Gets data for external library
        } else {
            $data = $this->includeLibraryService->getData($name, $type, $version);
        }

        //Returns xhtml code
        if (null != $fragment && null != $data) {
            $render = $environment->render($fragment, array(
                'data' => $data,
                'params' => $params,
                ));

            return str_replace(array("\n", '  ', '  ', '  ', '  ', '  '), ' ', $render);
        }

        //Throws an error if not found
        throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_lib()" was not found. Please check name and supported library/versions.');
    }
public function Code(Environment $environment, $name, $type, $version = 'latest', $params = null)
    {
        $type = strtolower($type);

        //Gets type for local file
        $local = false;
        if ('local' == $type) {
            $local = true;
            $type = strtolower(substr($name, strrpos($name, '.') + 1));
        }

        //Defines fragment to use
        $fragment = null;
        if ('css' == $type) {
            $fragment = '@c975LIncludeLibrary/fragments/css.html.twig';
        } elseif ('js' == $type || 'javascript' == $type || 'jscript' == $type || 'script' == $type) {
            $fragment = '@c975LIncludeLibrary/fragments/javascript.html.twig';
            $type = 'javascript';
        }

        //Gets data for local file
        if ($local) {
            $data = 'css' == $type ? array('href' => $name) : array('src' => $name);
        //Gets data for external library
        } else {
            $data = $this->includeLibraryService->getData($name, $type, $version);
        }

        //Returns xhtml code
        if (null != $fragment && null != $data) {
            $render = $environment->render($fragment, array(
                'data' => $data,
                'params' => $params,
                ));

            return str_replace(array("\n", '  ', '  ', '  ', '  ', '  '), ' ', $render);
        }

        //Throws an error if not found
        throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_lib()" was not found. Please check name and supported library/versions.');
    }
public function Code ( Environment $ environment , $ name , $ type , $ version = 'latest' , $ params = null ) { $ type = strtolower ( $ type ) ; //Gets type for local file $ local = false ; if ( 'local' == $ type ) { $ local = true ; $ type = strtolower ( substr ( $ name , strrpos ( $ name , '.' ) + 1 ) ) ; } //Defines fragment to use $ fragment = null ; if ( 'css' == $ type ) { $ fragment = '@c975LIncludeLibrary/fragments/css.html.twig' ; } elseif ( 'js' == $ type || 'javascript' == $ type || 'jscript' == $ type || 'script' == $ type ) { $ fragment = '@c975LIncludeLibrary/fragments/javascript.html.twig' ; $ type = 'javascript' ; } //Gets data for local file if ( $ local ) { $ data = 'css' == $ type ? array ( 'href' => $ name ) : array ( 'src' => $ name ) ; //Gets data for external library } else { $ data = $ this -> includeLibraryService -> getData ( $ name , $ type , $ version ) ; } //Returns xhtml code if ( null != $ fragment && null != $ data ) { $ render = $ environment -> render ( $ fragment , array ( 'data' => $ data , 'params' => $ params , ) ) ; return str_replace ( array ( "\n" , '  ' , '  ' , '  ' , '  ' , '  ' ) , ' ' , $ render ) ; } //Throws an error if not found throw new Error ( 'The Library "' . $ name . ' (' . $ type . ') version ' . $ version . '" requested via "inc_lib()" was not found. Please check name and supported library/versions.' ) ; }
Returns the xhtml code to be included
@return string
@throws Error
Returns the xhtml code to be included