merged 2.0
This commit is contained in:
commit
a6cdddd716
@ -97,7 +97,7 @@ class EntityChoiceList extends ArrayChoiceList
|
||||
* @param QueryBuilder|\Closure $queryBuilder An optional query builder
|
||||
* @param array|\Closure $choices An array of choices or a function returning an array
|
||||
*/
|
||||
public function __construct(EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = array(), $groupBy = null)
|
||||
public function __construct(EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = null, $groupBy = null)
|
||||
{
|
||||
// If a query builder was passed, it must be a closure or QueryBuilder
|
||||
// instance
|
||||
@ -126,7 +126,11 @@ class EntityChoiceList extends ArrayChoiceList
|
||||
$this->propertyPath = new PropertyPath($property);
|
||||
}
|
||||
|
||||
parent::__construct($choices);
|
||||
if (!is_array($choices) && !$choices instanceof \Closure && !is_null($choices)) {
|
||||
throw new UnexpectedTypeException($choices, 'array or \Closure or null');
|
||||
}
|
||||
|
||||
$this->choices = $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +148,7 @@ class EntityChoiceList extends ArrayChoiceList
|
||||
{
|
||||
parent::load();
|
||||
|
||||
if ($this->choices) {
|
||||
if (is_array($this->choices)) {
|
||||
$entities = $this->choices;
|
||||
} else if ($qb = $this->queryBuilder) {
|
||||
$entities = $qb->getQuery()->execute();
|
||||
|
@ -47,7 +47,7 @@ class EntityType extends AbstractType
|
||||
'class' => null,
|
||||
'property' => null,
|
||||
'query_builder' => null,
|
||||
'choices' => array(),
|
||||
'choices' => null,
|
||||
'group_by' => null,
|
||||
);
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ControllerResolver extends BaseControllerResolver
|
||||
$controller = $this->parser->parse($controller);
|
||||
} elseif (1 == $count) {
|
||||
// controller in the service:method notation
|
||||
list($service, $method) = explode(':', $controller);
|
||||
list($service, $method) = explode(':', $controller, 2);
|
||||
|
||||
return array($this->container->get($service), $method);
|
||||
} else {
|
||||
@ -66,7 +66,7 @@ class ControllerResolver extends BaseControllerResolver
|
||||
}
|
||||
}
|
||||
|
||||
list($class, $method) = explode('::', $controller);
|
||||
list($class, $method) = explode('::', $controller, 2);
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||
|
@ -209,7 +209,7 @@ class FrameworkExtension extends Extension
|
||||
'file' => 'Symfony\Component\HttpKernel\Profiler\FileProfilerStorage',
|
||||
'mongodb' => 'Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage',
|
||||
);
|
||||
list($class, ) = explode(':', $config['dsn']);
|
||||
list($class, ) = explode(':', $config['dsn'], 2);
|
||||
if (!isset($supported[$class])) {
|
||||
throw new \LogicException(sprintf('Driver "%s" is not supported for the profiler.', $class));
|
||||
}
|
||||
@ -526,7 +526,7 @@ class FrameworkExtension extends Extension
|
||||
})->in($dirs);
|
||||
foreach ($finder as $file) {
|
||||
// filename is domain.locale.format
|
||||
list($domain, $locale, $format) = explode('.', $file->getBasename());
|
||||
list($domain, $locale, $format) = explode('.', $file->getBasename(), 3);
|
||||
|
||||
$translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain));
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class CodeHelper extends Helper
|
||||
public function abbrMethod($method)
|
||||
{
|
||||
if (false !== strpos($method, '::')) {
|
||||
list($class, $method) = explode('::', $method);
|
||||
list($class, $method) = explode('::', $method, 2);
|
||||
$result = sprintf("%s::%s()", $this->abbrClass($class), $method);
|
||||
} else if ('Closure' === $method) {
|
||||
$result = sprintf("<abbr title=\"%s\">%s</abbr>", $method, $method);
|
||||
|
@ -28,7 +28,7 @@ class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
|
||||
public function parse($name)
|
||||
{
|
||||
list($bundle, $controller, $template) = explode(':', $name);
|
||||
list($bundle, $controller, $template) = explode(':', $name, 3);
|
||||
|
||||
if ($template[0] == '_') {
|
||||
$path = $this->rootTheme.'/Custom/'.$template;
|
||||
|
@ -172,7 +172,7 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
protected function checkIp4($requestIp, $ip)
|
||||
{
|
||||
if (false !== strpos($ip, '/')) {
|
||||
list($address, $netmask) = explode('/', $ip);
|
||||
list($address, $netmask) = explode('/', $ip, 2);
|
||||
|
||||
if ($netmask < 1 || $netmask > 32) {
|
||||
return false;
|
||||
@ -202,7 +202,7 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
|
||||
}
|
||||
|
||||
list($address, $netmask) = explode('/', $ip);
|
||||
list($address, $netmask) = explode('/', $ip, 2);
|
||||
|
||||
$bytesAddr = unpack("n*", inet_pton($address));
|
||||
$bytesTest = unpack("n*", inet_pton($requestIp));
|
||||
|
@ -145,7 +145,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
|
||||
}
|
||||
|
||||
list($class, $method) = explode('::', $controller);
|
||||
list($class, $method) = explode('::', $controller, 2);
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||
|
@ -59,7 +59,7 @@ abstract class FileLoader implements LoaderInterface
|
||||
if (strpos($name, '\\') !== false && class_exists($name)) {
|
||||
$className = (string) $name;
|
||||
} else if (strpos($name, ':') !== false) {
|
||||
list($prefix, $className) = explode(':', $name);
|
||||
list($prefix, $className) = explode(':', $name, 2);
|
||||
|
||||
if (!isset($this->namespaces[$prefix])) {
|
||||
throw new MappingException(sprintf('Undefined namespace prefix "%s"', $prefix));
|
||||
|
@ -92,6 +92,26 @@ class EntityChoiceListTest extends DoctrineOrmTestCase
|
||||
$this->assertSame(array(1 => 'Foo', 2 => 'Bar'), $choiceList->getChoices());
|
||||
}
|
||||
|
||||
public function testEmptyChoicesAreManaged()
|
||||
{
|
||||
$entity1 = new SingleIdentEntity(1, 'Foo');
|
||||
$entity2 = new SingleIdentEntity(2, 'Bar');
|
||||
|
||||
// Persist for managed state
|
||||
$this->em->persist($entity1);
|
||||
$this->em->persist($entity2);
|
||||
|
||||
$choiceList = new EntityChoiceList(
|
||||
$this->em,
|
||||
self::SINGLE_IDENT_CLASS,
|
||||
'name',
|
||||
null,
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertSame(array(), $choiceList->getChoices());
|
||||
}
|
||||
|
||||
public function testNestedChoicesAreManaged()
|
||||
{
|
||||
$entity1 = new SingleIdentEntity(1, 'Foo');
|
||||
|
Reference in New Issue
Block a user