Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 18ef7e3

Browse files
committed
Merge branch 'feature/22' into develop
Close #22
2 parents 0d65e19 + 83b3930 commit 18ef7e3

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file, in reverse
88

99
- [#24](https://github.com/zendframework/zend-mvc-plugin-flashmessenger/pull/24) adds support for PHP 7.3.
1010

11+
- [#22](https://github.com/zendframework/zend-mvc-plugin-flashmessenger/pull/22) adds `Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait`,
12+
which can be used to provide IDE autocompletion for view helpers
13+
provided by zend-mvc-plugin-flashmessenger. See
14+
https://docs.zendframework.com/zend-mvc-plugin-flashmessenger/flash-messenger-view-helper/#ide-auto-completion-in-templates
15+
for more information.
16+
1117
### Changed
1218

1319
- Nothing.

docs/book/flash-messenger-view-helper.md

+24
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,27 @@ data-dismiss="alert" aria-hidden="true">&times;</button><ul><li>',
144144
],
145145
],
146146
```
147+
148+
## IDE auto-completion in templates
149+
150+
The `Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait` trait can be used to
151+
provide auto-completion for modern IDEs. It defines the aliases of the view
152+
helpers in a DocBlock as `@method` tags.
153+
154+
### Usage
155+
156+
In order to allow auto-completion in templates, `$this` variable should be
157+
type-hinted via a DocBlock at the top of your template. It is recommended that
158+
you always add the `Zend\View\Renderer\PhpRenderer` as the first type, so that
159+
the IDE can auto-suggest the default view helpers from `zend-view`. Next, chain
160+
the `HelperTrait` from `zend-i18n` with a pipe symbol (a.k.a. vertical bar) `|`:
161+
162+
```php
163+
/**
164+
* @var Zend\View\Renderer\PhpRenderer|Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait $this
165+
*/
166+
```
167+
168+
You may chain as many `HelperTrait` traits as you like, depending on view
169+
helpers from which Zend Framework component you are using and would like to
170+
provide auto-completion for.

src/View/HelperTrait.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-mvc-plugin-flashmessenger for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-mvc-plugin-flashmessenger/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\Mvc\Plugin\FlashMessenger\View;
9+
10+
use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger as PluginFlashMessenger;
11+
use Zend\Mvc\Plugin\FlashMessenger\View\Helper\FlashMessenger;
12+
13+
/**
14+
* Helper trait for auto-completion of code in modern IDEs.
15+
*
16+
* The trait provides convenience methods for view helpers,
17+
* defined by the zend-mvc-plugin-flashmessenger component.
18+
* It is designed to be used for type-hinting $this variable
19+
* inside zend-view templates via doc blocks.
20+
*
21+
* The base class is PhpRenderer, followed by the helper trait from
22+
* the zend-mvc-plugin-flashmessenger component. However, multiple helper traits
23+
* from different Zend Framework components can be chained afterwards.
24+
*
25+
* @example @var \Zend\View\Renderer\PhpRenderer|\Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait $this
26+
*
27+
* @method FlashMessenger|PluginFlashMessenger flashMessenger(string|null $namespace = null)
28+
*/
29+
trait HelperTrait
30+
{
31+
}

0 commit comments

Comments
 (0)