Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/polidog/controllerfilterbundle
https://github.com/polidog/controllerfilterbundle
symfony symfony-bundle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/polidog/controllerfilterbundle
- Owner: polidog
- License: mit
- Created: 2017-05-12T17:12:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T14:58:30.000Z (over 6 years ago)
- Last Synced: 2024-10-14T18:21:13.277Z (about 1 month ago)
- Topics: symfony, symfony-bundle
- Language: PHP
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PolidogControllerFilterBundle
[![Build Status](https://travis-ci.org/polidog/ControllerFilterBundle.svg?branch=master)](https://travis-ci.org/polidog/ControllerFilterBundle)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/polidog/ControllerFilterBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/polidog/ControllerFilterBundle/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/polidog/ControllerFilterBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/polidog/ControllerFilterBundle/?branch=master)This bundle to allow you to describe filtering with annotations in the Controller class.
## Install
install polidog/controller-filter-bundle with composer.```
$ composer require polidog/controller-filter-bundle
```## Configuration
```php
// AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Polidog\ControllerFilterBundle\PolidogControllerFilterBundle(),
// ...
);
}
```## Using
```php
// controller class/**
* @Route("/card")
* @Filter(Filter::TYPE_BEFORE, method="checkSession", service="app.service.check_service")
*/
class CardController extends Controller
{
use DonationSessionTrait;/**
* @Route("/")
* @Method("GET")
* @Template()
* @Filter(Filter::TYPE_AFTER, method="changeResult", service="app.service.check_service")
*/
public function indexAction(Request $request)
{
return ['hoge' =>'fuga'];
}}
```
```php
// service class
class CheckService {
/**
* @Session
*/
private $session;
public function changeResult()
{
if ($this->session->has('hoge') {
throw new \Exception();
}
}
public function changeResult(GetResponseForControllerResultEvent $event)
{
$event->setControllerResult(['hoge' => 'hogehoge']);
}
}```
```yaml
// services.ymlservices:
app.service.check_service:
class: AppBundle\Service\CheckService
public: true
arguments: ["@session"]```