/**
* @param string $className
* @param string $moduleName
* @param string $namespaceName
* @param string $tableName
* @param array $loadedTable
* @param array $config
*/
public function __construct($className, $moduleName, $namespaceName, $tableName, array $loadedTable = [], array $config = [])
{
// set config data
$this->config = $config;
$this->loadedTable = $loadedTable;
$this->foreignKeys = [];
/** @var ConstraintObject $foreignKey */
foreach ($this->loadedTable['foreignKeys'] as $foreignKey) {
foreach ($foreignKey->getColumns() as $column) {
$this->foreignKeys[$column] = $foreignKey;
}
}
// call parent constructor
parent::__construct($className . 'Factory', $moduleName . '\\' . $namespaceName);
// add namespaces for foreign key tables
foreach ($this->foreignKeys as $foreignKey) {
$this->addUse($moduleName . '\\' . $this->config['namespaceStorage'] . '\\' . StaticFilter::execute($foreignKey->getReferencedTableName(), 'Word\\UnderscoreToCamelCase') . 'Storage');
}
// add used namespaces and extended classes
$this->addUse('Zend\\ServiceManager\\FactoryInterface');
$this->addUse('Zend\\ServiceManager\\ServiceLocatorAwareInterface');
$this->addUse('Zend\\ServiceManager\\ServiceLocatorInterface');
$this->setImplementedInterfaces(['FactoryInterface']);
// add methods
$this->addCreateServiceMethod($className, $moduleName);
$this->addClassDocBlock($className);
}