| 1 | <?php |
||
| 8 | trait CommonTrait |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param string $objectName |
||
| 12 | * @param string $field |
||
| 13 | * @param \DateTime $olderThan |
||
| 14 | * |
||
| 15 | * @return int |
||
| 16 | */ |
||
| 17 | protected function removeOlderThan($objectName, $field, \DateTime $olderThan) |
||
| 18 | { |
||
| 19 | /** @var DocumentManager $objectManager */ |
||
| 20 | $objectManager = $this->getObjectManager(); |
||
| 21 | $qb = $objectManager->createQueryBuilder($objectName); |
||
| 22 | $qb |
||
| 23 | ->remove() |
||
| 24 | ->field($field)->lt($olderThan); |
||
| 25 | |||
| 26 | $query = $qb->getQuery(); |
||
| 27 | $result = $query->execute(); |
||
| 28 | if (isset($result['n'])) { |
||
| 29 | return $result['n']; |
||
| 30 | } |
||
| 31 | |||
| 32 | return 0; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return ObjectManager |
||
| 37 | */ |
||
| 38 | abstract public function getObjectManager(); |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $objectName |
||
| 42 | */ |
||
| 43 | 1 | public function stopIdGenerator($objectName) |
|
| 47 | |||
| 48 | 1 | public function restoreIdGenerator($objectName) |
|
| 52 | } |
||
| 53 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.