Skip to content

Commit a729462

Browse files
committed
Merge branch '3.0'
* 3.0: (36 commits) Fixed form types in profiler [Process] Use stream based storage to avoid memory issues Fix upgrade guides concerning erroneous removal of assets helper [Process] Remove a misleading comment Fix markdown typo ChooseBaseUrl should return an index [Form] ChoiceType: Fix a notice when 'choices' normalizer is replaced Improve the phpdoc of SplFileInfo methods [Process] Use stream based storage to avoid memory issues [FrameworkBundle] Don't log twice with the error handler synchronize 2.8 and 3.0 upgrade files Remove useless is_object condition [Process] Fix typo, no arguments needed anymore [Serializer] Introduce constants for context keys Fixed the documentation of VoterInterface::supportsAttribute Fixed Bootstrap form theme form "reset" buttons Fixed the form profiler when using long form types [PropertyInfo] PhpDocExtractor: Fix a notice when the property doesn't exist Remove useless duplicated tests [FrameworkBundle] Optimize framework extension tests ...
2 parents cc84be9 + 67df429 commit a729462

File tree

38 files changed

+751
-276
lines changed

38 files changed

+751
-276
lines changed

UPGRADE-3.0.md

Lines changed: 342 additions & 72 deletions
Large diffs are not rendered by default.

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ public function startQuery($sql, array $params = null, array $types = null)
4949
$this->stopwatch->start('doctrine', 'doctrine');
5050
}
5151

52-
if (is_array($params)) {
53-
$params = $this->normalizeParams($params);
54-
}
55-
5652
if (null !== $this->logger) {
57-
$this->log($sql, null === $params ? array() : $params);
53+
$this->log($sql, null === $params ? array() : $this->normalizeParams($params));
5854
}
5955
}
6056

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
15-
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1615
use Symfony\Component\Validator\Constraint;
1716
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1817
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
@@ -139,16 +138,9 @@ public function validate($entity, Constraint $constraint)
139138
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
140139
$invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]];
141140

142-
if ($this->context instanceof ExecutionContextInterface) {
143-
$this->context->buildViolation($constraint->message)
144-
->atPath($errorPath)
145-
->setInvalidValue($invalidValue)
146-
->addViolation();
147-
} else {
148-
$this->buildViolation($constraint->message)
149-
->atPath($errorPath)
150-
->setInvalidValue($invalidValue)
151-
->addViolation();
152-
}
141+
$this->context->buildViolation($constraint->message)
142+
->atPath($errorPath)
143+
->setInvalidValue($invalidValue)
144+
->addViolation();
153145
}
154146
}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ col-sm-2
6565
{% endspaceless %}
6666
{% endblock submit_row %}
6767

68+
{% block reset_row -%}
69+
{% spaceless %}
70+
<div class="form-group">
71+
<div class="{{ block('form_label_class') }}"></div>
72+
<div class="{{ block('form_group_class') }}">
73+
{{ form_widget(form) }}
74+
</div>
75+
</div>
76+
{% endspaceless %}
77+
{% endblock reset_row %}
78+
6879
{% block form_group_class -%}
6980
col-sm-10
7081
{%- endblock form_group_class %}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@
167167
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
168168
{% endif %}
169169
{% if label is not same as(false) and label is empty %}
170-
{% set label = name|humanize %}
170+
{%- if label_format is not empty -%}
171+
{% set label = label_format|replace({
172+
'%name%': name,
173+
'%id%': id,
174+
}) %}
175+
{%- else -%}
176+
{% set label = name|humanize %}
177+
{%- endif -%}
171178
{% endif %}
172179
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
173180
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}

src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,14 @@
249249
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %}
250250
{% endif %}
251251
{% if label is empty %}
252-
{% set label = name|humanize %}
252+
{%- if label_format is not empty -%}
253+
{% set label = label_format|replace({
254+
'%name%': name,
255+
'%id%': id,
256+
}) %}
257+
{%- else -%}
258+
{% set label = name|humanize %}
259+
{%- endif -%}
253260
{% endif %}
254261
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
255262
{{ widget|raw }}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function process(ContainerBuilder $container)
3737
}
3838

3939
$class = $container->getParameterBag()->resolveValue($definition->getClass());
40-
$r = new \ReflectionClass($class);
41-
if (!$r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) {
40+
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
4241
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
4342
}
4443
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id);

src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434

3535
<service id="templating.helper.assets" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper">
3636
<tag name="templating.helper" alias="assets" />
37-
<argument /> <!-- default package -->
38-
<argument type="collection" /> <!-- named packages -->
37+
<argument /> <!-- packages -->
3938
</service>
4039

4140
<service id="templating.helper.actions" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper">
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
13+
14+
use Symfony\Component\Asset\Packages;
15+
use Symfony\Component\Templating\Helper\Helper;
16+
17+
/**
18+
* AssetsHelper helps manage asset URLs.
19+
*
20+
* @author Fabien Potencier <[email protected]>
21+
*/
22+
class AssetsHelper extends Helper
23+
{
24+
private $packages;
25+
26+
public function __construct(Packages $packages)
27+
{
28+
$this->packages = $packages;
29+
}
30+
31+
/**
32+
* Returns the public url/path of an asset.
33+
*
34+
* If the package used to generate the path is an instance of
35+
* UrlPackage, you will always get a URL and not a path.
36+
*
37+
* @param string $path A public path
38+
* @param string $packageName The name of the asset package to use
39+
*
40+
* @return string The public path of the asset
41+
*/
42+
public function getUrl($path, $packageName = null)
43+
{
44+
return $this->packages->getUrl($path, $packageName);
45+
}
46+
47+
/**
48+
* Returns the version of an asset.
49+
*
50+
* @param string $path A public path
51+
* @param string $packageName The name of the asset package to use
52+
*
53+
* @return string The asset version
54+
*/
55+
public function getVersion($path, $packageName = null)
56+
{
57+
return $this->packages->getVersion($path, $packageName);
58+
}
59+
60+
/**
61+
* {@inheritdoc}
62+
*/
63+
public function getName()
64+
{
65+
return 'assets';
66+
}
67+
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
abstract class FrameworkExtensionTest extends TestCase
2424
{
25+
private static $containerCache = array();
26+
2527
abstract protected function loadFromFile(ContainerBuilder $container, $file);
2628

2729
public function testFormCsrfProtection()
@@ -482,6 +484,10 @@ protected function createContainer(array $data = array())
482484

483485
protected function createContainerFromFile($file, $data = array())
484486
{
487+
$cacheKey = md5($file.serialize($data));
488+
if (isset(self::$containerCache[$cacheKey])) {
489+
return self::$containerCache[$cacheKey];
490+
}
485491
$container = $this->createContainer($data);
486492
$container->registerExtension(new FrameworkExtension());
487493
$this->loadFromFile($container, $file);
@@ -490,7 +496,7 @@ protected function createContainerFromFile($file, $data = array())
490496
$container->getCompilerPassConfig()->setRemovingPasses(array());
491497
$container->compile();
492498

493-
return $container;
499+
return self::$containerCache[$cacheKey] = $container;
494500
}
495501

496502
protected function createContainerFromClosure($closure, $data = array())

0 commit comments

Comments
 (0)