Magenta Pools in Zend Framework

I really like how Magento uses code pools so classes and functionality can be extended without changing the core functionality of the code.

(for those who are not familiar with Magento, you can have the same class in the "main" code pool and the "local" code pool, and when you create the class, it first looks in the "local" code pool, and if it does not exist, it looks into the "main" pool of codes)

I know that Magneto uses the Zend Framework, so I was wondering if Varien used something already inside the Zend Framework if they did it themselves? Or if someone knows, is there a good way to effectively do this in the Zend Framework?

+3
source share
1 answer

I don’t know how Magento does this (tipp: look at the source code), but you can probably achieve the same Zend_Autoloader, for example, when you try to load a class, the Foo_Bar_Bazautoloader first looks in Local/Foo/Bar/Baz, and if the file is not there, it will try to load from Core/Foo/Bar/Baz.


Note. . If anyone is interested, take a look at the top app/Mage.php(shutter speed) to see how this is set. --Alan

if (defined('COMPILER_INCLUDE_PATH')) {
    $appPath = COMPILER_INCLUDE_PATH;
    set_include_path($appPath . PS . Mage::registry('original_include_path'));
    include_once "Mage_Core_functions.php";
    include_once "Varien_Autoload.php";
} else {
    /**
     * Set include path
     */
    $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
    $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
    $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
    $paths[] = BP . DS . 'lib';

    $appPath = implode(PS, $paths);
    set_include_path($appPath . PS . Mage::registry('original_include_path'));
    include_once "Mage/Core/functions.php";
    include_once "Varien/Autoload.php";
}
+3
source

Source: https://habr.com/ru/post/1774516/


All Articles