Zend Framework 2 FrontController 插件 [英] Zend Framework 2 FrontController Plugin

查看:37
本文介绍了Zend Framework 2 FrontController 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定重写我很久以前在 ZF1 中编写的应用程序.其中一个关键部分是使用 FrontController 插件,该插件查看 URL,如果没有找到匹配的路由,它将把它传递给另一个控制器进行处理.这样做的好处是它适用于所有模块,而无需进行进一步更改,因为它已注册为前端控制器的插件.有人可以帮助我如何在 ZF2 中实现相同的目标提前致谢亚当

I have decided to rewrite an application that I wrote a long time ago in ZF1. A key part of this is the utilisation of a FrontController plugin that looks at a URL and if no matching route is found it will pass it on to another controller to process. The benefit of this is it worked for all modules without having to make further changes as it was registered as a plugin for the frontcontroller. Can someone please help as to how I could achieve the same in ZF2 Thanks in Adavance Adam

推荐答案

现在您可以在 Events 中进行.

Now you can do it in Events.

ZF2 具有默认事件,您可以将代码(侦听器)附加到特定事件.所有ZF2默认列表事件.

ZF2 have default events and you can attach your code(listeners) to particular event. List of all ZF2 default events.

您必须玩转 ZF2 事件/侦听器,以了解最适合您的选择.

You have to play around with ZF2 events/listeners to see what will be the best choice for you.

我在 MvcEvent::EVENT_ROUTE 中做类似的工作.检查当前路由,检查当前用户权限,如果用户没有权限,则返回不同的响应.

I am doing similar staff in MvcEvent::EVENT_ROUTE. Check current route, check current user permission and if user don't have permission just return different response.

在那里你可以找到关于如何创建事件/监听器的好文章"了解 Zend 框架 2活动经理".

There you can found great article about how to create event/listener "Understanding the Zend Framework 2 event manager".

这篇关于Zend Framework 2 FrontController 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