/** * @param string $field * @return string */ private function getField($field) { if ($this->fields === null) { $dm = $this->repository->getDocumentManager(); /** @todo Investigate if produces performance problems */ $entityMeta = $dm->getClassMetadata($this->repository->getDocumentName()); foreach ($entityMeta->fieldMappings as $fieldName => $fieldMapping) { $this->fields[$fieldMapping['name']] = $fieldName; } } return isset($this->fields[$field]) ? $this->fields[$field] : $field; }
/** * {@inheritDoc} * * @param string $documentId id of entity to delete * * @return null|Object */ public function deleteRecord($documentId) { $manager = $this->repository->getDocumentManager(); $entity = $this->find($documentId); $return = $entity; if ($entity) { $this->checkIfOriginRecord($entity); $manager->remove($entity); $manager->flush(); $return = null; } return $return; }
/** * Populate the DocumentRepository $repo with $count documents. * * @see \Population\Populator::populate * * @access public * @param DocumentRepository $repo * @param int $count * @param callable $callback Function which populates the data for each instance. It is passed a single argument, * the document to be populated. If $callback returns false, the document will not be persisted. * @param array $options (default: array()) * perFlush: Limit the number of insertions performed in a single flush (default: 100) * clearAfterFlush: Clear the DocumentManager after each flush (default:true) * factory: Optionally, specify a factory callback for populated objects * constructorArgs: An array of args, passed directly to the document's constructor (default: null) * @return void */ public function populateDocument(DocumentRepository $repo, $count, $callback, array $options = array()) { $dm = $repo->getDocumentManager(); if (isset($options['factory'])) { $factory = $options['factory']; } else { $reflClass = $repo->getClassMetadata()->reflClass; $factory = array($reflClass, 'newInstanceArgs'); } $this->populateObject($dm, $factory, $count, $callback, $options); }
/** * @return \Doctrine\ODM\MongoDB\DocumentManager */ protected function dm() { return $this->repository->getDocumentManager(); }
public function em() { return parent::getDocumentManager(); }