Skip to content

Commit 126a878

Browse files
phansysfranmomu
authored andcommitted
Replace calls to execute()
1 parent 28f53fe commit 126a878

File tree

16 files changed

+30
-44
lines changed

16 files changed

+30
-44
lines changed

src/Loggable/Document/Repository/LogEntryRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Gedmo\Loggable\Document\Repository;
1111

12-
use Doctrine\ODM\MongoDB\Iterator\Iterator;
1312
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
1413
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
1514
use Gedmo\Exception\RuntimeException;

src/Sluggable/Mapping/Event/Adapter/ODM.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Gedmo\Sluggable\Mapping\Event\Adapter;
1111

12-
use Doctrine\ODM\MongoDB\Iterator\Iterator;
1312
use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
1413
use Gedmo\Sluggable\Mapping\Event\SluggableAdapter;
1514
use Gedmo\Tool\Wrapper\AbstractWrapper;

src/Sluggable/Mapping/Event/Adapter/ORM.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Gedmo\Sluggable\Mapping\Event\Adapter;
1111

1212
use Doctrine\ORM\Mapping\ClassMetadataInfo;
13-
use Doctrine\ORM\Query;
1413
use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
1514
use Gedmo\Sluggable\Mapping\Event\SluggableAdapter;
1615
use Gedmo\Tool\Wrapper\AbstractWrapper;
@@ -76,10 +75,8 @@ public function getSimilarSlugs($object, $meta, array $config, $slug)
7675
$qb->setParameter($namedId, $value, $meta->getTypeOfField($namedId));
7776
}
7877
}
79-
$q = $qb->getQuery();
80-
$q->setHydrationMode(Query::HYDRATE_ARRAY);
8178

82-
return $q->execute();
79+
return $qb->getQuery()->getArrayResult();
8380
}
8481

8582
public function replaceRelative($object, array $config, $target, $replacement)

src/Translatable/Document/Repository/TranslationRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Gedmo\Translatable\Document\Repository;
1111

1212
use Doctrine\ODM\MongoDB\DocumentManager;
13-
use Doctrine\ODM\MongoDB\Iterator\Iterator;
1413
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
1514
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
1615
use Doctrine\ODM\MongoDB\Types\Type;

src/Translatable/Entity/Repository/TranslationRepository.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ public function findTranslations($entity)
141141
$qb->select('trans.content, trans.field, trans.locale')
142142
->from($translationClass, 'trans')
143143
->where('trans.foreignKey = :entityId', 'trans.objectClass = :entityClass')
144-
->orderBy('trans.locale');
144+
->orderBy('trans.locale')
145+
->setParameters([
146+
'entityId' => $entityId,
147+
'entityClass' => $entityClass,
148+
]);
145149
$q = $qb->getQuery();
146-
$data = $q->execute(
147-
compact('entityId', 'entityClass'),
148-
Query::HYDRATE_ARRAY
149-
);
150150

151-
foreach ($data as $row) {
151+
foreach ($q->getArrayResult() as $row) {
152152
$result[$row['locale']][$row['field']] = $row['content'];
153153
}
154154
}
@@ -210,14 +210,11 @@ public function findTranslationsByObjectId($id)
210210
$qb->select('trans.content, trans.field, trans.locale')
211211
->from($translationMeta->rootEntityName, 'trans')
212212
->where('trans.foreignKey = :entityId')
213-
->orderBy('trans.locale');
213+
->orderBy('trans.locale')
214+
->setParameter('entityId', $id);
214215
$q = $qb->getQuery();
215-
$data = $q->execute(
216-
['entityId' => $id],
217-
Query::HYDRATE_ARRAY
218-
);
219216

220-
foreach ($data as $row) {
217+
foreach ($q->getArrayResult() as $row) {
221218
$result[$row['locale']][$row['field']] = $row['content'];
222219
}
223220
}

src/Translatable/Mapping/Event/Adapter/ODM.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Gedmo\Translatable\Mapping\Event\Adapter;
1111

12-
use Doctrine\ODM\MongoDB\Iterator\Iterator;
1312
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
1413
use Doctrine\ODM\MongoDB\Types\Type;
1514
use Gedmo\Exception\RuntimeException;

src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getTreeQuery($rootNode = null)
5858
*/
5959
public function getTree($rootNode = null): Iterator
6060
{
61-
return $this->getTreeQuery($rootNode)->execute();
61+
return $this->getTreeQuery($rootNode)->getIterator();
6262
}
6363

6464
public function getRootNodesQueryBuilder($sortByField = null, $direction = 'asc')
@@ -152,7 +152,7 @@ public function getChildrenQuery($node = null, $direct = false, $sortByField = n
152152

153153
public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false)
154154
{
155-
return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->execute();
155+
return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->getIterator();
156156
}
157157

158158
public function getNodesHierarchyQueryBuilder($node = null, $direct = false, array $options = [], $includeNode = false)

src/Tree/Entity/Repository/MaterializedPathRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getTreeQuery($rootNode = null)
5757
*/
5858
public function getTree($rootNode = null)
5959
{
60-
return $this->getTreeQuery($rootNode)->execute();
60+
return $this->getTreeQuery($rootNode)->getResult();
6161
}
6262

6363
public function getRootNodesQueryBuilder($sortByField = null, $direction = 'asc')
@@ -72,7 +72,7 @@ public function getRootNodesQuery($sortByField = null, $direction = 'asc')
7272

7373
public function getRootNodes($sortByField = null, $direction = 'asc')
7474
{
75-
return $this->getRootNodesQuery($sortByField, $direction)->execute();
75+
return $this->getRootNodesQuery($sortByField, $direction)->getResult();
7676
}
7777

7878
/**
@@ -219,7 +219,7 @@ public function getChildrenQuery($node = null, $direct = false, $sortByField = n
219219

220220
public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'asc', $includeNode = false)
221221
{
222-
return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->execute();
222+
return $this->getChildrenQuery($node, $direct, $sortByField, $direction, $includeNode)->getResult();
223223
}
224224

225225
public function getNodesHierarchyQueryBuilder($node = null, $direct = false, array $options = [], $includeNode = false)

src/Tree/RepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getNodesHierarchy($node = null, $direct = false, array $options
5050
* @param string|string[] $direction Sort order ('asc'|'desc'|'ASC'|'DESC'). If $sortByField is an array, this may also be an array with matching number of elements
5151
* @param bool $includeNode Include the root node in results?
5252
*
53-
* @return array<int|string, object> List of children
53+
* @return iterable|null List of children
5454
*
5555
* @phpstan-param 'asc'|'desc'|'ASC'|'DESC'|array<int, 'asc'|'desc'|'ASC'|'DESC'> $direction
5656
*/

src/Tree/Strategy/ODM/MongoDB/MaterializedPath.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function removeNode($om, $meta, $config, $node)
3838
->find($meta->getName())
3939
->field($config['path'])->equals(new Regex('^'.preg_quote($wrapped->getPropertyValue($config['path'])).'.?+'))
4040
->getQuery()
41-
->execute();
41+
->getIterator();
4242

4343
foreach ($results as $node) {
4444
$uow->scheduleForDelete($node);
@@ -55,7 +55,7 @@ public function getChildren($om, $meta, $config, $originalPath)
5555
->field($config['path'])->equals(new Regex('^'.preg_quote($originalPath).'.+'))
5656
->sort($config['path'], 'asc') // This may save some calls to updateNode
5757
->getQuery()
58-
->execute();
58+
->getIterator();
5959
}
6060

6161
/**

0 commit comments

Comments
 (0)