views:

89

answers:

4

Hello, I was just traversing the workflow of zend framework and cant really find where the function "findByUri()" is located, I found the class it belongs , simply dumping it, but going through the hierarchy of that class(parents , interfaces and so forth) I cant really find it. I found where it is called from

....
 call_user_func_array(
            array($this->getContainer(), $method),
            $arguments);
    ...

but it is not in there (the class that GetContainer() returns)

any Idea, I know u can assign a variable to class simple by $class->someVar =...; But never had done it with class functions... Thanks

A: 

I use Agent Ransack to search through codebases that are not my own. You'd be looking for this string:

"function findByUri"
Raveren
Any half-decent IDE would allow searching through the codebase and also support Ctrl-Click on the method call to open it's declaring file.
Gordon
nea it has to do something with a dynamically assigning the function, I am sure it is not there
simple
@Gordon some of us prefer Notepad++
Raveren
@Raveren Yeah, those usually don't mind pain as well ;)
Gordon
There's no need to be all in my face about your programming habbits.
Raveren
@Raveren I apologize if my remarks offended you.
Gordon
A: 

grep is your friend.

From a shell:

grep -ir "function findByUri" .

More about the grep command:

http://unixhelp.ed.ac.uk/CGI/man-cgi?grep

Roberto Aloi
The thing is in the IDE and inside the class there is no such a method but -"findBy()", So I am thinking is there a way to override the function name ? sound silly for me now , though I am not really a newbie =)
simple
A: 

If it's really the implementation of a function you're looking for, I'd say that's what a PHP IDE is for. Every decent PHP IDE can find out where a function was defined.

Related: Any good PHP IDE, preferably free or cheap?

Pekka
once again I use Zend studio and I am not really the newbie, but cant find the function implementation, thought will go and google any function name overriding , thanks
simple
Aptana: http://aptana.org/NetBeans: http://www.netbeans.org/
Adrian
+1  A: 

There is no method by this name in the entire ZF. It's probably a magic accessor done within a __call method of $this->container. I take the snippet you provided is from Zend_View_Helper_Navigation_HelperAbstract, so it should be any of the classes belonging to the Zend_Navigation package.

EDIT
From the ZF Reference Manual on Zend_Navigation containers:

Containers have finder methods for retrieving pages. They are findOneBy($property, $value), findAllBy($property, $value), and findBy($property, $value, $all = false). Those methods will recursively search the container for pages matching the given $page->$property == $value. The first method, findOneBy(), will return a single page matching the property with the given value, or NULL if it cannot be found. The second method will return all pages with a property matching the given value. The third method will call one of the two former methods depending on the $all flag.

The finder methods can also be used magically by appending the property name to findBy, findOneBy, or findAllBy, e.g. findOneByLabel('Home') to return the first matching page with label Home. Other combinations are findByLabel(...), findOnyByTitle(...), findAllByController(...), etc. Finder methods also work on custom properties, such as findByFoo('bar').

Gordon
well yes it is the "__call()" is the one that is calling the $method =findByUri on Zend_Navigation object, Magic Accessor's - let me read on them. I knew there was some magic in it , hehe thanks
simple
@simple if you want to make sure, run XDebug or Zend Debugger on the code to see what happens.
Gordon
from manual "Keep in mind that when your class has a __call() function, it will be used when PHP calls some other magic functions"thanks that was it, I never used magic ones before hehe, sorry I abused my right to be stupid.
simple
@simple I added the corresponding part from the ZF manual to the answer
Gordon