mmucklo /
DtcQueueBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Dtc\QueueBundle\ODM; |
||
| 4 | |||
| 5 | use Doctrine\ODM\MongoDB\DocumentManager; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Dtc\QueueBundle\Document\Job; |
||
| 7 | use Dtc\QueueBundle\Document\JobTiming; |
||
| 8 | use Dtc\QueueBundle\Document\Run; |
||
| 9 | use MongoDB\DeleteResult; |
||
|
0 ignored issues
–
show
The type
MongoDB\DeleteResult was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | |||
| 11 | trait CommonTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param string $objectName |
||
| 15 | * @param string $field |
||
| 16 | * |
||
| 17 | * @return int |
||
| 18 | */ |
||
| 19 | 2 | protected function removeOlderThan($objectName, $field, \DateTime $olderThan) |
|
| 20 | { |
||
| 21 | /** @var DocumentManager $objectManager */ |
||
| 22 | 2 | $objectManager = $this->getObjectManager(); |
|
| 23 | 2 | $qb = $objectManager->createQueryBuilder($objectName); |
|
| 24 | $qb |
||
| 25 | 2 | ->remove() |
|
| 26 | 2 | ->field($field)->lt($olderThan); |
|
| 27 | |||
| 28 | 2 | $query = $qb->getQuery(); |
|
| 29 | 2 | $result = $query->execute(); |
|
| 30 | 2 | if ($result instanceof DeleteResult) { |
|
| 31 | 2 | return $result->getDeletedCount(); |
|
| 32 | } elseif (isset($result['n'])) { |
||
| 33 | return $result['n']; |
||
| 34 | } |
||
| 35 | |||
| 36 | return 0; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param Run|Job|JobTiming $object |
||
| 41 | * @param string $action |
||
| 42 | */ |
||
| 43 | 22 | protected function persist($object, $action = 'persist') |
|
| 44 | { |
||
| 45 | 22 | $objectManager = $this->getObjectManager(); |
|
| 46 | 22 | $objectManager->$action($object); |
|
| 47 | 22 | $objectManager->flush(); |
|
| 48 | 22 | } |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return ObjectManager |
||
|
0 ignored issues
–
show
The type
Dtc\QueueBundle\ODM\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 52 | */ |
||
| 53 | abstract public function getObjectManager(); |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $objectName |
||
| 57 | */ |
||
| 58 | 1 | public function stopIdGenerator($objectName) |
|
| 59 | { |
||
| 60 | // Not needed for ODM |
||
| 61 | 1 | } |
|
| 62 | |||
| 63 | 1 | public function restoreIdGenerator($objectName) |
|
| 64 | { |
||
| 65 | // Not needed for ODM |
||
| 66 | 1 | } |
|
| 67 | } |
||
| 68 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths