Skip to content

Commit

Permalink
Merge pull request lorenzo#5 from harikt/patch-1
Browse files Browse the repository at this point in the history
Fix a typo and add the configuration how to do when using standalone
  • Loading branch information
lorenzo committed Jan 15, 2016
2 parents cea07ae + f41bd48 commit 15014e9
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,25 @@ in your AppController.


```php

use AuditStash\Meta\ApplicationMetadata;
use Cake\Event\EventManager;

EventManager::instance()->on(new ApplicationMetadata('my_blog_app', [
'server' => $theServerID,
'extra' => $somExtraInformation,
'moon_phase' => $currentMoonPhase
]));
EventManager::instance()->on(new ApplicationMetadata('my_blog_app', [
'server' => $theServerID,
'extra' => $somExtraInformation,
'moon_phase' => $currentMoonPhase
]));

```

Implementing your own metadata listeners is as simple as attaching the listener to the `AuditStash.beforeLog` event. For example:

```php
EventManager::instance()->on('AuditStash.beforeLog', function ($event, array $logs) {
foreach ($logs as $event) {
$event->setMetadataInfo($event->getMetadataInfo() + ['extra' => 'This is extra data to be stored']);
}
});
EventManager::instance()->on('AuditStash.beforeLog', function ($event, array $logs) {
foreach ($logs as $event) {
$event->setMetadataInfo($event->getMetadataInfo() + ['extra' => 'This is extra data to be stored']);
}
});
```

### Implementing Your Own Persister Strategies
Expand All @@ -204,7 +203,7 @@ your own storage engines. It is as simple as implementing the `PersisterInterfac
```php
use AuditStash\PersisterInterface;

class DatabasePersister implements PersisteInterface
class DatabasePersister implements PersisterInterface
{
public function logEvents(array $logs)
{
Expand Down Expand Up @@ -237,4 +236,10 @@ lines:
'AuditStash' => ['persister' => 'App\Namespace\For\Your\DatabasePersister']
```

or if you are using as standalone via

```php
\Cake\Core\Configure::write('AuditStash.presister', 'App\Namespace\For\Your\DatabasePersister');
```

The configuration contains the fully namespaced class name of your persister.

0 comments on commit 15014e9

Please sign in to comment.