Jelajahi Sumber

removed CompatAssetsBundle, use AsseticBundle instead

Fabien Potencier 14 tahun lalu
induk
melakukan
a3207e939f

+ 0 - 23
src/Symfony/Bundle/CompatAssetsBundle/CompatAssetsBundle.php

@@ -1,23 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle;
-
-use Symfony\Component\HttpKernel\Bundle\Bundle;
-
-/**
- * CompatAssetsBundle.
- *
- * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class CompatAssetsBundle extends Bundle
-{
-}

+ 0 - 28
src/Symfony/Bundle/CompatAssetsBundle/Resources/config/assets.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0" ?>
-
-<container xmlns="http://www.symfony-project.org/schema/dic/services"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
-
-    <parameters>
-        <parameter key="templating.helper.javascripts.class">Symfony\Bundle\CompatAssetsBundle\Templating\Helper\JavascriptsHelper</parameter>
-        <parameter key="templating.helper.stylesheets.class">Symfony\Bundle\CompatAssetsBundle\Templating\Helper\StylesheetsHelper</parameter>
-    </parameters>
-
-    <services>
-        <service id="templating.helper.javascripts" class="%templating.helper.javascripts.class%">
-            <tag name="templating.helper" alias="javascripts" />
-            <argument type="service" id="templating.helper.assets" />
-        </service>
-
-        <service id="templating.helper.stylesheets" class="%templating.helper.stylesheets.class%">
-            <tag name="templating.helper" alias="stylesheets" />
-            <argument type="service" id="templating.helper.assets" />
-        </service>
-
-        <service id="twig.extension.assets" class="Symfony\Bundle\CompatAssetsBundle\Twig\Extension\AssetsExtension">
-            <tag name="twig.extension" />
-            <argument type="service" id="service_container" />
-        </service>
-    </services>
-</container>

+ 0 - 104
src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/JavascriptsHelper.php

@@ -1,104 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Templating\Helper;
-
-use Symfony\Component\Templating\Helper\Helper;
-use Symfony\Component\Templating\Helper\AssetsHelper;
-
-/**
- * JavascriptsHelper is a helper that manages JavaScripts.
- *
- * Usage:
- *
- * <code>
- *   $view['javascripts']->add('foo.js');
- *   echo $view['javascripts'];
- * </code>
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class JavascriptsHelper extends Helper
-{
-    protected $javascripts = array();
-    protected $assetHelper;
-
-    /**
-     * Constructor.
-     *
-     * @param AssetsHelper $assetHelper A AssetsHelper instance
-     */
-    public function __construct(AssetsHelper $assetHelper)
-    {
-        $this->assetHelper = $assetHelper;
-    }
-
-    /**
-     * Adds a JavaScript file.
-     *
-     * @param string $javascript A JavaScript file path
-     * @param array  $attributes An array of attributes
-     */
-    public function add($javascript, $attributes = array())
-    {
-        $this->javascripts[$this->assetHelper->getUrl($javascript)] = $attributes;
-    }
-
-    /**
-     * Returns all JavaScript files.
-     *
-     * @return array An array of JavaScript files to include
-     */
-    public function get()
-    {
-        return $this->javascripts;
-    }
-
-    /**
-     * Returns HTML representation of the links to JavaScripts.
-     *
-     * @return string The HTML representation of the JavaScripts
-     */
-    public function render()
-    {
-        $html = '';
-        foreach ($this->javascripts as $path => $attributes) {
-            $atts = '';
-            foreach ($attributes as $key => $value) {
-                $atts .= ' '.sprintf('%s="%s"', $key, htmlspecialchars($value, ENT_QUOTES, $this->charset));
-            }
-
-            $html .= sprintf('<script type="text/javascript" src="%s"%s></script>', $path, $atts)."\n";
-        }
-
-        return $html;
-    }
-
-    /**
-     * Returns a string representation of this helper as HTML.
-     *
-     * @return string The HTML representation of the JavaScripts
-     */
-    public function __toString()
-    {
-        return $this->render();
-    }
-
-    /**
-     * Returns the canonical name of this helper.
-     *
-     * @return string The canonical name
-     */
-    public function getName()
-    {
-        return 'javascripts';
-    }
-}

+ 0 - 104
src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/StylesheetsHelper.php

@@ -1,104 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Templating\Helper;
-
-use Symfony\Component\Templating\Helper\Helper;
-use Symfony\Component\Templating\Helper\AssetsHelper;
-
-/**
- * StylesheetsHelper is a helper that manages stylesheets.
- *
- * Usage:
- *
- * <code>
- *   $view['stylesheets']->add('foo.css', array('media' => 'print'));
- *   echo $view['stylesheets'];
- * </code>
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class StylesheetsHelper extends Helper
-{
-    protected $stylesheets = array();
-    protected $assetHelper;
-
-    /**
-     * Constructor.
-     *
-     * @param AssetsHelper $assetHelper A AssetsHelper instance
-     */
-    public function __construct(AssetsHelper $assetHelper)
-    {
-        $this->assetHelper = $assetHelper;
-    }
-
-    /**
-     * Adds a stylesheets file.
-     *
-     * @param string $stylesheet A stylesheet file path
-     * @param array  $attributes An array of attributes
-     */
-    public function add($stylesheet, $attributes = array())
-    {
-        $this->stylesheets[$this->assetHelper->getUrl($stylesheet)] = $attributes;
-    }
-
-    /**
-     * Returns all stylesheet files.
-     *
-     * @return array An array of stylesheet files to include
-     */
-    public function get()
-    {
-        return $this->stylesheets;
-    }
-
-    /**
-     * Returns HTML representation of the links to stylesheets.
-     *
-     * @return string The HTML representation of the stylesheets
-     */
-    public function render()
-    {
-        $html = '';
-        foreach ($this->stylesheets as $path => $attributes) {
-            $atts = '';
-            foreach ($attributes as $key => $value) {
-                $atts .= ' '.sprintf('%s="%s"', $key, htmlspecialchars($value, ENT_QUOTES, $this->charset));
-            }
-
-            $html .= sprintf('<link href="%s" rel="stylesheet" type="text/css"%s />', $path, $atts)."\n";
-        }
-
-        return $html;
-    }
-
-    /**
-     * Returns a string representation of this helper as HTML.
-     *
-     * @return string The HTML representation of the stylesheets
-     */
-    public function __toString()
-    {
-        return $this->render();
-    }
-
-    /**
-     * Returns the canonical name of this helper.
-     *
-     * @return string The canonical name
-     */
-    public function getName()
-    {
-        return 'stylesheets';
-    }
-}

+ 0 - 74
src/Symfony/Bundle/CompatAssetsBundle/Twig/Extension/AssetsExtension.php

@@ -1,74 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\Extension;
-
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser\StylesheetTokenParser;
-use Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser\StylesheetsTokenParser;
-use Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser\JavascriptTokenParser;
-use Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser\JavascriptsTokenParser;
-
-/**
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class AssetsExtension extends \Twig_Extension
-{
-    protected $container;
-
-    public function __construct(ContainerInterface $container)
-    {
-        $this->container = $container;
-    }
-
-    public function getContainer()
-    {
-        return $this->container;
-    }
-
-    public function getTemplating()
-    {
-        return $this->container->get('templating.engine');
-    }
-
-    /**
-     * Returns the token parser instance to add to the existing list.
-     *
-     * @return array An array of Twig_TokenParser instances
-     */
-    public function getTokenParsers()
-    {
-        return array(
-            // {% javascript 'bundles/blog/js/blog.js' %}
-            new JavascriptTokenParser(),
-
-            // {% javascripts %}
-            new JavascriptsTokenParser(),
-
-            // {% stylesheet 'bundles/blog/css/blog.css' with { 'media': 'screen' } %}
-            new StylesheetTokenParser(),
-
-            // {% stylesheets %}
-            new StylesheetsTokenParser(),
-        );
-    }
-
-    /**
-     * Returns the name of the extension.
-     *
-     * @return string The extension name
-     */
-    public function getName()
-    {
-        return 'assets';
-    }
-}

