xlabs / fingerprintbundle
指纹管理包
1.0.1
2021-09-01 11:57 UTC
Requires
- php: >=5.3.9
- composer/installers: ~1.0
Requires (Dev)
- doctrine/doctrine-bundle: ~1.4
- doctrine/orm: ^2.4.8
- friendsofsymfony/jsrouting-bundle: ^1.6
Suggests
- symfony/asset: For using the AssetExtension
- symfony/expression-language: For using the ExpressionExtension
- symfony/finder: For using the finder
- symfony/form: For using the FormExtension
- symfony/http-kernel: For using the HttpKernelExtension
- symfony/routing: For using the RoutingExtension
- symfony/security: For using the SecurityExtension
- symfony/stopwatch: For using the StopwatchExtension
- symfony/templating: For using the TwigEngine
- symfony/translation: For using the TranslationExtension
- symfony/var-dumper: For using the DumpExtension
- symfony/yaml: For using the YamlExtension
This package is auto-updated.
Last update: 2024-09-29 05:56:45 UTC
README
用于向指纹API发送数据的指纹包
安装
通过composer安装
php -d memory_limit=-1 composer.phar require atm/fingerprintbundle
在你的AppKernel中
public function registerbundles()
{
return [
...
...
new ATM\FingerprintBundle\ATMFingerprintBundle(),
];
}
配置示例
以下显示默认值
# app/config/config.yml
atm_fingerprint:
fingerprint_error_redirect_route_name: 'route to redirect the user when the fingerprint is not found'
site_name: 'sitename'
error_message: 'a message to show to the user when the fingerprint is not found'
use_assetic: false
如果你的应用使用assetic,记得在config.yml文件中将ATMFingerprintBundle包含到assetic的数组包中
assetic:
bundles: ['ATMFingerprintBundle']
包含到主页
{% include 'ATMFingerprintBundle:Fingerprint:store_fingerprint.html.twig' %}
事件
当API返回响应时,你可以使用2个事件
错误
class StatusError extends Event{ const NAME = 'atm_fingerprint_error.event'; protected $user; protected $response; public function __construct($user,$response) { $this->user = $user; $this->response = $response; } public function getUser() { return $this->user; } public function getResponse(){ return $this->response; } }
成功
class StatusSuccess extends Event{ const NAME = 'atm_fingerprint_success.event'; protected $user; protected $response; public function __construct($user,$response) { $this->user = $user; $this->response = $response; } public function getUser() { return $this->user; } public function getResponse(){ return $this->response; } }
事件监听器
有一个事件监听器,监听具有3级优先级的内核请求,并设置一个名为'atm_fingerprint_custom_redirect'的会话变量。
ATM\FingerprintBundle\EventListener\FingerprintRedirect:
autowire: true
public: true
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 3 }
arguments:
$atm_fingerprint_config: '%atm_fingerprint_config%'
你可以设置一个具有低优先级的自定义请求监听器以重定向到其他地方或放置一些自定义代码。记得要删除会话变量'atm_fingerprint_custom_redirect'
AppBundle\EventListener\CustomRequestListener:
autowire: true
public: true
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 2 }
namespace AppBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class CustomRequestListener{
private $session;
public function __construct(SessionInterface $session){
$this->session = $session;
}
public function onKernelRequest(GetResponseEvent $event){
if($this->session->has('atm_fingerprint_custom_redirect')){
$this->session->remove('atm_fingerprint_custom_redirect');
// YOUR CODE GOES HERE
$event->setResponse(new Response());
}
}
}