Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Umoe\ContractsBundle\Manager;
  4.  
  5. use Umoe\ContractsBundle\Model as Model;
  6.  
  7. abstract class BaseManagerMongo
  8. {
  9. /*
  10. * Remember these.
  11. * We might even do this simple and just use one name, for the Manager, Model
  12. * and MongoDB collection.
  13. * Right now they are all the same but I define different names here.
  14. * Or rather, they have to be defined in the object extending this one.
  15. */
  16. // protected static $collection = 'Base';
  17. // protected static $model = 'Model\Base';
  18.  
  19. protected $simple_mongo;
  20.  
  21. public function __construct($simple_mongo)
  22. {
  23. $this->simple_mongo = $simple_mongo;
  24. }
  25.  
  26. /*
  27. * Finders
  28. */
  29. public function findAll()
  30. {
  31.  
  32. $objects = array();
  33. foreach ($this->simple_mongo->findAll(static::$collection) as $o)
  34. {
  35. // $object = new Model\Contract($data);
  36. $object = new static::$model($o);
  37. $object->setId($o['_id']);
  38. $objects[] = $object;
  39. }
  40.  
  41. return $objects;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement