Problem constructing an ez publish class

Author Message

sean foley

Wednesday 17 June 2009 6:16:52 am

I have a problem when I construct a class using the instance method for example when I need to use ezHTTPTool and I construct it like ezHTTP::instance(); I dont get acces to its function and varibales I have to construct it with the new keyword like
$http = new ezHTTPTool() then I get access to its functions. I am using eclispe and everything works fine. does anyone have any suggestions on this for me.

Thanks

Sean

Carlos Revillo

Wednesday 17 June 2009 6:29:51 am

Don't know if you have made a typo error, but where you say

ezHTTP::instance(); 

shouldn't it be

ezHTTPTool::instance(); 

?

sean foley

Wednesday 17 June 2009 7:52:01 am

yes of course its a typo just here in my thread, I have the correct syntax in my main project script

its very strange that I need to use "new" to construct my class and that instance function does'nt allow me to have access to the classes functions. ??

I'm baffled by this I think its a bit stupid really there should only be one way to construct a class like in Java you have to use new, PHP has too many loose ends.

André R.

Wednesday 17 June 2009 7:58:21 am

Your ARE supposed to use instance(), it calls new for you and makes sure there is only one instance created of the object.
Your issue is very strange, what php version is this and what function do you try to call and how?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

André R.

Wednesday 17 June 2009 8:00:44 am

Working example from ezoe:

$http = eZHTTPTool::instance();

if ( $http->hasPostVariable( 'SearchStr' ) )
{
    $searchStr = trim( $http->postVariable( 'SearchStr' ) );
}

So, check your case/typing on the class/function name.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

sean foley

Thursday 18 June 2009 1:17:15 am

Hi,

The problem is when I am using the classes below I have a problem when I construct them like this:
$ini = eZINI::instance();
$http = eZHTTPTool::instance();

Whats happening in eclipse is when I then type $http->
I dont get the intelli sence list dropping down so I can select the method I need
but when I use the new I can get access to the methods

$http = new eZHTTPTool();
$ini = new eZINI('EclipseNetSettings.ini');

So why is that should'nt the instance method do the same thing?

André R.

Thursday 18 June 2009 1:44:36 am

ahh, your talking about eclipse IntelliSense..
Thought you where talking about code not working in php.

I'm not sure how eclipse would understand what the function returns, remember that php is loosely typed so it's a bit unfair to compare it to java since those are two different worlds, and comparing it by how a java IDE supports it is.... well..
But you can try to add some php doc to the function to see if that helps.

It would be something like:

    /**
     * Return the unique instance of the HTTP tool
     *
     * @static
     * @return eZHTTPTool
     */

At least that made NetBeans (6.7) understand what kind of object it was for me.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

sean foley

Friday 19 June 2009 6:13:43 am

Thanks for your reply Andre, Yes the code executes fine but I would like to get the intillisence drop down when I need to use a method. I will add the phpDoc and see what happens

Cheers
Sean

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.