Skip to content

Fix EntityManager namespace #5666

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

Closed
wants to merge 2 commits into from
Closed
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
34 changes: 17 additions & 17 deletions cookbook/form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ to and from the issue number and the ``Issue`` object::
namespace AppBundle\Form\DataTransformer;

use AppBundle\Entity\Issue;
use Doctrine\Common\Persistence\EntityManager;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

class IssueToNumberTransformer implements DataTransformerInterface
{
private $entityManager;
private $manager;

public function __construct(EntityManager $entityManager)
public function __construct(ObjectManager $manager)
{
$this->entityManager = $entityManager;
$this->manager = $manager;
}

/**
Expand Down Expand Up @@ -203,7 +203,7 @@ to and from the issue number and the ``Issue`` object::
return;
}

$issue = $this->entityManager
$issue = $this->manager
->getRepository('AppBundle:Issue')
// query for the issue with this id
->find($issueNumber)
Expand Down Expand Up @@ -253,16 +253,16 @@ to be passed in. Then, you can easily create and add the transformer::
namespace AppBundle\Form\Type;

use AppBundle\Form\DataTransformer\IssueToNumberTransformer;
use Doctrine\Common\Persistence\EntityManager;
use Doctrine\Common\Persistence\ObjectManager;

// ...
class TaskType extends AbstractType
{
private $entityManager;
private $manager;

public function __construct(EntityManager $entityManager)
public function __construct(ObjectManager $manager)
{
$this->entityManager = $entityManager;
$this->manager = $manager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
Expand All @@ -277,7 +277,7 @@ to be passed in. Then, you can easily create and add the transformer::
// ...

$builder->get('issue')
->addModelTransformer(new IssueToNumberTransformer($this->entityManager));
->addModelTransformer(new IssueToNumberTransformer($this->manager));
}

// ...
Expand All @@ -286,8 +286,8 @@ to be passed in. Then, you can easily create and add the transformer::
Now, when you create your ``TaskType``, you'll need to pass in the entity manager::

// e.g. in a controller somewhere
$entityManager = $this->getDoctrine()->getManager();
$form = $this->createForm(new TaskType($entityManager), $task);
$manager = $this->getDoctrine()->getManager();
$form = $this->createForm(new TaskType($manager), $task);

// ...

Expand Down Expand Up @@ -331,23 +331,23 @@ First, create the custom field type class::
namespace AppBundle\Form;

use AppBundle\Form\DataTransformer\IssueToNumberTransformer;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class IssueSelectorType extends AbstractType
{
private $entityManager;
private $manager;

public function __construct(EntityManager $entityManager)
public function __construct(ObjectManager $manager)
{
$this->entityManager = $entityManager;
$this->manager = $manager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$transformer = new IssueToNumberTransformer($this->entityManager);
$transformer = new IssueToNumberTransformer($this->manager);
$builder->addModelTransformer($transformer);
}

Expand Down