It'd be nice to have:
1) An easy to call, official "IsOverrideEngineInstalled()" function to quickly detect if your framework is installed. Modders would use that call to display a "OE not detected please install from <link>" or even perform an automated installation (like qQModerator does for vQMod).
2) A sort of "Installation success checker" php file. Basically a guy would install your framework and then enter an URL and would see something like:
- Checking if I can instantiate a class from the factory
- Checking for blah blah (basic sanity checks)
"OE succesfully installed"
3) A commented "Hello world" mod skeleton (maybe optional download) to help OE modders get started. After all vQMod comes with examples and the Hostjars website provides an OC module builder and even an OC module creator.
4) A badge, that is an icon that modders can put in their admin section or wherever (maybe embed the code to instantiate it directly in the framework) that says: "Powered by OE framework".
Nothing fancy, just something like the W3C badge you can get if your site validates:
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
OE has born to let extend OC easier.
However I did not find an easy way to extend OE itself.
Use case:
- I created a memcached cache manager for OC.
- I need to instantiate and use it in place of the default cache class.
In original OC, I'd open index.php and would replace:
$cache = new cache();
with
$cache = new mycache();
With OE I have to go dig what
$cache = $factory->newCache();
does.
In system/engine/factory.php I find:
public function newCache() {
return $this->newSystemClass( 'library/cache.php' );
}
Now, in an ideal OOP world I'd expect:
1) public function newCache( $cacheImpl = 'library/cache.php' ) {
return $this->newSystemClass( $cacheImpl );
}
where I can customize the php file I include. This is really easy to implement in the OE core *hint*
2) Ability to inherit
class Factory {
}
and override the newCache() method with my own.
But no, Factory declaration starts with
final class Factory
{
so I can't inherit from it.
What shall I do? A vQMod of factory.php? Sounds quite weird to have to hack in with vQMod into the core of the Engine born to avoid using vQMod.
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
Create an override/mycache/system/library/cache.php with something like this:
Code: Select all
<?php
class mycache_Cache extends Cache {
// overridden method
public function get($key) {
// do my own stuff
// ........
return parent::get($key);
}
// overriden method
public function set($key, $value) {
// do my own stuff
// ........
parent::set($key,$value);
}
..........
}
?>
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
I only have a doubt left about it: how do I tell Opencart's very engine that from now on it has to use a MyCache instance in place of the default class type?
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
The factory will detect the existence of an extended Cache class automatically. The factory class is reponsible for creating instances of Opencart core classes, see e.g.dfumagalli wrote:Thank you so much for the example!
I only have a doubt left about it: how do I tell Opencart's very engine that from now on it has to use a MyCache instance in place of the default class type?
$cache = $factory->newCache();
in the index.php.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
I have been directed here by another poster after I created this thread.
Basically, I'd like a way to intercept calls to controllers so that, in case of invalid controller name I don't get an ugly blank page (with or without PHP Notice printed on it) but I can redirect the user back to the home page.
Is this something managed by OE or that I can manage by subclassing an OC file with OE?
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Thank you,JNeuhoff wrote:You could use PHPs set_error_handler and register_shutdown_function to capture all kinds of errors and to do a graceful exit, e.g. a redirection to a dedicated error page or the home page.
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
I have another question.
I noticed OE forces vQMod to ignore controller.php
So I created a /override/FWMods/system/engine directory and put a derived class with this code:
Code: Select all
<?php
class FWMods_Controller extends Controller
{
protected function render($CacheTimeout = 0) {
foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child);
}
if ($this->factory) {
However my override does not get invoked, ever. Other overrides do but this one won't, I checked step by step with XDebug.
Is it intended?
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
I have both 3rd party and in house made mods that need to modify it.JNeuhoff wrote:This is intended. The system/engine/controller.php is part of Opencart's core engine and should never be modified.
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
I have noticed that the Controller::render function has 3 sections:
1) One deals with the children.
2) One checks for $this->factory != NULL, reads the template, assigns variables and renders the output, then it returns (so the 3rd is not executed).foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child);
}
Code: Select all
if ($this->factory) {
$prefix = $this->factory->getIsAdmin() ? 'admin_view_template_' : 'catalog_view_theme_';
$template_id = $prefix.str_replace( array('/','.'),array('_','_'),$this->template );
$GLOBALS[$template_id] = $this->preRender( $this->factory->readTemplate( $this->template ) );
extract($this->data);
ob_start();
/* Could have used the standard data://text/plain buffer stream,
e.g. require("data://text/plain;base64,".base64_encode($buffer))
but it is not always supported on cheaper web hosts.
Instead we use our own variable stream var://<global-var-id> based on library/variable_stream.php.
*/
require("var://".$template_id);
$this->output = ob_get_contents();
ob_end_clean();
return $this->output;
}
Code: Select all
if (file_exists(DIR_TEMPLATE . $this->template)) {
extract($this->data);
ob_start();
require(DIR_TEMPLATE . $this->template);
$this->output = ob_get_contents();
ob_end_clean();
return $this->output;
} else {
trigger_error('Error: Could not load template ' . DIR_TEMPLATE . $this->template . '!');
exit();
}
I have debugged it and it never gets executed, neither as front end nor in the admin.
It lacks a call to $this->preRender() so this function meant to intercept rendering seems not be invoked from this section.
So, when does section 3 come into play? If so, why no call to $this->preRender() in there?
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
I am back with another of my silly questions.
I am unit testing my OpenCart installation and my add ons.
Since my classes also use Override Engine, I had to include it when my tests are being performed.
But I hit a snag: looks like PHPUnit creates its own var:// wrapper so OE bombs out with:
stream_wrapper_register() /var/www/doman.tld/public_html/system/engine/factory.php:73
PHP Notice: Failed to register protocol for a variable stream in /var/www/domain.tld/public_html/system/engine/factory.php on line 75
Is there any way to make PHPUnit and OE co-exist together? It'd be nice to have OE auto-detect if the stream wrapper was already created and use it without exiting.
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
This is included in a StackOverflow.com question and answer.
Heavy OpenCart Customizations. Current project in progress: fleurworld.com
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
No.straightlight wrote:is it going to be by author from the system/cache folder ?
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Users browsing this forum: No registered users and 32 guests