在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
最满意答案
没有理由不能 。
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)
, orfoo (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是多余的吗?(Is ASSERT redundant?)[2023-12-30]
断言的重要(如果不是主要的)目的是记录应该在代码中的某个点保持的不变量。 如果不变量被破坏, 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 ...
-
如果使用私有访问修饰符是多余的?(Should you use the private access modifier if it's redundant? [closed])[2023-05-28]
我认为明确性表明私人有助于可读性。 它不会允许程序员不同地解释其可见性。 I think explicity stating private helps in readability. It won't allow for a programmer to interpret its visibility differently. -
为什么这个演员多余?(Why is this cast redundant?)[2023-05-04]
但是,为什么我的电话没有演员呢? 因为使用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 ...
-
在HTML5 + CSS中,[2022-11-21]
这不是多余的。 DOM元素nav与CSS类nav 。 如果您想按类设置此元素的样式,则可以使用此样式声明(例如): .nav { background-color : #F00; } 如果按元素类型设置样式,它将是: nav { background-color : #F00; } 这可能看似微不足道,但那个时期. 有所作为。 这意味着您要按类识别项目,而不是按元素名称识别项目。 如果您使用类语法(使用. ),那么您还可以编写: 如果您包含类定义,则会显 ...