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