Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed $cmd args/properties (Mongo command character) #703

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ class DocumentManager implements ObjectManager
*/
private $closed = false;

/**
* Mongo command character
*
* @var string
*/
private $cmd;

/**
* Collection of query filters.
*
Expand All @@ -145,7 +138,6 @@ class DocumentManager implements ObjectManager
protected function __construct(Connection $conn = null, Configuration $config = null, EventManager $eventManager = null) {
$this->config = $config ?: new Configuration();
$this->eventManager = $eventManager ?: new EventManager();
$this->cmd = $this->config->getMongoCmd();
$this->connection = $conn ?: new Connection(null, array(), $this->config, $this->eventManager);

$metadataFactoryClassName = $this->config->getClassMetadataFactoryName();
Expand All @@ -163,11 +155,10 @@ protected function __construct(Connection $conn = null, Configuration $config =
$this->eventManager,
$hydratorDir,
$hydratorNs,
$this->config->getAutoGenerateHydratorClasses(),
$this->config->getMongoCmd()
$this->config->getAutoGenerateHydratorClasses()
);

$this->unitOfWork = new UnitOfWork($this, $this->eventManager, $this->hydratorFactory, $this->cmd);
$this->unitOfWork = new UnitOfWork($this, $this->eventManager, $this->hydratorFactory);
$this->hydratorFactory->setUnitOfWork($this->unitOfWork);
$this->schemaManager = new SchemaManager($this, $this->metadataFactory);
$this->proxyFactory = new ProxyFactory($this,
Expand Down Expand Up @@ -369,7 +360,7 @@ public function getDocumentCollections()
*/
public function createQueryBuilder($documentName = null)
{
return new Query\Builder($this, $this->cmd, $documentName);
return new Query\Builder($this, $documentName);
}

/**
Expand Down Expand Up @@ -710,9 +701,9 @@ public function createDBRef($document, array $referenceMapping = null)
}

$dbRef = array(
$this->cmd . 'ref' => $class->getCollection(),
$this->cmd . 'id' => $class->getDatabaseIdentifierValue($id),
$this->cmd . 'db' => $this->getDocumentDatabase($className)->getName()
'$ref' => $class->getCollection(),
'$id' => $class->getDatabaseIdentifierValue($id),
'$db' => $this->getDocumentDatabase($className)->getName()
);

if ($class->discriminatorField) {
Expand Down
11 changes: 1 addition & 10 deletions lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,15 @@ class HydratorFactory
*/
private $hydrators = array();

/**
* Mongo command prefix
*
* @var string
*/
private $cmd;

/**
* @param DocumentManager $dm
* @param EventManager $evm
* @param string $hydratorDir
* @param string $hydratorNs
* @param boolean $autoGenerate
* @param string $cmd
* @throws HydratorException
*/
public function __construct(DocumentManager $dm, EventManager $evm, $hydratorDir, $hydratorNs, $autoGenerate, $cmd)
public function __construct(DocumentManager $dm, EventManager $evm, $hydratorDir, $hydratorNs, $autoGenerate)
{
if ( ! $hydratorDir) {
throw HydratorException::hydratorDirectoryRequired();
Expand All @@ -116,7 +108,6 @@ public function __construct(DocumentManager $dm, EventManager $evm, $hydratorDir
$this->hydratorDir = $hydratorDir;
$this->hydratorNamespace = $hydratorNs;
$this->autoGenerate = $autoGenerate;
$this->cmd = $cmd;
}

/**
Expand Down
11 changes: 1 addition & 10 deletions lib/Doctrine/ODM/MongoDB/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ class PersistentCollection implements BaseCollection
*/
private $uow;

/**
* Mongo command prefix
*
* @var string
*/
private $cmd;

/**
* The raw mongo data that will be used to initialize this collection.
*
Expand All @@ -112,14 +105,12 @@ class PersistentCollection implements BaseCollection
* @param BaseCollection $coll
* @param DocumentManager $dm
* @param UnitOfWork $uow
* @param string $cmd
*/
public function __construct(BaseCollection $coll, DocumentManager $dm, UnitOfWork $uow, $cmd)
public function __construct(BaseCollection $coll, DocumentManager $dm, UnitOfWork $uow)
{
$this->coll = $coll;
$this->dm = $dm;
$this->uow = $uow;
$this->cmd = $cmd;
}

/**
Expand Down
25 changes: 8 additions & 17 deletions lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,18 @@ class CollectionPersister
*/
private $pb;

/**
* Mongo command prefix
*
* @var string
*/
private $cmd;

/**
* Constructs a new CollectionPersister instance.
*
* @param DocumentManager $dm
* @param PersistenceBuilder $pb
* @param UnitOfWork $uow
* @param string $cmd
*/
public function __construct(DocumentManager $dm, PersistenceBuilder $pb, UnitOfWork $uow, $cmd)
public function __construct(DocumentManager $dm, PersistenceBuilder $pb, UnitOfWork $uow)
{
$this->dm = $dm;
$this->pb = $pb;
$this->uow = $uow;
$this->cmd = $cmd;
}

/**
Expand All @@ -92,7 +83,7 @@ public function delete(PersistentCollection $coll, array $options)
return; // ignore inverse side
}
list($propertyPath, $parent) = $this->getPathAndParent($coll);
$query = array($this->cmd . 'unset' => array($propertyPath => true));
$query = array('$unset' => array($propertyPath => true));
$this->executeQuery($parent, $query, $options);
}

Expand Down Expand Up @@ -156,7 +147,7 @@ private function setCollection(PersistentCollection $coll, array $options)
$setData = array_values($setData);
}

$query = array($this->cmd.'set' => array($propertyPath => $setData));
$query = array('$set' => array($propertyPath => $setData));

$this->executeQuery($parent, $query, $options);
}
Expand All @@ -180,10 +171,10 @@ private function deleteElements(PersistentCollection $coll, array $options)

list($propertyPath, $parent) = $this->getPathAndParent($coll);

$query = array($this->cmd . 'unset' => array());
$query = array('$unset' => array());

foreach ($deleteDiff as $key => $document) {
$query[$this->cmd . 'unset'][$propertyPath . '.' . $key] = true;
$query['$unset'][$propertyPath . '.' . $key] = true;
}

$this->executeQuery($parent, $query, $options);
Expand All @@ -194,7 +185,7 @@ private function deleteElements(PersistentCollection $coll, array $options)
* in the element being left in the array as null so we have to pull
* null values.
*/
$this->executeQuery($parent, array($this->cmd . 'pull' => array($propertyPath => null)), $options);
$this->executeQuery($parent, array('$pull' => array($propertyPath => null)), $options);
}

/**
Expand Down Expand Up @@ -226,10 +217,10 @@ private function insertElements(PersistentCollection $coll, array $options)
$value = array_values(array_map($callback, $insertDiff));

if ($mapping['strategy'] !== 'pushAll') {
$value = array($this->cmd . 'each' => $value);
$value = array('$each' => $value);
}

$query = array($this->cmd . $mapping['strategy'] => array($propertyPath => $value));
$query = array('$' . $mapping['strategy'] => array($propertyPath => $value));

$this->executeQuery($parent, $query, $options);
}
Expand Down
Loading