@@ -29,13 +29,19 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | # Validate name |
| 31 | 31 | |
| 32 | - if (false === ($name = Validate::templateComponentName($name))) return ['name', 'VARIABLE_ERROR_NAME_INVALID']; |
|
| 32 | + if (false === ($name = Validate::templateComponentName($name))) { |
|
| 33 | + return ['name', 'VARIABLE_ERROR_NAME_INVALID']; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | # Check name exists |
| 35 | 37 | |
| 36 | - if (false === ($check_name = $this->variable->check($name, 'name'))) return 'VARIABLE_ERROR_MODIFY'; |
|
| 38 | + if (false === ($check_name = $this->variable->check($name, 'name'))) { |
|
| 39 | + return 'VARIABLE_ERROR_MODIFY'; |
|
| 40 | + } |
|
| 37 | 41 | |
| 38 | - if ($check_name === 1) return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
| 42 | + if ($check_name === 1) { |
|
| 43 | + return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
| 44 | + } |
|
| 39 | 45 | |
| 40 | 46 | # Modify variable |
| 41 | 47 | |
@@ -47,7 +53,9 @@ discard block |
||
| 47 | 53 | |
| 48 | 54 | $modifier = ((0 === $this->variable->id) ? 'create' : 'edit'); |
| 49 | 55 | |
| 50 | - if (!$this->variable->$modifier($data)) return 'VARIABLE_ERROR_MODIFY'; |
|
| 56 | + if (!$this->variable->$modifier($data)) { |
|
| 57 | + return 'VARIABLE_ERROR_MODIFY'; |
|
| 58 | + } |
|
| 51 | 59 | |
| 52 | 60 | # ------------------------ |
| 53 | 61 | |
@@ -29,13 +29,19 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | # Validate name |
| 31 | 31 | |
| 32 | - if (false === ($name = Validate::templateComponentName($name))) return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
| 32 | + if (false === ($name = Validate::templateComponentName($name))) { |
|
| 33 | + return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | # Check name exists |
| 35 | 37 | |
| 36 | - if (false === ($check_name = $this->widget->check($name, 'name'))) return 'WIDGET_ERROR_MODIFY'; |
|
| 38 | + if (false === ($check_name = $this->widget->check($name, 'name'))) { |
|
| 39 | + return 'WIDGET_ERROR_MODIFY'; |
|
| 40 | + } |
|
| 37 | 41 | |
| 38 | - if ($check_name === 1) return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
| 42 | + if ($check_name === 1) { |
|
| 43 | + return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
| 44 | + } |
|
| 39 | 45 | |
| 40 | 46 | # Modify widget |
| 41 | 47 | |
@@ -48,7 +54,9 @@ discard block |
||
| 48 | 54 | |
| 49 | 55 | $modifier = ((0 === $this->widget->id) ? 'create' : 'edit'); |
| 50 | 56 | |
| 51 | - if (!$this->widget->$modifier($data)) return 'WIDGET_ERROR_MODIFY'; |
|
| 57 | + if (!$this->widget->$modifier($data)) { |
|
| 58 | + return 'WIDGET_ERROR_MODIFY'; |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | # ------------------------ |
| 54 | 62 | |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | |
| 68 | 68 | if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
| 69 | 69 | |
| 70 | - self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
|
| 70 | + self::$routes['/'.implode('/', $path)] = ('Addons\\'.$name.'\\'.implode('\\', $handler)); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | # Parse item |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $parts = preg_split('/\//', $string, 0, PREG_SPLIT_NO_EMPTY); |
| 54 | 54 | |
| 55 | - foreach ($parts as $name) if (!preg_match($regex, $name)) return false; |
|
| 55 | + foreach ($parts as $name) { |
|
| 56 | + if (!preg_match($regex, $name)) return false; |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | # ------------------------ |
| 58 | 60 | |
@@ -63,9 +65,13 @@ discard block |
||
| 63 | 65 | |
| 64 | 66 | private static function parseRoute(string $name, array $route) { |
| 65 | 67 | |
| 66 | - if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) return; |
|
| 68 | + if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 67 | 71 | |
| 68 | - if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
|
| 72 | + if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 69 | 75 | |
| 70 | 76 | self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
| 71 | 77 | } |
@@ -74,14 +80,18 @@ discard block |
||
| 74 | 80 | |
| 75 | 81 | private static function parseItem(array $item) { |
| 76 | 82 | |
| 77 | - foreach ($item['routes'] as $route) self::parseRoute($item['name'], $route); |
|
| 83 | + foreach ($item['routes'] as $route) { |
|
| 84 | + self::parseRoute($item['name'], $route); |
|
| 85 | + } |
|
| 78 | 86 | } |
| 79 | 87 | |
| 80 | 88 | # Autoloader |
| 81 | 89 | |
| 82 | 90 | public static function __autoload() { |
| 83 | 91 | |
| 84 | - foreach (Extend\Addons::items() as $item) self::parseItem($item); |
|
| 92 | + foreach (Extend\Addons::items() as $item) { |
|
| 93 | + self::parseItem($item); |
|
| 94 | + } |
|
| 85 | 95 | } |
| 86 | 96 | |
| 87 | 97 | # Get handler by url |