Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize documentation #618

Merged
merged 16 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion Resources/doc/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ For example, to get details about the ``doctrine:mongodb:query`` task, run:
``DoctrineFixturesBundle`` bundle installed. To learn how to do it, read
the "`DoctrineFixturesBundle`_" entry of the documentation.

.. _`DoctrineFixturesBundle`: http://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
.. _`DoctrineFixturesBundle`: https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
14 changes: 7 additions & 7 deletions Resources/doc/cookbook/registration_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ database. In this example, we'll create a registration form with some extra
fields and (like a "terms accepted" checkbox field) and embed the form that
actually stores the account information. We'll use MongoDB for storing the data.

The simple User model
The User Model
---------------------

So, in this tutorial we begin with the model for a ``User`` document:
Expand Down Expand Up @@ -118,9 +118,9 @@ Next, create the form for the ``User`` model:
}
}

We just added two fields: email and password (repeated to confirm the entered
password). The ``data_class`` option tells the form the name of data class
(i.e. your ``User`` document).
We added two fields: email and password (repeated to confirm the entered
password). The ``data_class`` option tells the form the name of the class
that holds the underlying data (i.e. your ``User`` document).

.. tip::

Expand All @@ -130,7 +130,7 @@ Embedding the User form into a Registration Form
------------------------------------------------

The form that you'll use for the registration page is not the same as the
form used to simply modify the ``User`` (i.e. ``UserType``). The registration
form used to modify the ``User`` (i.e. ``UserType``). The registration
form will contain further fields like "accept the terms", whose value won't be
stored in the database.

Expand Down Expand Up @@ -208,8 +208,8 @@ of the class ``UserType``.
Handling the Form Submission
----------------------------

Next, you need a controller to handle the form. Start by creating a simple
controller for displaying the registration form:
Next, you need a controller to handle the form. Start by creating a
controller that will display the registration form:

.. code-block:: php

Expand Down
4 changes: 2 additions & 2 deletions Resources/doc/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ available.
event(s). For this reason, the aforementioned tags have no ``method``
attribute.

.. _`event dispatcher`: http://symfony.com/doc/current/components/event_dispatcher/introduction.html
.. _`Event Documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/events.html
.. _`event dispatcher`: https://symfony.com/doc/current/components/event_dispatcher.html
.. _`Event Documentation`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/events.html
.. _`tagging`: https://symfony.com/doc/current/service_container/tags.html
49 changes: 24 additions & 25 deletions Resources/doc/first_steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ inside the ``Document`` directory of your ``AcmeStoreBundle``:
}

The class - often called a "document", meaning *a basic class that holds data* -
is simple and helps fulfill the business requirement of needing products
in your application. This class can't be persisted to Doctrine MongoDB yet -
it's just a simple PHP class.
helps fulfill the business requirement of needing products in your application.
This class can't be persisted to Doctrine MongoDB yet - currently it's
only plain PHP class.
SzymonKaminski marked this conversation as resolved.
Show resolved Hide resolved

Add Mapping Information
~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -51,8 +51,8 @@ you to persist entire *objects* to MongoDB and fetch entire objects out of
MongoDB. This works by mapping a PHP class and its properties to entries
of a MongoDB collection.

For Doctrine to be able to do this, you just have to create "metadata", or
configuration that tells Doctrine exactly how the ``Product`` class and its
For Doctrine to be able to do this, you have to create "metadata", or
configuration, that tells Doctrine exactly how the ``Product`` class and its
SzymonKaminski marked this conversation as resolved.
Show resolved Hide resolved
properties should be *mapped* to MongoDB. This metadata can be specified
in a number of different formats including XML or directly inside the
``Product`` class via annotations:
Expand Down Expand Up @@ -115,9 +115,8 @@ Persisting Objects to MongoDB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now that you have a mapped ``Product`` document complete with getter and
setter methods, you're ready to persist data to MongoDB. From inside a controller,
this is pretty easy. Add the following method to the ``DefaultController``
of the bundle:
setter methods, you're ready to persist data to MongoDB. Let's try it from inside
a controller. Create new Controller class inside source directory of your project:
Copy link
Member

@malarzm malarzm Feb 28, 2020

Choose a reason for hiding this comment

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

DefaultController was already created in this chapter, please bring back the part about adding a new method to it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the top of the file I've removed section with bin/console generate:bundle --namespace=Acme/StoreBundle command from which DefaultController came from

Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry then 👍 so we need to just change

Suggested change
a controller. Create new Controller class inside source directory of your project:
a controller. Create a new Controller class inside source directory of your project:

Also what do you think about having entire controller in example? Showing only method to add made sense when controller was already there, now it looks a bit off IMO

Copy link
Contributor Author

@SzymonKaminski SzymonKaminski Feb 28, 2020

Choose a reason for hiding this comment

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

Ok, will add class name to the example. Also the missing file path inside codeblock in the next section Fetching Objects from MongoDB. That example doesn't need full class, right?

Copy link
Member

Choose a reason for hiding this comment

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

That example doesn't need full class, right?

Right 👍


.. code-block:: php
:linenos:
Expand Down Expand Up @@ -208,8 +207,8 @@ they already exist in MongoDB.
Fetching Objects from MongoDB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fetching an object back out of MongoDB is even easier. For example, suppose
you've configured a route to display a specific ``Product`` based on its
Fetching an object back out of MongoDB is also possible. For example, suppose
that you've configured a route to display a specific ``Product`` based on its
``id`` value:

.. code-block:: php
Expand Down Expand Up @@ -260,8 +259,8 @@ Once you have your repository, you have access to all sorts of helpful methods:

.. note::

Of course, you can also issue complex queries, which you'll learn more
about in the `Querying for Objects`_ section.
You can also issue complex queries, you can learn more about them
in the `Querying for Objects`_ section.

You can also take advantage of the useful ``findBy()`` and ``findOneBy()`` methods
to easily fetch objects based on multiple conditions:
Expand All @@ -280,7 +279,7 @@ to easily fetch objects based on multiple conditions:
Updating an Object
~~~~~~~~~~~~~~~~~~

Once you've fetched an object from Doctrine, updating it is easy. Suppose
Once you've fetched an object from Doctrine, let's try to update it. Suppose
you have a route that maps a product id to an update action in a controller:

.. code-block:: php
Expand All @@ -299,14 +298,14 @@ you have a route that maps a product id to an update action in a controller:
return $this->redirectToRoute('homepage');
}

Updating an object involves just three steps:
Updating an object involves three steps:

1. Fetching the object from Doctrine;
2. Modifying the object;
3. Calling ``flush()`` on the document manager.

Notice that calling ``$dm->persist($product)`` isn't necessary. Recall that
this method simply tells Doctrine to manage or "watch" the ``$product`` object.
this method tells Doctrine to manage or "watch" the ``$product`` object.
In this case, since you fetched the ``$product`` object from Doctrine, it's
already managed.

Expand All @@ -321,16 +320,16 @@ method of the document manager:
$dm->remove($product);
$dm->flush();

As you might expect, the ``remove()`` method notifies Doctrine that you'd
like to remove the given document from the MongoDB. The actual delete operation
however, isn't actually executed until the ``flush()`` method is called.
The ``remove()`` method notifies Doctrine that you'd like to remove
the given document from the MongoDB. The actual delete operation
however, isn't executed until the ``flush()`` method is called.

Querying for Objects
--------------------

As you saw above, the built-in repository class allows you to query for one
or many objects based on an number of different parameters. When this is
enough, this is the easiest way to query for documents. Of course, you can
or many objects based on any number of different parameters. When this is
enough, this is the recommended way to query for documents. Of course, you can
SzymonKaminski marked this conversation as resolved.
Show resolved Hide resolved
also create more complex queries.

Using the Query Builder
Expand Down Expand Up @@ -425,7 +424,7 @@ for all of the ``Product`` documents, ordered alphabetically.
}
}

You can use this new method just like the default finder methods of the repository:
You can use this new method like the default finder methods of the repository:

.. code-block:: php

Expand Down Expand Up @@ -497,9 +496,9 @@ repositories as services you can use the following service configuration:
</services>
</container>

.. _`Basic Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html
.. _`Conditional Operators`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html#conditional-operators
.. _`DoctrineFixturesBundle`: http://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
.. _`Query Builder`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html
.. _`Basic Mapping Documentation`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html
.. _`Conditional Operators`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html#conditional-operators
.. _`DoctrineFixturesBundle`: https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
.. _`Query Builder`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html
.. _`autowiring`: https://symfony.com/doc/current/service_container/autowiring.html
.. _`autoconfiguration`: https://symfony.com/doc/current/service_container.html#the-autoconfigure-option
2 changes: 1 addition & 1 deletion Resources/doc/form_validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ means that the ``em`` option should be used if you wish to specify the document
manager explicitly instead of having it be inferred from the document class.

.. _`EntityType`: https://symfony.com/doc/current/reference/forms/types/entity.html
.. _`UniqueEntity`: http://symfony.com/doc/current/reference/constraints/UniqueEntity.html
.. _`UniqueEntity`: https://symfony.com/doc/current/reference/constraints/UniqueEntity.html
19 changes: 10 additions & 9 deletions Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ Doctrine Extensions: Timestampable, Sluggable, etc.
---------------------------------------------------

Doctrine is quite flexible, and a number of third-party extensions are available
that allow you to easily perform repeated and common tasks on your entities.
These include thing such as *Sluggable*, *Timestampable*, *Loggable*, *Translatable*,
that allow you to perform repeated and common tasks on your entities.
These include things such as *Sluggable*, *Timestampable*, *Loggable*, *Translatable*,
and *Tree*.

For more information on how to find and use these extensions, see the cookbook
article about `using common Doctrine extensions`_.
For more information about them, see `available Doctrine extensions`_
and use the `StofDoctrineExtensionsBundle`_ to integrate them in your application.

.. _`MongoDB`: http://www.mongodb.org/
.. _`Doctrine2 ORM`: http://symfony.com/doc/current/book/doctrine.html
.. _`documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
.. _`Doctrine2 ORM chapter`: http://symfony.com/doc/current/book/doctrine.html
.. _`using common Doctrine extensions`: http://symfony.com/doc/current/cookbook/doctrine/common_extensions.html
.. _`MongoDB`: https://www.mongodb.com
.. _`Doctrine2 ORM`: https://symfony.com/doc/current/book/doctrine.html
.. _`documentation`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
.. _`Doctrine2 ORM chapter`: https://symfony.com/doc/current/book/doctrine.html
.. _`available Doctrine extensions`: https://github.com/Atlantic18/DoctrineExtensions
.. _`StofDoctrineExtensionsBundle`: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
9 changes: 5 additions & 4 deletions Resources/doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ therefore you need to allow its usage:
Install the bundle with Composer
--------------------------------

To install DoctrineMongoDBBundle with Composer just run the following command:
To install DoctrineMongoDBBundle with Composer run the following command:

.. code-block:: bash

Expand Down Expand Up @@ -75,8 +75,8 @@ the MongoDB ODM across your application:

.. note::

Of course, you'll also need to make sure that the MongoDB server is running
in the background. For more details, see the MongoDB `Quick Start`_ guide.
Please also make sure that the MongoDB server is running in the background.
For more details, see the MongoDB `Installation Tutorials`_.


Authentication
Expand All @@ -95,4 +95,5 @@ password, and authentication database in the following way:

.. _`installation chapter`: https://getcomposer.org/doc/00-intro.md
.. _`MongoDB driver`: https://docs.mongodb.com/ecosystem/drivers/php/
.. _`Quick Start`: http://www.mongodb.org/display/DOCS/Quickstart
.. _`Installation Tutorials`: https://docs.mongodb.com/manual/installation/
.. _`Environment Variables`: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables
8 changes: 5 additions & 3 deletions Resources/doc/security_bundle.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
SecurityBundle integration
==========================

A user provider is available for your MongoDB projects, working exactly the
same as the ``entity`` provider described in `the cookbook`_:
A user provider is available for your MongoDB projects if you use
Symfony `SecurityBundle`_. It works exactly the same way as
the ``entity`` user provider described in `the cookbook`_:

.. configuration-block::

Expand All @@ -22,4 +23,5 @@ same as the ``entity`` provider described in `the cookbook`_:
</provider>
</config>

.. _`the cookbook`: http://symfony.com/doc/current/cookbook/security/entity_provider.html
.. _`SecurityBundle`: https://symfony.com/doc/current/security.html
.. _`the cookbook`: https://symfony.com/doc/current/cookbook/security/user_provider.html