merged 2.0
This commit is contained in:
commit
7a54fe41ca
@ -146,7 +146,11 @@ class HttpKernel extends BaseHttpKernel
|
||||
}
|
||||
} else {
|
||||
$options['attributes']['_controller'] = $controller;
|
||||
$options['attributes']['_format'] = $request->getRequestFormat();
|
||||
|
||||
if (!isset($options['attributes']['_format'])) {
|
||||
$options['attributes']['_format'] = $request->getRequestFormat();
|
||||
}
|
||||
|
||||
$options['attributes']['_route'] = '_internal';
|
||||
$subRequest = $request->duplicate($options['query'], null, $options['attributes']);
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
if (count($value) && !$this->ignoreExtraKeys) {
|
||||
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath().'.'.reset($value));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
@ -310,6 +310,19 @@ class Command
|
||||
return $this->definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InputDefinition to be used to create XML and Text representations of this Command.
|
||||
*
|
||||
* Can be overridden to provide the original command representation when it would otherwise
|
||||
* be changed by merging with the application InputDefinition.
|
||||
*
|
||||
* @return InputDefinition An InputDefinition instance
|
||||
*/
|
||||
protected function getNativeDefinition()
|
||||
{
|
||||
return $this->getDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an argument.
|
||||
*
|
||||
@ -543,7 +556,7 @@ class Command
|
||||
$messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
|
||||
}
|
||||
|
||||
$messages[] = $this->definition->asText();
|
||||
$messages[] = $this->getNativeDefinition()->asText();
|
||||
|
||||
if ($help = $this->getProcessedHelp()) {
|
||||
$messages[] = '<comment>Help:</comment>';
|
||||
@ -584,7 +597,7 @@ class Command
|
||||
$aliasXML->appendChild($dom->createTextNode($alias));
|
||||
}
|
||||
|
||||
$definition = $this->definition->asXml(true);
|
||||
$definition = $this->getNativeDefinition()->asXml(true);
|
||||
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
|
||||
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));
|
||||
|
||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
|
||||
/**
|
||||
* ListCommand displays the list of all available commands for the application.
|
||||
@ -31,11 +32,7 @@ class ListCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
|
||||
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
|
||||
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list')
|
||||
))
|
||||
->setDefinition($this->createDefinition())
|
||||
->setName('list')
|
||||
->setDescription('Lists commands')
|
||||
->setHelp(<<<EOF
|
||||
@ -58,6 +55,14 @@ EOF
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNativeDefinition()
|
||||
{
|
||||
return $this->createDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -69,4 +74,13 @@ EOF
|
||||
$output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw')));
|
||||
}
|
||||
}
|
||||
|
||||
private function createDefinition()
|
||||
{
|
||||
return new InputDefinition(array(
|
||||
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
|
||||
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
|
||||
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,9 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer
|
||||
}
|
||||
|
||||
try {
|
||||
$dateTime = new \DateTime(sprintf("@%s %s", $value, $this->outputTimezone));
|
||||
$dateTime = new \DateTime();
|
||||
$dateTime->setTimezone(new \DateTimeZone($this->outputTimezone));
|
||||
$dateTime->setTimestamp($value);
|
||||
|
||||
if ($this->inputTimezone !== $this->outputTimezone) {
|
||||
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
|
||||
|
@ -16,7 +16,6 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\ReversedTransformer;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
||||
@ -41,10 +40,6 @@ class DateTimeType extends AbstractType
|
||||
$timeParts[] = 'second';
|
||||
}
|
||||
|
||||
if ($options['date_widget'] !== $options['time_widget']) {
|
||||
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'));
|
||||
}
|
||||
|
||||
if ('single_text' === $options['widget']) {
|
||||
$builder->appendClientTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['user_timezone'], $format));
|
||||
} else {
|
||||
|
@ -32,7 +32,7 @@ interface CacheInterface
|
||||
*
|
||||
* @param string $class Class Name
|
||||
*
|
||||
* @return ClassMetadata
|
||||
* @return ClassMetadata|false A ClassMetadata instance or false on miss
|
||||
*/
|
||||
function read($class);
|
||||
|
||||
|
@ -74,6 +74,28 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
return $this->loadedClasses[$class];
|
||||
if (null !== $this->cache && false !== ($this->loadedClasses[$class] = $this->cache->read($class))) {
|
||||
return $this->loadedClasses[$class];
|
||||
}
|
||||
|
||||
$metadata = new ClassMetadata($class);
|
||||
|
||||
// Include constraints from the parent class
|
||||
if ($parent = $metadata->getReflectionClass()->getParentClass()) {
|
||||
$metadata->mergeConstraints($this->getClassMetadata($parent->getName()));
|
||||
}
|
||||
|
||||
// Include constraints from all implemented interfaces
|
||||
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
|
||||
$metadata->mergeConstraints($this->getClassMetadata($interface->getName()));
|
||||
}
|
||||
|
||||
$this->loader->loadClassMetadata($metadata);
|
||||
|
||||
if ($this->cache !== null) {
|
||||
$this->cache->write($metadata);
|
||||
}
|
||||
|
||||
return $this->loadedClasses[$class] = $metadata;
|
||||
}
|
||||
}
|
||||
|
@ -193,27 +193,6 @@ class DateTimeTypeTest extends LocalizedTestCase
|
||||
$this->assertEquals('2010-06-02 03:04:00', $form->getClientData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\FormException
|
||||
*/
|
||||
public function testDifferentWidgets()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'date_widget' => 'single_text',
|
||||
'time_widget' => 'choice',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\FormException
|
||||
*/
|
||||
public function testDefinedOnlyOneWidget()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
'date_widget' => 'single_text',
|
||||
));
|
||||
}
|
||||
|
||||
public function testSubmit_differentPattern()
|
||||
{
|
||||
$form = $this->factory->create('datetime', null, array(
|
||||
|
@ -74,8 +74,10 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
new ConstraintA(array('groups' => array('Default', 'EntityParent'))),
|
||||
);
|
||||
|
||||
$cache->expects($this->never())
|
||||
->method('has');
|
||||
$cache->expects($this->once())
|
||||
->method('has')
|
||||
->method('read')
|
||||
->with($this->equalTo(self::PARENTCLASS))
|
||||
->will($this->returnValue(false));
|
||||
$cache->expects($this->once())
|
||||
@ -103,10 +105,8 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$loader->expects($this->never())
|
||||
->method('loadClassMetadata');
|
||||
|
||||
$cache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->equalTo(self::PARENTCLASS))
|
||||
->will($this->returnValue(true));
|
||||
$cache->expects($this->never())
|
||||
->method('has');
|
||||
$cache->expects($this->once())
|
||||
->method('read')
|
||||
->will($this->returnValue($metadata));
|
||||
|
Reference in New Issue
Block a user