Today learning ZF2 process, the video said to the database in the table to inherit Tablegateway, and then registered in ServiceManager, but there is no $adapter, need in Servicemanger, configure initializer, Add a class that implements Intializerinterface, which has a initialize method that determines if the class that the service produces implements Adapterinterface, then Setdbadapter () is executed, Inject Serivcielocator->get (' adpater ') into the class so that the $adpater is automatically injected when the Usertable service is invoked.
Then, I think is if usertable directly implement Servicelocatorawareinterface is not can also inject adater into it, so, try, servicelocator can come in, but the service is to directly produce instances, There's no way to give servicelocator to $adapter, so we have to implement Adapterinterface, initialize it and inject it in.
About Servicelocator, Adpaterawareinterface injection