I can't seem to get the following request. Basically, I'm trying to add a message document to a conversation document, as shown below:
public function reply($conversationId, Message $message, $flush = true)
{
$this->dm->createQueryBuilder($this->class)
->field('archivers')->unsetField()
->field('repliedBy')->set($message->getUserId())
->field('repliedBody')->set($message->getBody())
->field('repliedAt')->set(new \DateTime())
->field('modifiedAt')->set(new \DateTime())
->field('messages')->push($message)
->field('id')->equals(new \MongoId($conversationId))
->getQuery()
->execute();
if ($flush) {
$this->dm->flush();
}
}
This response method is called in two ways. First, the user sends a message through the html form, and secondly, by a REST call made by the Android application. The form works, but the REST call fails (the JMSSerializerBundle with BOS-BOS-BODE is used otherwise) ...
I checked that the code is being called and the parameters passed to the method are valid in both cases, but for some reason, calling commit () inside UnitOfWork.php ignores changes to the document. See line 413 to see what I mean.
Does anyone have an idea why this could happen?
, :
-, update(), "Catchable Fatal Error: Object of class... /vendor/bundles/Symfony/Bundle/DoctrineMongoDBBundle/Logger/DoctrineMongoDBLogger.php 280".
public function reply($conversationId, Message $message, $flush = true)
{
$this->dm->createQueryBuilder($this->class)
->update()
->field('archivers')->unsetField()
->field('repliedBy')->set($message->getUserId())
->field('repliedBody')->set($message->getBody())
->field('repliedAt')->set(new \DateTime())
->field('modifiedAt')->set(new \DateTime())
->field('messages')->push($message)
->field('id')->equals(new \MongoId($conversationId))
->getQuery()
->execute();
if ($flush) {
$this->dm->flush();
}
}
, , - :
public function reply($conversationId, Message $message)
{
$this->dm->createQueryBuilder($this->class)
->update()
->field('archivers')->unsetField()
->field('repliedBy')->set($message->getUserId())
->field('repliedBody')->set($message->getBody())
->field('repliedAt')->set(new \DateTime())
->field('modifiedAt')->set(new \DateTime())
->field('messages')->push(array(
'_id' => new \MongoId(),
'userId' => $message->getuserId(),
'body' => $message->getBody(),
'createdAt' => new \DateTime(),
'modifiedAt' => new \DateTime(),
))
->field('id')->equals(new \MongoId($conversationId))
->getQuery()
->execute();
$this->dm->flush();
}
, flush(). () . , ( flush() , flush() ).
push-, :
public function archive($conversationId, $userId)
{
$userStamp = new UserStamp();
$userStamp->setUserId($userId);
$this->dm->createQueryBuilder($this->class)
->update()
->field('archivers')->push($userStamp)
->field('modifiedAt')->set(new \DateTime())
->field('id')->equals(new \MongoId($conversationId))
->getQuery()
->execute();
}
push() , .
.