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