8000 merged 2.0 · blahy/symfony@7a54fe4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a54fe4

Browse files
committed
merged 2.0
2 parents bbd686a + de5e80b commit 7a54fe4

File tree

10 files changed

+72
-43
lines changed

10 files changed

+72
-43
lines changed

src/Symfony/Bundle/FrameworkBundle/HttpKernel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ public function render($controller, array $options = array())
146146
}
147147
} else {
148148
$options['attributes']['_controller'] = $controller;
149-
$options['attributes']['_format'] = $request->getRequestFormat();
149+
150+
if (!isset($options['attributes']['_format'])) {
151+
$options['attributes']['_format'] = $request->getRequestFormat();
152+
}
153+
150154
$options['attributes']['_route'] = '_internal';
151155
$subRequest = $request->duplicate($options['query'], null, $options['attributes']);
152156
}

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected function normalizeValue($value)
277277
if (count($value) && !$this->ignoreExtraKeys) {
278278
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
279279
$ex = new InvalidConfigurationException($msg);
280-
$ex->setPath($this->getPath().'.'.reset($value));
280+
$ex->setPath($this->getPath());
281281

282282
throw $ex;
283283
}

src/Symfony/Component/Console/Command/Command.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ public function getDefinition()
310310
return $this->definition;
311311
}
312312

313+
/**
314+
* Gets the InputDefinition to be used to create XML and Text representations of this Command.
315+
*
316+
* Can be overridden to provide the original command representation when it would otherwise
317+
* be changed by merging with the application InputDefinition.
318+
*
319+
* @return InputDefinition An InputDefinition instance
320+
*/
321+
protected function getNativeDefinition()
322+
{
323+
return $this->getDefinition();
324+
}
325+
313326
/**
314327
* Adds an argument.
315328
*
@@ -543,7 +556,7 @@ public function asText()
543556
$messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
544557
}
545558

546-
$messages[] = $this->definition->asText();
559+
$messages[] = $this->getNativeDefinition()->asText();
547560

548561
if ($help = $this->getProcessedHelp()) {
549562
$messages[] = '<comment>Help:</comment>';
@@ -584,7 +597,7 @@ public function asXml($asDom = false)
584597
$aliasXML->appendChild($dom->createTextNode($alias));
585598
}
586599

587-
$definition = $this->definition->asXml(true);
600+
$definition = $this->getNativeDefinition()->asXml(true);
588601
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
589602
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));
590603

src/Symfony/Component/Console/Command/ListCommand.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Symfony\Component\Console\Output\Output;
1919
use Symfony\Component\Console\Command\Command;
20+
use Symfony\Component\Console\Input\InputDefinition;
2021

2122
/**
2223
* ListCommand displays the list of all available commands for the application.
@@ -31,11 +32,7 @@ class ListCommand extends Command
3132
protected function configure()
3233
{
3334
$this
34-
->setDefinition(array(
35-
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
36-
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
37-
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list')
38-
))
35+
->setDefinition($this->createDefinition())
3936
->setName('list')
4037
->setDescription('Lists commands')
4138
->setHelp(<<<EOF
@@ -58,6 +55,14 @@ protected function configure()
5855
);
5956
}
6057

58+
/**
59+
* {@inheritdoc}
60+
*/
61+
protected function getNativeDefinition()
62+
{
63+
return $this->createDefinition();
64+
}
65+
6166
/**
6267
* {@inheritdoc}
6368
*/
@@ -69,4 +74,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
6974
$output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw')));
7075
}
7176
}
77+
78+
private function createDefinition()
79+
{
80+
return new InputDefinition(array(
81+
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
82+
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
83+
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
84+
));
85+
}
7286
}

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public function reverseTransform($value)
7373
}
7474

7575
try {
76-
$dateTime = new \DateTime(sprintf("@%s %s", $value, $this->outputTimezone));
76+
$dateTime = new \DateTime();
77+
$dateTime->setTimezone(new \DateTimeZone($this->outputTimezone));
78+
$dateTime->setTimestamp($value);
7779

7880
if ($this->inputTimezone !== $this->outputTimezone) {
7981
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Form\FormBuilder;
1717
use Symfony\Component\Form\FormView;
1818
use Symfony\Component\Form\ReversedTransformer;
19-
use Symfony\Component\Form\Exception\FormException;
2019
use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
2120
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
2221
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
@@ -41,10 +40,6 @@ public function buildForm(FormBuilder $builder, array $options)
4140
$timeParts[] = 'second';
4241
}
4342

44-
if ($options['date_widget'] !== $options['time_widget']) {
45-
throw new FormException(sprintf('Options "date_widget" and "time_widget" need to be identical. Used: "date_widget" = "%s" and "time_widget" = "%s".', $options['date_widget'] ?: 'choice', $options['time_widget'] ?: 'choice'));
46-
}
47-
4843
if ('single_text' === $options['widget']) {
4944
$builder->appendClientTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['user_timezone'], $format));
5045
} else {

src/Symfony/Component/Validator/Mapping/Cache/CacheInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function has($class);
3232
*
3333
* @param string $class Class Name
3434
*
35-
* @return ClassMetadata
35+
* @return ClassMetadata|false A ClassMetadata instance or false on miss
3636
*/
3737
function read($class);
3838

src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ public function getClassMetadata($class)
7474
}
7575
}
7676

77-
return $this->loadedClasses[$class];
77+
if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) {
78+
return $this->loadedClasses[$class];
79+
}
80+
81+
$metadata = new ClassMetadata($class);
82+
83+
// Include constraints from the parent class
84+
if ($parent = $metadata->getReflectionClass()->getParentClass()) {
85+
$metadata->mergeConstraints($this->getClassMetadata($parent->getName()));
86+
}
87+
88+
// Include constraints from all implemented interfaces
89+
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
90+
$metadata->mergeConstraints($this->getClassMetadata($interface->getName()));
91+
}
92+
93+
$this->loader->loadClassMetadata($metadata);
94+
95+
if ($this->cache !== null) {
96+
$this->cache->write($metadata);
97+
}
98+
99+
return $this->loadedClasses[$class] = $metadata;
78100
}
79101
}

tests/Symfony/Tests/Component/Form/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -193,27 +193,6 @@ public function testSubmit_stringSingleText()
193193
$this->assertEquals('2010-06-02 03:04:00', $form->getClientData());
194194
}
195195

196-
/**
197-
* @expectedException Symfony\Component\Form\Exception\FormException
198-
*/
199-
public function testDifferentWidgets()
200-
{
201-
$form = $this->factory->create('datetime', null, array(
202-
'date_widget' => 'single_text',
203-
'time_widget' => 'choice',
204-
));
205-
}
206-
207-
/**
208-
* @expectedException Symfony\Component\Form\Exception\FormException
209-
*/
210-
public function testDefinedOnlyOneWidget()
211-
{
212-
$form = $this->factory->create('datetime', null, array(
213-
'date_widget' => 'single_text',
214-
));
215-
}
216-
217196
public function testSubmit_differentPattern()
218197
{
219198
$form = $this->factory->create('datetime', null, array(

tests/Symfony/Tests/Component/Validator/Mapping/ClassMetadataFactoryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ public function testWriteMetadataToCache()
7474
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
7575
);
7676

77+
$cache->expects($this->never())
78+
->method('has');
7779
$cache->expects($this->once())
78-
->method('has')
80+
->method('read')
7981
->with($this->equalTo(self::PARENTCLASS))
8082
->will($this->returnValue(false));
8183
$cache->expects($this->once())
@@ -103,10 +105,8 @@ public function testReadMetadataFromCache()
103105
$loader->expects($this->never())
104106
->method('loadClassMetadata');
105107

106-
$cache->expects($this->once())
107-
->method('has')
108-
->with($this->equalTo(self::PARENTCLASS))
109-
->will($this->returnValue(true));
108+
$cache->expects($this->never())
109+
->method('has');
110110
$cache->expects($this->once())
111111
->method('read')
112112
->will($this->returnValue($metadata));

0 commit comments

Comments
 (0)
0