예제 #1
0
 /**
  * Create a new MongoDB Query.
  *
  * @param DocumentManager $dm
  * @param string $className
  */
 public function __construct(DocumentManager $dm, $className = null)
 {
     $this->_dm = $dm;
     $this->_hydrator = $dm->getHydrator();
     if ($className !== null) {
         $this->_className = $className;
         $this->_class = $this->_dm->getClassMetadata($className);
     }
 }
 /**
  * Loads a list of documents by a list of field criteria.
  *
  * @param array $criteria
  * @return array
  */
 public function loadAll(array $query = array(), array $select = array())
 {
     $cursor = $this->collection->find($query, $select);
     return new MongoCursor($this->dm, $this->dm->getHydrator(), $this->class, $cursor);
 }
 /**
  * Refreshes a managed document.
  * 
  * @param array $id The identifier of the document.
  * @param object $document The document to refresh.
  */
 public function refresh($id, $document)
 {
     $data = $this->collection->findOne(array('_id' => $id));
     $this->dm->getHydrator()->hydrate($document, $data);
     $this->uow->setOriginalDocumentData($document, $data);
 }
 /**
  * Initializes a new UnitOfWork instance, bound to the given DocumentManager.
  *
  * @param Doctrine\ODM\MongoDB\DocumentManager $dm
  */
 public function __construct(DocumentManager $dm)
 {
     $this->_dm = $dm;
     $this->_evm = $dm->getEventManager();
     $this->_hydrator = $dm->getHydrator();
 }
예제 #5
0
 /**
  * Create a new MongoDB Query.
  *
  * @param DocumentManager $dm
  * @param string $className
  */
 public function __construct(DocumentManager $dm, $className = null)
 {
     $this->dm = $dm;
     $this->hydrator = $dm->getHydrator();
     $this->cmd = $dm->getConfiguration()->getMongoCmd();
     if ($className !== null) {
         $this->find($className);
     }
 }