@@ 264-287 (lines=24) @@ | ||
261 | * @param $name |
|
262 | * @return bool |
|
263 | */ |
|
264 | public function addWatchedFunction($name) |
|
265 | { |
|
266 | ||
267 | $name = trim($name); |
|
268 | if (empty($name)) { |
|
269 | return false; |
|
270 | } |
|
271 | ||
272 | try { |
|
273 | $id = new \MongoId(); |
|
274 | ||
275 | $data = [ |
|
276 | '_id' => $id, |
|
277 | 'name' => $name |
|
278 | ]; |
|
279 | $this->getConnection()->watches->insert($data); |
|
280 | ||
281 | return true; |
|
282 | } catch (\Exception $e) { |
|
283 | // if something goes wrong just ignore for now |
|
284 | // @todo add exception |
|
285 | } |
|
286 | return false; |
|
287 | } |
|
288 | ||
289 | /** |
|
290 | * @inheritDoc |
|
@@ 295-315 (lines=21) @@ | ||
292 | * @param $name |
|
293 | * @return bool |
|
294 | */ |
|
295 | public function updateWatchedFunction($id, $name) |
|
296 | { |
|
297 | $name = trim($name); |
|
298 | if (empty($name)) { |
|
299 | return false; |
|
300 | } |
|
301 | ||
302 | try { |
|
303 | $id = new \MongoId($id); |
|
304 | $data = [ |
|
305 | '_id' => $id, |
|
306 | 'name' => $name |
|
307 | ]; |
|
308 | $this->getConnection()->watches->save($data); |
|
309 | ||
310 | return true; |
|
311 | } catch (\Exception $e) { |
|
312 | } |
|
313 | ||
314 | return false; |
|
315 | } |
|
316 | ||
317 | /** |
|
318 | * @inheritDoc |