Removed property path changes again
This commit is contained in:
parent
cbe6071969
commit
b03ee7cc76
|
@ -35,7 +35,6 @@ abstract class AbstractProvider extends BaseAbstractProvider
|
|||
{
|
||||
$queryBuilder = $this->createQueryBuilder();
|
||||
$nbObjects = $this->countObjects($queryBuilder);
|
||||
$stepStartTime = 0;
|
||||
|
||||
for ($offset = 0; $offset < $nbObjects; $offset += $this->options['batch_size']) {
|
||||
if ($loggerClosure) {
|
||||
|
|
|
@ -18,7 +18,6 @@ class Provider extends AbstractProvider
|
|||
{
|
||||
$queryClass = $this->objectClass . 'Query';
|
||||
$nbObjects = $queryClass::create()->count();
|
||||
$stepStartTime = 0;
|
||||
|
||||
for ($offset = 0; $offset < $nbObjects; $offset += $this->options['batch_size']) {
|
||||
if ($loggerClosure) {
|
||||
|
|
|
@ -70,7 +70,7 @@ class Resetter
|
|||
*/
|
||||
protected function createMapping($indexConfig)
|
||||
{
|
||||
$mapping = \Elastica_Type_Mapping::create($indexConfig['properties']);
|
||||
$mapping = \Elastica_Type_Mapping::create($indexConfig['properties']);
|
||||
|
||||
foreach($indexConfig['properties'] as $type) {
|
||||
if (!empty($type['_parent']) && $type['_parent'] !== '~') {
|
||||
|
|
|
@ -201,7 +201,7 @@ class ModelToElasticaAutoTransformerTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\PropertyAccess\Exception\PropertyAccessDeniedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\PropertyAccessDeniedException
|
||||
*/
|
||||
public function testThatCannotTransformObjectWhenGetterDoesNotExistForPrivateMethod()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace FOQ\ElasticaBundle\Transformer;
|
||||
|
||||
use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||
use Symfony\Component\Form\Util\PropertyPath;
|
||||
|
||||
/**
|
||||
* Maps Elastica documents with Doctrine objects
|
||||
|
@ -40,26 +40,28 @@ class ModelToElasticaAutoTransformer implements ModelToElasticaTransformerInterf
|
|||
**/
|
||||
public function transform($object, array $fields)
|
||||
{
|
||||
$accessor = PropertyAccess::getPropertyAccessor();
|
||||
$identifier = $accessor->getValue($object, $this->options['identifier']);
|
||||
$identifierProperty = new PropertyPath($this->options['identifier']);
|
||||
$identifier = $identifierProperty->getValue($object);
|
||||
$document = new \Elastica_Document($identifier);
|
||||
foreach ($fields as $key => $mapping) {
|
||||
$property = new PropertyPath($key);
|
||||
if (!empty($mapping['_parent']) && $mapping['_parent'] !== '~') {
|
||||
$parent = $accessor->getValue($object, $key);
|
||||
$document->setParent($accessor->getValue($parent, $mapping['_parent']['identifier']));
|
||||
$parent = $property->getValue($object);
|
||||
$identifierProperty = new PropertyPath($mapping['_parent']['identifier']);
|
||||
$document->setParent($identifierProperty->getValue($parent));
|
||||
} else if (isset($mapping['type']) && in_array($mapping['type'], array('nested', 'object'))) {
|
||||
$submapping = $mapping['properties'];
|
||||
$subcollection = $accessor->getValue($object, $key);
|
||||
$subcollection = $property->getValue($object);
|
||||
$document->add($key, $this->transformNested($subcollection, $submapping, $document));
|
||||
} else if (isset($mapping['type']) && $mapping['type'] == 'attachment') {
|
||||
$attachment = $accessor->getValue($object, $key);
|
||||
$attachment = $property->getValue($object);
|
||||
if ($attachment instanceof \SplFileInfo) {
|
||||
$document->addFile($key, $attachment->getPathName());
|
||||
} else {
|
||||
$document->addFileContent($key, $attachment);
|
||||
}
|
||||
} else {
|
||||
$document->add($key, $this->normalizeValue($accessor->getValue($object, $key)));
|
||||
$document->add($key, $this->normalizeValue($property->getValue($object)));
|
||||
}
|
||||
}
|
||||
return $document;
|
||||
|
|
|
@ -12,24 +12,24 @@
|
|||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2",
|
||||
"symfony/framework-bundle": ">=2.2.0,<2.3-dev",
|
||||
"symfony/console": ">=2.2.0,<2.3-dev",
|
||||
"symfony/form": ">=2.2.0,<2.3-dev",
|
||||
"symfony/framework-bundle": ">=2.1.0,<2.3-dev",
|
||||
"symfony/console": ">=2.1.0,<2.3-dev",
|
||||
"symfony/form": ">=2.1.0,<2.3-dev",
|
||||
"ruflin/elastica": "0.19.8"
|
||||
},
|
||||
"require-dev":{
|
||||
"doctrine/orm":">=2.2,<2.5-dev",
|
||||
"doctrine/mongodb-odm":"dev-master",
|
||||
"propel/propel1":"1.6.*",
|
||||
"pagerfanta/pagerfanta":"1.x",
|
||||
"knplabs/knp-components":"1.2.x"
|
||||
"doctrine/orm": ">=2.2,<2.5-dev",
|
||||
"doctrine/mongodb-odm": "dev-master",
|
||||
"propel/propel1": "1.6.*",
|
||||
"pagerfanta/pagerfanta": "1.*",
|
||||
"knplabs/knp-components": "1.2.*"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/orm": ">=2.2,<2.5-dev",
|
||||
"doctrine/mongodb-odm": ">=3.0.0-beta2,<3.1-dev",
|
||||
"propel/propel1": "1.6.*",
|
||||
"pagerfanta/pagerfanta":"1.x",
|
||||
"knplabs/knp-components":"1.2.x"
|
||||
"pagerfanta/pagerfanta": "1.*",
|
||||
"knplabs/knp-components": "1.2.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "FOQ\\ElasticaBundle": "" }
|
||||
|
|
Loading…
Reference in a new issue