Because your model is just a POPO (Plain-Old PHP Object), just use the
`use` command in your controller:

// DefaultController.php
...
use MyBundle\Entity\User;

public class DefaultController extends Controller
{
    ...
    $user = new User(); // Instantiates MyBundle\Entity\User;
    $user->setName('Something besides Jonathan Wage');
    ...
}


You only need the Entity Manager
('doctrine.orm.default_entity_manager') if you want to persist the
User entity.

If you just want to have models to throw around, create them and use
them as you normally would use a plain PHP object.

Regards,
-Eric Clemmons


On Apr 14, 1:15 am, noRerih <kaupa...@gmail.com> wrote:
> Hi all, I use Sf2 vPR11 and have just created database, generated
> entity, created schema. Now the question is: how can I access and
> manipulate model from controller?
>
> Official docs (http://symfony.com/doc/2.0/book/doctrine/orm/
> overview.html) provide following example:
>         $user = new User();
>         $user->setName('Jonathan H. Wage');
>
>         $em = $this->get('doctrine.orm.entity_manager');
>         $em->persist($user);
>         $em->flush();
>
> It's not very clear why should entity manager be used, and what is it,
> etc. But ok, I tried to do this with my values from config:
>        $em =  $this->get('doctrine.orm.entity_managers.default');
>
> and got an error page with "The service
> "doctrine.orm.entity_managers.default" does not exist."
>
> What should I do to manipulate model, and does anyone know if there's
> way to do it without middle-layer (entity manager).
>
> Any help is appreciated, thanks in advance.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to