Passed
Pull Request — master (#195)
by
unknown
08:41
created

clearExternalMetadataByFeUserUid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
namespace EWW\Dpf\Domain\Repository;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * The repository for to be imported external metadata
19
 */
20
class ExternalMetadataRepository extends \EWW\Dpf\Domain\Repository\AbstractRepository
21
{
22
    /**
23
     * Find external metadata by a frontend user uid and a publication identifier.
24
     *
25
     * @param int $feUser
26
     * @param string $identifier
27
     * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
28
     */
29
    public function findOneByUserAndPublicationIdentifier($feUser, $identifier)
30
    {
31
        $query = $this->createQuery();
32
33
        $constraints = array();
34
        $constraints[] = $query->equals('publication_identifier', $identifier);
35
        $constraints[] = $query->equals('fe_user', $feUser);
36
37
        $query->matching($query->logicalAnd($constraints));
38
        return $query->execute()->getFirst();
39
    }
40
41
    /**
42
     * Deletes all stored external metadata of the given feUser.
43
     *
44
     * @param $feUserUid
45
     * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
46
     */
47
    public function clearExternalMetadataByFeUserUid($feUserUid)
48
    {
49
        $metadata = $this->findByFeUser($feUserUid);
0 ignored issues
show
Bug introduced by
The method findByFeUser() does not exist on EWW\Dpf\Domain\Repositor...ernalMetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        /** @scrutinizer ignore-call */ 
50
        $metadata = $this->findByFeUser($feUserUid);
Loading history...
50
51
        foreach ($metadata as $metadataItem) {
52
            $this->remove($metadataItem);
53
        }
54
    }
55
56
}
57