Merge branch '2.8' into 3.4
* 2.8: PropertyInfo\DoctrineExtractor - There is bug when indexBy is meta key [minor] SCA
This commit is contained in:
commit
9a0422ce45
@ -95,9 +95,19 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
|||||||
|
|
||||||
if (isset($associationMapping['indexBy'])) {
|
if (isset($associationMapping['indexBy'])) {
|
||||||
$indexProperty = $associationMapping['indexBy'];
|
$indexProperty = $associationMapping['indexBy'];
|
||||||
|
/** @var ClassMetadataInfo $subMetadata */
|
||||||
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
|
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
|
||||||
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
|
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
|
||||||
|
|
||||||
|
if (null === $typeOfField) {
|
||||||
|
$associationMapping = $subMetadata->getAssociationMapping($indexProperty);
|
||||||
|
|
||||||
|
/** @var ClassMetadataInfo $subMetadata */
|
||||||
|
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty);
|
||||||
|
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
|
||||||
|
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
|
||||||
|
}
|
||||||
|
|
||||||
$collectionKeyType = $this->getPhpType($typeOfField);
|
$collectionKeyType = $this->getPhpType($typeOfField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ class DoctrineExtractorTest extends TestCase
|
|||||||
'foo',
|
'foo',
|
||||||
'bar',
|
'bar',
|
||||||
'indexedBar',
|
'indexedBar',
|
||||||
|
'indexedFoo',
|
||||||
),
|
),
|
||||||
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
|
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
|
||||||
);
|
);
|
||||||
@ -141,6 +142,14 @@ class DoctrineExtractorTest extends TestCase
|
|||||||
new Type(Type::BUILTIN_TYPE_STRING),
|
new Type(Type::BUILTIN_TYPE_STRING),
|
||||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||||
))),
|
))),
|
||||||
|
array('indexedFoo', array(new Type(
|
||||||
|
Type::BUILTIN_TYPE_OBJECT,
|
||||||
|
false,
|
||||||
|
'Doctrine\Common\Collections\Collection',
|
||||||
|
true,
|
||||||
|
new Type(Type::BUILTIN_TYPE_STRING),
|
||||||
|
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||||
|
))),
|
||||||
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
|
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
|
||||||
array('customFoo', null),
|
array('customFoo', null),
|
||||||
array('notMapped', null),
|
array('notMapped', null),
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
|
|||||||
use Doctrine\ORM\Mapping\Column;
|
use Doctrine\ORM\Mapping\Column;
|
||||||
use Doctrine\ORM\Mapping\Entity;
|
use Doctrine\ORM\Mapping\Entity;
|
||||||
use Doctrine\ORM\Mapping\Id;
|
use Doctrine\ORM\Mapping\Id;
|
||||||
|
use Doctrine\ORM\Mapping\OneToMany;
|
||||||
use Doctrine\ORM\Mapping\ManyToMany;
|
use Doctrine\ORM\Mapping\ManyToMany;
|
||||||
use Doctrine\ORM\Mapping\ManyToOne;
|
use Doctrine\ORM\Mapping\ManyToOne;
|
||||||
|
|
||||||
@ -45,6 +46,11 @@ class DoctrineDummy
|
|||||||
*/
|
*/
|
||||||
protected $indexedBar;
|
protected $indexedBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="foo", indexBy="foo")
|
||||||
|
*/
|
||||||
|
protected $indexedFoo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Column(type="guid")
|
* @Column(type="guid")
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
|
|||||||
use Doctrine\ORM\Mapping\Column;
|
use Doctrine\ORM\Mapping\Column;
|
||||||
use Doctrine\ORM\Mapping\Entity;
|
use Doctrine\ORM\Mapping\Entity;
|
||||||
use Doctrine\ORM\Mapping\Id;
|
use Doctrine\ORM\Mapping\Id;
|
||||||
|
use Doctrine\ORM\Mapping\ManyToOne;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Entity
|
* @Entity
|
||||||
@ -32,4 +33,10 @@ class DoctrineRelation
|
|||||||
* @Column(type="guid")
|
* @Column(type="guid")
|
||||||
*/
|
*/
|
||||||
protected $rguid;
|
protected $rguid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Column(type="guid")
|
||||||
|
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="indexedFoo")
|
||||||
|
*/
|
||||||
|
protected $foo;
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,10 @@ class TemplateFinder implements TemplateFinderInterface
|
|||||||
private function findTemplatesInBundle(BundleInterface $bundle)
|
private function findTemplatesInBundle(BundleInterface $bundle)
|
||||||
{
|
{
|
||||||
$name = $bundle->getName();
|
$name = $bundle->getName();
|
||||||
$templates = array_merge(
|
$templates = array_unique(array_merge(
|
||||||
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
|
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
|
||||||
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
|
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
|
||||||
);
|
));
|
||||||
$templates = array_unique($templates);
|
|
||||||
|
|
||||||
foreach ($templates as $i => $template) {
|
foreach ($templates as $i => $template) {
|
||||||
$templates[$i] = $template->set('bundle', $name);
|
$templates[$i] = $template->set('bundle', $name);
|
||||||
|
@ -157,7 +157,7 @@ class CodeHelper extends Helper
|
|||||||
$file = trim($file);
|
$file = trim($file);
|
||||||
$fileStr = $file;
|
$fileStr = $file;
|
||||||
if (0 === strpos($fileStr, $this->rootDir)) {
|
if (0 === strpos($fileStr, $this->rootDir)) {
|
||||||
$fileStr = str_replace($this->rootDir, '', str_replace('\\', '/', $fileStr));
|
$fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr);
|
||||||
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
|
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
|
||||||
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
|
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ class JsonDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'name' => '--'.$option->getName(),
|
'name' => '--'.$option->getName(),
|
||||||
'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '',
|
'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
|
||||||
'accept_value' => $option->acceptValue(),
|
'accept_value' => $option->acceptValue(),
|
||||||
'is_value_required' => $option->isValueRequired(),
|
'is_value_required' => $option->isValueRequired(),
|
||||||
'is_multiple' => $option->isArray(),
|
'is_multiple' => $option->isArray(),
|
||||||
|
@ -70,7 +70,7 @@ class MarkdownDescriptor extends Descriptor
|
|||||||
{
|
{
|
||||||
$name = '--'.$option->getName();
|
$name = '--'.$option->getName();
|
||||||
if ($option->getShortcut()) {
|
if ($option->getShortcut()) {
|
||||||
$name .= '|-'.implode('|-', explode('|', $option->getShortcut())).'';
|
$name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->write(
|
$this->write(
|
||||||
|
@ -224,7 +224,7 @@ class XmlDescriptor extends Descriptor
|
|||||||
$pos = strpos($option->getShortcut(), '|');
|
$pos = strpos($option->getShortcut(), '|');
|
||||||
if (false !== $pos) {
|
if (false !== $pos) {
|
||||||
$objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
|
$objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
|
||||||
$objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut())));
|
$objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
|
||||||
} else {
|
} else {
|
||||||
$objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
|
$objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class InputOption
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function equals(InputOption $option)
|
public function equals(self $option)
|
||||||
{
|
{
|
||||||
return $option->getName() === $this->getName()
|
return $option->getName() === $this->getName()
|
||||||
&& $option->getShortcut() === $this->getShortcut()
|
&& $option->getShortcut() === $this->getShortcut()
|
||||||
|
@ -160,10 +160,6 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
|
|||||||
|
|
||||||
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
|
$class = ltrim(is_object($value) ? get_class($value) : $value, '\\');
|
||||||
|
|
||||||
if (class_exists($class) || interface_exists($class)) {
|
return class_exists($class) || interface_exists($class, false);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user