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

Various fixes for tutorial #562

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
6 changes: 5 additions & 1 deletion tutorial/content-to-controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object and all the ``Posts`` to the view::
*/
public function pageAction($contentDocument)
{
$dm = $this->get('doctrine_phpcr')->getManagerForClass('AcmeBasicCmsBundle:Post');
$dm = $this->get('doctrine_phpcr')->getManager();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just surplass to requirements..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean it makes things needlessly complex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

$posts = $dm->getRepository('AcmeBasicCmsBundle:Post')->findAll();

return array(
Expand Down Expand Up @@ -155,6 +155,10 @@ Add a corresponding Twig template (note that this works because you use the

Now have another look at: http://localhost:8000/page/home

.. note::

If you get an error, try clearing the cache.

Notice what is happening with the post object and the ``path`` function - you
pass the ``Post`` object and the ``path`` function will pass the object to the
router and because it implements the ``RouteReferrersReadInterface`` the
Expand Down
85 changes: 80 additions & 5 deletions tutorial/make-homepage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ node::

public function init(ManagerRegistry $registry)
{
$dm = $registry->getManagerForClass('Acme\BasicCmsBundle\Document\Site');
$dm = $registry->getManager();
if ($dm->find(null, $this->basePath)) {
return;
}
Expand Down Expand Up @@ -135,8 +135,8 @@ node::
documents in initializers. With 1.0, you would need to manually set the
``phpcr:class`` property to the right value.

Now modify the existing service configuration for ``GenericInitializer`` as
follows:
Now *remove* the old initializer service (``acme_basiccms.basic_cms.phpcr.initializer``) and
register your new site initializer:

.. configuration-block::

Expand Down Expand Up @@ -188,8 +188,6 @@ Now empty your repository, reinitialize it and reload your fixtures:

.. code-block:: bash

$ php app/console doctrine:phpcr:node:remove /cms
$ php app/console doctrine:phpcr:repository:init
$ php app/console doctrine:phpcr:fixtures:load
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the fixtures:load will both purge the repository and initialize it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was already the case in 1.1


and verify that the ``cms`` node has been created correctly, using the
Expand Down Expand Up @@ -219,6 +217,83 @@ and verify that the ``cms`` node has been created correctly, using the
with the right class. The drawback then is that there are two places where
initialization choices take place - do whatever you prefer.

Reconfigure the Admin Tree
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section really highlights usablitiy problems with the Tree, which I guess we all know about. It took me some time to figure this out.

It also highlights the risk of adding things earlier in the tutorial (i.e. adding the tree) which break later on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. everytime we add something to the tutorial, the tutorial needs to be tested manually from beginning to end.

--------------------------

If you look at your admin interface now, you will notice that the tree has
gone!

You need to tell the admin tree about the new ``Site`` document which is now
the root of your websites content tree:

.. configuration-block::

.. code-block:: yaml

sonata_doctrine_phpcr_admin:
# ...
document_tree:
# ...
Acme\BasicCmsBundle\Document\Site:
valid_children:
- all

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://sonata-project.org/schema/dic/doctrine_phpcr_admin" />

<!-- ... -->

<document-tree class="Acme\BasicCmsBundle\Document\Site">
<valid-child>all</valid-child>
</document-tree>
</config>
</container>

.. code-block:: php

$container->loadFromExtension('sonata_doctrine_phpcr_admin', array(
// ...
'document_tree' => array(
'Acme\BasicCmsBundle\Document\Site' => array(
'valid_children' => array(
'all',
),
),
// ...
));

If you check your admin interface you will see that the ``Site`` document is
now being displayed, however it has no children. You need to map the children on the
``Site`` document, modify it as follows::

// src/Acme/BasicCmsBundle/Document/Site.php

// ...

/**
* @PHPCR\Document()
*/
class Site
{
/**
* @PHPCR\Children()
*/
protected $children;

// ...

public function getChildren()
{
return $this->children;
}
}

The tree should now again show your website structure.

Create the Make Homepage Button
-------------------------------

Expand Down
3 changes: 2 additions & 1 deletion tutorial/the-frontend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ to which you will add the existing ``Home`` page and an additional ``About`` pag
{
public function load(ObjectManager $dm)
{
// ...
$parent = $dm->find(null, '/cms/pages');

$rootPage = new Page();
$rootPage->setTitle('main');
$rootPage->setParentDocument($parent);
Expand Down