/** * Constructor * * @param object $model Model instance * @param EntityManagerInterface $em * @param Mangan $mangan */ public function __construct($model, $em = null, $mangan = null) { $this->model = $model; $this->sm = new ScopeManager($model); if (null === $mangan) { $mangan = Mangan::fromModel($model); } $this->em = $em ?: EntityManager::create($model, $mangan); $this->mn = $mangan; $this->withCursor($this->mn->useCursor); }
/** * Get entity manager instance * @return EntityManagerInterface|EntityManager */ private function _getEm() { if (null === $this->_em) { $this->_em = EntityManager::create($this); } return $this->_em; }
public function testIfWillDeleteSimpleDocumentFromRealSignal() { $model = new SimpleModel(); $model->_id = new MongoId(); $model->title = 'Connecticut is a state'; // Signal save index EntityManager::create($model)->save(); $mnl = Manganel::fly(); $client = $mnl->getClient(); $get = ['index' => $mnl->index, 'type' => CollectionNamer::nameCollection($model), 'id' => (string) $model->_id]; $found = $client->get($get)['_source']; $this->assertSame($model->title, $found['title']); // Signal delete index EntityManager::create($model)->delete(); try { $client->get($get); $this->assertFalse(true, 'That missing exception was not thrown'); } catch (Missing404Exception $e) { $this->assertTrue(true, 'That missing exception was thrown'); } }