Skip to content

Commit a239a13

Browse files
committed
Add some preliminary docs on Elastica and MongoDB adapters
1 parent a128414 commit a239a13

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

docs/source/index.html.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public function registerBundles()
3737
}
3838
```
3939

40-
After installation you should register the bundle to your kernel, commonly `AppKernel.php`, before your
41-
own bundles but after the required external bundles, such as `FrameworkBundle` and `TwigBundle`.
40+
After installation, if not using Flex, you should register the bundle to your kernel, commonly `AppKernel.php`,
41+
before your own bundles but after the required external bundles, such as `FrameworkBundle` and `TwigBundle`.
4242

4343
Run the `assets:install` command to deploy the included Javascript files to your application's public folder.
4444

4545
<code>bin/console assets:install</code>
4646

47-
That last step is actually optional, as you can also load it through Assetic or WebPack, but a good starting point.
47+
That last step is optional, as you can also load it through Assetic or WebPack, but a good starting point.
4848

4949
## Clientside dependencies
5050

@@ -158,10 +158,10 @@ datatables:
158158
template_parameters:
159159

160160
# Default class attribute to apply to the root table elements
161-
className: 'table table-bordered'
161+
className: 'table table-bordered'
162162

163163
# If and where to enable the DataTables Filter module
164-
columnFilter: null # One of "thead"; "tfoot"; "both"; null
164+
columnFilter: null # One of "thead"; "tfoot"; "both"; null
165165

166166
# Default translation domain to be used
167167
translation_domain: messages
@@ -282,6 +282,42 @@ Note that implementing your own criteria overrides the default, meaning searchin
282282
longer work automatically. Add the `SearchCriteriaProvider` manually to combine the default behavior
283283
with your own implementation.
284284

285+
## Elastica
286+
287+
```php?start_inline=1
288+
use Omines\DataTablesBundle\Adapter\Elasticsearch\ElasticaAdapter;
289+
290+
$table = $this->createDataTable()
291+
->setName('log')
292+
->add('timestamp', DateTimeColumn::class, ['field' => '@timestamp', 'format' => 'Y-m-d H:i:s', 'orderable' => true])
293+
->add('level', MapColumn::class, [
294+
'default' => '<span class="label label-default">Unknown</span>',
295+
'map' => ['Emergency', 'Alert', 'Critical', 'Error', 'Warning', 'Notice', 'Info', 'Debug'],
296+
])
297+
->add('message', TextColumn::class, ['globalSearchable' => true])
298+
->createAdapter(ElasticaAdapter::class, [
299+
'client' => ['host' => 'elasticsearch'],
300+
'index' => 'logstash-*',
301+
]);
302+
```
303+
If you have installed `ruflin/elastica` you can use the provided `ElasticaAdapter` to use ElasticSearch
304+
indexes as the data source.
305+
306+
## MongoDB
307+
308+
```php?start_inline=1
309+
use Omines\DataTablesBundle\Adapter\MongoDB\MongoDBAdapter;
310+
311+
$table = $this->createDataTable()
312+
->add('name', TextColumn::class)
313+
->add('company', TextColumn::class)
314+
->createAdapter(MongoDBAdapter::class, [
315+
'collection' => 'myCollection',
316+
]);
317+
```
318+
If you have installed `mongodb/mongodb` you can use the provided `MongoDBAdapter` to use MongoDB
319+
collections as the data source.
320+
285321
## Arrays
286322

287323
TBD.

0 commit comments

Comments
 (0)