0

I originally wanted to find out how to access the Doctrine 2's Entity Manager from within Entity Classes. But I saw another question Using EntityManager inside Doctrine 2.0 entities, and learnt that I should be using a service class. I wonder where should I put in a Zend Framework Application? Also is it also called a DAO (Data Access Object)? I am thinking of naming it DAO instead of Service as Service sounds alot like something for external sites to use (like Web Service)?

I am thinking something like Application_Models_DAO_User?

Community
  • 1
  • 1
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

1 Answers1

0

Service classes are part of the autoloader mapping. Like Application_Model_Something can be found in application/models, it's the same for services.

An application service Application_Service_Something should be located at: application/services/Something.php

When you use service classes inside modules, for example Blog_Service_Something they need to be located at: application/modules/blog/services/Something.php

I think classes like entity managers shouldn't be part of your controllers nor your models, but located in service classes.

Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99
  • Of course, you can customize your own autoloader mapping with [Resource Autloaders](http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html) of which `Zend_Application_Module_Autoloader`, typically created in `Bootstrap`, is an example. – David Weinraub Dec 25 '10 at 02:48