1 | <?php |
||
26 | class SraaRepository extends EntityRepository |
||
27 | { |
||
28 | /** |
||
29 | * Removes all SRAA's from the database |
||
30 | */ |
||
31 | public function removeAll() |
||
32 | { |
||
33 | $this |
||
34 | ->getEntityManager() |
||
35 | ->createQuery( |
||
36 | 'DELETE FROM Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa' |
||
37 | ) |
||
38 | ->execute(); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Saves all SRAAs to the database, using inserts only |
||
43 | * |
||
44 | * @param array $sraaList |
||
45 | */ |
||
46 | public function saveAll(array $sraaList) |
||
47 | { |
||
48 | $invalid = []; |
||
49 | foreach ($sraaList as $index => $sraa) { |
||
50 | if (!$sraa instanceof Sraa) { |
||
51 | $invalid[$index] = $sraa; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | if (count($invalid)) { |
||
56 | $invalidIndications = []; |
||
57 | foreach ($invalid as $index => $value) { |
||
58 | $invalidIndications[] = sprintf( |
||
59 | '"%s" at index "%d"', |
||
60 | is_object($value) ? get_class($value) : gettype($value) |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | throw new InvalidArgumentException( |
||
65 | sprintf( |
||
66 | 'Expected array of Raa Objects, got %s', |
||
67 | implode(', ', $invalidIndications) |
||
68 | ) |
||
69 | ); |
||
70 | } |
||
71 | |||
72 | $entityManager = $this->getEntityManager(); |
||
73 | |||
74 | foreach ($sraaList as $sraa) { |
||
75 | $entityManager->persist($sraa); |
||
76 | } |
||
77 | |||
78 | $entityManager->flush(); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param NameId $nameId |
||
83 | * @return null|\Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa |
||
|
|||
84 | */ |
||
85 | public function findByNameId(NameId $nameId) |
||
89 | |||
90 | /** |
||
91 | * @param NameId $nameId |
||
92 | * @return boolean |
||
93 | */ |
||
94 | public function contains(NameId $nameId) |
||
98 | } |
||
99 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.