Skip to content

Commit 92674f0

Browse files
authored
Merge pull request #6575 from cakephp/4.next-add-helper
addHelper() migration docs.
2 parents 443fc5c + bf08f6f commit 92674f0

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

en/appendices/4-1-migration-guide.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Routing
5151
View
5252
----
5353

54-
* ``Form/ContextInteface::primaryKey()`` was deprecated. Use ``getPrimaryKey()``
54+
* ``Form/ContextInterface::primaryKey()`` was deprecated. Use ``getPrimaryKey()``
5555
instead.
5656

5757
Behavior Changes
@@ -156,6 +156,7 @@ View
156156

157157
* Added ``TextHelper::slug()``. This method delegates to
158158
``Cake\Utility\Text::slug()``.
159+
* Added ``ViewBuilder::addHelper()`` as chainable wrapper method to add helpers.
159160

160161
Utility
161162
-------

en/controllers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ theme that will be used when rendering the view, you can use the
199199
properties of the view before it is created::
200200

201201
$this->viewBuilder()
202-
->setHelpers(['MyCustom'])
202+
->addHelper('MyCustom')
203203
->setTheme('Modern')
204204
->setClassName('Modern.Admin');
205205

en/plugins.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ helpers by prefixing the name of the plugin.
187187

188188
For example, say you wanted to use the ContactManager plugin's
189189
ContactInfoHelper to output formatted contact information in
190-
one of your views. In your controller, ``setHelpers()``
190+
one of your views. In your controller, using ``addHelper()``
191191
could look like this::
192192

193-
$this->viewBuilder()->setHelpers(['ContactManager.ContactInfo']);
193+
$this->viewBuilder()->addHelper('ContactManager.ContactInfo');
194194

195195
.. note::
196196
This dot separated class name is referred to as :term:`plugin syntax`.

en/views/helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ You can also use your controller's ``beforeRender`` method to load helpers::
8383
public function beforeRender(EventInterface $event)
8484
{
8585
parent::beforeRender($event);
86-
$this->viewBuilder()->setHelpers(['MyHelper']);
86+
$this->viewBuilder()->addHelper('MyHelper');
8787
}
8888
}
8989

0 commit comments

Comments
 (0)