+ 0 - 42
src/Symfony/Bundle/CompatAssetsBundle/Twig/Node/JavascriptNode.php

@@ -1,42 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\Node;
-
-/**
- * Represents a javascript node.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class JavascriptNode extends \Twig_Node
-{
-    public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $attributes, $lineno, $tag = null)
-    {
-        parent::__construct(array('expr' => $expr, 'attributes' => $attributes), array(), $lineno, $tag);
-    }
-
-    /**
-     * Compiles the node to PHP.
-     *
-     * @param \Twig_Compiler A Twig_Compiler instance
-     */
-    public function compile(\Twig_Compiler $compiler)
-    {
-        $compiler
-            ->addDebugInfo($this)
-            ->write("echo \$this->env->getExtension('templating')->getContainer()->get('templating.helper.javascripts')->add(")
-            ->subcompile($this->getNode('expr'))
-            ->raw(', ')
-            ->subcompile($this->getNode('attributes'))
-            ->raw(");\n")
-        ;
-    }
-}

+ 0 - 38
src/Symfony/Bundle/CompatAssetsBundle/Twig/Node/JavascriptsNode.php

@@ -1,38 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\Node;
-
-/**
- * Represents a javascripts node.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class JavascriptsNode extends \Twig_Node
-{
-    public function __construct($lineno, $tag = null)
-    {
-        parent::__construct(array(), array(), $lineno, $tag);
-    }
-
-    /**
-     * Compiles the node to PHP.
-     *
-     * @param \Twig_Compiler A Twig_Compiler instance
-     */
-    public function compile(\Twig_Compiler $compiler)
-    {
-        $compiler
-            ->addDebugInfo($this)
-            ->write("echo \$this->env->getExtension('templating')->getContainer()->get('templating.helper.javascripts')->render();\n")
-        ;
-    }
-}

+ 0 - 42
src/Symfony/Bundle/CompatAssetsBundle/Twig/Node/StylesheetNode.php

@@ -1,42 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\Node;
-
-/**
- * Represents a stylesheet node.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class StylesheetNode extends \Twig_Node
-{
-    public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $attributes, $lineno, $tag = null)
-    {
-        parent::__construct(array('expr' => $expr, 'attributes' => $attributes), array(), $lineno, $tag);
-    }
-
-    /**
-     * Compiles the node to PHP.
-     *
-     * @param \Twig_Compiler A Twig_Compiler instance
-     */
-    public function compile(\Twig_Compiler $compiler)
-    {
-        $compiler
-            ->addDebugInfo($this)
-            ->write("echo \$this->env->getExtension('templating')->getContainer()->get('templating.helper.stylesheets')->add(")
-            ->subcompile($this->getNode('expr'))
-            ->raw(', ')
-            ->subcompile($this->getNode('attributes'))
-            ->raw(");\n")
-        ;
-    }
-}

+ 0 - 38
src/Symfony/Bundle/CompatAssetsBundle/Twig/Node/StylesheetsNode.php

@@ -1,38 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\Node;
-
-/**
- * Represents a stylesheets node.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class StylesheetsNode extends \Twig_Node
-{
-    public function __construct($lineno, $tag = null)
-    {
-        parent::__construct(array(), array(), $lineno, $tag);
-    }
-
-    /**
-     * Compiles the node to PHP.
-     *
-     * @param \Twig_Compiler A Twig_Compiler instance
-     */
-    public function compile(\Twig_Compiler $compiler)
-    {
-        $compiler
-            ->addDebugInfo($this)
-            ->write("echo \$this->env->getExtension('templating')->getContainer()->get('templating.helper.stylesheets')->render();\n")
-        ;
-    }
-}

+ 0 - 57
src/Symfony/Bundle/CompatAssetsBundle/Twig/TokenParser/JavascriptTokenParser.php

