@@ -72,67 +72,67 @@ discard block |
||
72 | 72 | $classLoader->inject('logger', $container->logger) |
73 | 73 | ->inject('applicationInfo', $container->applicationInfo); |
74 | 74 | $pageName = $this->getPageName(); |
75 | - $serviceClassName = $pageName . "Service"; |
|
76 | - $modelClassName = $pageName . "Model"; |
|
77 | - $helperClassName = $pageName . "Helper"; |
|
78 | - $appRoot = $container->applicationInfo->applicationRoot . "/app"; |
|
75 | + $serviceClassName = $pageName."Service"; |
|
76 | + $modelClassName = $pageName."Model"; |
|
77 | + $helperClassName = $pageName."Helper"; |
|
78 | + $appRoot = $container->applicationInfo->applicationRoot."/app"; |
|
79 | 79 | $controllerNamespace = $this->getNamespace($appRoot, $container->router->controller); |
80 | 80 | $serviceNamespace = $this->getNamespace($appRoot, $serviceClassName); |
81 | 81 | $modelNamespace = $this->getNamespace($appRoot, $modelClassName); |
82 | 82 | $helperNamespace = $this->getNamespace($appRoot, $helperClassName); |
83 | 83 | |
84 | 84 | // Controller |
85 | - $this->coreContainer->controller = function () use ($container, $controllerNamespace) { |
|
86 | - $controllerClassPath = $controllerNamespace . "\\" . $container->router->controller; |
|
85 | + $this->coreContainer->controller = function() use ($container, $controllerNamespace) { |
|
86 | + $controllerClassPath = $controllerNamespace."\\".$container->router->controller; |
|
87 | 87 | if (!class_exists($controllerClassPath)) { |
88 | - throw new ClassNotFoundException("Undefined class path: " . $controllerClassPath); |
|
88 | + throw new ClassNotFoundException("Undefined class path: ".$controllerClassPath); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return new $controllerClassPath($container); |
92 | 92 | }; |
93 | 93 | |
94 | 94 | // View |
95 | - $this->coreContainer->view = function () use ($container) { |
|
95 | + $this->coreContainer->view = function() use ($container) { |
|
96 | 96 | return new CoreView($container); |
97 | 97 | }; |
98 | 98 | |
99 | 99 | // Service |
100 | 100 | if ($serviceNamespace !== null) { |
101 | - $serviceClassPath = $serviceNamespace . "\\" . $serviceClassName; |
|
102 | - $this->coreContainer->service = function () use ($container, $classLoader, $serviceClassPath, $serviceClassName) { |
|
103 | - if ($classLoader->import($container->applicationInfo->applicationDir . "/services/" . $serviceClassName . ".php")) { |
|
101 | + $serviceClassPath = $serviceNamespace."\\".$serviceClassName; |
|
102 | + $this->coreContainer->service = function() use ($container, $classLoader, $serviceClassPath, $serviceClassName) { |
|
103 | + if ($classLoader->import($container->applicationInfo->applicationDir."/services/".$serviceClassName.".php")) { |
|
104 | 104 | return new $serviceClassPath($container); |
105 | 105 | } |
106 | 106 | }; |
107 | 107 | } else { |
108 | - $this->coreContainer->service = function () {}; |
|
108 | + $this->coreContainer->service = function() {}; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Model |
112 | 112 | if ($modelNamespace !== null) { |
113 | - $modelClassPath = $modelNamespace . "\\" . $modelClassName; |
|
114 | - $this->coreContainer->model = function () use ($container, $classLoader, $modelClassPath, $modelClassName) { |
|
115 | - if ($classLoader->import($container->applicationInfo->applicationDir . "/models/" . $modelClassName . ".php")) { |
|
113 | + $modelClassPath = $modelNamespace."\\".$modelClassName; |
|
114 | + $this->coreContainer->model = function() use ($container, $classLoader, $modelClassPath, $modelClassName) { |
|
115 | + if ($classLoader->import($container->applicationInfo->applicationDir."/models/".$modelClassName.".php")) { |
|
116 | 116 | return new $modelClassPath($container); |
117 | 117 | } |
118 | 118 | }; |
119 | 119 | } else { |
120 | 120 | $classpath = "\WebStream\Exception\Extend\ClassNotFoundException"; |
121 | - $message = $pageName . "Service and " . $pageName . "Model is not defined."; |
|
121 | + $message = $pageName."Service and ".$pageName."Model is not defined."; |
|
122 | 122 | $this->coreContainer->model = new CoreExceptionDelegator($classpath, $message); |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Helper |
126 | 126 | if ($helperNamespace !== null) { |
127 | - $helperClassPath = $helperNamespace . "\\" . $helperClassName; |
|
128 | - $this->coreContainer->helper = function () use ($container, $classLoader, $helperClassPath, $helperClassName) { |
|
129 | - if ($classLoader->import($container->applicationInfo->applicationDir . "/helpers/" . $helperClassName . ".php")) { |
|
127 | + $helperClassPath = $helperNamespace."\\".$helperClassName; |
|
128 | + $this->coreContainer->helper = function() use ($container, $classLoader, $helperClassPath, $helperClassName) { |
|
129 | + if ($classLoader->import($container->applicationInfo->applicationDir."/helpers/".$helperClassName.".php")) { |
|
130 | 130 | return new $helperClassPath($container); |
131 | 131 | } |
132 | 132 | }; |
133 | 133 | } else { |
134 | 134 | $classpath = "\WebStream\Exception\Extend\ClassNotFoundException"; |
135 | - $message = $pageName . "Helper is not defined."; |
|
135 | + $message = $pageName."Helper is not defined."; |
|
136 | 136 | $this->coreContainer->helper = new CoreExceptionDelegator($classpath, $message); |
137 | 137 | } |
138 | 138 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | \RecursiveIteratorIterator::CATCH_GET_CHILD // for Permission deny |
153 | 153 | ); |
154 | 154 | foreach ($iterator as $filepath => $fileObject) { |
155 | - if (strpos($filepath, $className . ".php") !== false) { |
|
155 | + if (strpos($filepath, $className.".php") !== false) { |
|
156 | 156 | return $this->getDefinedNamespace($filepath); |
157 | 157 | } |
158 | 158 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace WebStream\Module; |
3 | 3 | |
4 | -require_once dirname(__FILE__) . '/Utility/FileUtils.php'; |
|
5 | -require_once dirname(__FILE__) . '/../DI/Injector.php'; |
|
4 | +require_once dirname(__FILE__).'/Utility/FileUtils.php'; |
|
5 | +require_once dirname(__FILE__).'/../DI/Injector.php'; |
|
6 | 6 | |
7 | 7 | use WebStream\Module\Utility\ApplicationUtils; |
8 | 8 | use WebStream\Module\Utility\FileUtils; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function import($filepath, callable $filter = null) |
51 | 51 | { |
52 | - $includeFile = $this->applicationRoot . "/" . $filepath; |
|
52 | + $includeFile = $this->applicationRoot."/".$filepath; |
|
53 | 53 | if (is_file($includeFile)) { |
54 | 54 | $ext = pathinfo($includeFile, PATHINFO_EXTENSION); |
55 | 55 | if ($ext === 'php') { |
56 | 56 | if ($filter === null || (is_callable($filter) && $filter($includeFile) === true)) { |
57 | 57 | include_once $includeFile; |
58 | - $this->logger->debug($includeFile . " import success."); |
|
58 | + $this->logger->debug($includeFile." import success."); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function importAll($dirPath, callable $filter = null) |
75 | 75 | { |
76 | - $includeDir = realpath($this->applicationRoot . "/" . $dirPath); |
|
76 | + $includeDir = realpath($this->applicationRoot."/".$dirPath); |
|
77 | 77 | if (is_dir($includeDir)) { |
78 | 78 | $iterator = $this->getFileSearchIterator($includeDir); |
79 | 79 | $isSuccess = true; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | if ($ext === 'php') { |
87 | 87 | if ($filter === null || (is_callable($filter) && $filter($filepath) === true)) { |
88 | 88 | include_once $filepath; |
89 | - $this->logger->debug($filepath . " import success."); |
|
89 | + $this->logger->debug($filepath." import success."); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } else { |
93 | - $this->logger->warn($filepath . " import failure."); |
|
93 | + $this->logger->warn($filepath." import failure."); |
|
94 | 94 | $isSuccess = false; |
95 | 95 | } |
96 | 96 | } |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | // appディレクトリを名前空間付きで全検索し、マッチするもの全てをincludeする |
117 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
117 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
118 | 118 | $includeList = []; |
119 | 119 | foreach ($iterator as $filepath => $fileObject) { |
120 | - if (strpos($filepath, $className . ".php") !== false) { |
|
120 | + if (strpos($filepath, $className.".php") !== false) { |
|
121 | 121 | include_once $filepath; |
122 | 122 | $includeList[] = $filepath; |
123 | - $this->logger->debug($filepath . " load success. (search from " . $rootDir . "/app/)"); |
|
123 | + $this->logger->debug($filepath." load success. (search from ".$rootDir."/app/)"); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | if (!empty($includeList)) { |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | $classNameWithoutNamespace = $matches[1]; |
134 | 134 | // この処理が走るケースはapp配下のクラスがディレクトリ構成と名前空間が一致していない |
135 | 135 | // 場合以外ない(テスト用クラス除く)ので、app配下の検索を優先する |
136 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
136 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
137 | 137 | foreach ($iterator as $filepath => $fileObject) { |
138 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
138 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
139 | 139 | include_once $filepath; |
140 | 140 | $includeList[] = $filepath; |
141 | - $this->logger->debug($filepath . " load success. (full search)"); |
|
141 | + $this->logger->debug($filepath." load success. (full search)"); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | if (!empty($includeList)) { |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // プロジェクトルート配下すべてのディレクトリを検索する |
149 | - $iterator = $this->getFileSearchIterator($rootDir . "/core"); |
|
149 | + $iterator = $this->getFileSearchIterator($rootDir."/core"); |
|
150 | 150 | foreach ($iterator as $filepath => $fileObject) { |
151 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
151 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
152 | 152 | include_once $filepath; |
153 | 153 | $includeList[] = $filepath; |
154 | - $this->logger->debug($filepath . " load success. (full search, use in test)"); |
|
154 | + $this->logger->debug($filepath." load success. (full search, use in test)"); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (!empty($includeList)) { |