1 | <?php |
||
29 | class Link extends Plugin |
||
30 | { |
||
31 | /** |
||
32 | * The event name |
||
33 | */ |
||
34 | const EVENT_REGISTER_TYPES = 'registerTypes'; |
||
35 | |||
36 | /** |
||
37 | * The first party link types |
||
38 | */ |
||
39 | const FIRST_PARTY_TYPES = [ |
||
40 | Asset::class, |
||
41 | Category::class, |
||
42 | Entry::class, |
||
43 | Url::class, |
||
44 | User::class |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * @var TypeInterface[] |
||
49 | */ |
||
50 | private $types; |
||
51 | |||
52 | /** |
||
53 | * @inheritdoc |
||
54 | */ |
||
55 | public function init() |
||
68 | |||
69 | /** |
||
70 | * @return array |
||
71 | */ |
||
72 | public function findAllTypes() |
||
80 | |||
81 | /** |
||
82 | * @param string $class |
||
83 | * @return TypeInterface|null |
||
84 | */ |
||
85 | public function findType(string $class) |
||
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | protected function registerTypes() |
||
111 | |||
112 | /** |
||
113 | * @param array $types |
||
114 | * @return array |
||
115 | */ |
||
116 | private function resolveTypes(array $types) |
||
128 | |||
129 | |||
130 | /** |
||
131 | * Translates a message to the specified language. |
||
132 | * |
||
133 | * This is a shortcut method of [[\Craft::t()]]. |
||
134 | * |
||
135 | * The translation will be conducted according to the message category and the target language will be used. |
||
136 | * |
||
137 | * You can add parameters to a translation message that will be substituted with the corresponding value after |
||
138 | * translation. The format for this is to use curly brackets around the parameter name as you can see in the |
||
139 | * following example: |
||
140 | * |
||
141 | * ```php |
||
142 | * $username = 'Alexander'; |
||
143 | * echo \flipbox\craft\link\Link::t('Hello, {username}!', ['username' => $username]); |
||
144 | * ``` |
||
145 | * |
||
146 | * Further formatting of message parameters is supported using the [PHP |
||
147 | * intl...craft-link/src/web/assets/settings/dist/LinkConfiguration.min.jsgit add * |
||
148 | * extensions](http://www.php.net/manual/en/intro.intl.php) |
||
149 | * message formatter. See [[\Craft::t()]] for more details. |
||
150 | * |
||
151 | * @param string $message the message to be translated. |
||
152 | * @param array $params the parameters that will be used to replace the corresponding |
||
153 | * placeholders in...craft-link/src/web/assets/settings/dist/LinkConfiguration.min.js |
||
154 | * the message. |
||
155 | * @param string $language the language code (e.g. `en-US`, `en`). If this is null, the current |
||
156 | * [[\yii\base\Application::language|application language]] will be used. |
||
157 | * @return string the translated message. |
||
158 | */ |
||
159 | public static function t($message, $params = [], $language = null) |
||
163 | } |
||
164 |