Hello,I'm new to ZF2 and i'm trying to use the same models trough all my
modules. So my modules are organize like that in the module directory:
RezFrontApp, RezBackApp, RezRestApi.My models are in my RezRestApi (under
"src/RezRestApi/Model/") module and i would like to use them in my front and
back App. In my application.config.php i put:
'modules' => array( 'RezFrontApp', 'RezBackApp',
'RezRestApi' ),
I also did a getServiceConfig() in the module.php of RezRestApi :
return array( 'factories' => array(
'RezRestApi\Model\UserTable' => function($sm) {
$tableGateway = $sm->get('UserTableGateway'); $table =
new UserTable($tableGateway); return $table;
}, 'UserTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new User());
return new TableGateway('docrdv_user', $dbAdapter, null,
$resultSetPrototype); },
'RezRestApi\Model\EventTable' => function($sm) {
$tableGateway = $sm->get('EventTableGateway'); $table =
new EventTable($tableGateway); return $table;
}, 'EventTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Event());
return new TableGateway('docrdv_event', $dbAdapter, null,
$resultSetPrototype); }, ), );
I also added That after my namespace declaration in module.php of RezRestApi
:
use RezRestApi\Model\User;use RezRestApi\Model\UserTable;use
RezRestApi\Model\Event;use RezRestApi\Model\EventTable;
but when i try
/$this->getServiceLocator()->get('RezRestApi\Model\EventTable')/ in an
action of my IndexController of RezFrontApp , i got this message : Fatal
error: Class 'RezRestApi\Model\Event' not found in
/homez.636/agencecl/app/docrdv/module/RezRestApi/Module.php on line 62. But
The file is there .Hope you can lighten my poor soul
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-Models-shared-between-Modules-tp4660745.html
Sent from the Zend Framework mailing list archive at Nabble.com.