@@ -127,7 +127,6 @@ |
||
| 127 | 127 | * |
| 128 | 128 | * @link http://www.faqs.org/rfcs/rfc4646.html Tags for Identifying Languages |
| 129 | 129 | * @link http://www.faqs.org/rfcs/rfc4647.html Matching of Language Tags |
| 130 | - * @param string $ident Language identifier |
|
| 131 | 130 | * @return self |
| 132 | 131 | * |
| 133 | 132 | * @todo Implement proper ISO 639 sanitization |
@@ -13,30 +13,30 @@ discard block |
||
| 13 | 13 | class Language implements LanguageInterface |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * The language identifier, commonly a ISO 639 code |
|
| 17 | - * |
|
| 18 | - * @var string $ident |
|
| 19 | - */ |
|
| 16 | + * The language identifier, commonly a ISO 639 code |
|
| 17 | + * |
|
| 18 | + * @var string $ident |
|
| 19 | + */ |
|
| 20 | 20 | private $ident; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * The language name |
|
| 24 | - * |
|
| 25 | - * @var TranslationString $name; |
|
| 26 | - */ |
|
| 23 | + * The language name |
|
| 24 | + * |
|
| 25 | + * @var TranslationString $name; |
|
| 26 | + */ |
|
| 27 | 27 | private $name; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * The language locale |
|
| 31 | - * |
|
| 32 | - * @var string $locale; |
|
| 33 | - */ |
|
| 30 | + * The language locale |
|
| 31 | + * |
|
| 32 | + * @var string $locale; |
|
| 33 | + */ |
|
| 34 | 34 | private $locale; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * @param array $data |
|
| 38 | - * @return self |
|
| 39 | - */ |
|
| 37 | + * @param array $data |
|
| 38 | + * @return self |
|
| 39 | + */ |
|
| 40 | 40 | public function set_data(array $data) |
| 41 | 41 | { |
| 42 | 42 | if (isset($data['ident']) && $data['ident'] !== null) { |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * Set the language identifier |
|
| 53 | - * |
|
| 54 | - * A valid ISO 639 code is recommended (either 639-1, 639-2, or 639-3). |
|
| 55 | - * Within a routable application, the identifier is most often used |
|
| 56 | - * as a base URI path. |
|
| 57 | - * |
|
| 58 | - * @param string $ident Language identifier |
|
| 59 | - * @return self |
|
| 60 | - */ |
|
| 52 | + * Set the language identifier |
|
| 53 | + * |
|
| 54 | + * A valid ISO 639 code is recommended (either 639-1, 639-2, or 639-3). |
|
| 55 | + * Within a routable application, the identifier is most often used |
|
| 56 | + * as a base URI path. |
|
| 57 | + * |
|
| 58 | + * @param string $ident Language identifier |
|
| 59 | + * @return self |
|
| 60 | + */ |
|
| 61 | 61 | public function set_ident($ident) |
| 62 | 62 | { |
| 63 | 63 | $this->ident = $ident; |
@@ -65,30 +65,30 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Get the language identifier |
|
| 69 | - * |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 68 | + * Get the language identifier |
|
| 69 | + * |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | 72 | public function ident() |
| 73 | 73 | { |
| 74 | 74 | return $this->ident; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | - * Set the name of the language and, optionally, |
|
| 79 | - * the name translated in other languages. |
|
| 80 | - * |
|
| 81 | - * @param TranslationString|array|string $name { |
|
| 82 | - * The language's name in one or more languages. |
|
| 83 | - * |
|
| 84 | - * Accept 3 types of arguments: |
|
| 85 | - * - object (TranslationStringInterface): The data will be copied from the object's. |
|
| 86 | - * - array: All languages available in the array. The format of the array should |
|
| 87 | - * be a hash in the `lang` => `string` format. |
|
| 88 | - * - string: The value will be assigned to the current language. |
|
| 89 | - * } |
|
| 90 | - * @return self |
|
| 91 | - */ |
|
| 78 | + * Set the name of the language and, optionally, |
|
| 79 | + * the name translated in other languages. |
|
| 80 | + * |
|
| 81 | + * @param TranslationString|array|string $name { |
|
| 82 | + * The language's name in one or more languages. |
|
| 83 | + * |
|
| 84 | + * Accept 3 types of arguments: |
|
| 85 | + * - object (TranslationStringInterface): The data will be copied from the object's. |
|
| 86 | + * - array: All languages available in the array. The format of the array should |
|
| 87 | + * be a hash in the `lang` => `string` format. |
|
| 88 | + * - string: The value will be assigned to the current language. |
|
| 89 | + * } |
|
| 90 | + * @return self |
|
| 91 | + */ |
|
| 92 | 92 | public function set_name($name) |
| 93 | 93 | { |
| 94 | 94 | if ($name instanceof TranslationStringInterface) { |
@@ -103,35 +103,35 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Get the name of the language |
|
| 107 | - * |
|
| 108 | - * @return TranslationString |
|
| 109 | - */ |
|
| 106 | + * Get the name of the language |
|
| 107 | + * |
|
| 108 | + * @return TranslationString |
|
| 109 | + */ |
|
| 110 | 110 | public function name() |
| 111 | 111 | { |
| 112 | 112 | return $this->name; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Alias of self::name() |
|
| 117 | - * |
|
| 118 | - * @return string |
|
| 119 | - */ |
|
| 116 | + * Alias of self::name() |
|
| 117 | + * |
|
| 118 | + * @return string |
|
| 119 | + */ |
|
| 120 | 120 | public function __toString() |
| 121 | 121 | { |
| 122 | 122 | return (string)$this->name(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * Set the language's locale |
|
| 127 | - * |
|
| 128 | - * @link http://www.faqs.org/rfcs/rfc4646.html Tags for Identifying Languages |
|
| 129 | - * @link http://www.faqs.org/rfcs/rfc4647.html Matching of Language Tags |
|
| 130 | - * @param string $ident Language identifier |
|
| 131 | - * @return self |
|
| 132 | - * |
|
| 133 | - * @todo Implement proper ISO 639 sanitization |
|
| 134 | - */ |
|
| 126 | + * Set the language's locale |
|
| 127 | + * |
|
| 128 | + * @link http://www.faqs.org/rfcs/rfc4646.html Tags for Identifying Languages |
|
| 129 | + * @link http://www.faqs.org/rfcs/rfc4647.html Matching of Language Tags |
|
| 130 | + * @param string $ident Language identifier |
|
| 131 | + * @return self |
|
| 132 | + * |
|
| 133 | + * @todo Implement proper ISO 639 sanitization |
|
| 134 | + */ |
|
| 135 | 135 | public function set_locale($locale) |
| 136 | 136 | { |
| 137 | 137 | $this->locale = $locale; |
@@ -139,24 +139,24 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Get the language's locale |
|
| 143 | - * |
|
| 144 | - * @return string |
|
| 145 | - */ |
|
| 142 | + * Get the language's locale |
|
| 143 | + * |
|
| 144 | + * @return string |
|
| 145 | + */ |
|
| 146 | 146 | public function locale() |
| 147 | 147 | { |
| 148 | 148 | return $this->locale; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * Get the language's ISO 639-1 (alpha-2) code. |
|
| 153 | - * |
|
| 154 | - * @link http://www.iso.org/iso/home/standards/language_codes.htm for specification |
|
| 155 | - * @return string |
|
| 156 | - * |
|
| 157 | - * @todo Implement proper ISO 639 sanitization |
|
| 158 | - * @todo Added support for retrieving codes in 639-1, 639-2/B, 639-2/T, and 639-3 |
|
| 159 | - */ |
|
| 152 | + * Get the language's ISO 639-1 (alpha-2) code. |
|
| 153 | + * |
|
| 154 | + * @link http://www.iso.org/iso/home/standards/language_codes.htm for specification |
|
| 155 | + * @return string |
|
| 156 | + * |
|
| 157 | + * @todo Implement proper ISO 639 sanitization |
|
| 158 | + * @todo Added support for retrieving codes in 639-1, 639-2/B, 639-2/T, and 639-3 |
|
| 159 | + */ |
|
| 160 | 160 | public function iso639() |
| 161 | 161 | { |
| 162 | 162 | return $this->ident(); |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | if ($name instanceof TranslationStringInterface) { |
| 95 | 95 | $config = $name->available_langs(); |
| 96 | 96 | } elseif (is_array($name)) { |
| 97 | - $config = [ 'languages' => array_keys($name) ]; |
|
| 97 | + $config = ['languages' => array_keys($name)]; |
|
| 98 | 98 | } else { |
| 99 | 99 | $config = null; |
| 100 | 100 | } |
@@ -44,7 +44,6 @@ |
||
| 44 | 44 | /** |
| 45 | 45 | * Set the language's locale |
| 46 | 46 | * |
| 47 | - * @param string $ident |
|
| 48 | 47 | * @return LanguageInterface Chainable |
| 49 | 48 | */ |
| 50 | 49 | public function set_locale($locale); |
@@ -5,61 +5,61 @@ |
||
| 5 | 5 | interface LanguageInterface |
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | - * @param array $data |
|
| 9 | - * @return LanguageInterface Chainable |
|
| 10 | - */ |
|
| 8 | + * @param array $data |
|
| 9 | + * @return LanguageInterface Chainable |
|
| 10 | + */ |
|
| 11 | 11 | public function set_data(array $data); |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Set the language identifier |
|
| 15 | - * |
|
| 16 | - * @param string $ident |
|
| 17 | - * @return LanguageInterface Chainable |
|
| 18 | - */ |
|
| 14 | + * Set the language identifier |
|
| 15 | + * |
|
| 16 | + * @param string $ident |
|
| 17 | + * @return LanguageInterface Chainable |
|
| 18 | + */ |
|
| 19 | 19 | public function set_ident($ident); |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * Get the language identifier |
|
| 23 | - * |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 22 | + * Get the language identifier |
|
| 23 | + * |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | 26 | public function ident(); |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Set the name of the language and, optionally, |
|
| 30 | - * the name translated in other languages. |
|
| 31 | - * |
|
| 32 | - * @param TranslationString|array|string $name |
|
| 33 | - * @return LanguageInterface Chainable |
|
| 34 | - */ |
|
| 29 | + * Set the name of the language and, optionally, |
|
| 30 | + * the name translated in other languages. |
|
| 31 | + * |
|
| 32 | + * @param TranslationString|array|string $name |
|
| 33 | + * @return LanguageInterface Chainable |
|
| 34 | + */ |
|
| 35 | 35 | public function set_name($name); |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Get the name of the language |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 38 | + * Get the name of the language |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | 42 | public function name(); |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * Set the language's locale |
|
| 46 | - * |
|
| 47 | - * @param string $ident |
|
| 48 | - * @return LanguageInterface Chainable |
|
| 49 | - */ |
|
| 45 | + * Set the language's locale |
|
| 46 | + * |
|
| 47 | + * @param string $ident |
|
| 48 | + * @return LanguageInterface Chainable |
|
| 49 | + */ |
|
| 50 | 50 | public function set_locale($locale); |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Get the language's locale |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 53 | + * Get the language's locale |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public function locale(); |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Get the language's ISO 639 code. |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 60 | + * Get the language's ISO 639 code. |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | 64 | public function iso639(); |
| 65 | 65 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @param LanguageInterface &$lang The instance that needs resolution |
| 147 | 147 | * @param array $config Array element of fallbacks |
| 148 | - * @param mixed $ident Optional key/index of $config in previous method |
|
| 148 | + * @param string|null $ident Optional key/index of $config in previous method |
|
| 149 | 149 | * @return void |
| 150 | 150 | * @throws InvalidArgumentException |
| 151 | 151 | */ |
@@ -174,7 +174,6 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * Set the manager's available languages |
| 176 | 176 | * |
| 177 | - * @param LanguageInterface[] $lang |
|
| 178 | 177 | * @return self |
| 179 | 178 | */ |
| 180 | 179 | public function set_languages($languages) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if (isset($config['languages'])) { |
| 66 | - $available_langs = array_filter($config['languages'], function ($config) { |
|
| 66 | + $available_langs = array_filter($config['languages'], function($config) { |
|
| 67 | 67 | return (!isset($config['active']) || $config['active']); |
| 68 | 68 | }); |
| 69 | 69 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public static function language_index() |
| 134 | 134 | { |
| 135 | 135 | if (!isset(self::$language_index)) { |
| 136 | - self::$language_index = new GenericConfig(__DIR__ . '/../../../../config/languages.json'); |
|
| 136 | + self::$language_index = new GenericConfig(__DIR__.'/../../../../config/languages.json'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return self::$language_index; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @return void |
| 148 | 148 | * @throws InvalidArgumentException |
| 149 | 149 | */ |
| 150 | - public function resolve_ident(LanguageInterface &$lang, $ident = null) |
|
| 150 | + public function resolve_ident(LanguageInterface & $lang, $ident = null) |
|
| 151 | 151 | { |
| 152 | 152 | if (is_string($ident)) { |
| 153 | 153 | $lang->set_ident($ident); |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | class LanguageManager extends AbstractManager |
| 24 | 24 | { |
| 25 | 25 | /** |
| 26 | - * @var array LanguageInterface |
|
| 27 | - */ |
|
| 26 | + * @var array LanguageInterface |
|
| 27 | + */ |
|
| 28 | 28 | private $languages; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * @var TranslationConfig |
|
| 32 | - */ |
|
| 31 | + * @var TranslationConfig |
|
| 32 | + */ |
|
| 33 | 33 | private $translation_config; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * @var GenericConfig |
|
| 37 | - */ |
|
| 36 | + * @var GenericConfig |
|
| 37 | + */ |
|
| 38 | 38 | private static $language_index; |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * Set up the available languages, defaults, and active |
|
| 42 | - * |
|
| 43 | - * @return void |
|
| 44 | - */ |
|
| 41 | + * Set up the available languages, defaults, and active |
|
| 42 | + * |
|
| 43 | + * @return void |
|
| 44 | + */ |
|
| 45 | 45 | public function setup() |
| 46 | 46 | { |
| 47 | 47 | $this->setup_translations(); |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * Set up the available languages, defaults, and active |
|
| 53 | - * |
|
| 54 | - * Settings: |
|
| 55 | - * - languages |
|
| 56 | - * - default_lang |
|
| 57 | - * |
|
| 58 | - * @return void |
|
| 59 | - */ |
|
| 52 | + * Set up the available languages, defaults, and active |
|
| 53 | + * |
|
| 54 | + * Settings: |
|
| 55 | + * - languages |
|
| 56 | + * - default_lang |
|
| 57 | + * |
|
| 58 | + * @return void |
|
| 59 | + */ |
|
| 60 | 60 | public function setup_translations() |
| 61 | 61 | { |
| 62 | 62 | $config = $this->config(); |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | - * Set up the available languages, defaults, and active |
|
| 85 | - * |
|
| 86 | - * @return void |
|
| 87 | - */ |
|
| 84 | + * Set up the available languages, defaults, and active |
|
| 85 | + * |
|
| 86 | + * @return void |
|
| 87 | + */ |
|
| 88 | 88 | public function setup_languages() |
| 89 | 89 | { |
| 90 | 90 | $config = $this->config(); |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * Resolve a string identifier for a given Language. |
|
| 149 | - * |
|
| 150 | - * @param LanguageInterface &$lang The instance that needs resolution |
|
| 151 | - * @param mixed $ident Optional key/index of $config in previous method |
|
| 152 | - * @return void |
|
| 153 | - * @throws InvalidArgumentException |
|
| 154 | - */ |
|
| 148 | + * Resolve a string identifier for a given Language. |
|
| 149 | + * |
|
| 150 | + * @param LanguageInterface &$lang The instance that needs resolution |
|
| 151 | + * @param mixed $ident Optional key/index of $config in previous method |
|
| 152 | + * @return void |
|
| 153 | + * @throws InvalidArgumentException |
|
| 154 | + */ |
|
| 155 | 155 | public function resolve_ident(LanguageInterface &$lang, $ident = null) |
| 156 | 156 | { |
| 157 | 157 | if (is_string($ident)) { |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | - * Set the manager's available languages |
|
| 182 | - * |
|
| 183 | - * @param LanguageInterface[] $lang |
|
| 184 | - * @return self |
|
| 185 | - * @throws InvalidArgumentException if array has a member that isn't an instance of Language |
|
| 186 | - */ |
|
| 181 | + * Set the manager's available languages |
|
| 182 | + * |
|
| 183 | + * @param LanguageInterface[] $lang |
|
| 184 | + * @return self |
|
| 185 | + * @throws InvalidArgumentException if array has a member that isn't an instance of Language |
|
| 186 | + */ |
|
| 187 | 187 | public function set_languages($languages) |
| 188 | 188 | { |
| 189 | 189 | $this->languages = []; |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * Add or update an available language to the manager |
|
| 203 | - * |
|
| 204 | - * @param LanguageInterface $lang |
|
| 205 | - * @return self |
|
| 206 | - */ |
|
| 202 | + * Add or update an available language to the manager |
|
| 203 | + * |
|
| 204 | + * @param LanguageInterface $lang |
|
| 205 | + * @return self |
|
| 206 | + */ |
|
| 207 | 207 | public function add_language(LanguageInterface $lang) |
| 208 | 208 | { |
| 209 | 209 | $this->languages[$lang->ident()] = $lang; |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * Get the manager's list of available languages |
|
| 215 | - * |
|
| 216 | - * @return LanguageInterface[] |
|
| 217 | - */ |
|
| 214 | + * Get the manager's list of available languages |
|
| 215 | + * |
|
| 216 | + * @return LanguageInterface[] |
|
| 217 | + */ |
|
| 218 | 218 | public function languages() |
| 219 | 219 | { |
| 220 | 220 | return $this->languages; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * Set the manager's translations for TranslationConfig |
|
| 225 | - * |
|
| 226 | - * @param array|TranslationConfig $translation |
|
| 227 | - * @return self |
|
| 228 | - */ |
|
| 224 | + * Set the manager's translations for TranslationConfig |
|
| 225 | + * |
|
| 226 | + * @param array|TranslationConfig $translation |
|
| 227 | + * @return self |
|
| 228 | + */ |
|
| 229 | 229 | public function set_translation($translation) |
| 230 | 230 | { |
| 231 | 231 | if ($translation instanceof TranslationConfig) { |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | - * Get the manager's translations |
|
| 241 | - * |
|
| 242 | - * @return TranslationConfig |
|
| 243 | - */ |
|
| 240 | + * Get the manager's translations |
|
| 241 | + * |
|
| 242 | + * @return TranslationConfig |
|
| 243 | + */ |
|
| 244 | 244 | public function translation() |
| 245 | 245 | { |
| 246 | 246 | return $this->translation_config; |
@@ -12,7 +12,6 @@ discard block |
||
| 12 | 12 | interface RoutableInterface |
| 13 | 13 | { |
| 14 | 14 | /** |
| 15 | - * @param boolean $data |
|
| 16 | 15 | * @return RoutableInterface Chainable |
| 17 | 16 | */ |
| 18 | 17 | public function set_routable($routable); |
@@ -23,7 +22,6 @@ discard block |
||
| 23 | 22 | public function routable(); |
| 24 | 23 | |
| 25 | 24 | /** |
| 26 | - * @param mixed $url |
|
| 27 | 25 | * @return RoutableInterface Chainable |
| 28 | 26 | */ |
| 29 | 27 | public function set_slug_pattern($pattern); |
@@ -12,53 +12,53 @@ |
||
| 12 | 12 | interface RoutableInterface |
| 13 | 13 | { |
| 14 | 14 | /** |
| 15 | - * @param boolean $data |
|
| 16 | - * @return RoutableInterface Chainable |
|
| 17 | - */ |
|
| 15 | + * @param boolean $data |
|
| 16 | + * @return RoutableInterface Chainable |
|
| 17 | + */ |
|
| 18 | 18 | public function set_routable($routable); |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * @return boolean |
|
| 22 | - */ |
|
| 21 | + * @return boolean |
|
| 22 | + */ |
|
| 23 | 23 | public function routable(); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * @param mixed $url |
|
| 27 | - * @return RoutableInterface Chainable |
|
| 28 | - */ |
|
| 26 | + * @param mixed $url |
|
| 27 | + * @return RoutableInterface Chainable |
|
| 28 | + */ |
|
| 29 | 29 | public function set_slug_pattern($pattern); |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * @return string |
|
| 33 | - */ |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | 34 | public function slug_pattern(); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * @param mixed $slug |
|
| 38 | - * @return RoutableInterface Chainable |
|
| 39 | - */ |
|
| 37 | + * @param mixed $slug |
|
| 38 | + * @return RoutableInterface Chainable |
|
| 39 | + */ |
|
| 40 | 40 | public function set_slug($slug); |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * @return string |
|
| 44 | - */ |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | 45 | public function slug(); |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Generate a URL slug from the object's URL slug pattern. |
|
| 49 | - */ |
|
| 48 | + * Generate a URL slug from the object's URL slug pattern. |
|
| 49 | + */ |
|
| 50 | 50 | public function generate_slug(); |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * @return string |
|
| 54 | - */ |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | 55 | public function url(); |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * @param string $path |
|
| 59 | - * @param RequestInterface $request |
|
| 60 | - * @param ResponseInterface $response |
|
| 61 | - * @return callable|null Route callable |
|
| 62 | - */ |
|
| 58 | + * @param string $path |
|
| 59 | + * @param RequestInterface $request |
|
| 60 | + * @param ResponseInterface $response |
|
| 61 | + * @return callable|null Route callable |
|
| 62 | + */ |
|
| 63 | 63 | public function route_handler($path, RequestInterface $request, ResponseInterface $response); |
| 64 | 64 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | private $slug; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @param boolean $data |
|
| 36 | - * @return RoutableInterface Chainable |
|
| 35 | + * @return RoutableTrait Chainable |
|
| 37 | 36 | */ |
| 38 | 37 | public function set_routable($routable) |
| 39 | 38 | { |
@@ -50,8 +49,7 @@ discard block |
||
| 50 | 49 | } |
| 51 | 50 | |
| 52 | 51 | /** |
| 53 | - * @param mixed $url |
|
| 54 | - * @return RoutableInterface Chainable |
|
| 52 | + * @return RoutableTrait Chainable |
|
| 55 | 53 | */ |
| 56 | 54 | public function set_slug_pattern($pattern) |
| 57 | 55 | { |
@@ -69,7 +67,7 @@ discard block |
||
| 69 | 67 | |
| 70 | 68 | /** |
| 71 | 69 | * @param mixed $slug |
| 72 | - * @return RoutableInterface Chainable |
|
| 70 | + * @return RoutableTrait Chainable |
|
| 73 | 71 | */ |
| 74 | 72 | public function set_slug($slug) |
| 75 | 73 | { |
@@ -17,24 +17,24 @@ discard block |
||
| 17 | 17 | trait RoutableTrait |
| 18 | 18 | { |
| 19 | 19 | /** |
| 20 | - * @var boolean routable |
|
| 21 | - */ |
|
| 20 | + * @var boolean routable |
|
| 21 | + */ |
|
| 22 | 22 | private $routable = true; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @var string |
|
| 26 | - */ |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | 27 | private $slug_pattern = ''; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * @var string $slug |
|
| 31 | - */ |
|
| 30 | + * @var string $slug |
|
| 31 | + */ |
|
| 32 | 32 | private $slug; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @param boolean $data |
|
| 36 | - * @return RoutableInterface Chainable |
|
| 37 | - */ |
|
| 35 | + * @param boolean $data |
|
| 36 | + * @return RoutableInterface Chainable |
|
| 37 | + */ |
|
| 38 | 38 | public function set_routable($routable) |
| 39 | 39 | { |
| 40 | 40 | $this->routable = !!$routable; |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @return boolean |
|
| 46 | - */ |
|
| 45 | + * @return boolean |
|
| 46 | + */ |
|
| 47 | 47 | public function routable() |
| 48 | 48 | { |
| 49 | 49 | return $this->routable; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * @param mixed $url |
|
| 54 | - * @return RoutableInterface Chainable |
|
| 55 | - */ |
|
| 53 | + * @param mixed $url |
|
| 54 | + * @return RoutableInterface Chainable |
|
| 55 | + */ |
|
| 56 | 56 | public function set_slug_pattern($pattern) |
| 57 | 57 | { |
| 58 | 58 | $this->slug_pattern = new TranslationString($pattern); |
@@ -60,17 +60,17 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * @return TranslationString |
|
| 64 | - */ |
|
| 63 | + * @return TranslationString |
|
| 64 | + */ |
|
| 65 | 65 | public function slug_pattern() |
| 66 | 66 | { |
| 67 | 67 | return $this->slug_pattern; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @param mixed $slug |
|
| 72 | - * @return RoutableInterface Chainable |
|
| 73 | - */ |
|
| 71 | + * @param mixed $slug |
|
| 72 | + * @return RoutableInterface Chainable |
|
| 73 | + */ |
|
| 74 | 74 | public function set_slug($slug) |
| 75 | 75 | { |
| 76 | 76 | $this->slug = $slug; |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * @return string |
|
| 82 | - */ |
|
| 81 | + * @return string |
|
| 82 | + */ |
|
| 83 | 83 | public function slug() |
| 84 | 84 | { |
| 85 | 85 | if ($this->slug === null) { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * Generate a URL slug from the object's URL slug pattern. |
|
| 93 | - */ |
|
| 92 | + * Generate a URL slug from the object's URL slug pattern. |
|
| 93 | + */ |
|
| 94 | 94 | public function generate_slug() |
| 95 | 95 | { |
| 96 | 96 | $pattern = $this->slug_pattern(); |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * @return string |
|
| 107 | - */ |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 108 | 108 | public function url() |
| 109 | 109 | { |
| 110 | 110 | return $this->slug(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | - * Get the route callback that matches a gien path (or null). |
|
| 115 | - * |
|
| 116 | - * @param string $path |
|
| 117 | - * @param RequestInterface $request |
|
| 118 | - * @param ResponseInterface $response |
|
| 119 | - * @return callable|null Route callable |
|
| 120 | - */ |
|
| 114 | + * Get the route callback that matches a gien path (or null). |
|
| 115 | + * |
|
| 116 | + * @param string $path |
|
| 117 | + * @param RequestInterface $request |
|
| 118 | + * @param ResponseInterface $response |
|
| 119 | + * @return callable|null Route callable |
|
| 120 | + */ |
|
| 121 | 121 | abstract public function route_handler($path, RequestInterface $request, ResponseInterface $response); |
| 122 | 122 | } |
@@ -10,8 +10,7 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * Getter for creating/returning the unique instance of this class |
| 12 | 12 | * |
| 13 | - * @param mixed $param,... |
|
| 14 | - * @return object |
|
| 13 | + * @return SingletonTrait |
|
| 15 | 14 | */ |
| 16 | 15 | public static function instance(); |
| 17 | 16 | } |
@@ -51,7 +51,6 @@ |
||
| 51 | 51 | /** |
| 52 | 52 | * Getter for creating/returning the unique instance of this class |
| 53 | 53 | * |
| 54 | - * @param mixed $param,... |
|
| 55 | 54 | * @return self |
| 56 | 55 | */ |
| 57 | 56 | public static function instance() |
@@ -11,7 +11,6 @@ |
||
| 11 | 11 | class WidgetFactory extends ResolverFactory |
| 12 | 12 | { |
| 13 | 13 | /** |
| 14 | - * @param array $data |
|
| 15 | 14 | */ |
| 16 | 15 | public function base_class() |
| 17 | 16 | { |
@@ -11,16 +11,16 @@ |
||
| 11 | 11 | class WidgetFactory extends ResolverFactory |
| 12 | 12 | { |
| 13 | 13 | /** |
| 14 | - * @param array $data |
|
| 15 | - */ |
|
| 14 | + * @param array $data |
|
| 15 | + */ |
|
| 16 | 16 | public function base_class() |
| 17 | 17 | { |
| 18 | 18 | return '\Charcoal\App\Template\WidgetInterface'; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * @return string |
|
| 23 | - */ |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | 24 | public function resolver_suffix() |
| 25 | 25 | { |
| 26 | 26 | return 'Widget'; |
@@ -1,54 +1,54 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | return [ |
| 3 | 3 | |
| 4 | - 'logger'=>[ |
|
| 5 | - 'level'=>'debug' |
|
| 6 | - ], |
|
| 4 | + 'logger'=>[ |
|
| 5 | + 'level'=>'debug' |
|
| 6 | + ], |
|
| 7 | 7 | |
| 8 | - 'view'=>[ |
|
| 9 | - 'path'=>[ |
|
| 10 | - '../templates/' |
|
| 11 | - ], |
|
| 8 | + 'view'=>[ |
|
| 9 | + 'path'=>[ |
|
| 10 | + '../templates/' |
|
| 11 | + ], |
|
| 12 | 12 | 'default_template'=>'default', |
| 13 | - 'default_engine'=>'mustache' |
|
| 14 | - ], |
|
| 13 | + 'default_engine'=>'mustache' |
|
| 14 | + ], |
|
| 15 | 15 | |
| 16 | - 'routes' => [ |
|
| 17 | - 'templates' => [ |
|
| 18 | - 'default' => [ |
|
| 19 | - 'ident'=>'default' |
|
| 20 | - ], |
|
| 21 | - 'example' => [ |
|
| 22 | - 'ident'=>'example', |
|
| 23 | - 'controller'=>null, |
|
| 24 | - 'methods'=>['GET'], |
|
| 25 | - 'group'=>null, |
|
| 26 | - 'template'=>'example', |
|
| 27 | - 'engine'=>'mustache', |
|
| 28 | - 'cache'=>[ |
|
| 29 | - 'active'=>true, |
|
| 30 | - 'key'=>'route/{{ident}}/{{lang}}/' |
|
| 31 | - ], |
|
| 32 | - 'options'=>[] |
|
| 33 | - ] |
|
| 34 | - ], |
|
| 35 | - 'actions' => [ |
|
| 36 | - 'default' => [], |
|
| 37 | - 'example' => [ |
|
| 38 | - 'ident'=>'example', |
|
| 39 | - 'controller'=>null, |
|
| 40 | - 'methods'=>['POST'], |
|
| 41 | - 'group'=>null |
|
| 42 | - ] |
|
| 43 | - ], |
|
| 44 | - 'scripts' => [ |
|
| 45 | - 'example' => [ |
|
| 46 | - 'ident'=>'example', |
|
| 47 | - 'controller'=>null, |
|
| 48 | - 'methods'=>['GET'], |
|
| 49 | - 'group'=>null |
|
| 50 | - ] |
|
| 51 | - ] |
|
| 52 | - ] |
|
| 16 | + 'routes' => [ |
|
| 17 | + 'templates' => [ |
|
| 18 | + 'default' => [ |
|
| 19 | + 'ident'=>'default' |
|
| 20 | + ], |
|
| 21 | + 'example' => [ |
|
| 22 | + 'ident'=>'example', |
|
| 23 | + 'controller'=>null, |
|
| 24 | + 'methods'=>['GET'], |
|
| 25 | + 'group'=>null, |
|
| 26 | + 'template'=>'example', |
|
| 27 | + 'engine'=>'mustache', |
|
| 28 | + 'cache'=>[ |
|
| 29 | + 'active'=>true, |
|
| 30 | + 'key'=>'route/{{ident}}/{{lang}}/' |
|
| 31 | + ], |
|
| 32 | + 'options'=>[] |
|
| 33 | + ] |
|
| 34 | + ], |
|
| 35 | + 'actions' => [ |
|
| 36 | + 'default' => [], |
|
| 37 | + 'example' => [ |
|
| 38 | + 'ident'=>'example', |
|
| 39 | + 'controller'=>null, |
|
| 40 | + 'methods'=>['POST'], |
|
| 41 | + 'group'=>null |
|
| 42 | + ] |
|
| 43 | + ], |
|
| 44 | + 'scripts' => [ |
|
| 45 | + 'example' => [ |
|
| 46 | + 'ident'=>'example', |
|
| 47 | + 'controller'=>null, |
|
| 48 | + 'methods'=>['GET'], |
|
| 49 | + 'group'=>null |
|
| 50 | + ] |
|
| 51 | + ] |
|
| 52 | + ] |
|
| 53 | 53 | ]; |
| 54 | 54 | |