How to extend kernel classes and module's views ?

Author Message

H-Works Agency

Tuesday 28 August 2007 6:31:53 am

Hi all,

Is it possible to extend a kernel class in a custom extension ? For exemple ezOrder ?

I tried to create such an extension by making a "class myOrder extend ezOrder {}". It works of course but i can't add my view to the ezShop module.

I tried to add my new view to viewList() array but its not taken into consideration.

It would be great if we could extend a core class inside a module and to be able to add new views to this module without having to write down a new module with custom class.

This is the same topic as being able to override kernel functions (without going through the "php_include_path" technique).

This would be a great help by allowing us to make small changes, or to correct wrong behavior in kernel functions without having to modify ezp sources or to wait futur releases.

EZP is Great

Piotrek Karaś

Wednesday 07 November 2007 11:09:02 am

Isn't eZ Publish 4 supposed to provide such functionality (to override kernel classes)? Can anyone elaborate on that subject?

(...)

Here we go:
<i>Kernel classes may be overridden by classes in extensions, due to the new autoload regime (making kernel modifications mostly unnecessary), however this flexibility should be exercised with caution.</i>
http://ez.no/developer/news/ez_publish_4_0

Time to try ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

André R.

Wednesday 07 November 2007 12:47:27 pm

Yes it is currently possible to override core classes in eZ Publish 4 with the autoload system, but it's not a intentional feature so might change in the future.

Could you elaborate on what you need it for? (bugs / missing features...)

Overriding classes is of course not recommended in the long run since your override classes could break stuff in a future version and you need to closely watch any changes that are made to those classes each time you update/upgrade.

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

Piotrek Karaś

Wednesday 07 November 2007 1:43:12 pm

That's interesting, the way it was described during the partner meeting - I got an impression that it was a goal that was going to be achieved ;)

Yes, I do see the possible risks, even though I suspect that override system is always provides little bit of safety and flexibility more than direct modification of critical files. Since I don't know how it works exactly at this point, I cannot assess it and tell you whether I will find it useful in the future or not. Maybe once I've played with it a bit in the next days.

I'm mostly thinking of altering some of the system core functions and options. eZ Publish is quite well written and it's very tempting to make use of it ;) The other thing is that I still may not see all the direct and elegant solutions. One of such things: http://ez.no/developer/forum/general/poll_unique_vote_options_summary_and_questions

Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

H-Works Agency

Wednesday 15 June 2011 6:19:21 am

Hello,

Is it possible to add/override a new view to a kernel module ?

Three simple examples/questions :

- You take the built-in "shop" module and you want to add a "reservation" view to it, how would you proceed ?

- Still in that module the built-in "basket" view doesn't suit your needs, how to override it ?

For now to resolve those problems i have to create a whole new module which is long, boring and conceptually not very satisfying.

Thanx in advance.

EZP is Great

Gaetano Giunta

Wednesday 15 June 2011 7:07:58 am

To add a view to an existing module, you could create the view in a custom module then add a virtual-url rule to make your custom view belong in the original module. One drawback: you cannot declare in module.php for module B that a view depends on an access function defined in module A. To do so, you'll have to do explicit perm checking within the view code.

Using url rewrites, you can also "take control" of existing views. Another way to reach the same goal is to change settings in site.ini so that your extension's modules/views are scanned before the kernel ones (but be careful with that)

Principal Consultant International Business
Member of the Community Project Board

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

eZ debug

Timing: Jan 18 2025 03:04:38
Script start
Timing: Jan 18 2025 03:04:38
Module start 'layout'
Timing: Jan 18 2025 03:04:38
Module start 'content'
Timing: Jan 18 2025 03:04:38
Module end 'content'
Timing: Jan 18 2025 03:04:38
Script end

Main resources:

Total runtime0.0168 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.0469152.6406
Module start 'layout' 0.00520.0039 740.687539.4766
Module start 'content' 0.00910.0058 780.164197.3672
Module end 'content' 0.01490.0018 877.531342.3047
Script end 0.0168  919.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002313.5905140.0002
Check MTime0.00105.8874140.0001
Mysql Total
Database connection0.00084.639510.0008
Mysqli_queries0.003319.416830.0011
Looping result0.00000.102210.0000
Template Total0.00159.010.0015
Template load0.00105.692910.0010
Template processing0.00053.251010.0005
Override
Cache load0.00074.244810.0007
General
dbfile0.00095.577980.0001
String conversion0.00000.065340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs