@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | $objects = scandir($dir); |
| 24 | 24 | foreach ($objects as $object) { |
| 25 | 25 | if ($object != "." && $object != "..") { |
| 26 | - if (filetype($dir . "/" . $object) == "dir") { |
|
| 27 | - self::deleteDir($dir . "/" . $object); |
|
| 28 | - } else { |
|
| 29 | - unlink($dir . "/" . $object); |
|
| 26 | + if (filetype($dir."/".$object) == "dir") { |
|
| 27 | + self::deleteDir($dir."/".$object); |
|
| 28 | + }else { |
|
| 29 | + unlink($dir."/".$object); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $rootDirs = array("css", "js", "media", "font"); |
| 44 | 44 | foreach ($rootDirs as $dir) { |
| 45 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 45 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 46 | 46 | try { |
| 47 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 48 | - } catch (\Exception $e) { |
|
| 47 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 48 | + }catch (\Exception $e) { |
|
| 49 | 49 | syslog(LOG_INFO, $e->getMessage()); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | try { |
| 63 | 63 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 64 | - throw new \Exception(t('Can\'t create directory ') . $dir); |
|
| 64 | + throw new \Exception(t('Can\'t create directory ').$dir); |
|
| 65 | 65 | } |
| 66 | - } catch (\Exception $e) { |
|
| 66 | + }catch (\Exception $e) { |
|
| 67 | 67 | syslog(LOG_WARNING, $e->getMessage()); |
| 68 | 68 | if (!file_exists(dirname($dir))) { |
| 69 | - throw new GeneratorException($e->getMessage() . $dir); |
|
| 69 | + throw new GeneratorException($e->getMessage().$dir); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public static function getTemplatePath() |
| 79 | 79 | { |
| 80 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 80 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 81 | 81 | return realpath($path); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | * @throws \ReflectionException |
| 97 | 97 | */ |
| 98 | 98 | public static function checkCustomNamespaceApi($namespace) { |
| 99 | - if(!empty($namespace)) { |
|
| 100 | - if(class_exists($namespace)) { |
|
| 99 | + if (!empty($namespace)) { |
|
| 100 | + if (class_exists($namespace)) { |
|
| 101 | 101 | $reflector = new \ReflectionClass($namespace); |
| 102 | - if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
| 102 | + if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
| 103 | 103 | throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
| 104 | - } elseif(!$reflector->isAbstract()) { |
|
| 104 | + } elseif (!$reflector->isAbstract()) { |
|
| 105 | 105 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
| 106 | 106 | } |
| 107 | - } else { |
|
| 107 | + }else { |
|
| 108 | 108 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | 117 | public static function getDomainPaths($domain) { |
| 118 | - $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true); |
|
| 118 | + $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true); |
|
| 119 | 119 | $paths = []; |
| 120 | - if(null !== $domains) { |
|
| 120 | + if (null !== $domains) { |
|
| 121 | 121 | $keyDomains = array_keys($domains); |
| 122 | - foreach($keyDomains as $keyDomain) { |
|
| 122 | + foreach ($keyDomains as $keyDomain) { |
|
| 123 | 123 | $key = strtoupper(str_replace(['@', '/'], '', $keyDomain)); |
| 124 | - if(strtoupper($domain) === $key) { |
|
| 124 | + if (strtoupper($domain) === $key) { |
|
| 125 | 125 | $paths = $domains[$keyDomain]; |
| 126 | 126 | break; |
| 127 | 127 | } |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public static function createRoot($path = WEB_DIR, OutputInterface $output = null) { |
| 139 | 139 | |
| 140 | - if(null === $output) { |
|
| 140 | + if (null === $output) { |
|
| 141 | 141 | $output = new ConsoleOutput(); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | GeneratorHelper::createDir($path); |
| 145 | 145 | $paths = array("js", "css", "img", "media", "font"); |
| 146 | 146 | foreach ($paths as $htmlPath) { |
| 147 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
| 147 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Generates the root needed files |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | ]; |
| 158 | 158 | $output->writeln('Start creating html files'); |
| 159 | 159 | foreach ($files as $templates => $filename) { |
| 160 | - $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
| 161 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
| 162 | - $output->writeln('Can\t create the file ' . $filename); |
|
| 163 | - } else { |
|
| 164 | - $output->writeln($filename . ' created successfully'); |
|
| 160 | + $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
| 161 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
| 162 | + $output->writeln('Can\t create the file '.$filename); |
|
| 163 | + }else { |
|
| 164 | + $output->writeln($filename.' created successfully'); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | //Export base locale translations |
| 169 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
| 170 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 171 | - GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 169 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
| 170 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 171 | + GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | \ No newline at end of file |