@@ -122,27 +122,27 @@ discard block |
||
| 122 | 122 | $behaviors = $tableMap->getBehaviors(); |
| 123 | 123 | foreach ($map::getFieldNames() as $field) { |
| 124 | 124 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
| 125 | - if(null !== $fDto) { |
|
| 125 | + if (null !== $fDto) { |
|
| 126 | 126 | $form->addField($fDto); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if(array_key_exists('i18n', $behaviors)) { |
|
| 131 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 132 | - if(null !== $relateI18n) { |
|
| 130 | + if (array_key_exists('i18n', $behaviors)) { |
|
| 131 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 132 | + if (null !== $relateI18n) { |
|
| 133 | 133 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 134 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
| 134 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
| 135 | 135 | $columnName = self::getColumnMapName($columnMap); |
| 136 | - if(!$form->fieldExists($columnName)) { |
|
| 136 | + if (!$form->fieldExists($columnName)) { |
|
| 137 | 137 | /** @var Field $fDto */ |
| 138 | 138 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
| 139 | - if(null !== $fDto) { |
|
| 139 | + if (null !== $fDto) { |
|
| 140 | 140 | $fDto->pk = false; |
| 141 | 141 | $fDto->required = true; |
| 142 | - if(strtolower($fDto->name) === 'locale') { |
|
| 142 | + if (strtolower($fDto->name) === 'locale') { |
|
| 143 | 143 | $fDto->type = Field::COMBO_TYPE; |
| 144 | 144 | $languages = explode(',', Config::getParam('i18n.locales', Config::getParam('default.language', 'es_ES'))); |
| 145 | - foreach($languages as $language) { |
|
| 145 | + foreach ($languages as $language) { |
|
| 146 | 146 | $fDto->data[] = [ |
| 147 | 147 | $fDto->name => $language, |
| 148 | 148 | 'Label' => t($language), |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $column = null; |
| 171 | 171 | try { |
| 172 | - foreach($tableMap->getColumns() as $tableMapColumn) { |
|
| 172 | + foreach ($tableMap->getColumns() as $tableMapColumn) { |
|
| 173 | 173 | $columnName = $tableMapColumn->getPhpName(); |
| 174 | - if(preg_match('/^'.$field.'$/i', $columnName)) { |
|
| 174 | + if (preg_match('/^'.$field.'$/i', $columnName)) { |
|
| 175 | 175 | $column = $tableMapColumn; |
| 176 | 176 | break; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - } catch (\Exception $e) { |
|
| 179 | + }catch (\Exception $e) { |
|
| 180 | 180 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 181 | 181 | } |
| 182 | 182 | return $column; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public static function getFieldTypes() { |
| 189 | 189 | $configType = Config::getParam('api.field.case', TableMap::TYPE_PHPNAME); |
| 190 | - switch($configType) { |
|
| 190 | + switch ($configType) { |
|
| 191 | 191 | default: |
| 192 | 192 | case 'UpperCamelCase': |
| 193 | 193 | case TableMap::TYPE_PHPNAME: |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | //Generating the templates translations |
| 45 | 45 | $translations = $this->tpl->regenerateTemplates(); |
| 46 | 46 | |
| 47 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 48 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 47 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 48 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 49 | 49 | |
| 50 | 50 | //xgettext localizations |
| 51 | 51 | $translations = array_merge($translations, I18nHelper::findTranslations(SOURCE_DIR, $locale)); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $translations = array_merge($translations, I18nHelper::findTranslations(CACHE_DIR, $locale)); |
| 54 | 54 | |
| 55 | 55 | $translations[] = "msgfmt {$localePath}translations.po -o {$localePath}translations.mo"; |
| 56 | - $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '. $localePath . 'translations.po -o ' . $localePath . 'translations.mo'); |
|
| 56 | + $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '.$localePath.'translations.po -o '.$localePath.'translations.mo'); |
|
| 57 | 57 | return $this->render('translations.html.twig', array( |
| 58 | 58 | 'translations' => $translations, |
| 59 | 59 | )); |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | $objects = scandir($dir); |
| 25 | 25 | foreach ($objects as $object) { |
| 26 | 26 | if ($object != "." && $object != "..") { |
| 27 | - if (filetype($dir . "/" . $object) == "dir") { |
|
| 28 | - self::deleteDir($dir . "/" . $object); |
|
| 29 | - } else { |
|
| 30 | - unlink($dir . "/" . $object); |
|
| 27 | + if (filetype($dir."/".$object) == "dir") { |
|
| 28 | + self::deleteDir($dir."/".$object); |
|
| 29 | + }else { |
|
| 30 | + unlink($dir."/".$object); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $rootDirs = array("css", "js", "media", "font"); |
| 45 | 45 | foreach ($rootDirs as $dir) { |
| 46 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 46 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 47 | 47 | try { |
| 48 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 49 | - } catch (\Exception $e) { |
|
| 48 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 49 | + }catch (\Exception $e) { |
|
| 50 | 50 | syslog(LOG_INFO, $e->getMessage()); |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | try { |
| 64 | 64 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 65 | - throw new \Exception(t('Can\'t create directory ') . $dir); |
|
| 65 | + throw new \Exception(t('Can\'t create directory ').$dir); |
|
| 66 | 66 | } |
| 67 | - } catch (\Exception $e) { |
|
| 67 | + }catch (\Exception $e) { |
|
| 68 | 68 | syslog(LOG_WARNING, $e->getMessage()); |
| 69 | 69 | if (!file_exists(dirname($dir))) { |
| 70 | - throw new GeneratorException($e->getMessage() . $dir); |
|
| 70 | + throw new GeneratorException($e->getMessage().$dir); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public static function getTemplatePath() |
| 80 | 80 | { |
| 81 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 81 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 82 | 82 | return realpath($path); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -97,15 +97,15 @@ discard block |
||
| 97 | 97 | * @throws \ReflectionException |
| 98 | 98 | */ |
| 99 | 99 | public static function checkCustomNamespaceApi($namespace) { |
| 100 | - if(!empty($namespace)) { |
|
| 101 | - if(class_exists($namespace)) { |
|
| 100 | + if (!empty($namespace)) { |
|
| 101 | + if (class_exists($namespace)) { |
|
| 102 | 102 | $reflector = new \ReflectionClass($namespace); |
| 103 | - if(!$reflector->isSubclassOf(Api::class)) { |
|
| 103 | + if (!$reflector->isSubclassOf(Api::class)) { |
|
| 104 | 104 | throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
| 105 | - } elseif(!$reflector->isAbstract()) { |
|
| 105 | + } elseif (!$reflector->isAbstract()) { |
|
| 106 | 106 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
| 107 | 107 | } |
| 108 | - } else { |
|
| 108 | + }else { |
|
| 109 | 109 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @return array |
| 117 | 117 | */ |
| 118 | 118 | public static function getDomainPaths($domain) { |
| 119 | - $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true); |
|
| 119 | + $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true); |
|
| 120 | 120 | $paths = []; |
| 121 | - if(null !== $domains) { |
|
| 121 | + if (null !== $domains) { |
|
| 122 | 122 | $keyDomains = array_keys($domains); |
| 123 | - foreach($keyDomains as $keyDomain) { |
|
| 123 | + foreach ($keyDomains as $keyDomain) { |
|
| 124 | 124 | $key = strtoupper(str_replace(['@', '/'], '', $keyDomain)); |
| 125 | - if(strtoupper($domain) === $key) { |
|
| 125 | + if (strtoupper($domain) === $key) { |
|
| 126 | 126 | $paths = $domains[$keyDomain]; |
| 127 | 127 | break; |
| 128 | 128 | } |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public static function createRoot($path = WEB_DIR, OutputInterface $output = null) { |
| 140 | 140 | |
| 141 | - if(null === $output) { |
|
| 141 | + if (null === $output) { |
|
| 142 | 142 | $output = new ConsoleOutput(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | GeneratorHelper::createDir($path); |
| 146 | 146 | $paths = array("js", "css", "img", "media", "font"); |
| 147 | 147 | foreach ($paths as $htmlPath) { |
| 148 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
| 148 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Generates the root needed files |
@@ -158,18 +158,18 @@ discard block |
||
| 158 | 158 | ]; |
| 159 | 159 | $output->writeln('Start creating html files'); |
| 160 | 160 | foreach ($files as $templates => $filename) { |
| 161 | - $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
| 162 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
| 163 | - $output->writeln('Can\t create the file ' . $filename); |
|
| 164 | - } else { |
|
| 165 | - $output->writeln($filename . ' created successfully'); |
|
| 161 | + $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
| 162 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
| 163 | + $output->writeln('Can\t create the file '.$filename); |
|
| 164 | + }else { |
|
| 165 | + $output->writeln($filename.' created successfully'); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | //Export base locale translations |
| 170 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
| 171 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 172 | - self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 170 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
| 171 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 172 | + self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | if (file_exists($filenamePath)) { |
| 187 | 187 | $destfolder = basename($filenamePath); |
| 188 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
| 188 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
| 189 | 189 | if (is_dir($filenamePath)) { |
| 190 | - self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
| 191 | - } else { |
|
| 192 | - if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
| 193 | - throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
| 190 | + self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
| 191 | + }else { |
|
| 192 | + if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
| 193 | + throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -208,10 +208,10 @@ discard block |
||
| 208 | 208 | self::createDir($dst); |
| 209 | 209 | while (false !== ($file = readdir($dir))) { |
| 210 | 210 | if (($file != '.') && ($file != '..')) { |
| 211 | - if (is_dir($src . '/' . $file)) { |
|
| 212 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
| 213 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
| 214 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
| 211 | + if (is_dir($src.'/'.$file)) { |
|
| 212 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
| 213 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
| 214 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | // TODO check more en locales |
| 45 | 45 | if (strtolower($locale) === 'en') { |
| 46 | 46 | $locale = 'en_GB'; |
| 47 | - } else { |
|
| 48 | - $locale = $locale . '_' . strtoupper($locale); |
|
| 47 | + }else { |
|
| 48 | + $locale = $locale.'_'.strtoupper($locale); |
|
| 49 | 49 | } |
| 50 | 50 | $defaultLocales = explode(',', Config::getParam('i18n.locales', '')); |
| 51 | 51 | if (!in_array($locale, array_merge($defaultLocales, self::$langs))) { |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $translations = array(); |
| 65 | 65 | if (file_exists($absoluteFileName)) { |
| 66 | 66 | @include($absoluteFileName); |
| 67 | - } else { |
|
| 67 | + }else { |
|
| 68 | 68 | Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | public static function setLocale($default = null) |
| 80 | 80 | { |
| 81 | 81 | $locale = self::extractLocale($default); |
| 82 | - Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG); |
|
| 82 | + Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG); |
|
| 83 | 83 | // Load translations |
| 84 | - putenv("LC_ALL=" . $locale); |
|
| 84 | + putenv("LC_ALL=".$locale); |
|
| 85 | 85 | setlocale(LC_ALL, $locale); |
| 86 | 86 | // Load the locale path |
| 87 | - $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 88 | - Logger::log('Set locale dir ' . $localePath); |
|
| 87 | + $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 88 | + Logger::log('Set locale dir '.$localePath); |
|
| 89 | 89 | GeneratorHelper::createDir($localePath); |
| 90 | 90 | bindtextdomain('translations', $localePath); |
| 91 | 91 | textdomain('translations'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
| 152 | 152 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
| 153 | 153 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
| 154 | - ['n', 'N', 'c', 'C',], |
|
| 154 | + ['n', 'N', 'c', 'C', ], |
|
| 155 | 155 | ]; |
| 156 | 156 | |
| 157 | 157 | $text = filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
@@ -170,24 +170,24 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public static function findTranslations($path, $locale) |
| 172 | 172 | { |
| 173 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 174 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 173 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 174 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 175 | 175 | |
| 176 | 176 | $translations = array(); |
| 177 | 177 | if (file_exists($path)) { |
| 178 | 178 | $directory = dir($path); |
| 179 | 179 | while (false !== ($fileName = $directory->read())) { |
| 180 | 180 | GeneratorHelper::createDir($localePath); |
| 181 | - if (!file_exists($localePath . 'translations.po')) { |
|
| 182 | - file_put_contents($localePath . 'translations.po', ''); |
|
| 181 | + if (!file_exists($localePath.'translations.po')) { |
|
| 182 | + file_put_contents($localePath.'translations.po', ''); |
|
| 183 | 183 | } |
| 184 | - $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName); |
|
| 185 | - $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
| 186 | - $inspectPath . DIRECTORY_SEPARATOR . |
|
| 184 | + $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName); |
|
| 185 | + $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
| 186 | + $inspectPath.DIRECTORY_SEPARATOR. |
|
| 187 | 187 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
| 188 | - if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 189 | - $res = t('Revisando directorio: ') . $inspectPath; |
|
| 190 | - $res .= t('Comando ejecutado: ') . $cmdPhp; |
|
| 188 | + if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 189 | + $res = t('Revisando directorio: ').$inspectPath; |
|
| 190 | + $res .= t('Comando ejecutado: ').$cmdPhp; |
|
| 191 | 191 | $res .= shell_exec($cmdPhp); |
| 192 | 192 | usleep(10); |
| 193 | 193 | $translations[] = $res; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | // Creates the src folder |
| 25 | 25 | GeneratorHelper::createDir($modPath); |
| 26 | 26 | // Create module path |
| 27 | - GeneratorHelper::createDir($modPath . $module); |
|
| 27 | + GeneratorHelper::createDir($modPath.$module); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | Logger::log("Generamos la estructura"); |
| 41 | 41 | $paths = [ |
| 42 | 42 | "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc", |
| 43 | - "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES" |
|
| 43 | + "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES" |
|
| 44 | 44 | ]; |
| 45 | - $modulePath = $modPath . $module; |
|
| 45 | + $modulePath = $modPath.$module; |
|
| 46 | 46 | foreach ($paths as $path) { |
| 47 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . $path); |
|
| 47 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR.$path); |
|
| 48 | 48 | } |
| 49 | 49 | //Creamos las carpetas de los assets |
| 50 | 50 | $htmlPaths = array("css", "js", "img", "media", "font"); |
| 51 | 51 | foreach ($htmlPaths as $path) { |
| 52 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
| 52 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | //Generamos el fichero de configuración |
| 65 | 65 | Logger::log("Generamos ficheros para assets base"); |
| 66 | 66 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
| 67 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
| 67 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
| 68 | 68 | $force); |
| 69 | 69 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
| 70 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
| 70 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
| 71 | 71 | $force); |
| 72 | 72 | return ($css && $js); |
| 73 | 73 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | "class" => $class, |
| 90 | 90 | )); |
| 91 | 91 | return $this->writeTemplateToFile($controller, |
| 92 | - $modPath . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
| 92 | + $modPath.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
| 93 | 93 | $force); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | "autoloader" => preg_replace('/(\\\|\/)/', '_', $module), |
| 109 | 109 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
| 110 | 110 | )); |
| 111 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
| 111 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
| 112 | 112 | |
| 113 | 113 | Logger::log("Generamos el phpunit"); |
| 114 | 114 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
| 115 | 115 | "module" => $module, |
| 116 | 116 | )); |
| 117 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
| 117 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
| 118 | 118 | return $autoload && $phpunit; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | private function getPropelPaths($modulePath) |
| 24 | 24 | { |
| 25 | - $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $modulePath; |
|
| 25 | + $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$modulePath; |
|
| 26 | 26 | GeneratorHelper::createDir($moduleDir); |
| 27 | 27 | $moduleDir = realpath($moduleDir); |
| 28 | - $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config'; |
|
| 29 | - $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql'; |
|
| 30 | - $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations'; |
|
| 28 | + $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'; |
|
| 29 | + $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql'; |
|
| 30 | + $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations'; |
|
| 31 | 31 | $paths = [ |
| 32 | 32 | 'projectDir' => $moduleDir, |
| 33 | 33 | 'outputDir' => $moduleDir, |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, $workingDir = CORE_DIR) |
| 94 | 94 | { |
| 95 | 95 | $manager->setGeneratorConfig($configGenerator); |
| 96 | - $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml'); |
|
| 96 | + $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml'); |
|
| 97 | 97 | $manager->setSchemas([$schemaFile]); |
| 98 | - $manager->setLoggerClosure(function ($message) { |
|
| 98 | + $manager->setLoggerClosure(function($message) { |
|
| 99 | 99 | Logger::log($message, LOG_INFO); |
| 100 | 100 | }); |
| 101 | 101 | $manager->setWorkingDirectory($workingDir); |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | try { |
| 29 | 29 | Cache::getInstance()->storeData($filename, $fileContent, Cache::TEXT, true); |
| 30 | 30 | $created = true; |
| 31 | - } catch (\Exception $e) { |
|
| 31 | + }catch (\Exception $e) { |
|
| 32 | 32 | Logger::log($e->getMessage(), LOG_ERR); |
| 33 | 33 | } |
| 34 | - } else { |
|
| 35 | - Logger::log($filename . t(' not exists or cant write'), LOG_ERR); |
|
| 34 | + }else { |
|
| 35 | + Logger::log($filename.t(' not exists or cant write'), LOG_ERR); |
|
| 36 | 36 | } |
| 37 | 37 | return $created; |
| 38 | 38 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function createStructureModule($module, $force = false, $type = "", $apiClass = "") |
| 40 | 40 | { |
| 41 | - $modPath = CORE_DIR . DIRECTORY_SEPARATOR; |
|
| 41 | + $modPath = CORE_DIR.DIRECTORY_SEPARATOR; |
|
| 42 | 42 | $module = ucfirst($module); |
| 43 | 43 | $this->createModulePath($module, $modPath); |
| 44 | 44 | $this->createModulePathTree($module, $modPath); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | private function createModuleBaseFiles($module, $modPath, $force = false, $controllerType = '') |
| 61 | 61 | { |
| 62 | - $modulePath = $modPath . $module; |
|
| 62 | + $modulePath = $modPath.$module; |
|
| 63 | 63 | $this->generateControllerTemplate($module, $modulePath, $force, $controllerType); |
| 64 | 64 | $this->generateServiceTemplate($module, $modulePath, $force); |
| 65 | 65 | $this->genereateAutoloaderTemplate($module, $modulePath, $force); |
@@ -87,28 +87,28 @@ discard block |
||
| 87 | 87 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
| 88 | 88 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
| 89 | 89 | "class" => $class, |
| 90 | - "controllerType" => $class . "Base", |
|
| 90 | + "controllerType" => $class."Base", |
|
| 91 | 91 | "is_base" => false |
| 92 | 92 | )); |
| 93 | - $controller = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
| 94 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
| 93 | + $controller = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
| 94 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
| 95 | 95 | |
| 96 | 96 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
| 97 | 97 | "module" => $module, |
| 98 | 98 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
| 99 | 99 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
| 100 | - "class" => $class . "Base", |
|
| 100 | + "class" => $class."Base", |
|
| 101 | 101 | "service" => $class, |
| 102 | 102 | "controllerType" => $controllerType, |
| 103 | 103 | "is_base" => true, |
| 104 | 104 | "domain" => $class, |
| 105 | 105 | )); |
| 106 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
| 107 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
| 106 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
| 107 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
| 108 | 108 | |
| 109 | - $filename = $modPath . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
| 109 | + $filename = $modPath.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
| 110 | 110 | $test = true; |
| 111 | - if(!file_exists($filename)) { |
|
| 111 | + if (!file_exists($filename)) { |
|
| 112 | 112 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
| 113 | 113 | "module" => $module, |
| 114 | 114 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | private function createModuleModels($module, $path) |
| 129 | 129 | { |
| 130 | - $modulePath = $path . $module; |
|
| 131 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $modulePath); |
|
| 130 | + $modulePath = $path.$module; |
|
| 131 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $modulePath); |
|
| 132 | 132 | |
| 133 | 133 | $configGenerator = $this->getConfigGenerator($modulePath); |
| 134 | 134 | |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
| 139 | 139 | "module" => $module, |
| 140 | 140 | )); |
| 141 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $modulePath . DIRECTORY_SEPARATOR . "Config" . |
|
| 142 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
| 141 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$modulePath.DIRECTORY_SEPARATOR."Config". |
|
| 142 | + DIRECTORY_SEPARATOR."config.php", true); |
|
| 143 | 143 | Logger::log("Generado config genérico para propel"); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
| 155 | 155 | { |
| 156 | 156 | $created = true; |
| 157 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
| 158 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
| 157 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
| 158 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
| 159 | 159 | if (file_exists($modelPath)) { |
| 160 | 160 | $dir = dir($modelPath); |
| 161 | 161 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | //Generamos el fichero de configuración |
| 174 | 174 | Logger::log("Generamos fichero vacío de configuración"); |
| 175 | 175 | return $this->writeTemplateToFile("<?php\n\t", |
| 176 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
| 176 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
| 177 | 177 | $force); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | "db" => $this->config->get("db_name"), |
| 195 | 195 | )); |
| 196 | 196 | return $this->writeTemplateToFile($schema, |
| 197 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
| 197 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
| 198 | 198 | $force); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
| 213 | 213 | )); |
| 214 | 214 | return $this->writeTemplateToFile($buildProperties, |
| 215 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", |
|
| 215 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", |
|
| 216 | 216 | $force); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | "module" => $module, |
| 231 | 231 | )); |
| 232 | 232 | return $this->writeTemplateToFile($index, |
| 233 | - $modPath . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
| 233 | + $modPath.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
| 234 | 234 | $force); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | )); |
| 261 | 261 | |
| 262 | 262 | return $this->writeTemplateToFile($controller, |
| 263 | - $modPath . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
| 263 | + $modPath.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | "package" => $package, |
| 286 | 286 | )); |
| 287 | 287 | |
| 288 | - return $this->writeTemplateToFile($controller, $modPath . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
| 288 | + return $this->writeTemplateToFile($controller, $modPath.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -302,15 +302,15 @@ discard block |
||
| 302 | 302 | $base = $dir->path; |
| 303 | 303 | while ($file = $dir->read()) { |
| 304 | 304 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
| 305 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
| 306 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
| 307 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
| 305 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
| 306 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
| 307 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
| 308 | 308 | && !preg_match('/I18n\.php$/i', $file) |
| 309 | 309 | && preg_match('/\.php$/i', $file) |
| 310 | 310 | ) { |
| 311 | 311 | $filename = str_replace(".php", "", $file); |
| 312 | 312 | $this->log->addLog("Generamos Api BASES para {$filename}"); |
| 313 | - if($this->checkIfIsModel($module, $filename, $package)) { |
|
| 313 | + if ($this->checkIfIsModel($module, $filename, $package)) { |
|
| 314 | 314 | $this->createApiBaseFile($module, $apiPath, $filename, $apiClass, $package); |
| 315 | 315 | $this->createApi($module, $apiPath, $force, $filename, $package); |
| 316 | 316 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $parts[] = $package; |
| 334 | 334 | } |
| 335 | 335 | $parts[] = $filename; |
| 336 | - $namespace = '\\' . implode('\\', $parts); |
|
| 336 | + $namespace = '\\'.implode('\\', $parts); |
|
| 337 | 337 | $reflectorClass = new \ReflectionClass($namespace); |
| 338 | 338 | $isModel = $reflectorClass->isInstantiable(); |
| 339 | 339 | return $isModel; |