Doctrine\ODM\MongoDB\DocumentManager::refresh PHP Method

refresh() public method

Refreshes the persistent state of a document from the database, overriding any local changes that have not yet been persisted.
public refresh ( object $document )
$document object The document to refresh.
    public function refresh($document)
    {
        if (!is_object($document)) {
            throw new \InvalidArgumentException(gettype($document));
        }
        $this->errorIfClosed();
        $this->unitOfWork->refresh($document);
    }

Usage Example

Example #1
0
 protected function initOrganization()
 {
     $repo = $this->getApplicationServiceLocator()->get('repositories')->get('Organizations/Organization');
     $name = 'Job Repository Test Organization';
     $results = $repo->findByName($name);
     $organization = $results[0];
     if (!$organization) {
         $organization = new Organization();
         $organization->setIsDraft(false);
         $organization->setOrganizationName(new OrganizationName());
         $organization->getOrganizationName()->setName($name);
         $this->dm->persist($organization);
         $this->dm->flush($organization);
         $this->dm->refresh($organization);
     }
     $this->organization = $organization;
 }
All Usage Examples Of Doctrine\ODM\MongoDB\DocumentManager::refresh