Forums / General / Problem constructing an ez publish class

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

eZ debug

Timing: Jan 18 2025 11:33:46
Script start
Timing: Jan 18 2025 11:33:46
Module start 'content'
Timing: Jan 18 2025 11:33:46
Module end 'content'
Timing: Jan 18 2025 11:33:47
Script end

Main resources:

Total runtime1.0058 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0104 587.8203180.8203
Module start 'content' 0.01040.8737 768.6406642.4609
Module end 'content' 0.88410.1216 1,411.1016341.0781
Script end 1.0057  1,752.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3856210.0002
Check MTime0.00150.1505210.0001
Mysql Total
Database connection0.00130.131010.0013
Mysqli_queries0.927492.21242110.0044
Looping result0.00210.20702090.0000
Template Total0.969396.420.4847
Template load0.00190.192320.0010
Template processing0.967496.183620.4837
Template load and register function0.00020.020510.0002
states
state_id_array0.00110.111610.0011
state_identifier_array0.00100.095720.0005
Override
Cache load0.00170.1648500.0000
Sytem overhead
Fetch class attribute can translate value0.00150.147340.0004
Fetch class attribute name0.00080.081390.0001
XML
Image XML parsing0.00090.090240.0002
class_abstraction
Instantiating content class attribute0.00000.0020110.0000
General
dbfile0.00200.1973280.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs