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

add documentation about phpcr_document. fix #346 #347

Merged
merged 1 commit into from
Dec 16, 2013
Merged
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
46 changes: 46 additions & 0 deletions bundles/phpcr_odm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,51 @@ Form Types
The bundle provides a couple of handy form types for PHPCR and PHPCR-ODM
specific cases, along with form type guessers.

phpcr_document
~~~~~~~~~~~~~~

This form type is suitable to edit associations of PHPCR-ODM documents. It
works for ReferenceOne, ReferenceMany and Referrers but also for
ParentDocument associations. Make sure to set the ``multiple`` option
for ReferenceMany and Referrers, and to not set it for the others.

.. note::

While Children is also an association, it makes no sense to edit it
with this form type. Children are automatically attached to its parent.
MixedReferrers could be shown as a ``disabled`` but never edited,
because this association is immutable.

This form type is equivalent to the ``entity`` form type provided by Symfony
Copy link
Member

Choose a reason for hiding this comment

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

What about linking to those docs?

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 link it at the end of the section. should i link twice, or only up here?

Copy link
Member

Choose a reason for hiding this comment

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

No, I think it's fine this way. Didn't came that far when writing this comment

for Doctrine ORM. It has the same options as the ``entity`` type, including
that the option for the document manager is called ``em``.

A simple example of using the ``phpcr_document`` form type looks as follows::

$form
->add(
'speakers',
'phpcr_document',
array(
'property' => 'title',
'class' => 'Acme\DemoBundle\Document\TargetClass',
'multiple' => true,
)
)
;

This will produce a multiple choice select field with the value of
``getTitle`` called on each instance of ``TargetClass`` found in the
content repository. Alternatively, you can set the ``choices`` option
to a list of allowed managed documents. Please refer to the
`Symfony documentation on the entity form type`_ for more details,
including how you can configure a query.

If you are using Sonata Admin, you might want to look into
``sonata_type_collection``. This form type allows to edit related
documents (references as well as children) inline and also to create
and remove them on the fly.

phpcr_odm_reference_collection
Copy link
Member Author

Choose a reason for hiding this comment

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

@elHornair git blame says you worked on this type. do you remember what it was able to do? i wonder if it makes sense to keep it.

Copy link
Member

Choose a reason for hiding this comment

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

Not entirely sure anymore, but I think we used it to edit a collection of n references to phpcr nodes

Copy link
Member Author

Choose a reason for hiding this comment

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

nodes or documents? i think its based on documents.
@lsmith77 do you remember anything about this?

i grepped through our codebases and the cmf sandbox and found it used nowhere...

Copy link
Member

Choose a reason for hiding this comment

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

nope :-/

Copy link
Member Author

Choose a reason for hiding this comment

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -816,6 +861,7 @@ Dumping nodes under ``/cms/simple`` including their properties:
.. _`the PHPCR-ODM documentation`: http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/events.html
.. _`Symfony event subscriber`: http://symfony.com/doc/master/components/event_dispatcher/introduction.html#using-event-subscribers
.. _`Symfony cookbook entry`: http://symfony.com/doc/current/cookbook/doctrine/event_listeners_subscribers.html
.. _`Symfony documentation on the entity form type`: http://symfony.com/doc/current/reference/forms/types/entity.html
.. _`currently broken`: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/145
.. _`DoctrineMigrationsBundle`: http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html
.. _`DoctrineFixturesBundle`: http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html
Expand Down