PHP code example of polidog / controller-filter-bundle
1. Go to this page and download the library: Download polidog/controller-filter-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
polidog / controller-filter-bundle example snippets
// AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Polidog\ControllerFilterBundle\PolidogControllerFilterBundle(),
// ...
);
}
// 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'];
}
}
// 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']);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.