Skip to content

A few minor improvements #7113

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

Merged
merged 2 commits into from
Nov 10, 2016
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
6 changes: 3 additions & 3 deletions doctrine/associations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ You can also query in the other direction::

In this case, the same things occur: you first query out for a single ``Category``
object, and then Doctrine makes a second query to retrieve the related ``Product``
objects, but only once/if you ask for them (i.e. when you call ``->getProducts()``).
objects, but only once/if you ask for them (i.e. when you call ``getProducts()``).
The ``$products`` variable is an array of all ``Product`` objects that relate
to the given ``Category`` object via their ``category_id`` value.

Expand Down Expand Up @@ -365,7 +365,7 @@ Of course, if you know up front that you'll need to access both objects, you
can avoid the second query by issuing a join in the original query. Add the
following method to the ``ProductRepository`` class::

// src/AppBundle/Entity/ProductRepository.php
// src/AppBundle/Repository/ProductRepository.php
Copy link
Member

Choose a reason for hiding this comment

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

In other chapters (doctrine/repository.rst, security/entity_provider.rst, testing/doctrine.rst), we have the repository classes in the Entity subnamespace. We should either update them as well or keep this example as is.

Copy link
Member

Choose a reason for hiding this comment

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

best_practices/configuration.rst on other hand also uses the Repository namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think to keep entities and repositories separately is a better option. Let's use the Repository namespace like in best practices. I'll push more changes

public function findOneByIdJoinedToCategory($productId)
{
$query = $this->getEntityManager()
Expand Down Expand Up @@ -407,7 +407,7 @@ Doctrine's `Association Mapping Documentation`_.
.. note::

If you're using annotations, you'll need to prepend all annotations with
``ORM\`` (e.g. ``ORM\OneToMany``), which is not reflected in Doctrine's
``@ORM\`` (e.g. ``@ORM\OneToMany``), which is not reflected in Doctrine's
documentation. You'll also need to include the ``use Doctrine\ORM\Mapping as ORM;``
statement, which *imports* the ``ORM`` annotations prefix.

Expand Down
10 changes: 5 additions & 5 deletions doctrine/repository.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To do this, add the repository class name to your entity's mapping definition:
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass="AppBundle\Entity\ProductRepository")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
class Product
{
Expand All @@ -33,7 +33,7 @@ To do this, add the repository class name to your entity's mapping definition:
# src/AppBundle/Resources/config/doctrine/Product.orm.yml
AppBundle\Entity\Product:
type: entity
repositoryClass: AppBundle\Entity\ProductRepository
repositoryClass: AppBundle\Repository\ProductRepository
# ...

.. code-block:: xml
Expand All @@ -47,7 +47,7 @@ To do this, add the repository class name to your entity's mapping definition:

<entity
name="AppBundle\Entity\Product"
repository-class="AppBundle\Entity\ProductRepository">
repository-class="AppBundle\Repository\ProductRepository">

<!-- ... -->
</entity>
Expand All @@ -72,8 +72,8 @@ entities, ordered alphabetically by name.

.. code-block:: php

// src/AppBundle/Entity/ProductRepository.php
namespace AppBundle\Entity;
// src/AppBundle/Repository/ProductRepository.php
namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

Expand Down
6 changes: 3 additions & 3 deletions security/entity_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For this entry, suppose that you already have a ``User`` entity inside an

/**
* @ORM\Table(name="app_users")
* @ORM\Entity(repositoryClass="AppBundle\Entity\UserRepository")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
*/
class User implements UserInterface, \Serializable
{
Expand Down Expand Up @@ -428,8 +428,8 @@ To do this, make your ``UserRepository`` implement a special
interface requires three methods: ``loadUserByUsername($username)``,
``refreshUser(UserInterface $user)``, and ``supportsClass($class)``::

// src/AppBundle/Entity/UserRepository.php
namespace AppBundle\Entity;
// src/AppBundle/Repository/UserRepository.php
namespace AppBundle\Repository;

use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
Expand Down
28 changes: 14 additions & 14 deletions service_container/parent_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ have related classes that share some of the same dependencies. For example,
you may have multiple repository classes which need the
``doctrine.entity_manager`` service and an optional ``logger`` service::

// src/AppBundle/Doctrine/BaseDoctrineRepository.php
namespace AppBundle\Doctrine;
// src/AppBundle/Repository/BaseDoctrineRepository.php
namespace AppBundle\Repository;

// ...
abstract class BaseDoctrineRepository
Expand Down Expand Up @@ -48,12 +48,12 @@ duplicated service definitions:
- [setLogger, ['@logger']]

app.user_repository:
class: AppBundle\Doctrine\DoctrineUserRepository
class: AppBundle\Repository\DoctrineUserRepository
# extend the app.base_doctrine_repository service
parent: app.base_doctrine_repository

app.post_repository:
class: AppBundle\Doctrine\DoctrinePostRepository
class: AppBundle\Repository\DoctrinePostRepository
parent: app.base_doctrine_repository

# ...
Expand All @@ -77,12 +77,12 @@ duplicated service definitions:

<!-- extends the app.base_doctrine_repository service -->
<service id="app.user_repository"
class="AppBundle\Doctrine\DoctrineUserRepository"
class="AppBundle\Repository\DoctrineUserRepository"
parent="app.base_doctrine_repository"
/>

<service id="app.post_repository"
class="AppBundle\Doctrine\DoctrineUserRepository"
class="AppBundle\Repository\DoctrineUserRepository"
parent="app.base_doctrine_repository"
/>

Expand All @@ -103,11 +103,11 @@ duplicated service definitions:

// extend the app.base_doctrine_repository service
$definition = new DefinitionDecorator('app.base_doctrine_repository');
$definition->setClass('AppBundle\Doctrine\DoctrineUserRepository');
$definition->setClass('AppBundle\Repository\DoctrineUserRepository');
$container->setDefinition('app.user_repository', $definition);

$definition = new DefinitionDecorator('app.base_doctrine_repository');
$definition->setClass('AppBundle\Doctrine\DoctrinePostRepository');
$definition->setClass('AppBundle\Repository\DoctrinePostRepository');
$container->setDefinition('app.post_repository', $definition);

// ...
Expand Down Expand Up @@ -144,7 +144,7 @@ in the child class:
# ...

app.user_repository:
class: AppBundle\Doctrine\DoctrineUserRepository
class: AppBundle\Repository\DoctrineUserRepository
parent: app.base_doctrine_repository

# overrides the public setting of the parent service
Expand All @@ -155,7 +155,7 @@ in the child class:
arguments: ['@app.username_checker']

app.post_repository:
class: AppBundle\Doctrine\DoctrinePostRepository
class: AppBundle\Repository\DoctrinePostRepository
parent: app.base_doctrine_repository

# overrides the first argument (using the special index_N key)
Expand All @@ -174,7 +174,7 @@ in the child class:

<!-- overrides the public setting of the parent service -->
<service id="app.user_repository"
class="AppBundle\Doctrine\DoctrineUserRepository"
class="AppBundle\Repository\DoctrineUserRepository"
parent="app.base_doctrine_repository"
public="false"
>
Expand All @@ -184,7 +184,7 @@ in the child class:
</service>

<service id="app.post_repository"
class="AppBundle\Doctrine\DoctrineUserRepository"
class="AppBundle\Repository\DoctrineUserRepository"
parent="app.base_doctrine_repository"
>
<!-- overrides the first argument (using the index attribute) -->
Expand All @@ -202,15 +202,15 @@ in the child class:
// ...

$definition = new DefinitionDecorator('app.base_doctrine_repository');
$definition->setClass('AppBundle\Doctrine\DoctrineUserRepository');
$definition->setClass('AppBundle\Repository\DoctrineUserRepository');
// overrides the public setting of the parent service
$definition->setPublic(false);
// appends the '@app.username_checker' argument to the parent argument list
$definition->addArgument(new Reference('app.username_checker'));
$container->setDefinition('app.user_repository', $definition);

$definition = new DefinitionDecorator('app.base_doctrine_repository');
$definition->setClass('AppBundle\Doctrine\DoctrinePostRepository');
$definition->setClass('AppBundle\Repository\DoctrinePostRepository');
// overrides the first argument
$definition->replaceArgument(0, new Reference('doctrine.custom_entity_manager'));
$container->setDefinition('app.post_repository', $definition);
4 changes: 2 additions & 2 deletions testing/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ If you need to actually execute a query, you will need to boot the kernel
to get a valid connection. In this case, you'll extend the ``KernelTestCase``,
which makes all of this quite easy::

// src/AppBundle/Tests/Entity/ProductRepositoryFunctionalTest.php
namespace AppBundle\Tests\Entity;
// src/AppBundle/Tests/Repository/ProductRepositoryFunctionalTest.php
namespace AppBundle\Tests\Repository;

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

Expand Down