/** * @expectedException \Doctrine\ODM\PHPCR\Exception\InvalidArgumentException */ public function testRefreshDetached() { $user = new CmsUser(); $user->id = '/functional/Guilherme'; $user->username = '******'; $this->dm->refresh($user); }
/** * @param \ServerGrove\KbBundle\Document\Article $article * @param string $locale * @return string */ public function renderArticleLocale(Article $article, $locale) { try { $active = $this->manager->findTranslation(get_class($article), $article->getId(), $locale, false)->getIsActive(); } catch (\InvalidArgumentException $e) { $active = false; } $this->manager->refresh($article); return $this->twig->renderBlock('article_locale', array('active' => $active, 'locale' => $locale, 'locale_name' => Locale::getDisplayLanguage($locale))); }
/** * Test Referrers ManyToMany cascade Flush */ public function testCascadeManagedDocumentReferrerMtoMDuringFlush() { $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle(); $article1->text = "foo"; $article1->topic = "bar"; $article1->id = '/functional/article_m2m_referrer_1'; $this->dm->persist($article1); $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle(); $article2->text = "foo2"; $article2->topic = "bar2"; $article2->id = '/functional/article_m2m_referrer_2'; $this->dm->persist($article2); $superman = new \Doctrine\Tests\Models\CMS\CmsArticlePerson(); $superman->name = "superman"; $this->dm->persist($superman); $article1->addPerson($superman); $this->dm->flush(); $this->dm->refresh($superman); $this->assertEquals($superman, $article1->getPersons()->first()); // we want to attach article2 to superman // in the form of edition, we will submit article1 and article2 at the same time $superman->getArticlesReferrers()->add($article1); $superman->getArticlesReferrers()->add($article2); $this->dm->flush(); $this->dm->refresh($superman); $this->assertEquals(1, $article1->getPersons()->count()); $this->assertEquals(2, $superman->getArticlesReferrers()->count()); $this->dm->clear(); }
/** * Restore the document to the state it was before * * @param string $documentVersion the version name to restore * @param boolean $removeExisting how to handle identifier collisions * * @see VersionManager::restore */ public function restoreVersion($documentVersion, $removeExisting) { $oid = spl_object_hash($documentVersion); $history = $this->documentHistory[$oid]; $version = $this->documentVersion[$oid]; $document = $this->dm->find(null, $history->getVersionableIdentifier()); $vm = $this->session->getWorkspace()->getVersionManager(); $vm->restore($removeExisting, $version); $this->dm->refresh($document); }
/** * @param object $document * @return object Document instance */ public function refresh($document) { return $this->dm->refresh($document); }