Merge remote-tracking branch 'remotes/symfony/master'
This commit is contained in:
commit
cc49cd9498
29
README.md
29
README.md
@ -11,28 +11,25 @@ websites with PHP.
|
|||||||
Symfony can be used to develop all kind of websites, from your personal blog
|
Symfony can be used to develop all kind of websites, from your personal blog
|
||||||
to high traffic ones like Dailymotion or Yahoo! Answers.
|
to high traffic ones like Dailymotion or Yahoo! Answers.
|
||||||
|
|
||||||
High Performance
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Built with performance in mind, Symfony2 is one of the fastest PHP frameworks.
|
|
||||||
It is up to 3 times faster than symfony 1.4 or Zend Framework 1.10 and
|
|
||||||
consumes half the memory.
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Symfony2 is only supported on PHP 5.3.2 and up.
|
Symfony2 is only supported on PHP 5.3.2 and up.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
The best way to install Symfony2 is to download the Symfony Standard Edition
|
||||||
|
available at [http://symfony.com/download][1].
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Symfony 2.0 is still in the early stages of development, but the
|
The "[Quick Tour][2]" tutorial gives you a first feeling of the framework. If,
|
||||||
"[Quick Tour][1]" tutorial can get you started fast.
|
like us, you think that Symfony2 can help speed up your development and take
|
||||||
|
the quality of your work to the next level, read the official
|
||||||
|
[Symfony2 documentation][3].
|
||||||
|
|
||||||
The "Quick Tour" tutorial barely scratches the surface of Symfony 2.0, but it
|
[1]: http://symfony.com/download
|
||||||
gives you a first feeling of the framework. If, like us, you think that
|
[2]: http://symfony.com/get_started
|
||||||
Symfony2 can help speed up your development and take the quality of your work
|
[3]: http://symfony.com/doc/current/
|
||||||
to the next level, visit the official [Symfony2 website][2] to learn more.
|
|
||||||
|
|
||||||
[1]: http://symfony.com/get_started
|
|
||||||
[2]: http://symfony.com/
|
|
||||||
|
22
UPDATE.md
22
UPDATE.md
@ -6,6 +6,28 @@ one. It only discusses changes that need to be done when using the "public"
|
|||||||
API of the framework. If you "hack" the core, you should probably follow the
|
API of the framework. If you "hack" the core, you should probably follow the
|
||||||
timeline closely anyway.
|
timeline closely anyway.
|
||||||
|
|
||||||
|
beta2 to beta3
|
||||||
|
--------------
|
||||||
|
|
||||||
|
* The settings under "framework.annotations" have changed slightly:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
framework:
|
||||||
|
annotations:
|
||||||
|
cache: file
|
||||||
|
file_cache:
|
||||||
|
debug: true
|
||||||
|
dir: /foo
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
framework:
|
||||||
|
annotations:
|
||||||
|
cache: file
|
||||||
|
debug: true
|
||||||
|
file_cache_dir: /foo
|
||||||
|
|
||||||
beta1 to beta2
|
beta1 to beta2
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -7,16 +7,28 @@
|
|||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="assetic.filter.jpegtran.class">Assetic\Filter\JpegtranFilter</parameter>
|
<parameter key="assetic.filter.jpegtran.class">Assetic\Filter\JpegtranFilter</parameter>
|
||||||
<parameter key="assetic.filter.jpegtran.bin">/usr/bin/jpegtran</parameter>
|
<parameter key="assetic.filter.jpegtran.bin">/usr/bin/jpegtran</parameter>
|
||||||
|
<parameter key="assetic.filter.jpegtran.copy">null</parameter>
|
||||||
<parameter key="assetic.filter.jpegtran.optimize">false</parameter>
|
<parameter key="assetic.filter.jpegtran.optimize">false</parameter>
|
||||||
|
<parameter key="assetic.filter.jpegtran.progressive">false</parameter>
|
||||||
|
<parameter key="assetic.filter.jpegtran.restart">null</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="assetic.filter.jpegtran" class="%assetic.filter.jpegtran.class%">
|
<service id="assetic.filter.jpegtran" class="%assetic.filter.jpegtran.class%">
|
||||||
<tag name="assetic.filter" alias="jpegtran" />
|
<tag name="assetic.filter" alias="jpegtran" />
|
||||||
<argument>%assetic.filter.jpegtran.bin%</argument>
|
<argument>%assetic.filter.jpegtran.bin%</argument>
|
||||||
|
<call method="setCopy">
|
||||||
|
<argument>%assetic.filter.jpegtran.copy%</argument>
|
||||||
|
</call>
|
||||||
<call method="setOptimize">
|
<call method="setOptimize">
|
||||||
<argument>%assetic.filter.jpegtran.optimize%</argument>
|
<argument>%assetic.filter.jpegtran.optimize%</argument>
|
||||||
</call>
|
</call>
|
||||||
|
<call method="setProgressive">
|
||||||
|
<argument>%assetic.filter.jpegtran.progressive%</argument>
|
||||||
|
</call>
|
||||||
|
<call method="setRestart">
|
||||||
|
<argument>%assetic.filter.jpegtran.restart%</argument>
|
||||||
|
</call>
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -7,12 +7,16 @@
|
|||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="assetic.filter.optipng.class">Assetic\Filter\OptiPngFilter</parameter>
|
<parameter key="assetic.filter.optipng.class">Assetic\Filter\OptiPngFilter</parameter>
|
||||||
<parameter key="assetic.filter.optipng.bin">/usr/bin/optipng</parameter>
|
<parameter key="assetic.filter.optipng.bin">/usr/bin/optipng</parameter>
|
||||||
|
<parameter key="assetic.filter.optipng.level">null</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="assetic.filter.optipng" class="%assetic.filter.optipng.class%">
|
<service id="assetic.filter.optipng" class="%assetic.filter.optipng.class%">
|
||||||
<tag name="assetic.filter" alias="optipng" />
|
<tag name="assetic.filter" alias="optipng" />
|
||||||
<argument>%assetic.filter.optipng.bin%</argument>
|
<argument>%assetic.filter.optipng.bin%</argument>
|
||||||
|
<call method="setLevel">
|
||||||
|
<argument>%assetic.filter.optipng.level%</argument>
|
||||||
|
</call>
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -50,7 +50,9 @@ class XmlDriver extends BaseXmlDriver
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
|
$fileName = $file->getBasename($this->_fileExtension);
|
||||||
|
|
||||||
|
if ($fileName == $file->getBasename() || $fileName == $this->_globalFile) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,9 @@ class YamlDriver extends BaseYamlDriver
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
|
$fileName = $file->getBasename($this->_fileExtension);
|
||||||
|
|
||||||
|
if ($fileName == $file->getBasename() || $fileName == $this->_globalFile) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,16 +274,11 @@ class Configuration implements ConfigurationInterface
|
|||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('cache')->defaultValue('file')->end()
|
->scalarNode('cache')->defaultValue('file')->end()
|
||||||
->arrayNode('file_cache')
|
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
|
||||||
->addDefaultsIfNotSet()
|
|
||||||
->children()
|
|
||||||
->scalarNode('dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
|
|
||||||
->booleanNode('debug')->defaultValue($this->debug)->end()
|
->booleanNode('debug')->defaultValue($this->debug)->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
|
||||||
->end()
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,23 +517,24 @@ class FrameworkExtension extends Extension
|
|||||||
$loader->load('annotations.xml');
|
$loader->load('annotations.xml');
|
||||||
|
|
||||||
if ('file' === $config['cache']) {
|
if ('file' === $config['cache']) {
|
||||||
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache']['dir']);
|
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
|
||||||
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
|
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
|
||||||
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
|
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->getDefinition('annotations.cache.file_cache')
|
->getDefinition('annotations.file_cache_reader')
|
||||||
->replaceArgument(0, $cacheDir)
|
->replaceArgument(1, $cacheDir)
|
||||||
->replaceArgument(1, $config['file_cache']['debug'])
|
->replaceArgument(2, $config['debug'])
|
||||||
;
|
;
|
||||||
} else if ('none' === $config['cache']) {
|
$container->setAlias('annotation_reader', 'annotations.file_cache_reader');
|
||||||
$container->setAlias('annotation_reader', 'annotations.reader');
|
} else if('none' !== $config['cache']) {
|
||||||
} else {
|
|
||||||
$container
|
$container
|
||||||
->getDefinition('annotations.cached_reader')
|
->getDefinition('annotations.cached_reader')
|
||||||
->replaceArgument(1, new Reference($config['cache']))
|
->replaceArgument(1, new Reference($config['cache']))
|
||||||
|
->replaceArgument(2, $config['debug'])
|
||||||
;
|
;
|
||||||
|
$container->setAlias('annotation_reader', 'annotations.cached_reader');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,25 +5,26 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="annotations.cache.file_cache.class">Doctrine\Common\Annotations\Cache\FileCache</parameter>
|
|
||||||
|
|
||||||
<parameter key="annotations.reader.class">Doctrine\Common\Annotations\AnnotationReader</parameter>
|
<parameter key="annotations.reader.class">Doctrine\Common\Annotations\AnnotationReader</parameter>
|
||||||
<parameter key="annotations.cached_reader.class">Doctrine\Common\Annotations\CachedReader</parameter>
|
<parameter key="annotations.cached_reader.class">Doctrine\Common\Annotations\CachedReader</parameter>
|
||||||
|
<parameter key="annotations.file_cache_reader.class">Doctrine\Common\Annotations\FileCacheReader</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="annotations.cache.file_cache" class="%annotations.cache.file_cache.class%" public="false">
|
|
||||||
<argument /><!-- Cache Directory -->
|
|
||||||
<argument /><!-- Debug-Flag -->
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="annotations.reader" class="%annotations.reader.class%" public="false" />
|
<service id="annotations.reader" class="%annotations.reader.class%" public="false" />
|
||||||
|
|
||||||
<service id="annotations.cached_reader" class="%annotations.cached_reader.class%" public="false">
|
<service id="annotations.cached_reader" class="%annotations.cached_reader.class%" public="false">
|
||||||
<argument type="service" id="annotations.reader" />
|
<argument type="service" id="annotations.reader" />
|
||||||
<argument type="service" id="annotations.cache.file_cache" />
|
<argument /><!-- Cache Implementation -->
|
||||||
|
<argument /><!-- Debug-Flag -->
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="annotation_reader" alias="annotations.cached_reader" />
|
<service id="annotations.file_cache_reader" class="%annotations.file_cache_reader.class%" public="false">
|
||||||
|
<argument type="service" id="annotations.reader" />
|
||||||
|
<argument /><!-- Cache-Directory -->
|
||||||
|
<argument /><!-- Debug Flag -->
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="annotation_reader" alias="annotations.reader" />
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -128,15 +128,8 @@
|
|||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="annotations">
|
<xsd:complexType name="annotations">
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="file-cache" type="annotations.file_cache" minOccurs="0" maxOccurs="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
|
|
||||||
<xsd:attribute name="cache" type="xsd:string" />
|
<xsd:attribute name="cache" type="xsd:string" />
|
||||||
</xsd:complexType>
|
|
||||||
|
|
||||||
<xsd:complexType name="annotations.file_cache">
|
|
||||||
<xsd:attribute name="dir" type="xsd:string" />
|
|
||||||
<xsd:attribute name="debug" type="xsd:string" />
|
<xsd:attribute name="debug" type="xsd:string" />
|
||||||
|
<xsd:attribute name="file-cache-dir" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:schema>
|
</xsd:schema>
|
||||||
|
@ -59,9 +59,7 @@ $container->loadFromExtension('framework', array(
|
|||||||
),
|
),
|
||||||
'annotations' => array(
|
'annotations' => array(
|
||||||
'cache' => 'file',
|
'cache' => 'file',
|
||||||
'file_cache' => array(
|
|
||||||
'dir' => '%kernel.cache_dir%/annotations',
|
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
)
|
'file_cache_dir' => '%kernel.cache_dir%/annotations',
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
</framework:templating>
|
</framework:templating>
|
||||||
<framework:translator enabled="true" fallback="fr" />
|
<framework:translator enabled="true" fallback="fr" />
|
||||||
<framework:validation enabled="true" cache="apc" />
|
<framework:validation enabled="true" cache="apc" />
|
||||||
<framework:annotations cache="file">
|
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
|
||||||
<framework:file-cache dir="%kernel.cache_dir%/annotations" debug="true" />
|
|
||||||
</framework:annotations>
|
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -45,6 +45,5 @@ framework:
|
|||||||
cache: apc
|
cache: apc
|
||||||
annotations:
|
annotations:
|
||||||
cache: file
|
cache: file
|
||||||
file_cache:
|
|
||||||
dir: %kernel.cache_dir%/annotations
|
|
||||||
debug: true
|
debug: true
|
||||||
|
file_cache_dir: %kernel.cache_dir%/annotations
|
||||||
|
@ -172,8 +172,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = $this->createContainerFromFile('full');
|
$container = $this->createContainerFromFile('full');
|
||||||
|
|
||||||
$this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.cache.file_cache')->getArgument(0));
|
$this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.file_cache_reader')->getArgument(1));
|
||||||
$this->assertEquals('annotations.cached_reader', (string) $container->getAlias('annotation_reader'));
|
$this->assertInstanceOf('Doctrine\Common\Annotations\FileCacheReader', $container->get('annotation_reader'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidationAnnotations()
|
public function testValidationAnnotations()
|
||||||
|
@ -15,12 +15,10 @@
|
|||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="handler">
|
<xsd:complexType name="handler">
|
||||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
<xsd:sequence>
|
||||||
<xsd:element name="processor" type="xsd:string" />
|
<xsd:element name="processor" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||||
</xsd:choice>
|
<xsd:element name="member" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
</xsd:sequence>
|
||||||
<xsd:element name="member" type="xsd:string" />
|
|
||||||
</xsd:choice>
|
|
||||||
<xsd:attribute name="type" type="xsd:string" use="required" />
|
<xsd:attribute name="type" type="xsd:string" use="required" />
|
||||||
<xsd:attribute name="priority" type="xsd:integer" />
|
<xsd:attribute name="priority" type="xsd:integer" />
|
||||||
<xsd:attribute name="level" type="level" />
|
<xsd:attribute name="level" type="level" />
|
||||||
|
@ -15,6 +15,10 @@ use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
|||||||
use Symfony\Component\DependencyInjection\Alias;
|
use Symfony\Component\DependencyInjection\Alias;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||||
|
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\DependencyInjection\Parameter;
|
use Symfony\Component\DependencyInjection\Parameter;
|
||||||
@ -566,7 +570,15 @@ class SecurityExtension extends Extension
|
|||||||
// load service templates
|
// load service templates
|
||||||
$c = new ContainerBuilder();
|
$c = new ContainerBuilder();
|
||||||
$parameterBag = $container->getParameterBag();
|
$parameterBag = $container->getParameterBag();
|
||||||
$loader = new XmlFileLoader($c, new FileLocator(__DIR__.'/../Resources/config'));
|
|
||||||
|
$locator = new FileLocator(__DIR__.'/../Resources/config');
|
||||||
|
$resolver = new LoaderResolver(array(
|
||||||
|
new XmlFileLoader($c, $locator),
|
||||||
|
new YamlFileLoader($c, $locator),
|
||||||
|
new PhpFileLoader($c, $locator),
|
||||||
|
));
|
||||||
|
$loader = new DelegatingLoader($resolver);
|
||||||
|
|
||||||
$loader->load('security_factories.xml');
|
$loader->load('security_factories.xml');
|
||||||
|
|
||||||
// load user-created listener factories
|
// load user-created listener factories
|
||||||
|
67
src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php
Normal file
67
src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\TwigBundle\Extension;
|
||||||
|
|
||||||
|
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Twig extension for Symfony actions helper
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*/
|
||||||
|
class ActionsExtension extends \Twig_Extension
|
||||||
|
{
|
||||||
|
private $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param ContainerInterface $container The service container
|
||||||
|
*/
|
||||||
|
public function __construct(ContainerInterface $container)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Response content for a given controller or URI.
|
||||||
|
*
|
||||||
|
* @param string $controller A controller name to execute (a string like BlogBundle:Post:index), or a relative URI
|
||||||
|
* @param array $attributes An array of request attributes
|
||||||
|
* @param array $options An array of options
|
||||||
|
*
|
||||||
|
* @see Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver::render()
|
||||||
|
*/
|
||||||
|
public function renderAction($controller, array $attributes = array(), array $options = array())
|
||||||
|
{
|
||||||
|
return $this->container->get('templating.helper.actions')->render($controller, $attributes, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the token parser instance to add to the existing list.
|
||||||
|
*
|
||||||
|
* @return array An array of Twig_TokenParser instances
|
||||||
|
*/
|
||||||
|
public function getTokenParsers()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
// {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
|
||||||
|
new RenderTokenParser(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'actions';
|
||||||
|
}
|
||||||
|
}
|
76
src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php
Normal file
76
src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\TwigBundle\Extension;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*/
|
||||||
|
class AssetsExtension extends \Twig_Extension
|
||||||
|
{
|
||||||
|
private $container;
|
||||||
|
|
||||||
|
public function __construct(ContainerInterface $container)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of functions to add to the existing list.
|
||||||
|
*
|
||||||
|
* @return array An array of functions
|
||||||
|
*/
|
||||||
|
public function getFunctions()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'asset' => new \Twig_Function_Method($this, 'getAssetUrl'),
|
||||||
|
'assets_version' => new \Twig_Function_Method($this, 'getAssetsVersion'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the public path of an asset
|
||||||
|
*
|
||||||
|
* Absolute paths (i.e. http://...) are returned unmodified.
|
||||||
|
*
|
||||||
|
* @param string $path A public path
|
||||||
|
* @param string $packageName The name of the asset package to use
|
||||||
|
*
|
||||||
|
* @return string A public path which takes into account the base path and URL path
|
||||||
|
*/
|
||||||
|
public function getAssetUrl($path, $packageName = null)
|
||||||
|
{
|
||||||
|
return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the version of the assets in a package
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getAssetsVersion($packageName = null)
|
||||||
|
{
|
||||||
|
return $this->container->get('templating.helper.assets')->getVersion($packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the extension.
|
||||||
|
*
|
||||||
|
* @return string The extension name
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'assets';
|
||||||
|
}
|
||||||
|
}
|
@ -12,16 +12,20 @@
|
|||||||
namespace Symfony\Bundle\TwigBundle\Extension;
|
namespace Symfony\Bundle\TwigBundle\Extension;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class TemplatingExtension extends \Twig_Extension
|
class CodeExtension extends \Twig_Extension
|
||||||
{
|
{
|
||||||
protected $container;
|
private $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of Twig Extension to provide functions for code formatting
|
||||||
|
*
|
||||||
|
* @param Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper $helper Helper to use
|
||||||
|
*/
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
@ -44,74 +48,6 @@ class TemplatingExtension extends \Twig_Extension
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of functions to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return array An array of functions
|
|
||||||
*/
|
|
||||||
public function getFunctions()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'asset' => new \Twig_Function_Method($this, 'getAssetUrl'),
|
|
||||||
'assets_version' => new \Twig_Function_Method($this, 'getAssetsVersion'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the public path of an asset
|
|
||||||
*
|
|
||||||
* Absolute paths (i.e. http://...) are returned unmodified.
|
|
||||||
*
|
|
||||||
* @param string $path A public path
|
|
||||||
* @param string $packageName The name of the asset package to use
|
|
||||||
*
|
|
||||||
* @return string A public path which takes into account the base path and URL path
|
|
||||||
*/
|
|
||||||
public function getAssetUrl($path, $packageName = null)
|
|
||||||
{
|
|
||||||
return $this->container->get('templating.helper.assets')->getUrl($path, $packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the version of the assets in a package
|
|
||||||
*
|
|
||||||
* @param string $packageName
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getAssetsVersion($packageName = null)
|
|
||||||
{
|
|
||||||
return $this->container->get('templating.helper.assets')->getVersion($packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Response content for a given controller or URI.
|
|
||||||
*
|
|
||||||
* @param string $controller A controller name to execute (a string like BlogBundle:Post:index), or a relative URI
|
|
||||||
* @param array $attributes An array of request attributes
|
|
||||||
* @param array $options An array of options
|
|
||||||
*
|
|
||||||
* @see Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver::render()
|
|
||||||
*/
|
|
||||||
public function renderAction($controller, array $attributes = array(), array $options = array())
|
|
||||||
{
|
|
||||||
$options['attributes'] = $attributes;
|
|
||||||
|
|
||||||
return $this->container->get('http_kernel')->render($controller, $options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the token parser instance to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return array An array of Twig_TokenParser instances
|
|
||||||
*/
|
|
||||||
public function getTokenParsers()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
// {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
|
|
||||||
new RenderTokenParser(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function abbrClass($class)
|
public function abbrClass($class)
|
||||||
{
|
{
|
||||||
return $this->container->get('templating.helper.code')->abbrClass($class);
|
return $this->container->get('templating.helper.code')->abbrClass($class);
|
||||||
@ -152,13 +88,8 @@ class TemplatingExtension extends \Twig_Extension
|
|||||||
return $this->container->get('templating.helper.code')->formatFileFromText($text);
|
return $this->container->get('templating.helper.code')->formatFileFromText($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of the extension.
|
|
||||||
*
|
|
||||||
* @return string The extension name
|
|
||||||
*/
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'templating';
|
return 'code';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,7 +32,7 @@ class RenderNode extends \Twig_Node
|
|||||||
{
|
{
|
||||||
$compiler
|
$compiler
|
||||||
->addDebugInfo($this)
|
->addDebugInfo($this)
|
||||||
->write("echo \$this->env->getExtension('templating')->renderAction(")
|
->write("echo \$this->env->getExtension('actions')->renderAction(")
|
||||||
->subcompile($this->getNode('expr'))
|
->subcompile($this->getNode('expr'))
|
||||||
->raw(', ')
|
->raw(', ')
|
||||||
->subcompile($this->getNode('attributes'))
|
->subcompile($this->getNode('attributes'))
|
||||||
|
@ -9,6 +9,15 @@
|
|||||||
<parameter key="twig.loader.class">Symfony\Bundle\TwigBundle\Loader\FilesystemLoader</parameter>
|
<parameter key="twig.loader.class">Symfony\Bundle\TwigBundle\Loader\FilesystemLoader</parameter>
|
||||||
<parameter key="templating.engine.twig.class">Symfony\Bundle\TwigBundle\TwigEngine</parameter>
|
<parameter key="templating.engine.twig.class">Symfony\Bundle\TwigBundle\TwigEngine</parameter>
|
||||||
<parameter key="twig.cache_warmer.class">Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer</parameter>
|
<parameter key="twig.cache_warmer.class">Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer</parameter>
|
||||||
|
<parameter key="twig.extension.trans.class">Symfony\Bridge\Twig\Extension\TranslationExtension</parameter>
|
||||||
|
<parameter key="twig.extension.assets.class">Symfony\Bundle\TwigBundle\Extension\AssetsExtension</parameter>
|
||||||
|
<parameter key="twig.extension.actions.class">Symfony\Bundle\TwigBundle\Extension\ActionsExtension</parameter>
|
||||||
|
<parameter key="twig.extension.code.class">Symfony\Bundle\TwigBundle\Extension\CodeExtension</parameter>
|
||||||
|
<parameter key="twig.extension.routing.class">Symfony\Bridge\Twig\Extension\RoutingExtension</parameter>
|
||||||
|
<parameter key="twig.extension.yaml.class">Symfony\Bridge\Twig\Extension\YamlExtension</parameter>
|
||||||
|
<parameter key="twig.extension.form.class">Symfony\Bridge\Twig\Extension\FormExtension</parameter>
|
||||||
|
<parameter key="twig.extension.text.class">Twig_Extensions_Extension_Text</parameter>
|
||||||
|
<parameter key="twig.extension.debug.class">Twig_Extensions_Extension_Debug</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
@ -33,32 +42,42 @@
|
|||||||
<argument type="service" id="templating.globals" />
|
<argument type="service" id="templating.globals" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.trans" class="Symfony\Bridge\Twig\Extension\TranslationExtension" public="false">
|
<service id="twig.extension.trans" class="%twig.extension.trans.class%" public="false">
|
||||||
<tag name="twig.extension" />
|
<tag name="twig.extension" />
|
||||||
<argument type="service" id="translator" />
|
<argument type="service" id="translator" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.helpers" class="Symfony\Bundle\TwigBundle\Extension\TemplatingExtension" public="false">
|
<service id="twig.extension.assets" class="%twig.extension.assets.class%" public="false">
|
||||||
<tag name="twig.extension" />
|
<tag name="twig.extension" />
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.routing" class="Symfony\Bridge\Twig\Extension\RoutingExtension" public="false">
|
<service id="twig.extension.actions" class="%twig.extension.actions.class%" public="false">
|
||||||
|
<tag name="twig.extension" />
|
||||||
|
<argument type="service" id="service_container" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="twig.extension.code" class="%twig.extension.code.class%" public="false">
|
||||||
|
<tag name="twig.extension" />
|
||||||
|
<argument type="service" id="service_container" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="twig.extension.routing" class="%twig.extension.routing.class%" public="false">
|
||||||
<tag name="twig.extension" />
|
<tag name="twig.extension" />
|
||||||
<argument type="service" id="router" />
|
<argument type="service" id="router" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.yaml" class="Symfony\Bridge\Twig\Extension\YamlExtension" public="false">
|
<service id="twig.extension.yaml" class="%twig.extension.yaml.class%" public="false">
|
||||||
<tag name="twig.extension" />
|
<tag name="twig.extension" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.form" class="Symfony\Bridge\Twig\Extension\FormExtension" public="false">
|
<service id="twig.extension.form" class="%twig.extension.form.class%" public="false">
|
||||||
<tag name="twig.extension" />
|
<tag name="twig.extension" />
|
||||||
<argument>%twig.form.resources%</argument>
|
<argument>%twig.form.resources%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="twig.extension.text" class="Twig_Extensions_Extension_Text" public="false" />
|
<service id="twig.extension.text" class="%twig.extension.text.class%" public="false" />
|
||||||
|
|
||||||
<service id="twig.extension.debug" class="Twig_Extensions_Extension_Debug" public="false" />
|
<service id="twig.extension.debug" class="%twig.extension.debug.class%" public="false" />
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -29,6 +29,7 @@ class Cookie
|
|||||||
protected $domain;
|
protected $domain;
|
||||||
protected $secure;
|
protected $secure;
|
||||||
protected $httponly;
|
protected $httponly;
|
||||||
|
protected $rawValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a cookie.
|
* Sets a cookie.
|
||||||
@ -40,13 +41,20 @@ class Cookie
|
|||||||
* @param string $domain The domain that the cookie is available
|
* @param string $domain The domain that the cookie is available
|
||||||
* @param Boolean $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
|
* @param Boolean $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
|
||||||
* @param Boolean $httponly The cookie httponly flag
|
* @param Boolean $httponly The cookie httponly flag
|
||||||
|
* @param Boolean $encodedValue Whether the value is encoded or not
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $value, $expires = null, $path = '/', $domain = '', $secure = false, $httponly = true)
|
public function __construct($name, $value, $expires = null, $path = '/', $domain = '', $secure = false, $httponly = true, $encodedValue = false)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
if ($encodedValue) {
|
||||||
|
$this->value = urldecode($value);
|
||||||
|
$this->rawValue = $value;
|
||||||
|
} else {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
|
$this->rawValue = urlencode($value);
|
||||||
|
}
|
||||||
|
$this->name = $name;
|
||||||
$this->expires = null === $expires ? null : (integer) $expires;
|
$this->expires = null === $expires ? null : (integer) $expires;
|
||||||
$this->path = empty($path) ? '/' : $path;
|
$this->path = empty($path) ? '/' : $path;
|
||||||
$this->domain = $domain;
|
$this->domain = $domain;
|
||||||
@ -63,7 +71,7 @@ class Cookie
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$cookie = sprintf('%s=%s', $this->name, urlencode($this->value));
|
$cookie = sprintf('%s=%s', $this->name, $this->rawValue);
|
||||||
|
|
||||||
if (null !== $this->expires) {
|
if (null !== $this->expires) {
|
||||||
$cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('UTC'))->format(static::DATE_FORMAT), 0, -5);
|
$cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('UTC'))->format(static::DATE_FORMAT), 0, -5);
|
||||||
@ -110,12 +118,13 @@ class Cookie
|
|||||||
|
|
||||||
$values = array(
|
$values = array(
|
||||||
'name' => trim($name),
|
'name' => trim($name),
|
||||||
'value' => urldecode(trim($value)),
|
'value' => trim($value),
|
||||||
'expires' => null,
|
'expires' => null,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'domain' => '',
|
'domain' => '',
|
||||||
'secure' => false,
|
'secure' => false,
|
||||||
'httponly' => false,
|
'httponly' => false,
|
||||||
|
'passedRawValue' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (null !== $url) {
|
if (null !== $url) {
|
||||||
@ -162,7 +171,8 @@ class Cookie
|
|||||||
$values['path'],
|
$values['path'],
|
||||||
$values['domain'],
|
$values['domain'],
|
||||||
$values['secure'],
|
$values['secure'],
|
||||||
$values['httponly']
|
$values['httponly'],
|
||||||
|
$values['passedRawValue']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +200,18 @@ class Cookie
|
|||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the raw value of the cookie.
|
||||||
|
*
|
||||||
|
* @return string The cookie value
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
public function getRawValue()
|
||||||
|
{
|
||||||
|
return $this->rawValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the expires time of the cookie.
|
* Gets the expires time of the cookie.
|
||||||
*
|
*
|
||||||
|
@ -101,20 +101,24 @@ class CookieJar
|
|||||||
* Returns not yet expired cookie values for the given URI.
|
* Returns not yet expired cookie values for the given URI.
|
||||||
*
|
*
|
||||||
* @param string $uri A URI
|
* @param string $uri A URI
|
||||||
|
* @param Boolean $returnsRawValue returnes raw value or urldecoded value
|
||||||
*
|
*
|
||||||
* @return array An array of cookie values
|
* @return array An array of cookie values
|
||||||
*/
|
*/
|
||||||
public function allValues($uri)
|
public function allValues($uri, $returnsRawValue = false)
|
||||||
{
|
{
|
||||||
$this->flushExpiredCookies();
|
$this->flushExpiredCookies();
|
||||||
|
|
||||||
$parts = parse_url($uri);
|
$parts = array_replace(array('path' => '/'), parse_url($uri));
|
||||||
|
|
||||||
$cookies = array();
|
$cookies = array();
|
||||||
foreach ($this->cookieJar as $cookie) {
|
foreach ($this->cookieJar as $cookie) {
|
||||||
if ($cookie->getDomain() && $cookie->getDomain() != substr($parts['host'], -strlen($cookie->getDomain()))) {
|
if ($cookie->getDomain()) {
|
||||||
|
$domain = ltrim($cookie->getDomain(), '.');
|
||||||
|
if ($domain != substr($parts['host'], -strlen($domain))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath()))) {
|
if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath()))) {
|
||||||
continue;
|
continue;
|
||||||
@ -124,12 +128,24 @@ class CookieJar
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cookies[$cookie->getName()] = $cookie->getValue();
|
$cookies[$cookie->getName()] = $returnsRawValue ? $cookie->getRawValue() : $cookie->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cookies;
|
return $cookies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns not yet expired raw cookie values for the given URI.
|
||||||
|
*
|
||||||
|
* @param string $uri A URI
|
||||||
|
*
|
||||||
|
* @return array An array of cookie values
|
||||||
|
*/
|
||||||
|
public function allRawValues($uri)
|
||||||
|
{
|
||||||
|
return $this->allValues($uri, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all expired cookies.
|
* Removes all expired cookies.
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +79,8 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
|||||||
$cookieJar->set($cookie1 = new Cookie('foo_nothing', 'foo'));
|
$cookieJar->set($cookie1 = new Cookie('foo_nothing', 'foo'));
|
||||||
$cookieJar->set($cookie2 = new Cookie('foo_expired', 'foo', time() - 86400));
|
$cookieJar->set($cookie2 = new Cookie('foo_expired', 'foo', time() - 86400));
|
||||||
$cookieJar->set($cookie3 = new Cookie('foo_path', 'foo', null, '/foo'));
|
$cookieJar->set($cookie3 = new Cookie('foo_path', 'foo', null, '/foo'));
|
||||||
$cookieJar->set($cookie4 = new Cookie('foo_domain', 'foo', null, '/', 'example.com'));
|
$cookieJar->set($cookie4 = new Cookie('foo_domain', 'foo', null, '/', '.example.com'));
|
||||||
|
$cookieJar->set($cookie4 = new Cookie('foo_strict_domain', 'foo', null, '/', '.www4.example.com'));
|
||||||
$cookieJar->set($cookie5 = new Cookie('foo_secure', 'foo', null, '/', '', true));
|
$cookieJar->set($cookie5 = new Cookie('foo_secure', 'foo', null, '/', '', true));
|
||||||
|
|
||||||
$this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI');
|
$this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI');
|
||||||
@ -88,11 +89,22 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function provideAllValuesValues()
|
public function provideAllValuesValues()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
array('http://www.example.com', array('foo_nothing', 'foo_domain')),
|
||||||
array('http://www.example.com/', array('foo_nothing', 'foo_domain')),
|
array('http://www.example.com/', array('foo_nothing', 'foo_domain')),
|
||||||
array('http://foo.example.com/', array('foo_nothing', 'foo_domain')),
|
array('http://foo.example.com/', array('foo_nothing', 'foo_domain')),
|
||||||
array('http://foo.example1.com/', array('foo_nothing')),
|
array('http://foo.example1.com/', array('foo_nothing')),
|
||||||
array('https://foo.example.com/', array('foo_nothing', 'foo_domain', 'foo_secure')),
|
array('https://foo.example.com/', array('foo_nothing', 'foo_domain', 'foo_secure')),
|
||||||
array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')),
|
array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')),
|
||||||
|
array('http://www4.example.com/', array('foo_nothing', 'foo_domain', 'foo_strict_domain')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEncodedValues()
|
||||||
|
{
|
||||||
|
$cookieJar = new CookieJar();
|
||||||
|
$cookieJar->set($cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true));
|
||||||
|
|
||||||
|
$this->assertEquals(array('foo' => 'bar=baz'), $cookieJar->allValues('/'));
|
||||||
|
$this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ class CookieTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('foo=bar; secure'),
|
array('foo=bar; secure'),
|
||||||
array('foo=bar; httponly'),
|
array('foo=bar; httponly'),
|
||||||
array('foo=bar; domain=google.com; path=/foo; secure; httponly'),
|
array('foo=bar; domain=google.com; path=/foo; secure; httponly'),
|
||||||
|
array('foo=bar=baz'),
|
||||||
|
array('foo=bar%3Dbaz'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +72,17 @@ class CookieTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$cookie = new Cookie('foo', 'bar');
|
$cookie = new Cookie('foo', 'bar');
|
||||||
$this->assertEquals('bar', $cookie->getValue(), '->getValue() returns the cookie value');
|
$this->assertEquals('bar', $cookie->getValue(), '->getValue() returns the cookie value');
|
||||||
|
|
||||||
|
$cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value
|
||||||
|
$this->assertEquals('bar=baz', $cookie->getValue(), '->getValue() returns the urldecoded cookie value');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetRawValue()
|
||||||
|
{
|
||||||
|
$cookie = new Cookie('foo', 'bar=baz'); // decoded value
|
||||||
|
$this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the urlencoded cookie value');
|
||||||
|
$cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value
|
||||||
|
$this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the non-urldecoded cookie value');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPath()
|
public function testGetPath()
|
||||||
|
@ -10,6 +10,15 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
CAUTION: This file installs the dependencies needed to run the Symfony2 test suite.
|
||||||
|
If you want to create a new project, download the Symfony Standard Edition instead:
|
||||||
|
|
||||||
|
http://symfony.com/download
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
if (!is_dir($vendorDir = dirname(__FILE__).'/vendor')) {
|
if (!is_dir($vendorDir = dirname(__FILE__).'/vendor')) {
|
||||||
mkdir($vendorDir, 0777, true);
|
mkdir($vendorDir, 0777, true);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user