Im working with automatic code generator for my projects. And im using Zend Framework 2 for File/Class/Method reflection. I need to add elements to returned array:
public function getServiceConfig()
{
return array(
'factories' => array(
'Album\Model\AlbumTable' => function($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new AlbumTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
I can get 'factories' array, but cannot add new element (functions). (I need to add new element to factories like " 'objectTableGateway' => function($sm){ ... }") After that i write method body like body = var_export(array, true);
- if i add just function - function executes;
- if i add in quotes - i need manually clean quotes after code writes to file.
How to solve this problem?
Only solution i see is generate whole method body as plain text