├── CONTIBUTING.md
├── LICENSE
├── README.md
├── app
├── code
│ └── community
│ │ ├── Eltrino
│ │ └── Compatibility
│ │ │ ├── Block
│ │ │ └── Head
│ │ │ │ └── Item.php
│ │ │ ├── Helper
│ │ │ └── Data.php
│ │ │ ├── Model
│ │ │ ├── Layout.php
│ │ │ ├── Modules.php
│ │ │ ├── Observer.php
│ │ │ ├── SplAutoloader.php
│ │ │ └── Xml
│ │ │ │ ├── Config.php
│ │ │ │ ├── Config
│ │ │ │ └── Module.php
│ │ │ │ └── Modules.php
│ │ │ ├── etc
│ │ │ └── config.xml
│ │ │ └── sql
│ │ │ └── eltrino_compatibility_setup
│ │ │ └── mysql4-install-1.0.0.php
│ │ └── Magento
│ │ ├── Checkout
│ │ ├── Block
│ │ │ └── Onepage
│ │ │ │ └── Success.php
│ │ └── Model
│ │ │ └── Session.php
│ │ ├── Cron
│ │ └── Model
│ │ │ └── Schedule.php
│ │ ├── Customer
│ │ └── Model
│ │ │ └── Session.php
│ │ ├── Framework
│ │ ├── App
│ │ │ ├── Action
│ │ │ │ ├── Action.php
│ │ │ │ └── Context.php
│ │ │ └── Helper
│ │ │ │ └── AbstractHelper.php
│ │ ├── Controller
│ │ │ └── Result
│ │ │ │ └── ForwardFactory.php
│ │ ├── Event
│ │ │ └── Observer.php
│ │ ├── Exception
│ │ │ └── LocalizedException.php
│ │ ├── Model
│ │ │ ├── AbstractModel.php
│ │ │ └── Resource
│ │ │ │ └── Db
│ │ │ │ └── AbstractDb.php
│ │ ├── Registry.php
│ │ └── View
│ │ │ └── Element
│ │ │ └── Template.php
│ │ └── Sales
│ │ └── Model
│ │ ├── Order.php
│ │ └── Order
│ │ └── Config.php
└── etc
│ └── modules
│ └── Eltrino_Compatibility.xml
└── modman
/CONTIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | ## Adding new features and coverage
4 |
5 | * All improvements should be submitted as Github issues
6 | * We prefer that all code will pass PSR-1 & PSR-2
7 | * Pull requests should be submitted to master branch
8 | * If possible include tests for new functionality
9 | * New features should include updates to documentation
10 |
11 | Don’t get discouraged! We estimate that the response time from the maintainers is around 2 days
12 |
13 | ## Documentation
14 |
15 | Documentation for existing functionality could be improved in the same way as new features
16 |
17 | * All improvements should be submitted as Github issues
18 | * Pull requests should be submitted to master branch
19 |
20 | If you have further questions, contact: @eltrino
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Eltrino LLC (http://eltrino.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compatibility
2 |
3 | This extension is built for Magento 1.x. It allows to use newer extensions built for Magento 2 on older version of Magento.
4 |
5 | There are following main parts of this extension:
6 | - Adapters which helps to run new architecture elements (layouts, controllers, helpers, etc) on the old platform
7 | - Extended autoloader
8 | - Class placeholders to retain inheritance between classes
9 |
10 | ## Installation
11 |
12 | Download this extension from Github and unpack it into Magento root folder.
13 |
14 | Also it’s possible to install it through composer. Make sure you have added [Firegento repository](http://packages.firegento.com/) to your `composer.json`.
15 |
16 | Add as dependency to your project using composer
17 |
18 | ```bash
19 | composer require eltrino/compatibility:dev-master
20 | ```
21 |
22 | ## Bugs
23 |
24 | Please report all found issues or suggest improvements as Github issues.
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Block/Head/Item.php:
--------------------------------------------------------------------------------
1 | getCss()) {
31 | return $this->getCssOutput();
32 | }
33 | }
34 |
35 | public function getCssOutput()
36 | {
37 | $args = explode('::', $this->getCss());
38 | $file = Mage::getModuleDir('', $args[0]).'/view/frontend/web/'.$args[1];
39 | $url = str_replace(Mage::getBaseDir(), rtrim(Mage::getBaseUrl(), '/'), $file);
40 |
41 | return sprintf('', $url);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Helper/Data.php:
--------------------------------------------------------------------------------
1 | getFrontController()->getAction();
32 | /** @var Mage_Core_Model_Layout $layout */
33 | $layout = $action->getLayout();
34 | /** @var Mage_Core_Model_Layout_Update $update */
35 | $update = $layout->getUpdate();
36 | /** @var array $handles */
37 | $handles = $update->getHandles();
38 |
39 | foreach (static::$_loadedModules as $moduleName) {
40 | $layoutDir = Mage::getModuleDir('', $moduleName).'/view/frontend/layout/';
41 | if (!is_readable($layoutDir)) {
42 | continue;
43 | }
44 |
45 | $handlesToUpdate = array();
46 | foreach (glob($layoutDir.'*.xml') as $layoutFile) {
47 | $handleName = basename($layoutFile, '.xml');
48 | if (in_array($handleName, $handles)) {
49 | $handlesToUpdate[] = $handleName;
50 | }
51 | }
52 |
53 | if (!count($handlesToUpdate)) {
54 | return;
55 | }
56 |
57 | $action->loadLayoutUpdates();
58 |
59 | foreach ($handlesToUpdate as $handleName) {
60 | $layoutFile = $layoutDir.$handleName.'.xml';
61 | $xml = new Varien_Simplexml_Element(file_get_contents($layoutFile));
62 | $newXml = new Mage_Core_Model_Layout_Element('');
63 | /* @var Varien_Simplexml_Element $child */
64 |
65 | if ($xml->getName() == 'page') {
66 | $layoutPageUpdate = $xml->getAttribute('layout');
67 | if ($layoutPageUpdate) {
68 | $reference = $newXml->addChild('reference');
69 | $reference->addAttribute('name', 'root');
70 | $reference->addChild('action');
71 | $reference->action->addAttribute('method', 'setTemplate');
72 | $reference->action->addChild('template', 'page/'.$layoutPageUpdate.'.phtml');
73 | }
74 | }
75 |
76 | foreach ($xml as $child) {
77 | if ($child->getName() == 'head') {
78 | $reference = $newXml->addChild('reference');
79 | $reference->addAttribute('name', 'head');
80 | foreach ($child as $element) {
81 | if ($element->getName() == 'css') {
82 | $block = $reference->addChild('block');
83 | $block->addAttribute('name', 'head.item');
84 | $block->addAttribute('type', 'eltrino_compatibility/head_item');
85 | $xmlAction = $block->addChild('action');
86 | $xmlAction->addAttribute('method', 'setCss');
87 | $xmlAction->addChild('src', $element['src']);
88 | }
89 | }
90 | }
91 | if ($child->getName() == 'body') {
92 | foreach ($child as $element) {
93 | if ($element->getName() == 'referenceContainer') {
94 | $reference = $newXml->addChild('reference');
95 | $reference->addAttribute('name', $element['name']);
96 | foreach ($element as $subElement) {
97 | if ($subElement->getName() == 'block') {
98 | $block = $reference->addChild('block');
99 | /* TODO: do check is attribute exists before add */
100 | $block->addAttribute('name', $subElement['name']);
101 | $block->addAttribute('type', $subElement['class']);
102 | $block->addAttribute('after', $subElement['after']);
103 | $block->addAttribute('template', $subElement['template']);
104 | }
105 | }
106 | }
107 | }
108 | }
109 | }
110 | $newXml = $newXml->asNiceXml();
111 | $newXml = str_replace('', '', $newXml);
112 | $newXml = str_replace('', '', $newXml);
113 | $update->addUpdate($newXml);
114 | }
115 | $action->generateLayoutXml()->generateLayoutBlocks();
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/Modules.php:
--------------------------------------------------------------------------------
1 | fetchFiles();
34 |
35 | if (empty($files)) {
36 | return;
37 | }
38 |
39 | $loadedModules = Mage::getModel('eltrino_compatibility/xml_modules')->loadModules($files);
40 |
41 | if (empty($loadedModules)) {
42 | return;
43 | }
44 |
45 | static::$_loadedModules = array_merge(static::$_loadedModules, $loadedModules);
46 |
47 | Mage::getModel('eltrino_compatibility/xml_config')->loadConfig($loadedModules);
48 |
49 | Mage::getConfig()->saveCache();
50 | }
51 |
52 | /**
53 | * Retrieve list of magento2 modules on the basis of files "module.xml".
54 | *
55 | * @return array
56 | */
57 | public function fetchFiles()
58 | {
59 | if ($cache = $this->getCache()) {
60 | if ($files = $cache->load(static::COMPATIBILITY_MODULES_FILE_CACHE)) {
61 | return unserialize($files);
62 | }
63 | }
64 |
65 | $files = array();
66 | foreach ($this->_allowedPools as $pool) {
67 | foreach (glob(Mage::getBaseDir().'/app/code/'.$pool.'/*/*/') as $moduleDir) {
68 | $file = realpath($moduleDir.'etc/module.xml');
69 | if (file_exists($file)) {
70 | $files[] = $file;
71 | }
72 | }
73 | }
74 |
75 | if ($cache) {
76 | $cache->save(serialize($files), static::COMPATIBILITY_MODULES_FILE_CACHE, array(static::CACHE_TAG));
77 | }
78 |
79 | return $files;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/Observer.php:
--------------------------------------------------------------------------------
1 | _useCache = Mage::app()->useCache(static::CACHE_GROUP);
51 | $this->_cacheTags = array(
52 | Mage_Core_Model_Config::CACHE_TAG,
53 | static::CACHE_TAG,
54 | );
55 | }
56 |
57 | /**
58 | * This is a first observer in magento
59 | * where we can update module list and configuration.
60 | *
61 | * @param $observer
62 | */
63 | public function resourceGetTableName($observer)
64 | {
65 | if ($observer->getTableName() !== 'core_website') {
66 | return;
67 | }
68 |
69 | try {
70 | Mage::getSingleton('eltrino_compatibility/modules')->loadModules();
71 | Mage_Core_Model_Resource_Setup::applyAllUpdates();
72 | } catch (Exception $e) {
73 | Mage::logException($e);
74 | }
75 | }
76 |
77 | public function controllerActionLayoutRenderBefore($observer)
78 | {
79 | try {
80 | Mage::getSingleton('eltrino_compatibility/layout')->addLayoutUpdates();
81 | } catch (Exception $e) {
82 | Mage::logException($e);
83 | }
84 | }
85 |
86 | public function getLoadedModules()
87 | {
88 | return static::$_loadedModules;
89 | }
90 |
91 | public function addLoadedModules($modules)
92 | {
93 | if (!is_array($modules)) {
94 | $modules = array($modules);
95 | }
96 | static::$_loadedModules = array_merge(static::$_loadedModules, $modules);
97 | }
98 |
99 | public function getCache()
100 | {
101 | if ($this->_useCache) {
102 | return Mage::app()->getCache();
103 | }
104 |
105 | return false;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/SplAutoloader.php:
--------------------------------------------------------------------------------
1 | .
18 | */
19 |
20 | /**
21 | * SplClassLoader implementation that implements the technical interoperability
22 | * standards for PHP 5.3 namespaces and class names.
23 | *
24 | * http://groups.google.com/group/php-standards/web/final-proposal
25 | *
26 | * // Example which loads classes for the Doctrine Common package in the
27 | * // Doctrine\Common namespace.
28 | * $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');
29 | * $classLoader->register();
30 | *
31 | * @license http://www.opensource.org/licenses/mit-license.html MIT License
32 | * @author Jonathan H. Wage
33 | * @author Roman S. Borschel
34 | * @author Matthew Weier O'Phinney
35 | * @author Kris Wallsmith
36 | * @author Fabien Potencier
37 | */
38 | class Eltrino_Compatibility_Model_SplAutoloader extends Mage_Core_Model_Abstract
39 | {
40 | private $_fileExtension = '.php';
41 | private $_namespace;
42 | private $_includePath;
43 | private $_namespaceSeparator = '\\';
44 |
45 | /**
46 | * Creates a new SplClassLoader that loads classes of the
47 | * specified namespace.
48 | *
49 | * @param string $ns The namespace to use.
50 | */
51 | public function __construct($ns = null, $includePath = null)
52 | {
53 | $this->_namespace = $ns;
54 | $this->_includePath = $includePath;
55 | }
56 |
57 | /**
58 | * Sets the namespace separator used by classes in the namespace of this class loader.
59 | *
60 | * @param string $sep The separator to use.
61 | */
62 | public function setNamespaceSeparator($sep)
63 | {
64 | $this->_namespaceSeparator = $sep;
65 | }
66 |
67 | /**
68 | * Gets the namespace seperator used by classes in the namespace of this class loader.
69 | *
70 | * @return string
71 | */
72 | public function getNamespaceSeparator()
73 | {
74 | return $this->_namespaceSeparator;
75 | }
76 |
77 | /**
78 | * Sets the base include path for all class files in the namespace of this class loader.
79 | *
80 | * @param string $includePath
81 | */
82 | public function setIncludePath($includePath)
83 | {
84 | $this->_includePath = $includePath;
85 | }
86 |
87 | /**
88 | * Gets the base include path for all class files in the namespace of this class loader.
89 | *
90 | * @return string $includePath
91 | */
92 | public function getIncludePath()
93 | {
94 | return $this->_includePath;
95 | }
96 |
97 | /**
98 | * Sets the file extension of class files in the namespace of this class loader.
99 | *
100 | * @param string $fileExtension
101 | */
102 | public function setFileExtension($fileExtension)
103 | {
104 | $this->_fileExtension = $fileExtension;
105 | }
106 |
107 | /**
108 | * Gets the file extension of class files in the namespace of this class loader.
109 | *
110 | * @return string $fileExtension
111 | */
112 | public function getFileExtension()
113 | {
114 | return $this->_fileExtension;
115 | }
116 |
117 | /**
118 | * Installs this class loader on the SPL autoload stack.
119 | */
120 | public function register()
121 | {
122 | spl_autoload_register(array($this, 'loadClass'), true, true);
123 | }
124 |
125 | /**
126 | * Uninstalls this class loader from the SPL autoloader stack.
127 | */
128 | public function unregister()
129 | {
130 | spl_autoload_unregister(array($this, 'loadClass'));
131 | }
132 |
133 | /**
134 | * Loads the given class or interface.
135 | *
136 | * @param string $className The name of the class to load.
137 | */
138 | public function loadClass($className)
139 | {
140 | $className = ltrim($className, '\\');
141 | $fileName = '';
142 | if ($lastNsPos = strripos($className, '\\')) {
143 | $namespace = substr($className, 0, $lastNsPos);
144 | $className = substr($className, $lastNsPos + 1);
145 | $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR;
146 | }
147 | $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
148 | $fileName = stream_resolve_include_path($fileName);
149 | if (false !== $fileName) {
150 | include_once $fileName;
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/Xml/Config.php:
--------------------------------------------------------------------------------
1 | loadModuleConfig();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/Xml/Config/Module.php:
--------------------------------------------------------------------------------
1 | _config = Mage::getConfig();
42 | $this->_moduleName = $moduleName;
43 | $this->_moduleDir = realpath(Mage::getModuleDir('', $moduleName));
44 | $this->_etcModuleDir = realpath(Mage::getModuleDir('etc', $moduleName));
45 | }
46 |
47 | public function loadModuleConfig()
48 | {
49 | /* Register Psr0 AutoLoader */
50 | Mage::getModel('eltrino_compatibility/splAutoloader')->register();
51 |
52 | $this->loadGlobalConfig();
53 | $this->loadDiConfig();
54 | $this->loadFrontendConfig();
55 | $this->loadCrontabConfig();
56 | }
57 |
58 | public function loadGlobalConfig()
59 | {
60 | /** @var Mage_Core_Model_Config_Element $globalNode */
61 | $globalNode = $this->_config->getNode('global');
62 | if (is_readable($this->_moduleDir.'/Block')) {
63 | /** @var Mage_Core_Model_Config_Element $blocks */
64 | $blocks = $globalNode->blocks;
65 | $namespace = str_replace('_', '\\', $this->_moduleName).'\\'.'Block';
66 | $child = $blocks->addChild(strtolower($this->_moduleName));
67 | $child->addChild('class', $namespace);
68 |
69 | // Block factory not used autoloader
70 | // so we need to load file here
71 | foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->_moduleDir.'/Block/')) as $filename) {
72 | if (pathinfo($filename, PATHINFO_EXTENSION) != 'php') {
73 | continue;
74 | }
75 | if (is_readable($filename)) {
76 | include_once $filename;
77 | }
78 | }
79 | }
80 |
81 | if (is_readable($this->_moduleDir.'/Model')) {
82 | /** @var Mage_Core_Model_Config_Element $models */
83 | $models = $globalNode->models;
84 | $namespace = str_replace('_', '\\', $this->_moduleName).'\\'.'Model';
85 | $child = $models->addChild(strtolower($this->_moduleName));
86 | $child->addChild('class', $namespace);
87 |
88 | // Add resource model
89 | // TODO: Now works only with one resource model
90 | if (is_readable($this->_moduleDir.'/Model/Resource')) {
91 | $resourceModelName = strtolower($this->_moduleName).'_resource';
92 | $child->addChild('resourceModel', $resourceModelName);
93 | $resourceModelChild = $models->addChild($resourceModelName);
94 | $entities = $resourceModelChild->addChild('entities');
95 | foreach (glob($this->_moduleDir.'/Model/Resource/*.php') as $file) {
96 | $entity = strtolower(basename($file, '.php'));
97 | $entities->addChild($entity);
98 | $resourceToParse = file_get_contents($file);
99 | preg_match("~init\('(.*)'\,~", $resourceToParse, $ms);
100 | if (!isset($ms[1])) {
101 | continue;
102 | }
103 | $entities->$entity->addChild('table', $ms[1]);
104 | $resourceModelChild->addChild('class', $namespace.'\Resource\\'.basename($file, '.php'));
105 | }
106 | }
107 | }
108 |
109 | if (is_readable($this->_moduleDir.'/sql')) {
110 | /** @var Mage_Core_Model_Config_Element $resources */
111 | $resources = $globalNode->resources;
112 | foreach (glob($this->_moduleDir.'/sql/*', GLOB_ONLYDIR) as $dir) {
113 | $nodeName = basename($dir);
114 | $resources->addChild($nodeName);
115 | $resources->$nodeName->addChild('setup');
116 | $resources->$nodeName->setup->addChild('module', $this->_moduleName);
117 | }
118 | }
119 |
120 | if (is_readable($this->_moduleDir.'/Helper')) {
121 | /** @var Mage_Core_Model_Config_Element $helpers */
122 | $helpers = $globalNode->helpers;
123 | $namespace = str_replace('_', '\\', $this->_moduleName).'\\'.'Helper';
124 | $child = $helpers->addChild(strtolower($this->_moduleName));
125 | $child->addChild('class', $namespace);
126 | }
127 | }
128 |
129 | public function loadFrontendConfig()
130 | {
131 | $frontendConfigDir = realpath($this->_etcModuleDir.DIRECTORY_SEPARATOR.'frontend');
132 | if (!is_readable($frontendConfigDir)) {
133 | return;
134 | }
135 | /** @var Mage_Core_Model_Config_Element $frontend */
136 | $frontend = $this->_config->getNode('frontend');
137 | foreach (glob($frontendConfigDir.'/*.xml') as $file) {
138 | $sectionName = basename($file, '.xml');
139 | $newConfig = Mage::getModel('core/config_base');
140 | $newConfig->loadFile($file);
141 | if ($sectionName == 'events') {
142 | /** @var Mage_Core_Model_Config_Element $events */
143 | $events = $frontend->{$sectionName};
144 | foreach ($newConfig->getNode('event') as $newEvent) {
145 | $eventName = (string) $newEvent['name'];
146 | if (!isset($events->$eventName)) {
147 | $child = $events->addChild((string) $newEvent['name']);
148 | $observers = $child->addChild('observers');
149 | } else {
150 | $observers = $events->{$eventName}->observers;
151 | }
152 |
153 | $observerChild = $observers->addChild((string) $newEvent->observer['name']);
154 | $observerChild->addChild('class', (string) $newEvent->observer['instance']);
155 | $observerChild->addChild('method', (string) $newEvent->observer['method']);
156 | }
157 | }
158 |
159 | if ($sectionName == 'routes') {
160 | /** @var Mage_Core_Model_Config_Element $routers */
161 | $router = $frontend->routers->addChild(
162 | $newConfig->getNode('router')->getAttribute('id')
163 | );
164 | $router->addChild('use', (string) $newConfig->getNode('router')->getAttribute('id'));
165 | $router->addChild('args');
166 | $router->args->addChild('frontName',
167 | (string) $newConfig->getNode('router/route')->getAttribute('frontName'));
168 | $router->args->addChild('module',
169 | (string) $newConfig->getNode('router/route/module')->getAttribute('name')
170 | );
171 | }
172 | }
173 | }
174 |
175 | public function loadDiConfig()
176 | {
177 | $diFile = realpath($this->_etcModuleDir.DIRECTORY_SEPARATOR.'di.xml');
178 | if (!is_readable($diFile)) {
179 | return;
180 | }
181 | $newConfig = Mage::getModel('core/config_base');
182 | $newConfig->loadFile($diFile);
183 | $preference = $newConfig->getNode('preference');
184 | foreach ($preference as $preferenceChild) {
185 | $parts = explode('\\', $preferenceChild['for']);
186 | $rewriteModule = strtolower($parts[1]);
187 | $rewriteType = strtolower($parts[2]).'s';
188 | unset($parts[0], $parts[1], $parts[2]);
189 | $rewriteFile = strtolower(implode('_', $parts));
190 | $rewriteModuleNode = $this->_config->getNode("global/{$rewriteType}/{$rewriteModule}");
191 | $rewriteModuleNode->addChild('rewrite');
192 | $rewriteModuleNode->rewrite->addChild($rewriteFile, (string) $preferenceChild['type']);
193 |
194 | // Block factory not used autoloader
195 | // so we need to include file here
196 | if ($rewriteType == 'blocks') {
197 | $newClassName = (string) $preferenceChild['type'];
198 | Mage::getModel('eltrino_compatibility/splAutoloader')->loadClass($newClassName);
199 | }
200 | }
201 | }
202 |
203 | public function loadCrontabConfig()
204 | {
205 | $crontabFile = realpath($this->_etcModuleDir.DIRECTORY_SEPARATOR.'crontab.xml');
206 | if (!is_readable($crontabFile)) {
207 | return;
208 | }
209 |
210 | /** @var Mage_Core_Model_Config_Element $jobs */
211 | $jobs = $this->_config->getNode('crontab/jobs');
212 | $newConfig = Mage::getModel('core/config_base');
213 | $newConfig->loadFile($crontabFile);
214 | /* @var Mage_Core_Model_Config_Element $group */
215 | foreach ($newConfig->getNode('group/job') as $job) {
216 | /** @var Mage_Core_Model_Config_Element $newJob */
217 | $newJob = $jobs->addChild((string) $job['name']);
218 | $newJob->addChild('schedule');
219 | $newJob->schedule->addChild('cron_expr', (string) $job->schedule);
220 | $newJob->addChild('run');
221 | $newJob->run->addChild('model', (string) $job['instance'].'::'.(string) $job['method']);
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/Model/Xml/Modules.php:
--------------------------------------------------------------------------------
1 | _magento2config = new Mage_Core_Model_Config_Base();
35 | }
36 |
37 | public function loadModules(array $files)
38 | {
39 | $this->loadString('');
40 | $loadedModules = array();
41 | foreach ($files as $file) {
42 | $this->_magento2config->loadFile($file);
43 | $moduleName = $this->_magento2config->getNode('module')->getAttribute('name');
44 |
45 | if ($this->isModuleLoaded($moduleName)) {
46 | $loadedModules[] = $moduleName;
47 | continue;
48 | }
49 |
50 | $loadedModules[] = $moduleName;
51 | $version = $this->_magento2config->getNode('module')->getAttribute('schema_version');
52 | $modules = Mage::getConfig()->getNode('modules');
53 | $child = $modules->addChild($moduleName);
54 | $child->addChild('active', 'true');
55 | $child->addChild('codePool', 'community');
56 | $child->addChild('version', $version);
57 | $this->loadString('');
58 | }
59 |
60 | return $loadedModules;
61 | }
62 |
63 | public function isModuleLoaded($moduleName)
64 | {
65 | $node = Mage::getConfig()->getNode('modules/'.$moduleName);
66 |
67 | return (bool) $node;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/etc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | 1.0.0
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | singleton
39 | eltrino_compatibility/observer
40 | resourceGetTableName
41 |
42 |
43 |
44 |
45 |
46 |
47 | singleton
48 | eltrino_compatibility/observer
49 | controllerActionLayoutRenderBefore
50 |
51 |
52 |
53 |
54 |
55 |
56 | Eltrino_Compatibility_Model
57 |
58 |
59 |
60 |
61 | Eltrino_Compatibility_Block
62 |
63 |
64 |
65 |
66 | Eltrino_Compatibility_Helper
67 |
68 |
69 |
70 |
71 |
72 | Eltrino_Compatibility
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | Magento2 modules compatibility cache
81 | COMPATIBILITY
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/code/community/Eltrino/Compatibility/sql/eltrino_compatibility_setup/mysql4-install-1.0.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
30 |
31 | $installer->endSetup();
32 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Checkout/Block/Onepage/Success.php:
--------------------------------------------------------------------------------
1 | getRequest(), \Mage::app()->getResponse());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Framework/App/Action/Context.php:
--------------------------------------------------------------------------------
1 | _action = $action;
40 | }
41 |
42 | public function getView()
43 | {
44 | return $this->_action;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Framework/App/Helper/AbstractHelper.php:
--------------------------------------------------------------------------------
1 | _resourceName = $resourceName;
48 | if (is_null($resourceCollectionName)) {
49 | $resourceCollectionName = $resourceName.'\\Collection';
50 | }
51 | $this->_resourceCollectionName = $resourceCollectionName;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Framework/Model/Resource/Db/AbstractDb.php:
--------------------------------------------------------------------------------
1 | getNode('global/models');
38 | $resource = $config->xpath("//*[table='{$mainTable}']")[0];
39 | $table = $resource->xpath('.')[0]->getName();
40 | $resourceName = $resource->xpath('../..')[0]->getName();
41 | $model = str_replace('_resource', '', $resourceName);
42 |
43 | parent::_init($model.'/'.$table, $idFieldName);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Framework/Registry.php:
--------------------------------------------------------------------------------
1 | getTemplate();
35 | $html = '';
36 | if (is_readable($filePath)) {
37 | ob_start();
38 | $block = $this;
39 | include $filePath;
40 | $html = ob_get_clean();
41 | }
42 | $this->setTemplate('');
43 |
44 | return $html;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Sales/Model/Order.php:
--------------------------------------------------------------------------------
1 | getData('state');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/code/community/Magento/Sales/Model/Order/Config.php:
--------------------------------------------------------------------------------
1 | getVisibleOnFrontStates();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/etc/modules/Eltrino_Compatibility.xml:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | true
31 | community
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | app/code/community/Magento/ app/code/community/Magento/
2 | app/code/community/Eltrino/Compatibility/ app/code/community/Eltrino/Compatibility/
3 | app/etc/modules/Eltrino_Compatibility.xml app/etc/modules/Eltrino_Compatibility.xml
4 |
--------------------------------------------------------------------------------