Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openclassrooms/usecasebundle
Symfony2 Bundle for OpenClassrooms Use Case Library
https://github.com/openclassrooms/usecasebundle
Last synced: 3 days ago
JSON representation
Symfony2 Bundle for OpenClassrooms Use Case Library
- Host: GitHub
- URL: https://github.com/openclassrooms/usecasebundle
- Owner: OpenClassrooms
- License: mit
- Created: 2014-06-02T13:44:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T15:24:23.000Z (3 months ago)
- Last Synced: 2024-11-11T11:54:27.166Z (6 days ago)
- Language: PHP
- Homepage:
- Size: 124 KB
- Stars: 4
- Watchers: 25
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
UseCaseBundle
=============
[![Build Status](https://travis-ci.org/OpenClassrooms/UseCaseBundle.svg?branch=master)](https://travis-ci.org/OpenClassrooms/UseCaseBundle)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/5ac2e986-fda3-49d4-9529-4c1b9c7505b8/mini.png)](https://insight.sensiolabs.com/projects/5ac2e986-fda3-49d4-9529-4c1b9c7505b8)
[![Coverage Status](https://coveralls.io/repos/OpenClassrooms/UseCaseBundle/badge.png)](https://coveralls.io/r/OpenClassrooms/UseCaseBundle)UseCaseBundle provides OpenClassrooms\UseCase Library in a Symfony2 context.
UseCase Library provides facilities to manage technical code over a Use Case in a Clean / Hexagonal / Use Case Architecture.- **Security access**
- **Cache management**
- **Transactional context**
- **Events**The goal is to have only functional code on the Use Case and manage technical code in an elegant way using annotations.
For usage of UseCase Library, please see the UseCase Library [documentation](https://github.com/OpenClassrooms/UseCase/blob/master/README.md#usage).
## Installation
This bundle can be installed using composer:```composer require openclassrooms/use-case-bundle```
or by adding the package to the composer.json file directly.```json
{
"require": {
"openclassrooms/use-case-bundle": "*"
}
}
```After the package has been installed, add the bundle to the AppKernel.php file:
```php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new OpenClassrooms\Bundle\OpenClassroomsUseCaseBundle(),
// ...
);
```
If cache facilities are needed, add the OpenClassrooms\CacheBundle to the AppKernel.php file:```php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new OpenClassrooms\Bundle\CacheBundle\OpenClassroomsCacheBundle(),
new OpenClassrooms\Bundle\UseCaseBundle\OpenClassroomsUseCaseBundle(),
// ...
);
```## Configuration
UseCaseBundle requires no initial configuration.This is the default configuration:
```yaml
# app/config/config.yml
openclassrooms_use_case:
security: security_context
# an implementation of OpenClassrooms\UseCase\Application\Services\Security\Security
transaction: doctrine.orm.entity_manager
# an implementation of EntityManagerInterface or OpenClassrooms\UseCase\Application\Services\Transaction\Transaction
event_sender: event_dispatcher
# an implementation of EventDispatcherInterface or OpenClassrooms\UseCase\Application\Services\Event\EventSender
event_factory: openclassrooms.use_case.event_factory
# an implementation of OpenClassrooms\UseCase\Application\Services\Event\EventFactory
```If cache facilities are needed, CacheBundle configuration MUST be set. See [documentation](https://github.com/OpenClassrooms/CacheBundle/blob/master/README.md#configuration) for more details.
Furthermore, **only needed services are used**. It means, for example, if only security is used, the others services will never be called. **Even if the services of the default configuration exist or not.**
## Usage
For usage of UseCase Library, please see the UseCase Library [documentation](https://github.com/OpenClassrooms/UseCase/blob/master/README.md#usage).
Add the tag ```openclassrooms.use_case``` to the use case declaration to enable UseCase Library facilities.
### Resources/config/services.xml
```xml
AProject\BusinessRules\UseCases\AUseCase
```
The different services used are those defined in the configuration file.
For each tag and each facility, a specific service can be set:```xml
```
- *security* parameter MUST be an implementation of OpenClassrooms\UseCase\Application\Services\Security\Security
- *cache* parameter MUST be an implementation of OpenClassrooms\Cache\Cache\Cache
- *transaction* parameter MUST be an implementation of EntityManagerInterface or OpenClassrooms\UseCase\Application\Services\Transaction\Transaction
- *event-sender* parameter MUST be an implementation of EventDispatcherInterface or OpenClassrooms\UseCase\Application\Services\Event\EventSender
- *event-factory* parameter MUST be an implementation of OpenClassrooms\UseCase\Application\Services\Event\EventFactory