Twig/IncludeLibraryContent.php
public function Content($name, $type, $version = 'latest')
    {
        $type = strtolower($type);

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

        //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 the content from href or src part
        if (null != $data) {
            $content = null;
            if ('css' == $type) {
                $content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>';
            } elseif ('js' == $type) {
                $content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>';
            }

            return $content;
        }

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

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

        //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 the content from href or src part
        if (null != $data) {
            $content = null;
            if ('css' == $type) {
                $content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>';
            } elseif ('js' == $type) {
                $content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>';
            }

            return $content;
        }

        //Throws an error if not found
        throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.');
    }
public function Content ( $ name , $ type , $ version = 'latest' ) { $ type = strtolower ( $ type ) ; //Gets type for local file $ local = false ; if ( 'local' == $ type ) { $ local = true ; $ type = strtolower ( substr ( $ name , strrpos ( $ name , '.' ) + 1 ) ) ; } //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 the content from href or src part if ( null != $ data ) { $ content = null ; if ( 'css' == $ type ) { $ content = '<style type="text/css">' . file_get_contents ( $ data [ 'href' ] ) . '</style>' ; } elseif ( 'js' == $ type ) { $ content = '<script type="text/javascript">' . file_get_contents ( $ data [ 'src' ] ) . '</script>' ; } return $ content ; } //Throws an error if not found throw new Error ( 'The Library "' . $ name . ' (' . $ type . ') version ' . $ version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.' ) ; }
Returns the content of the requested library
@return string
@throws Error
Returns the content of the requested library