带视图的装饰器
如何在结构视图中应用装饰器,知道只有一个视图负责执行代码块来呈现模板?如:
<?php
class View {
public function render ( $template ) {
printf ( 'Rendering template %s' , $template ) ;
}
}
class MemberView { }
class AdministratorView { }
$Admin = new MemberView ( new AdministratorView ( ) ) ;
$Admin->render ( ) ;
在本例中,我正在呈现管理员,但是在浏览驱动程序时,将获取每个成员已到达视图并执行以显示面板的基本功能,或者只有管理员可以看到的东西,但在逻辑上,管理员也是成员..因此必须制定结构,适用于版主、全局版主..
我的问题是如何在这种情况下应用装饰器..
How to apply a decorator in a structure views, knowing that only a single view is responsible for executing the block of code to render the template? as:
<?php
class View {
public function render ( $template ) {
printf ( 'Rendering template %s' , $template ) ;
}
}
class MemberView { }
class AdministratorView { }
$Admin = new MemberView ( new AdministratorView ( ) ) ;
$Admin->render ( ) ;
In this case, I am rendering an administrator, but when going through the drivers, will acquire and the basic functions that every member has reached the view and perform to show panels, or things that only administrators can see, but in logic, a administrator is also a member .. so the structure has to be made, applies to moderators, global moderators ..
My question is that of how to apply the decorator in this case ..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我们设法解决了问题.. 解决方案:
输出:渲染模板 管理员
如果我删除管理员的渲染。
输出:渲染模板成员
Well, we managed to solve the problem .. the solution:
The output: Rendering template Administrator
If I remove the rendering of the administrator.
The output: Rendering template Member