Skip to content

Fix form csrf tokens on kernel reload #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bdada47
[Translation] Added CsvFileLoader to support csv translation resources.
umpirsky Jan 8, 2011
e85546e
[DependencyInjection] made some improvments to the container compiler
schmittjoh Jan 8, 2011
d1a2a65
[DependencyInjection] performance improvement, better analysis tools
schmittjoh Jan 9, 2011
f1e41a9
[DependencyInjection] made some improvments to the container compiler
schmittjoh Jan 9, 2011
99a5097
[HttpFoundation] Correcting the PHPDoc for the public $headers proper…
weaverryan Jan 9, 2011
09a876b
[HttpFoundation] Adding a few internal notes to clarify the process o…
weaverryan Jan 9, 2011
361a0dc
[Translation] Adding PHPDoc to the MessageSelector::choose() method.
weaverryan Jan 9, 2011
98c787a
[CompatAssetsBundle] Add missing namespace
ornicar Jan 10, 2011
dedf29f
[HttpKernel] No longer reformat {} "a la python"
igorw Jan 9, 2011
3734c0e
updated bootstrap file
fabpot Jan 10, 2011
d6b57bc
[HttpFoundation] fixed error casting broken in DomCrawler\Form::getPh…
avalanche123 Jan 10, 2011
7cab551
[FrameworkBundle] removed public=false from security.encoder_factory
ruudk Jan 11, 2011
c85b587
made security.acl.dbal.connection public for use in acl:init
Jan 10, 2011
18a34c5
[DoctrineBundle] Changed visibility of doctrine db connections to public
Jan 10, 2011
f41654f
[Console] added rendering previous exceptions
hason Jan 11, 2011
08c3a2b
method buildContainer divided into logical parts
hason Jan 10, 2011
9a2e053
[Event] Collected data is about listener (not event) calls
vicb Jan 9, 2011
47b87e9
[TwigBundle] made global more powerful
fabpot Jan 11, 2011
4beac30
[Form, FrameworkBundle] added csrf tokens reset on Kernel::shutdown()…
avalanche123 Jan 11, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[TwigBundle] made global more powerful
A global can now be a service or a string:

<twig:config debug="%kernel.debug%" strict-variables="%kernel.debug%">
    <twig:global key="request" type="service" id="request" />
    <twig:global key="PI">3.14</twig:global>
</twig:config>
  • Loading branch information
fabpot committed Jan 11, 2011
commit 47b87e902eff70b226748455a2d0fb05d391fd41
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ public function configLoad($config, ContainerBuilder $container)
$globals = $this->fixConfig($config, 'global');
if (isset($globals[0])) {
foreach ($globals as $global) {
$def->addMethodCall('addGlobal', array($global['key'], new Reference($global['id'])));
if (isset($global['type']) && 'service' === $global['type']) {
$def->addMethodCall('addGlobal', array($global['key'], new Reference($global['id'])));
} elseif (isset($global['value'])) {
$def->addMethodCall('addGlobal', array($global['key'], $global['value']));
} else {
throw new \InvalidArgumentException(sprintf('Unable to understand global configuration (%s).', var_export($global, true)));
}
}
} else {
foreach ($globals as $key => $id) {
$def->addMethodCall('addGlobal', array($key, new Reference($id)));
foreach ($globals as $key => $value) {
if ('@' === substr($value, 0, 1)) {
$def->addMethodCall('addGlobal', array($key, new Reference(substr($value, 1))));
} else {
$def->addMethodCall('addGlobal', array($key, $value));
}
}
}
unset($config['globals'], $config['global']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<xsd:complexType name="config">
<xsd:sequence>
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="1" />
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="extension" type="extension" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>

Expand All @@ -29,8 +29,9 @@
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="global">
<xsd:attribute name="key" type="xsd:string" />
<xsd:complexType name="global" mixed="true">
<xsd:attribute name="key" type="xsd:string" use="required" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="id" type="xsd:string" />
</xsd:complexType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class TwigExtensionTest extends TestCase
{
Expand All @@ -36,18 +37,28 @@ public function testConfigGlobals()
// XML
$container = new ContainerBuilder();
$loader = new TwigExtension();
$loader->configLoad(array('global' => array(array('key' => 'foo', 'id' => 'bar'))), $container);
$loader->configLoad(array('global' => array(
array('key' => 'foo', 'type' => 'service', 'id' => 'bar'),
array('key' => 'pi', 'value' => 3.14),
)), $container);
$config = $container->getDefinition('twig')->getMethodCalls();
$this->assertEquals('foo', $config[0][1][0]);
$this->assertEquals('bar', (string) $config[0][1][1]);
$this->assertEquals(new Reference('bar'), $config[0][1][1]);
$this->assertEquals('pi', $config[1][1][0]);
$this->assertEquals(3.14, $config[1][1][1]);

// YAML, PHP
$container = new ContainerBuilder();
$loader = new TwigExtension();
$loader->configLoad(array('globals' => array('foo' => 'bar')), $container);
$loader->configLoad(array('globals' => array(
'foo' => '@bar',
'pi' => 3.14,
)), $container);
$config = $container->getDefinition('twig')->getMethodCalls();
$this->assertEquals('foo', $config[0][1][0]);
$this->assertEquals('bar', (string) $config[0][1][1]);
$this->assertEquals(new Reference('bar'), $config[0][1][1]);
$this->assertEquals('pi', $config[1][1][0]);
$this->assertEquals(3.14, $config[1][1][1]);
}

public function testConfigExtensions()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy