1 | <?php |
||
33 | abstract class MongoDb extends Dao |
||
34 | { |
||
35 | /** |
||
36 | * @var \MongoDB\Driver\Manager The driver manager |
||
37 | */ |
||
38 | protected $manager; |
||
39 | /** |
||
40 | * |
||
41 | * @var string The collection name |
||
42 | */ |
||
43 | protected $collection; |
||
44 | |||
45 | /** |
||
46 | * Creates a new MongoDB DAO. |
||
47 | * |
||
48 | * @param \MongoDB\Driver\Manager $manager The MongoDB driver manager |
||
49 | * @param string $collection The collection name (e.g. `database.collection`) |
||
50 | * @param \Psr\Log\LoggerInterface $logger A logger |
||
51 | */ |
||
52 | 2 | public function __construct(Manager $manager, string $collection, \Psr\Log\LoggerInterface $logger = null) |
|
58 | |||
59 | /** |
||
60 | * Executes something in the context of the collection. |
||
61 | * |
||
62 | * Exceptions are caught and translated. |
||
63 | * |
||
64 | * @param callable $cb The closure to execute, takes the entityManager and collection |
||
65 | * @return mixed Whatever the function returns, this method also returns |
||
66 | * @throws \Caridea\Dao\Exception If a database problem occurs |
||
67 | * @see \Caridea\Dao\Exception\Translator\MongoDb |
||
68 | */ |
||
69 | 2 | protected function doExecute(\Closure $cb) |
|
77 | } |
||
78 |