Friday 11 December 2009 9:29:49 am - 20 replies
Hi all -
I am trying to override the class eZContentOperationCollection.
I have added this line in ezp_override.php:
'eZContentOperationCollection' => 'extension/myext/kernel/content/ezcontentoperationcollection.php',
But It won't override the kernel file. When I try to generate the autoload-array I get an error message: already defined and not added to the autoload array..
What am I doing wrong? I hope someone can help me soon as this is kind of urgent =/
Frank
Friday 11 December 2009 10:04:18 am
Hi Frank,
usually the method is the following :
php bin/php/ezpgenerateautoloads.php -o
No direct edition of the autolad files.
Have you tried this already ?
Let us know,
Nicolas
Friday 11 December 2009 11:56:54 am
for versions 4.1 and 4.2 you also have to set this in the /config.php file:
/*
KERNEL OVERRIDES
----------------
This setting controls if eZ Publish's autoload system should allow, and
load classes, which override kernel classes from extensions.
*/
define( 'EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE', true );
I think before that it was an undocumented "feature".
Friday 11 December 2009 11:58:11 am
Hi Nicolas and thank you for your quick reply!
I do not have shell access, but the server owner ran the commands for me - this is the output:
Still not working ![]()
- - - - - -
php bin/php/ezpgenerateautoloads.php -o
Scanning for PHP-files.
Scan complete. Found 176 PHP files.
Searching for classes (tokenizing).
Class eZUserShopAccountHandler in file extension/myext/kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php will override:
kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php (autoload/ezp_kernel.php)
Class eZContentOperationCollection in file extension/myext/kernel/content/ezcontentoperationcollection.php will override:
kernel/content/ezcontentoperationcollection.php (autoload/ezp_kernel.php)
Found 37 classes, added 2 of them to the autoload array.
php bin/php/ezpgenerateautoloads.php
Scanning for PHP-files.
Scan complete. Found 176 PHP files.
Searching for classes (tokenizing).
Warning:
Class eZUserShopAccountHandler in file extension/myext/kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php is already defined in:
kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php (autoload/ezp_kernel.php)
This class was not added to the autoload array.
Warning:
Class eZContentOperationCollection in file extension/myext/kernel/content/ezcontentoperationcollection.php is already defined in:
kernel/content/ezcontentoperationcollection.php (autoload/ezp_kernel.php)
This class was not added to the autoload array.
Found 37 classes, added 35 of them to the autoload array.
PHP Warning: chmod(): Operation not permitted in /home/sites/XXX.no/www/kernel/private/classes/ezautoloadgenerator.php on line 253
Modified on Friday 11 December 2009 12:00:23 pm by Frank Reiersen
Saturday 12 December 2009 12:32:31 pm
Just a note: there are still a few places in eZP (esp. ez-approved extensions) where include_once and require_once are present, hardcoded to the php classes in the standard directories. You should take care about that when overriding the provided php classes...
Monday 14 December 2009 1:20:44 pm
PHP Warning: chmod(): Operation not permitted in /home/sites/XXX.no/www/kernel/private/classes/ezautoloadgenerator.php on line 253
Hi Frank,
The quote above tells us the autoload file can not be written. You need to run the same command as a sufficiently privileged user. This can be something like this :
sudo php bin/php/ezpgenerateautoloads.php -o
Let us know how it goes,
Modified on Tuesday 22 December 2009 9:44:46 am by Nicolas Pastorino
Monday 21 December 2009 12:17:00 pm
Kernel override capability is great but there are 2 issues though :
Tuesday 22 December 2009 10:26:47 am
Kernel override capability is great but there are 2 issues though :
- Does not work with datatypes (sometimes really annoying)
- When setting EZP_AUTOLOAD_ALLOW_KERNEL_OVERRIDE in config.php, it does a require_once() statement of var/autoload/ezp_override.php without testing if it exists. So you can have a PHP Fatal Error if you just plan to make a kernel override...
I can only agree with this, and can not find any bug report for this. It seems like you'd need to author a few ones ![]()
Cheers Jérôme!
Tuesday 22 December 2009 11:36:31 am
Done !
http://issues.ez.no/IssueView.php?Id=15982
http://issues.ez.no/IssueView.php?Id=15983 (with patch)
Modified on Tuesday 22 December 2009 11:37:17 am by Jérôme Vieilledent
Tuesday 22 December 2009 12:23:05 pm
http://issues.ez.no/IssueView.php?Id=15983 (with patch)
I can see a teasing comment on this one... (in the issue tracker directly), from a certain Bertrand Dunogier...you may want to have a look at it ![]()
Brilliant otherwise !
Tuesday 22 December 2009 6:48:35 pm
http://issues.ez.no/IssueView.php?Id=15983 (with patch)
And ... fixed!
Thanks Jerome for reporting, and Bertrand for fixing ![]()
Friday 30 April 2010 1:07:09 pm
Hi,
A little trick to Override a module in ez, (this is not very clean but it can be useful when you can not do this otherwise)
In the file module.ini, define:
[ModuleSettings]
# Important to initialize the variable
ModuleRepositories []
ModuleRepositories [] =extension / [costum_extension] / modules
ModuleRepositories [] =kernel
ModuleRepositories []=kernel / private / modules
PS: But we must override all of the views's module.
I hope it will be useful for someone![]()
Modified on Friday 30 April 2010 1:08:41 pm by Abdelkader RHOUATI
Friday 30 April 2010 7:41:24 pm
@Jérôme, yes, every day we discovered new things about EZ ![]()
In fact we can do the same thing to override the datatype. On a project, I overloaded single relation object datatype in order to redirect the link browse to the destination defined in the class. and it work well.
to do it, edit file content.ini, and set the parameter :
[DataTypeSettings]
RepositoryDirectories []
RepositoryDirectories []=extension/[Costum Extension]/datatypes
RepositoryDirectories []=kernel/classes/datatypes
Regrads
Tks
Modified on Friday 30 April 2010 7:46:25 pm by Abdelkader RHOUATI
Tuesday 25 January 2011 11:52:08 am
To override the default shop user handler (kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php) you need to create settings/override/shopaccount.ini.append.php:
<?php /* #?ini charset="utf-8"? [HandlerSettings] Repositories[] Repositories[]=extension/your_extension/classes Repositories[]=kernel/classes */ ?>
Then take a copy of kernel/classes/shopaccounthandlers/ezusershopaccounthandler.php to extension/your_extension/classes/shopaccounthandlers/ezusershopaccounthandler.php
Then run kernel override autorun. Easiest way to verify that it is working is just to echo something in the beginning of your custom ezusershopaccounthandler.php
You must be logged in to post messages in this topic!