@@ -1,57 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser;
-
-use Symfony\Bundle\CompatAssetsBundle\Twig\Node\JavascriptNode;
-
-/**
- * 
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class JavascriptTokenParser extends \Twig_TokenParser
-{
-    /**
-     * Parses a token and returns a node.
-     *
-     * @param \Twig_Token $token A \Twig_Token instance
-     *
-     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
-     */
-    public function parse(\Twig_Token $token)
-    {
-        $expr = $this->parser->getExpressionParser()->parseExpression();
-
-        // attributes
-        if ($this->parser->getStream()->test(\Twig_Token::NAME_TYPE, 'with')) {
-            $this->parser->getStream()->next();
-
-            $attributes = $this->parser->getExpressionParser()->parseExpression();
-        } else {
-            $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine());
-        }
-
-        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
-
-        return new JavascriptNode($expr, $attributes, $token->getLine(), $this->getTag());
-    }
-
-    /**
-     * Gets the tag name associated with this token parser.
-     *
-     * @param string The tag name
-     */
-    public function getTag()
-    {
-        return 'javascript';
-    }
-}

+ 0 - 46
src/Symfony/Bundle/CompatAssetsBundle/Twig/TokenParser/JavascriptsTokenParser.php

@@ -1,46 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser;
-
-use Symfony\Bundle\CompatAssetsBundle\Twig\Node\JavascriptsNode;
-
-/**
- * 
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class JavascriptsTokenParser extends \Twig_TokenParser
-{
-    /**
-     * Parses a token and returns a node.
-     *
-     * @param \Twig_Token $token A \Twig_Token instance
-     *
-     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
-     */
-    public function parse(\Twig_Token $token)
-    {
-        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
-
-        return new JavascriptsNode($token->getLine(), $this->getTag());
-    }
-
-    /**
-     * Gets the tag name associated with this token parser.
-     *
-     * @param string The tag name
-     */
-    public function getTag()
-    {
-        return 'javascripts';
-    }
-}

+ 0 - 57
src/Symfony/Bundle/CompatAssetsBundle/Twig/TokenParser/StylesheetTokenParser.php

@@ -1,57 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser;
-
-use Symfony\Bundle\CompatAssetsBundle\Twig\Node\StylesheetNode;
-
-/**
- * 
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class StylesheetTokenParser extends \Twig_TokenParser
-{
-    /**
-     * Parses a token and returns a node.
-     *
-     * @param \Twig_Token $token A \Twig_Token instance
-     *
-     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
-     */
-    public function parse(\Twig_Token $token)
-    {
-        $expr = $this->parser->getExpressionParser()->parseExpression();
-
-        // attributes
-        if ($this->parser->getStream()->test(\Twig_Token::NAME_TYPE, 'with')) {
-            $this->parser->getStream()->next();
-
-            $attributes = $this->parser->getExpressionParser()->parseExpression();
-        } else {
-            $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine());
-        }
-
-        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
-
-        return new StylesheetNode($expr, $attributes, $token->getLine(), $this->getTag());
-    }
-
-    /**
-     * Gets the tag name associated with this token parser.
-     *
-     * @param string The tag name
-     */
-    public function getTag()
-    {
-        return 'stylesheet';
-    }
-}

+ 0 - 46
src/Symfony/Bundle/CompatAssetsBundle/Twig/TokenParser/StylesheetsTokenParser.php

@@ -1,46 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\CompatAssetsBundle\Twig\TokenParser;
-
-use Symfony\Bundle\CompatAssetsBundle\Twig\Node\StylesheetsNode;
-
-/**
- * 
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class StylesheetsTokenParser extends \Twig_TokenParser
-{
-    /**
-     * Parses a token and returns a node.
-     *
-     * @param \Twig_Token $token A \Twig_Token instance
-     *
-     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
-     */
-    public function parse(\Twig_Token $token)
-    {
-        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
-
-        return new StylesheetsNode($token->getLine(), $this->getTag());
-    }
-
-    /**
-     * Gets the tag name associated with this token parser.
-     *
-     * @param string The tag name
-     */
-    public function getTag()
-    {
-        return 'stylesheets';
-    }
-}