public function getDataFromServices() { foreach (self::$tables as $table => $data) { // clean interface array foreach ($this->getSetting('types') as $type => $get_data) { if ($get_data) { // Quit if no primary key is set. if (isset($data['primary_key'])) { // set object names to Ucfirst then lowercase. $table = ucfirst(strtolower($table)); switch ($type) { case "create_dto": $DTOService = new DTOCreatorService(); $this->_data[$table]['DTO'] = $DTOService->createDTO($table, $data); break; case "create_dao": $DAOService = new DAOCreatorService(); $this->_data[$table]['DAO'] = $DAOService->createDAO($table, $data); break; case "create_entity": $EntityService = new EntityCreatorService(); $this->_data[$table]['ENT'] = $EntityService->createEntity($table, $data); break; case "create_service": $ServiceService = new ServiceCreatorService(); $this->_data[$table]['SRV'] = $ServiceService->createService($table, $data); break; case "create_interface": $InterfaceService = new InterfaceCreatorService(); $this->_data[$table]['INT'] = $InterfaceService->createInterface($table, self::$interface[strtolower($table)]); break; case "create_exception": $ServiceExceptionCreatorService = new ServiceExceptionCreatorService(); $this->_data[$table]['EXC'] = $ServiceExceptionCreatorService->createServiceException($table); break; case "create_genericfiles": break; case "create_errorconstants": break; default: die("Settings not set correctly. [types]"); break; } } } } } $types = $this->getSetting('types'); if ($types['create_errorconstants']) { $ErrorconstantsCreatorService = new ErrorconstantsCreatorService(); $this->_data['ZENDMODELCREATOR_ERR'] = $ErrorconstantsCreatorService->createErrorconstants(self::$errorconstants); } }
/** * Get generated data from our services */ public function getDataFromServices() { $createModule = false; $createAutoloaders = false; $createConfig = false; $createOptions = false; foreach (self::$tables as $table => $data) { // clean interface array foreach ($this->getSetting('types') as $type => $get_data) { if ($get_data) { // Quit if no primary key is set. if (isset($data['primary_key'])) { // set object names to Ucfirst then lowercase. $table = ucfirst(strtolower($table)); switch ($type) { case "create_entity": $EntityService = new EntityCreatorService(); $this->_data[$table]['entity'] = $EntityService->createEntity($table, $data); break; case "create_mapper": $MapperService = new MapperCreatorService(); $this->_data[$table]['mapper'] = $MapperService->createMapper($table, $data); break; case "create_service": $serviceCreator = new ServiceCreatorService(); $this->_data[$table]['service'] = $serviceCreator->createService($table, $data); $EventService = new EventCreatorService(); $this->_data[$table]['service_event'] = $EventService->createEventService($table, $data); break; case "create_module": $createModule = true; break; case "create_autoloaders": $createAutoloaders = true; break; case "create_config": $createConfig = true; break; case "create_options": $createOptions = true; break; default: die("Settings not set correctly. [types]"); break; } } } } } // Check if we want to create the module if ($createModule) { $moduleCreator = new ModuleCreatorService(); $this->_files['module'] = $moduleCreator->createModule($table, self::$tables); } // Check if we want to create the options file if ($createOptions) { $optionsCreator = new OptionsCreatorService(); $this->_files['options'] = $optionsCreator->createOptions($table); } // Check if we want to create the config if ($createConfig) { // Build config file $this->_files['config'] = "<?php\n"; $this->_files['config'] .= "return array(\n"; $this->_files['config'] .= "\t'service_manager' => array(\n"; $this->_files['config'] .= "\t\t'aliases' => array(\n"; $this->_files['config'] .= "\t\t\t'" . strtolower(self::getNamespace()) . "_zend_db_adapter' => 'Zend\\Db\\Adapter\\Adapter',\n"; $this->_files['config'] .= "\t\t),\n"; $this->_files['config'] .= "\t),\n"; $this->_files['config'] .= ");"; } // Check if we want to create the options file if ($createConfig) { // Build config file $this->_files['config'] = "<?php\n"; $this->_files['config'] .= "return array(\n"; $this->_files['config'] .= "\t'service_manager' => array(\n"; $this->_files['config'] .= "\t\t'aliases' => array(\n"; $this->_files['config'] .= "\t\t\t'" . strtolower(self::getNamespace()) . "_zend_db_adapter' => 'Zend\\Db\\Adapter\\Adapter',\n"; $this->_files['config'] .= "\t\t),\n"; $this->_files['config'] .= "\t),\n"; $this->_files['config'] .= ");"; } // Check if we want to create autoloaders if ($createAutoloaders) { // Build classmap file $this->_files['classmap'] = "<?php\n"; $this->_files['classmap'] .= "return array(\n"; $this->_files['classmap'] .= "\t'" . ZendModelCreator::getNamespace() . "\\Module' => __DIR__ . '/Module.php',\n"; $this->_files['classmap'] .= ");"; // Build function file $this->_files['function'] = "<?php\n"; $this->_files['function'] .= "return function (\$class) {\n"; $this->_files['function'] .= "\tstatic \$map;\n"; $this->_files['function'] .= "\tif (!\$map) {\n"; $this->_files['function'] .= "\t\t\$map = include __DIR__ . '/autoload_classmap.php';\n"; $this->_files['function'] .= "\t}\n"; $this->_files['function'] .= "\tif (!isset(\$map[\$class])) {\n"; $this->_files['function'] .= "\t\treturn false;\n"; $this->_files['function'] .= "\t}\n"; $this->_files['function'] .= "\treturn include \$map[\$class];\n"; $this->_files['function'] .= "};\n"; // Build register file $this->_files['register'] = "<?php\n"; $this->_files['register'] .= "spl_autoload_register(include __DIR__ . '/autoload_function.php');"; } }