@@ -80,33 +80,33 @@ |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Method combines both [[setHasCache()]] and [[getHasCache()]] methods to retrieve value identified by a $key, |
|
| 84 | - * or to store the result of $closure execution if there is no cache available for the $key. |
|
| 85 | - * |
|
| 86 | - * Usage example: |
|
| 87 | - * |
|
| 88 | - * ```php |
|
| 89 | - * use CacheableTrait; |
|
| 90 | - * |
|
| 91 | - * public function getTopProducts($count = 10) |
|
| 92 | - * { |
|
| 93 | - * return $this->getOrSetHasCache(['top-n-products', 'n' => $count], function ($cache) use ($count) { |
|
| 94 | - * return Products::find()->mostPopular()->limit(10)->all(); |
|
| 95 | - * }, 1000); |
|
| 96 | - * } |
|
| 97 | - * ``` |
|
| 98 | - * |
|
| 99 | - * @param mixed $key a key identifying the value to be cached. This can be a simple string or |
|
| 100 | - * a complex data structure consisting of factors representing the key. |
|
| 101 | - * @param \Closure $closure the closure that will be used to generate a value to be cached. |
|
| 102 | - * In case $closure returns `false`, the value will not be cached. |
|
| 103 | - * @param int $duration default duration in seconds before the cache will expire. If not set, |
|
| 104 | - * [[defaultDuration]] value will be used. 0 means never expire. |
|
| 105 | - * @param Dependency $dependency dependency of the cached item. If the dependency changes, |
|
| 106 | - * the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. |
|
| 107 | - * This parameter is ignored if [[serializer]] is `false`. |
|
| 108 | - * @return mixed result of $closure execution |
|
| 109 | - */ |
|
| 83 | + * Method combines both [[setHasCache()]] and [[getHasCache()]] methods to retrieve value identified by a $key, |
|
| 84 | + * or to store the result of $closure execution if there is no cache available for the $key. |
|
| 85 | + * |
|
| 86 | + * Usage example: |
|
| 87 | + * |
|
| 88 | + * ```php |
|
| 89 | + * use CacheableTrait; |
|
| 90 | + * |
|
| 91 | + * public function getTopProducts($count = 10) |
|
| 92 | + * { |
|
| 93 | + * return $this->getOrSetHasCache(['top-n-products', 'n' => $count], function ($cache) use ($count) { |
|
| 94 | + * return Products::find()->mostPopular()->limit(10)->all(); |
|
| 95 | + * }, 1000); |
|
| 96 | + * } |
|
| 97 | + * ``` |
|
| 98 | + * |
|
| 99 | + * @param mixed $key a key identifying the value to be cached. This can be a simple string or |
|
| 100 | + * a complex data structure consisting of factors representing the key. |
|
| 101 | + * @param \Closure $closure the closure that will be used to generate a value to be cached. |
|
| 102 | + * In case $closure returns `false`, the value will not be cached. |
|
| 103 | + * @param int $duration default duration in seconds before the cache will expire. If not set, |
|
| 104 | + * [[defaultDuration]] value will be used. 0 means never expire. |
|
| 105 | + * @param Dependency $dependency dependency of the cached item. If the dependency changes, |
|
| 106 | + * the corresponding value in the cache will be invalidated when it is fetched via [[get()]]. |
|
| 107 | + * This parameter is ignored if [[serializer]] is `false`. |
|
| 108 | + * @return mixed result of $closure execution |
|
| 109 | + */ |
|
| 110 | 110 | public function getOrSetHasCache($key, \Closure $closure, $duration = null, $dependency = null) |
| 111 | 111 | { |
| 112 | 112 | if (($value = $this->getHasCache($key)) !== false) { |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Place extends BaseThing implements PlaceInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @inheritdoc |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @inheritdoc |
|
| 17 | + */ |
|
| 18 | 18 | public function typeDefintion() |
| 19 | 19 | { |
| 20 | 20 | return 'Place'; |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Organization extends BaseThing implements OrganizationInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @inheritdoc |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @inheritdoc |
|
| 17 | + */ |
|
| 18 | 18 | public function typeDefintion() |
| 19 | 19 | { |
| 20 | 20 | return 'Organization'; |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Person extends BaseThing implements PersonInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @inheritdoc |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @inheritdoc |
|
| 17 | + */ |
|
| 18 | 18 | public function typeDefintion() |
| 19 | 19 | { |
| 20 | 20 | return 'Person'; |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Thing extends BaseThing |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @inheritdoc |
|
| 19 | - */ |
|
| 20 | - public function typeDefintion() |
|
| 21 | - { |
|
| 22 | - return 'Thing'; |
|
| 23 | - } |
|
| 17 | + /** |
|
| 18 | + * @inheritdoc |
|
| 19 | + */ |
|
| 20 | + public function typeDefintion() |
|
| 21 | + { |
|
| 22 | + return 'Thing'; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Event extends BaseThing implements EventInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @inheritdoc |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @inheritdoc |
|
| 17 | + */ |
|
| 18 | 18 | public function typeDefintion() |
| 19 | 19 | { |
| 20 | 20 | return 'Event'; |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class BaseDevCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var string The location of the devconfig json where data is stored. |
|
| 20 | - */ |
|
| 18 | + /** |
|
| 19 | + * @var string The location of the devconfig json where data is stored. |
|
| 20 | + */ |
|
| 21 | 21 | public $configFile = '@appFolder/devconfig.json'; |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -27,17 +27,17 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function actionConfigInfo() |
| 29 | 29 | { |
| 30 | - $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile)); |
|
| 30 | + $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile)); |
|
| 31 | 31 | |
| 32 | - $config = $this->readConfig(); |
|
| 32 | + $config = $this->readConfig(); |
|
| 33 | 33 | |
| 34 | - if (!$config) { |
|
| 35 | - return $this->outputError("Unable to open config file."); |
|
| 36 | - } |
|
| 34 | + if (!$config) { |
|
| 35 | + return $this->outputError("Unable to open config file."); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - foreach ($config as $key => $value) { |
|
| 39 | - $this->output("{$key} => {$value}"); |
|
| 40 | - } |
|
| 38 | + foreach ($config as $key => $value) { |
|
| 39 | + $this->output("{$key} => {$value}"); |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class RepoController extends BaseDevCommand |
| 33 | 33 | { |
| 34 | - const CONFIG_VAR_USERNAME = 'username'; |
|
| 34 | + const CONFIG_VAR_USERNAME = 'username'; |
|
| 35 | 35 | |
| 36 | - const CONFIG_VAR_CLONETYPE = 'cloneType'; |
|
| 36 | + const CONFIG_VAR_CLONETYPE = 'cloneType'; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string Default action is actionInit(); |
|
| 40 | - */ |
|
| 41 | - public $defaultAction = 'init'; |
|
| 38 | + /** |
|
| 39 | + * @var string Default action is actionInit(); |
|
| 40 | + */ |
|
| 41 | + public $defaultAction = 'init'; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var array The default repos from luyadev |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var array The default repos from luyadev |
|
| 45 | + */ |
|
| 46 | 46 | public $repos = [ |
| 47 | 47 | 'luya', |
| 48 | 48 | 'luya-module-admin', |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function actionClone($repo = null, $vendor = null) |
| 168 | 168 | { |
| 169 | - if (empty($repo)) { |
|
| 170 | - $repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)"); |
|
| 171 | - } |
|
| 169 | + if (empty($repo)) { |
|
| 170 | + $repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)"); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if (empty($vendor)) { |
|
| 174 | - $vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)"); |
|
| 175 | - } |
|
| 173 | + if (empty($vendor)) { |
|
| 174 | + $vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)"); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor); |
|
| 177 | + return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | private $_gitWrapper; |
@@ -184,38 +184,38 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function getGitWrapper() |
| 186 | 186 | { |
| 187 | - if ($this->_gitWrapper === null) { |
|
| 188 | - $this->_gitWrapper = new GitWrapper(); |
|
| 189 | - $this->_gitWrapper->setTimeout(300); |
|
| 190 | - } |
|
| 187 | + if ($this->_gitWrapper === null) { |
|
| 188 | + $this->_gitWrapper = new GitWrapper(); |
|
| 189 | + $this->_gitWrapper->setTimeout(300); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - return $this->_gitWrapper; |
|
| 192 | + return $this->_gitWrapper; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | private function summaryItem($repo, $isFork, $exists) |
| 196 | 196 | { |
| 197 | - return [$repo, $exists, $isFork]; |
|
| 197 | + return [$repo, $exists, $isFork]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | private function getFilesystemRepoPath($repo) |
| 201 | 201 | { |
| 202 | - return 'repos' . DIRECTORY_SEPARATOR . $repo; |
|
| 202 | + return 'repos' . DIRECTORY_SEPARATOR . $repo; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | private function forkExists($username, $repo) |
| 206 | 206 | { |
| 207 | - return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess(); |
|
| 207 | + return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess(); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | private function markdown($text, $paragraph = false) |
| 211 | 211 | { |
| 212 | - $parser = new Markdown(); |
|
| 212 | + $parser = new Markdown(); |
|
| 213 | 213 | |
| 214 | - if ($paragraph) { |
|
| 215 | - return $parser->parseParagraph($text); |
|
| 216 | - } |
|
| 214 | + if ($paragraph) { |
|
| 215 | + return $parser->parseParagraph($text); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - return $parser->parse($text); |
|
| 218 | + return $parser->parse($text); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | private function getCloneUrlBasedOnType($repo, $username) |
| 229 | 229 | { |
| 230 | - return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git"; |
|
| 230 | + return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git"; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | private function cloneRepo($repo, $cloneUrl, $newRepoHome, $upstreamUsername) |
| 242 | 242 | { |
| 243 | - $this->outputSuccess("{$repo}: cloning ..."); |
|
| 244 | - $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome); |
|
| 245 | - if (!empty($upstreamUsername)) { |
|
| 246 | - $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
| 247 | - $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git"); |
|
| 248 | - } |
|
| 249 | - $this->outputSuccess("{$repo}: ✔ complete"); |
|
| 243 | + $this->outputSuccess("{$repo}: cloning ..."); |
|
| 244 | + $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome); |
|
| 245 | + if (!empty($upstreamUsername)) { |
|
| 246 | + $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome); |
|
| 247 | + $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git"); |
|
| 248 | + } |
|
| 249 | + $this->outputSuccess("{$repo}: ✔ complete"); |
|
| 250 | 250 | } |
| 251 | 251 | } |