Code Duplication    Length = 17-17 lines in 2 locations

src/system/RoutesModule/Entity/Repository/Base/AbstractRouteRepository.php 2 locations

@@ 208-224 (lines=17) @@
205
     *
206
     * @throws InvalidArgumentException Thrown if invalid parameters are received
207
     */
208
    public function deleteByCreator($userId, TranslatorInterface $translator, LoggerInterface $logger, CurrentUserApiInterface $currentUserApi)
209
    {
210
        // check id parameter
211
        if ($userId == 0 || !is_numeric($userId)) {
212
            throw new InvalidArgumentException($translator->__('Invalid user identifier received.'));
213
        }
214
    
215
        $qb = $this->getEntityManager()->createQueryBuilder();
216
        $qb->delete($this->mainEntityClass, 'tbl')
217
           ->where('tbl.createdBy = :creator')
218
           ->setParameter('creator', $userId);
219
        $query = $qb->getQuery();
220
        $query->execute();
221
    
222
        $logArgs = ['app' => 'ZikulaRoutesModule', 'user' => $currentUserApi->get('uname'), 'entities' => 'routes', 'userid' => $userId];
223
        $logger->debug('{app}: User {user} deleted {entities} created by user id {userid}.', $logArgs);
224
    }
225
    
226
    /**
227
     * Deletes all objects updated by a certain user.
@@ 238-254 (lines=17) @@
235
     *
236
     * @throws InvalidArgumentException Thrown if invalid parameters are received
237
     */
238
    public function deleteByLastEditor($userId, TranslatorInterface $translator, LoggerInterface $logger, CurrentUserApiInterface $currentUserApi)
239
    {
240
        // check id parameter
241
        if ($userId == 0 || !is_numeric($userId)) {
242
            throw new InvalidArgumentException($translator->__('Invalid user identifier received.'));
243
        }
244
    
245
        $qb = $this->getEntityManager()->createQueryBuilder();
246
        $qb->delete($this->mainEntityClass, 'tbl')
247
           ->where('tbl.updatedBy = :editor')
248
           ->setParameter('editor', $userId);
249
        $query = $qb->getQuery();
250
        $query->execute();
251
    
252
        $logArgs = ['app' => 'ZikulaRoutesModule', 'user' => $currentUserApi->get('uname'), 'entities' => 'routes', 'userid' => $userId];
253
        $logger->debug('{app}: User {user} deleted {entities} edited by user id {userid}.', $logArgs);
254
    }
255
256
    /**
257
     * Adds an array of id filters to given query instance.