Skip to content

Commit

Permalink
Update to v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cassani committed Jul 26, 2017
1 parent 39a1219 commit 2230f4b
Show file tree
Hide file tree
Showing 6 changed files with 987 additions and 537 deletions.
13 changes: 8 additions & 5 deletions Controller/EventStoreManagerBundleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,28 @@
class EventStoreManagerBundleController extends Controller
{
/**
* @Route("/{page}", requirements={"page" = "\d+"}, defaults={"page" = null}) , name="event_store_manager_index")
* @Route("/{aggregate}/{page}",
* requirements={"page" = "\d+"},
* defaults={"page" = null}) ,
* name="event_store_manager_index")
*/
public function indexAction(Request $request, $page = null)
public function aggregateAction(Request $request, $aggregate, $page = null)
{
/** @var Manager $manager */
$manager = $this->container->get('simple_event_store_manager');
$eventStore = $manager->getMananger()->eventStore();
$eventManager = $manager->getMananger();

$config = $this->container->getParameter('simple_event_store_manager');
$dataTransformer = 'SimpleEventStoreManager\\Infrastructure\\DataTransformers\\'.ucfirst($config['api_format']).'EventDataTransformer';
$eventsQuery = new EventQuery(
$eventStore,
$eventManager,
new $dataTransformer(
SerializerBuilder::create()->build(),
$request,
true
)
);

return $eventsQuery->paginate(($page) ?: 1);
return $eventsQuery->aggregate($aggregate, ($page) ?: 1);
}
}
5 changes: 5 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function getConfigTreeBuilder()
->prototype('variable')
->end()
->end()
->children()
->arrayNode('elastic')
->prototype('variable')
->end()
->end()
;

return $treeBuilder;
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ simple_event_store_manager:
password: ~
database: 'eventstore_demo'
port: '27017'
elastic:
host: 'localhost'
port: '9200'
```

`api_format` is an optional parameter; you can choose between `json`, `xml` or `yaml`.
* `api_format` is an optional parameter; you can choose between `json` (default), `xml` or `yaml`
* `elastic` is an optional parameter; you can send your events to a Elastic server

Please refer to [Simple EventStore Manager page](https://github.com/mauretto78/simple-event-store-manager) for more details.

Expand Down Expand Up @@ -73,7 +77,7 @@ Please refer to [official documentation of Simple EventStore Manager](https://gi

## API support ##

An API endpoint is automatically exposed to `/_events/{page}` path; it will automatically with **25 records per page**.
An API endpoint is automatically exposed to `/_events/{aggregate}/{page}` route; it will automatically paged with **25 records per page**.

When a page is complete, it will set automatically an infinite cache on it.

Expand Down
7 changes: 6 additions & 1 deletion Service/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ public function __construct(array $config = [])
*/
private function setMananger($config)
{
$this->manager = new EventManager($config['driver'], $config['parameters']);
$this->manager = new EventManager(
$config['driver'],
$config['parameters'],
($config['elastic']) ? ['elastic' => true, 'elastic_hosts' => $config['elastic']] : null
);
}

/**
* @return EventManager
*/
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"symfony/http-kernel": "~2.3|~3.0",
"symfony/dependency-injection": "~2.3|~3.0",
"symfony/yaml": "~2.3|~3.0",
"symfony/config": "~2.3|~3.0"
"symfony/config": "~2.3|~3.0",
"symfony/framework-bundle": "^3.3"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 2230f4b

Please sign in to comment.