douyong6589 2013-10-16 13:01
浏览 44
已采纳

Symfony2的。 如何确保控制器实现某些方法无论是公共/私有/受保护还是有任何参数?

I wonder if I can make controllers implementing some methods no matters if that method will be public, private or protected and if it will have any parameter. I just want to ensure, that controller has method with specified name, no more.

For example:

interface SomeInterface {
  function someFunction();
  function someOtherFunction();
}

class SomeController extends SomeBaseController implements SomeInterface {
  //some action
  public function someAction() { ... }

  //an implementation of SomeInterface method
  public function someFunction() { ... }  

  //an implementation of SomeInterface method
  protected function someOtherFunction($someParameter) { ... }
}

I know that it's not possible to do this with ordinary php interfaces but maybe there is some other way in php or maybe symfony2 has some tool to accomplish this?

  • 写回答

2条回答 默认 最新

  • dongtang5229 2013-11-07 15:01
    关注

    It seems there is no way to accomplish this. So I mark my question as reslolved, however if someone knows an answer let me know! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容