Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

validate we have the right type of object manager in the fixtures #596

Merged
merged 1 commit into from
Oct 25, 2014
Merged
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
5 changes: 5 additions & 0 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ follows::
*/
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$route = new Route();
$route->setParentDocument($dm->find(null, '/cms/routes'));
$route->setName('projects');
Expand Down
10 changes: 10 additions & 0 deletions book/simplecms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ To create a page, use the
*/
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$parent = $dm->find(null, '/cms/simple');
$page = new Page();
$page->setTitle('About Symfony CMF');
Expand Down Expand Up @@ -111,6 +116,11 @@ structure, you would do::
*/
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$root = $dm->find(null, '/cms/simple');

$about = new Page();
Expand Down
5 changes: 5 additions & 0 deletions bundles/phpcr_odm/fixtures_initializers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ A simple example fixture class looks like this::
{
public function load(ObjectManager $manager)
{
if (!$manager instanceof DocumentManager) {
$class = get_class($manager);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

// ... create and persist your data here
}
}
Expand Down
5 changes: 5 additions & 0 deletions bundles/seo/seo_aware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ And after that, you can use the
{
public function load(ObjectManager $manager)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$page = new Page();
// ... set some page properties

Expand Down
15 changes: 15 additions & 0 deletions quick_tour/the_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ PHPCR. But first, you have to create a new Page document::
// ...
public function load(ObjectManager $documentManager)
{
if (!$documentManager instanceof DocumentManager) {
$class = get_class($documentManager);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$page = new Page(); // create a new Page object (document)
$page->setName('new_page'); // the name of the node
$page->setLabel('Another new Page');
Expand All @@ -130,6 +135,11 @@ it as its parent::
// ...
public function load(ObjectManager $documentManager)
{
if (!$documentManager instanceof DocumentManager) {
$class = get_class($documentManager);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

// ...

// get root document (/cms/simple)
Expand All @@ -144,6 +154,11 @@ document using the Doctrine API::
// ...
public function load(ObjectManager $documentManager)
{
if (!$documentManager instanceof DocumentManager) {
$class = get_class($documentManager);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

// ...
$documentManager->persist($page); // add the Page in the queue
$documentManager->flush(); // add the Page to PHPCR
Expand Down
5 changes: 5 additions & 0 deletions quick_tour/the_router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ Now you can add a new ``Route`` to the tree using Doctrine::
{
public function load(ObjectManager $documentManager)
{
if (!$documentManager instanceof DocumentManager) {
$class = get_class($documentManager);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$routesRoot = $documentManager->find(null, '/cms/routes');

$route = new Route();
Expand Down
5 changes: 5 additions & 0 deletions tutorial/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ Create a page for your CMS::
{
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$parent = $dm->find(null, '/cms/pages');

$page = new Page();
Expand Down
5 changes: 5 additions & 0 deletions tutorial/the-frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ to which you will add the existing ``Home`` page and an additional ``About`` pag
{
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}

$parent = $dm->find(null, '/cms/pages');

$rootPage = new Page();
Expand Down