Skip to content

Commit d81d12f

Browse files
committed
Update documentation for CakePHP 5 compatibility
- Update all CakePHP documentation links: 3.x -> 5 - Update template path and extension: src/Template/.ctp -> templates/.php - Replace deprecated loadModel() with fetchIndex() - Add return types to all method examples - Remove outdated version note
1 parent 873a397 commit d81d12f

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

docs/en/index.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Overview
5757

5858
The ElasticSearch plugin makes it easier to interact with an elasticsearch index
5959
and provides an interface similar to the `ORM
60-
<https://book.cakephp.org/3/en/orm.html>`__. To get started you should
60+
<https://book.cakephp.org/5/en/orm.html>`__. To get started you should
6161
create an ``Index`` object. ``Index`` objects are the "Repository" or table-like
6262
class in elasticsearch::
6363

@@ -72,11 +72,11 @@ class in elasticsearch::
7272

7373
You can then use your index class in your controllers::
7474

75-
public function beforeFilter(Event $event)
75+
public function beforeFilter(\Cake\Event\EventInterface $event): void
7676
{
7777
parent::beforeFilter($event);
78-
// Load the Index using the 'Elastic' provider.
79-
$this->loadModel('Articles', 'Elastic');
78+
// Load the Index using the IndexLocator.
79+
$this->Articles = $this->fetchIndex('Articles');
8080
}
8181

8282
public function add()
@@ -93,7 +93,7 @@ You can then use your index class in your controllers::
9393

9494
We would also need to create a basic view for our indexed articles::
9595

96-
// in src/Template/Articles/add.ctp
96+
// in templates/Articles/add.php
9797
<?= $this->Form->create($article) ?>
9898
<?= $this->Form->control('title') ?>
9999
<?= $this->Form->control('body') ?>
@@ -122,7 +122,7 @@ plugin::
122122
Outside of constructor logic that makes Documents work with data from
123123
elasticsearch, the interface and functionality provided by ``Document`` are the
124124
same as those in `Entities
125-
<https://book.cakephp.org/3.0/en/orm/entities.html>`__
125+
<https://book.cakephp.org/5/en/orm/entities.html>`__
126126

127127
Searching Indexed Documents
128128
===========================
@@ -163,9 +163,9 @@ Validating Data & Using Application Rules
163163
Like the ORM, the ElasticSearch plugin lets you validate data when marshalling
164164
documents. Validating request data, and applying application rules works the
165165
same as it does with the relational ORM. See the `validating request data
166-
<https://book.cakephp.org/3.0/en/orm/validation.html#validating-data-before-building-entities>`__
166+
<https://book.cakephp.org/5/en/orm/validation.html#validating-data-before-building-entities>`__
167167
and `Application Rules
168-
<https://book.cakephp.org/3.0/en/orm/validation.html#applying-application-rules>`__
168+
<https://book.cakephp.org/5/en/orm/validation.html#applying-application-rules>`__
169169
sections for more information.
170170

171171
.. Need information on nested validators.
@@ -255,7 +255,7 @@ use ``embedOne`` and ``embedMany`` to define embedded documents::
255255

256256
class ArticlesIndex extends Index
257257
{
258-
public function initialize()
258+
public function initialize(): void
259259
{
260260
$this->embedOne('User');
261261
$this->embedMany('Comments', [
@@ -293,7 +293,8 @@ index use which connections. This is the ``defaultConnectionName()`` method::
293293

294294
class ArticlesIndex extends Index
295295
{
296-
public static function defaultConnectionName() {
296+
public static function defaultConnectionName(): string
297+
{
297298
return 'replica_db';
298299
}
299300
}
@@ -412,9 +413,6 @@ following::
412413
];
413414
}
414415

415-
.. versionchanged:: 3.4.0
416-
Prior to CakePHP 4.3.0 schema was defined on each fixture in the ``$schema``
417-
property.
418416

419417

420418
Once your fixtures are created you can use them in your test cases by including

0 commit comments

Comments
 (0)