1 | <?php |
||
16 | class ApplicationTrait extends \Silex\Application |
||
17 | { |
||
18 | /** |
||
19 | * Application Shortcut Methods |
||
20 | 23 | */ |
|
21 | public function addSuccess($message, $namespace = 'front') |
||
25 | 2 | ||
26 | public function addError($message, $namespace = 'front') |
||
30 | |||
31 | public function addDanger($message, $namespace = 'front') |
||
35 | 1 | ||
36 | public function addWarning($message, $namespace = 'front') |
||
40 | |||
41 | public function addInfo($message, $namespace = 'front') |
||
45 | |||
46 | public function addRequestError($message, $namespace = 'front') |
||
50 | |||
51 | public function clearMessage() |
||
55 | |||
56 | public function deleteMessage() |
||
61 | |||
62 | public function setLoginTargetPath($targetPath, $namespace = null) |
||
70 | |||
71 | public function isAdminRequest() |
||
75 | |||
76 | public function isFrontRequest() |
||
80 | |||
81 | /* |
||
82 | * 注意!以下コードはSilexのコードのコピーなので触らないコト |
||
83 | * |
||
84 | * 以下のコードの著作権について |
||
85 | * |
||
86 | * (c) Fabien Potencier <[email protected]> |
||
87 | * |
||
88 | * For the full copyright and license information, please view the silex |
||
89 | * LICENSE file that was distributed with this source code. |
||
90 | */ |
||
91 | |||
92 | /** FormTrait */ |
||
93 | /** |
||
94 | * Creates and returns a form builder instance |
||
95 | * |
||
96 | * @param mixed $data The initial data for the form |
||
97 | * @param array $options Options for the form |
||
98 | * |
||
99 | * @return FormBuilder |
||
100 | */ |
||
101 | 12 | public function form($data = null, array $options = array()) |
|
105 | |||
106 | /** MonologTrait */ |
||
107 | /** |
||
108 | * Adds a log record. |
||
109 | * |
||
110 | * @param string $message The log message |
||
111 | * @param array $context The log context |
||
112 | * @param int $level The logging level |
||
113 | * |
||
114 | * @return bool Whether the record has been processed |
||
115 | */ |
||
116 | public function log($message, array $context = array(), $level = Logger::INFO) |
||
120 | |||
121 | /** SecurityTrait */ |
||
122 | /** |
||
123 | * Gets a user from the Security context. |
||
124 | * |
||
125 | * @return mixed |
||
126 | * |
||
127 | * @see TokenInterface::getUser() |
||
128 | * |
||
129 | */ |
||
130 | 1 | public function user() |
|
134 | |||
135 | /** |
||
136 | * Encodes the raw password. |
||
137 | * |
||
138 | * @param UserInterface $user A UserInterface instance |
||
139 | * @param string $password The password to encode |
||
140 | * |
||
141 | * @return string The encoded password |
||
142 | * |
||
143 | * @throws \RuntimeException when no password encoder could be found for the user |
||
144 | */ |
||
145 | 21 | public function encodePassword(UserInterface $user, $password) |
|
149 | |||
150 | /** |
||
151 | * Checks if the attributes are granted against the current authentication token and optionally supplied object. |
||
152 | * |
||
153 | * @param mixed $attributes |
||
154 | * @param mixed $object |
||
155 | * |
||
156 | * @return bool |
||
157 | * |
||
158 | * @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token. |
||
159 | 23 | */ |
|
160 | public function isGranted($attributes, $object = null) |
||
164 | |||
165 | /** SwiftmailerTrait */ |
||
166 | /** |
||
167 | * Sends an email. |
||
168 | * |
||
169 | * @param \Swift_Message $message A \Swift_Message instance |
||
170 | * @param array $failedRecipients An array of failures by-reference |
||
171 | * |
||
172 | * @return int The number of sent messages |
||
173 | */ |
||
174 | public function mail(\Swift_Message $message, &$failedRecipients = null) |
||
178 | |||
179 | /** TranslationTrait */ |
||
180 | /** |
||
181 | * Translates the given message. |
||
182 | * |
||
183 | * @param string $id The message id |
||
184 | * @param array $parameters An array of parameters for the message |
||
185 | * @param string $domain The domain for the message |
||
186 | * @param string $locale The locale |
||
187 | * |
||
188 | * @return string The translated string |
||
189 | */ |
||
190 | public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) |
||
194 | |||
195 | /** |
||
196 | * Translates the given choice message by choosing a translation according to a number. |
||
197 | * |
||
198 | * @param string $id The message id |
||
199 | * @param int $number The number to use to find the indice of the message |
||
200 | * @param array $parameters An array of parameters for the message |
||
201 | * @param string $domain The domain for the message |
||
202 | * @param string $locale The locale |
||
203 | * |
||
204 | * @return string The translated string |
||
205 | */ |
||
206 | public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) |
||
210 | |||
211 | /** TwigTrait */ |
||
212 | 48 | /** |
|
213 | * Renders a view and returns a Response. |
||
214 | * |
||
215 | * To stream a view, pass an instance of StreamedResponse as a third argument. |
||
216 | * |
||
217 | 47 | * @param string $view The view name |
|
218 | * @param array $parameters An array of parameters to pass to the view |
||
219 | * @param Response $response A Response instance |
||
220 | * |
||
221 | 1 | * @return Response A Response instance |
|
222 | */ |
||
223 | 48 | public function render($view, array $parameters = array(), Response $response = null) |
|
262 | |||
263 | /** |
||
264 | 60 | * Renders a view. |
|
265 | * |
||
266 | * @param string $view The view name |
||
267 | * @param array $parameters An array of parameters to pass to the view |
||
268 | * |
||
269 | * @return string The rendered view |
||
270 | */ |
||
271 | public function renderView($view, array $parameters = array()) |
||
275 | |||
276 | /** UrlGeneratorTrait */ |
||
277 | /** |
||
278 | * Generates a path from the given parameters. |
||
279 | * |
||
280 | * @param string $route The name of the route |
||
281 | * @param mixed $parameters An array of parameters |
||
282 | * |
||
283 | * @return string The generated path |
||
284 | */ |
||
285 | public function path($route, $parameters = array()) |
||
289 | |||
290 | /** |
||
291 | * Generates an absolute URL from the given parameters. |
||
292 | * |
||
293 | * @param string $route The name of the route |
||
294 | * @param mixed $parameters An array of parameters |
||
295 | * |
||
296 | * @return string The generated URL |
||
297 | */ |
||
298 | public function url($route, $parameters = array()) |
||
302 | } |
||
303 |