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