Skip to content

Commit 287c55a

Browse files
committed
Update README to reflect changes
Update codecov ci config + update badge
1 parent 1e13d5e commit 287c55a

2 files changed

Lines changed: 28 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ jobs:
8787
fi
8888
8989
- name: Submit code coverage
90-
if: matrix.php-version == '8.1'
91-
uses: codecov/codecov-action@v3
90+
if: matrix.php-version == '8.4'
91+
uses: codecov/codecov-action@v5
92+
with:
93+
token: ${{ secrets.CODECOV_TOKEN }}
9294

9395
cs-stan:
9496
name: Coding Standard & Static Analysis

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Build Status](https://github.com/cakephp/elastic-search/actions/workflows/ci.yml/badge.svg?branch=5.x)
44
[![Latest Stable Version](https://img.shields.io/github/v/release/cakephp/elastic-search?sort=semver&style=flat-square)](https://packagist.org/packages/cakephp/elastic-search)
55
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/elastic-search?style=flat-square)](https://packagist.org/packages/cakephp/elastic-search/stats)
6-
[![Code Coverage](https://img.shields.io/coveralls/cakephp/elastic-search/5.x.svg?style=flat-square)](https://coveralls.io/r/cakephp/elastic-search?branch=5.x)
6+
[![codecov](https://codecov.io/gh/cakephp/elastic-search/branch/5.x/graph/badge.svg?token=G3Tcg116OX)](https://codecov.io/gh/cakephp/elastic-search)
77
[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat-square)](https://phpstan.org/)
88
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
99

@@ -92,14 +92,33 @@ Elasticsearch query logs will go. Query logging is done at a 'debug' level.
9292
## Getting a Index object
9393

9494
Index objects are the equivalent of `ORM\Table` instances in elastic search. You can
95-
use the `IndexRegistry` factory to get instances, much like `TableRegistry`:
95+
use the `IndexLocatorAwareTrait` to get instances in your classes:
9696

9797
```php
98-
use Cake\ElasticSearch\IndexRegistry;
98+
use Cake\ElasticSearch\Datasource\IndexLocatorAwareTrait;
9999

100-
$comments = IndexRegistry::get('Comments');
100+
class MyClass
101+
{
102+
use IndexLocatorAwareTrait;
103+
104+
public function someMethod()
105+
{
106+
$comments = $this->fetchIndex('Comments');
107+
}
108+
}
101109
```
102110

111+
Alternatively, you can use the `IndexLocator` directly:
112+
113+
```php
114+
use Cake\ElasticSearch\Datasource\IndexLocator;
115+
116+
$locator = new IndexLocator();
117+
$comments = $locator->get('Comments');
118+
```
119+
120+
> **Note for upgrading users**: The `IndexRegistry` class has been deprecated since version 3.4.3. If you're upgrading from an older version, replace `IndexRegistry::get('Comments')` with the `IndexLocatorAwareTrait` approach shown above or use `IndexLocator` directly.
121+
103122
If you have loaded the plugin with bootstrap enabled you could load indexes using the model factory in your controllers
104123
```php
105124
class SomeController extends AppController
@@ -119,7 +138,7 @@ class SomeController extends AppController
119138

120139
Each `Index` object needs a correspondent Elasticsearch _index_, just like most of `ORM\Table` needs a database _table_.
121140

122-
In the above example, if you have defined a class as `CommentsIndex` and the `IndexRegistry` can find it, the `$comments` will receive a initialized object with inner configurations of connection and index. But if you don't have that class, a default one will be initialized and the index name on Elasticsearch mapped to the class.
141+
In the above example, if you have defined a class as `CommentsIndex` and the `IndexLocator` can find it, the `$comments` will receive an initialized object with inner configurations of connection and index. But if you don't have that class, a default one will be initialized and the index name on Elasticsearch mapped to the class.
123142

124143
## The Index class
125144

0 commit comments

Comments
 (0)