首页 \ 问答 \ 在zend框架2中获取我的一些控制器(get some of my controllers in zend framework 2)

在zend框架2中获取我的一些控制器(get some of my controllers in zend framework 2)

我正在基于zend框架2创建一个cms。 我有som模块,让我们说新闻模块。 它有两个控制器,一个用于后端,一个用于头版:

News Module :
-- AdminController 
-- IndexController

我的问题是如何在管理模块中列出所有AdminControllers? 我认为它可以由活动经理实现,但我不知道如何

提前致谢


I am createing a cms based on zend framework 2 . I have som modules , let's say News module. It has two controllers one for backend and one for front page :

News Module :
-- AdminController 
-- IndexController

My question is How can I list all AdminControllers in my admin module ? I think it can be achieved by event manager but I don't know how

Thanks in advance


原文:https://stackoverflow.com/questions/21230252
更新时间:2022-07-06 10:07

最满意答案

没有理由不能

Haskell没有方法参数的逗号,尽管它用于数组元素分隔。

从那以后,Smalltalk就没有逗号,因为它们存在于Ruby中。 鉴于Ruby受Smalltalk的影响,似乎添加逗号是一种刻意的语言选择。 (然后,Smalltalk的参数列表样式更像是使用参数传递哈希,但仍然是逗号。)

但是,Ruby确实使用了文字的无逗号数组:

%w[I don't have any commas!]  #=> ["I", "don't", "have", "any", "commas!"]

最后,我认为要问的问题是,使用逗号是否能让事情变得更清晰,更容易解析。 例如,这有多清楚:

foo bar baz

那是foo (bar baz) ,还是foo (bar (baz)) ? 或者甚至((foo) bar) baz) (尽管在非功能性语言中这可能没有多大意义)? 虽然显然知道无论优先级是什么允许你弄清楚这一点,但它也意味着你可能需要更频繁地包括括号,而使用逗号时差异很明显:

foo bar baz   # foo(bar(baz))
foo bar, baz  # foo(bar, baz)

显然,在Ruby中省略括号有时也会导致歧义,但通常会导致语法错误,而不是依赖于事物的优先级。

最终,它是Matz等人的语言选择。 没有理由不这样做,这正是他们认为最有意义的。


There's no reason it couldn't.

Haskell doesn't have commas for method arguments, though it does for array element delimitation.

Smalltalk doesn't have commas at all in the sense of how they exist in Ruby—since. Given that Ruby is influenced by Smalltalk, it seems adding commas was a deliberate language choice. (Then again, Smalltalk's parameter list style is more like passing a hash with arguments, but nevertheless is comma-less.)

Ruby, though, does have comma-less arrays using literals:

%w[I don't have any commas!]  #=> ["I", "don't", "have", "any", "commas!"]

Ultimately I think the question to ask is whether having commas makes things clearer and easier to parse mentally. For example, how clear is this:

foo bar baz

Is that foo (bar baz), or foo (bar (baz))? Or perhaps even ((foo) bar) baz) (though that probably doesn't make much sense in a non-functional language anyway)? While obviously knowing whatever the precedence would be allows you to figure this out, it also means that you may have to include parenthesis more often, while with commas the difference is clear:

foo bar baz   # foo(bar(baz))
foo bar, baz  # foo(bar, baz)

Obviously leaving out parenthesis in Ruby can sometimes cause ambiguity as well, but often it results in a syntax error rather than relying on the precedence of things.

Ultimately, it's a language choice Matz, et al., made. There's no reason it couldn't have been otherwise, it's just what they thought made the most sense.

相关问答

更多
  • 没有理由不能 。 Haskell没有方法参数的逗号,尽管它用于数组元素分隔。 从那以后,Smalltalk就没有逗号,因为它们存在于Ruby中。 鉴于Ruby受Smalltalk的影响,似乎添加逗号是一种刻意的语言选择。 (然后,Smalltalk的参数列表样式更像是使用参数传递哈希,但仍然是逗号。) 但是,Ruby确实使用了文字的无逗号数组: %w[I don't have any commas!] #=> ["I", "don't", "have", "any", "commas!"] 最后,我认为 ...
  • 断言的重要(如果不是主要的)目的是记录应该在代码中的某个点保持的不变量。 如果不变量被破坏, assert也会中止程序的事实只是锦上添花,尽管它非常有用。 我会说在一个典型的程序中,90%的断言是断言,显然不能失败,永远不会失败。 换句话说, assert在很大程度上是一种形式化的评论语言。 形式化的意思是这些“注释”是用相同的语言编写的,其余的代码是用(C / C ++)编写的,而不是简单的英文。 在你的代码示例中,断言在那里告诉你,指针在这里不应该为空。 这就是为什么它在那里。 在这个意义上,这个ass ...
  • 这是多余的,因为除了返回它之外,在emailresult分配值之后,您没有对emailresult做任何事情。 您可以在不需要创建变量的情况下执行以下操作: return email.substring(matcher.start(), matcher.end()); It is redundant because you aren't doing anything with emailresult after assigning it a value besides returning it. You ...
  • 我认为明确性表明私人有助于可读性。 它不会允许程序员不同地解释其可见性。 I think explicity stating private helps in readability. It won't allow for a programmer to interpret its visibility differently.
  • 但是,为什么我的电话没有演员呢? 因为使用JObject参数的重载比使用object参数的重载更好“,因为从null到JObject的转换比从null转换到object更好。 JObject比object更具体,因为有一个从JObject到object的隐式转换,反之亦然。 如果第一个方法的最后一个参数是string (例如),那么这两个重载都不会比另一个更好, 如果没有转换,调用将是不明确的。 有关所有复杂细节,请参见C#5规范的7.5.3节。 特别是7.5.3.5节(“更好的转换目标”)在这里是相关的。 ...
  • 字符串的和平被双重引用。 在添加之前,您可以检查字符串是否已经开始并以引号结束。 if(!tbl.Rows[m][n].StartsWith("\"") && !tbl.Rows[m][n].EndsWith("\"")) strRowValue += tbl.Rows[m][n] + ","; else strRowValue += "\"" + tbl.Rows[m][n] + "\","; That peace of string got doublequoted. You could check ...
  • 根据RFC 8259(JavaScript Object Notation(JSON)数据交换格式) , 冒号和逗号分别列为name-separator和value-separator 。 请参阅第2节.JSON语法 : These are the six structural characters: begin-array = ws %x5B ws ; [ left square bracket begin-object = ws %x7B ws ; { le ...
  • 一个简单的CASE表达式将执行此操作: SELECT *, D = STUFF(( CASE WHEN A = 1 THEN ',A' ELSE '' END + CASE WHEN B = 1 THEN ',B' ELSE '' END + ...
  • “冗余”意味着不必要。 由于在这些情况下编译器显然不需要关键字,因此ReSharper是正确的。 你是否有文体异议是另一回事。 我确信ReSharper可以配置为忽略那些用途,如果这更适合你。 “Redundant” means unnecessary. Since the keyword is clearly not necessary for the compiler in those cases, ReSharper is right. Whether you have stylistic objec ...
  • 这不是多余的。 DOM元素nav与CSS类nav 。 如果您想按类设置此元素的样式,则可以使用此样式声明(例如): .nav { background-color : #F00; } 如果按元素类型设置样式,它将是: nav { background-color : #F00; } 这可能看似微不足道,但那个时期. 有所作为。 这意味着您要按类识别项目,而不是按元素名称识别项目。 如果您使用类语法(使用. ),那么您还可以编写: 如果您包含类定义,则会显 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。