1 | <?php |
||
13 | class TranslationRepository extends AbstractTranslatorRepository |
||
14 | { |
||
15 | /** |
||
16 | * Get an array of all domains group by locales |
||
17 | * |
||
18 | * @return array array[0] = ["name" => "messages", "locale" => "nl"] |
||
19 | */ |
||
20 | 3 | public function getAllDomainsByLocale() |
|
29 | |||
30 | /** |
||
31 | * Get an array of all non disabled translations |
||
32 | * |
||
33 | * @param string $locale |
||
34 | * @param string $domain |
||
|
|||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | 1 | public function findAllNotDisabled($locale, $domain = null) |
|
54 | |||
55 | /** |
||
56 | * @return DateTime|null |
||
57 | */ |
||
58 | 1 | public function getLastChangedTranslationDate() |
|
59 | { |
||
60 | 1 | $em = $this->getEntityManager(); |
|
61 | |||
62 | 1 | $flagNew = \Kunstmaan\TranslatorBundle\Entity\Translation::FLAG_NEW; |
|
63 | 1 | $flagUpdated = \Kunstmaan\TranslatorBundle\Entity\Translation::FLAG_UPDATED; |
|
64 | |||
65 | $sql = <<<EOQ |
||
66 | 1 | SELECT |
|
67 | MAX(compare) as newestDate, |
||
68 | flag |
||
69 | FROM ( |
||
70 | SELECT created_at as compare, flag FROM %s |
||
71 | UNION ALL |
||
72 | SELECT updated_at as compare, flag FROM %s) CACHE_CHECK |
||
73 | WHERE |
||
74 | 1 | flag IN ('{$flagUpdated}','{$flagNew}') |
|
75 | GROUP BY flag |
||
76 | HAVING MAX(compare) IS NOT NULL |
||
77 | ORDER BY newestDate DESC |
||
78 | EOQ; |
||
79 | 1 | $table = $em->getClassMetadata('KunstmaanTranslatorBundle:Translation')->getTableName(); |
|
80 | |||
81 | 1 | $stmt = $em->getConnection()->prepare(sprintf($sql, $table, $table)); |
|
82 | 1 | $stmt->execute(); |
|
83 | 1 | $result = $stmt->fetch(); |
|
84 | |||
85 | 1 | if (\is_array($result) && \count($result) > 0) { |
|
86 | 1 | return new \DateTime($result['newestDate']); |
|
87 | } |
||
88 | |||
89 | return null; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @return mixed |
||
94 | */ |
||
95 | public function resetAllFlags() |
||
103 | |||
104 | /** |
||
105 | * @param $locales |
||
106 | * @param $domains |
||
107 | * |
||
108 | * @return mixed |
||
109 | */ |
||
110 | 1 | public function getTranslationsByLocalesAndDomains($locales, $domains) |
|
134 | |||
135 | /** |
||
136 | * @param null $entity |
||
137 | * |
||
138 | * @return mixed |
||
139 | */ |
||
140 | 3 | public function flush($entity = null) |
|
148 | |||
149 | /** |
||
150 | * @param $entity |
||
151 | * |
||
152 | * @return mixed |
||
153 | */ |
||
154 | 3 | public function persist($entity) |
|
158 | |||
159 | /** |
||
160 | * @param TranslationModel $translationModel |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | public function isUnique(TranslationModel $translationModel) |
||
177 | |||
178 | /** |
||
179 | * @param TranslationModel $translationModel |
||
180 | */ |
||
181 | public function createTranslations(TranslationModel $translationModel) |
||
211 | |||
212 | /** |
||
213 | * @param TranslationModel $translationModel |
||
214 | * @param $translationId |
||
215 | */ |
||
216 | public function updateTranslations(TranslationModel $translationModel, $translationId) |
||
251 | |||
252 | /** |
||
253 | * Removes all translations with the given translation id |
||
254 | * |
||
255 | * @param string $translationId |
||
256 | * |
||
257 | * @return mixed |
||
258 | */ |
||
259 | public function removeTranslations($translationId) |
||
268 | |||
269 | /** |
||
270 | * @return int |
||
271 | */ |
||
272 | 3 | public function getUniqueTranslationId() |
|
284 | |||
285 | /** |
||
286 | * @param DateTime $date |
||
287 | * @param string $domain |
||
288 | * |
||
289 | * @return mixed |
||
290 | */ |
||
291 | 1 | public function findDeprecatedTranslationsBeforeDate(DateTime $date, $domain) |
|
306 | } |
||
307 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.