From 28826e0dbe1e434b55acc4012a7ac8b9ec6e69a5 Mon Sep 17 00:00:00 2001 From: Kevin Kong Date: Thu, 12 Sep 2019 15:41:53 -0700 Subject: [PATCH] Revert "no serial" --- .../Block/Adminhtml/Compatibility/Tool.php | 68 +++++++ .../Compatibility/Tool/ClassRewrites.php | 48 +++++ .../Adminhtml/Compatibility/Tool/Compiler.php | 38 ++++ .../Adminhtml/Compatibility/Tool/Event.php | 38 ++++ .../Compatibility/Tool/ClassRewrites.php | 184 ++++++++++++++++++ .../Model/Compatibility/Tool/Compiler.php | 117 +++++++++++ .../Compatibility/Tool/Entity/Abstract.php | 116 +++++++++++ .../Affirm/Model/Compatibility/Tool/Event.php | 100 ++++++++++ .../Affirm/Affirm/Model/Order/Observer.php | 4 +- .../Model/Order/Observer/AfterSaveOrder.php | 2 +- .../Compatibility/ToolController.php | 68 +++++++ .../Affirm/controllers/PaymentController.php | 8 +- .../community/Affirm/Affirm/etc/adminhtml.xml | 22 +++ .../default/default/layout/affirm/affirm.xml | 19 ++ .../template/affirm/compatibility/tool.phtml | 49 +++++ .../compatibility/tool/class-rewrites.phtml | 28 +++ .../affirm/compatibility/tool/compiler.phtml | 13 ++ .../affirm/compatibility/tool/event.phtml | 14 ++ modman | 1 + 19 files changed, 931 insertions(+), 6 deletions(-) create mode 100644 extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool.php create mode 100644 extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/ClassRewrites.php create mode 100644 extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Compiler.php create mode 100644 extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Event.php create mode 100644 extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/ClassRewrites.php create mode 100644 extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Compiler.php create mode 100644 extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Entity/Abstract.php create mode 100644 extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Event.php create mode 100644 extension/app/code/community/Affirm/Affirm/controllers/Adminhtml/Compatibility/ToolController.php create mode 100644 extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool.phtml create mode 100644 extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/class-rewrites.phtml create mode 100644 extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/compiler.phtml create mode 100644 extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/event.phtml diff --git a/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool.php b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool.php new file mode 100644 index 0000000..4cc4b5b --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool.php @@ -0,0 +1,68 @@ +setChild('run_button', + $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => $this->helper('affirm')->__('Validate Affirm Compatibility'), + 'onclick' => 'AFFIRM_AFFIRM.tool.validateCompatibility(\'' . $this->getAjaxUrl() . '\');', + 'class' => 'save' + )) + ); + return parent::_prepareLayout(); + } + + /** + * Get page header text + * + * @return string + */ + public function getHeader() + { + return $this->helper('affirm')->__('Affirm Compatibility Tool'); + } + + /** + * Get ajax validate url + * + * @return string + */ + public function getAjaxUrl() + { + return $this->getUrl('adminhtml/compatibility_tool/validate', + array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); + } + + /** + * Get html code of rum button + * + * @return string + */ + public function getRunButtonHtml() + { + return $this->getChildHtml('run_button'); + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/ClassRewrites.php b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/ClassRewrites.php new file mode 100644 index 0000000..59dd9ab --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/ClassRewrites.php @@ -0,0 +1,48 @@ +setTemplate('affirm/compatibility/tool/class-rewrites.phtml'); + } + + /** + * Get xml declaration rewrites + * + * @return array + */ + public function getXmlClassRewrites() + { + return Mage::getModel('affirm/compatibility_tool_classRewrites')->getXmlClassRewrites(); + } + + /** + * Get code pool declaration rewrites + * + * @return array + */ + public function getCodePoolClassRewrite() + { + return Mage::getModel('affirm/compatibility_tool_classRewrites')->getCodePoolClassRewrite(); + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Compiler.php b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Compiler.php new file mode 100644 index 0000000..2d46dd9 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Compiler.php @@ -0,0 +1,38 @@ +setTemplate('affirm/compatibility/tool/compiler.phtml'); + } + + /** + * Get compiler controller issue list + * + * @return array + */ + public function getCompilerControllerList() + { + return Mage::getModel('affirm/compatibility_tool_compiler')->getCompilerControllerList(); + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Event.php b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Event.php new file mode 100644 index 0000000..6767039 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Block/Adminhtml/Compatibility/Tool/Event.php @@ -0,0 +1,38 @@ +setTemplate('affirm/compatibility/tool/event.phtml'); + } + + /** + * Get event duplicate declaration list + * + * @return array + */ + public function getDuplicateEventList() + { + return Mage::getModel('affirm/compatibility_tool_event')->getObserverDeclarationDuplicate(); + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/ClassRewrites.php b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/ClassRewrites.php new file mode 100644 index 0000000..855997b --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/ClassRewrites.php @@ -0,0 +1,184 @@ + array('setReservedOrderId', 'save'), + 'Mage_Sales_Model_Order' => array('loadByIncrementId', 'save', 'getBillingAddress') + ); + } + + /** + * Get group Id + * + * @param array $parts + * @return string + */ + protected function _getGroupId($parts) + { + return isset($parts[1]) ? strtolower($parts[1]): ''; + } + + /** + * Get class Id + * + * @param array $parts + * @return string + */ + protected function _getClassId($parts) + { + return isset($parts[3]) ? strtolower($parts[3]): ''; + } + + /** + * Get rewrites in code pool + * + * @return array + */ + public function getCodePoolClassRewrite() + { + $cache = Mage::app()->loadCache(self::CACHE_KEY_CODE_POOL); + if ($this->useCache() && $cache) { + $classCodePoolRewrite = unserialize($cache); + } else { + $classCodePoolRewrite = array(); + $usedClasses = $this->_getUsedClassMethods(); + foreach ($usedClasses as $class => $methods) { + $refl = new ReflectionClass($class); + $filename = $refl->getFileName(); + $pathByName = str_replace('_', DS, $class) . '.php'; + if ((strpos($filename, 'local' . DS . $pathByName) !== false) || + (strpos($filename, 'community'. DS . $pathByName) !== false)) + { + $classCodePoolRewrite[] = $class; + } + } + if ($this->useCache()) { + Mage::app()->saveCache(serialize($classCodePoolRewrite), self::CACHE_KEY_CODE_POOL, + array(self::CACHE_TYPE)); + } + } + return $classCodePoolRewrite; + } + + /** + * Get rewrites in xml + * + * @return array + */ + public function getXmlClassRewrites() + { + $cache = Mage::app()->loadCache(self::CACHE_KEY_XML); + if ($this->useCache() && $cache) { + $result = unserialize($cache); + } else { + $classRewrites = array(); + $modules = $this->_getAllModules(); + + foreach ($modules as $modName => $module) { + if ($this->_skipValidation($modName, $module)) { + continue; + } + $result = $this->_getRewritesInModule($modName); + if (!empty($result)) { + $classRewrites[] = $result; + } + } + $result = $this->_getClassMethodRewrites($classRewrites); + if ($this->useCache()) { + Mage::app()->saveCache(serialize($result), self::CACHE_KEY_XML, + array(self::CACHE_TYPE)); + } + } + return $result; + } + + /** + * Get class methods rewrites + * + * @param array $classRewrites + * @return array + */ + protected function _getClassMethodRewrites($classRewrites) + { + $usedClasses = $this->_getUsedClassMethods(); + foreach ($classRewrites as $position => &$usedClass) { + foreach ($usedClass as $class => &$rewrites) { + if (isset($rewrites['class'])) { + $refl = new ReflectionClass($rewrites['class']); + foreach ($usedClasses[$class] as $method) { + $classOwner = $refl->getMethod($method)->class; + if (($class != $classOwner) && !in_array($method, $rewrites['methods'])) { + array_push($rewrites['methods'], $method); + } + } + } + } + } + return $classRewrites; + } + + /** + * Get rewrites in separate module + * + * @param string $modName + * @return array + */ + protected function _getRewritesInModule($modName) + { + $classes = array(); + $moduleConfig = $this->_getModuleConfig($modName); + + $usedClasses = $this->_getUsedClassMethods(); + foreach ($usedClasses as $class => $methods) { + $parts = explode('_', $class); + $groupId = $this->_getGroupId($parts); + $classId = $this->_getClassId($parts); + if (!$groupId || ! $classId) { + continue; + } + $typeNode = $moduleConfig->getNode()->global->{self::CONFLICT_TYPE . 's'}->$groupId; + if (!$typeNode) { + continue; + }; + + $rewrites = $typeNode->rewrite; + + if ($rewrites && $rewrites->$classId) { + $classes[$class] = array('class' => (string) $rewrites->$classId, 'methods' => array()); + } + } + return $classes; + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Compiler.php b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Compiler.php new file mode 100644 index 0000000..ce3ebbe --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Compiler.php @@ -0,0 +1,117 @@ +getPathname()); + $from = strpos($relativeFilePath, DS); + $to = strpos($relativeFilePath, 'controllers'); + $moduleData = substr($relativeFilePath, $from, $to - $from); + $modName = str_replace(DS, '_', trim($moduleData, DS)); + return Mage::helper('core')->isModuleEnabled($modName); + } + + /** + * Check if skip controller file from specific module + * + * @param SplFileInfo $info + * @param string $codePoolPath + * @return int + */ + protected function _ignoreFromSkippedModule($info, $codePoolPath) + { + $subPath = $codePoolPath . DS . str_replace('_', DS, $this->_getSkipModuleName()); + $isEnable = $this->_isControllerModuleEnabled($info, $subPath); + + return (strpos($info->getPathname(), $subPath) === 0) || !$isEnable; + } + + /** + * If type of controller + * + * @param SplFileInfo $info + * @return int + */ + protected function _isTypeOfController($info) + { + return preg_match("/Controller.php$/", $info->getFileName()); + } + + /** + * Get controller list with bad OnepageController require statement + * + * @return array + */ + public function getCompilerControllerList() + { + $cache = Mage::app()->loadCache(self::CACHE_KEY); + if ($this->useCache() && $cache) { + $controllersCompilerProblems = unserialize($cache); + } else { + $modulesPath = Mage::getBaseDir('code'); + $controllers = array(); + $controllersCompilerProblems = array(); + foreach ($this->_getNonCoreCodePools() as $codePool) { + $codePoolPath = $modulesPath . DS . $codePool; + if (file_exists($codePoolPath) && is_dir($codePoolPath)) { + $directory = new \RecursiveDirectoryIterator($modulesPath . DS . $codePool); + $iterator = new \RecursiveIteratorIterator($directory); + foreach ($iterator as $info) { + if ($info->isFile() && $this->_isTypeOfController($info) && + !$this->_ignoreFromSkippedModule($info, $codePoolPath) + ) { + $controllers[] = $info->getPathname(); + } + } + } + } + foreach ($controllers as $controller) { + $contents = file_get_contents($controller); + if (preg_match_all(self::REQUIRE_PATTERN, $contents, $matches)) { + if (isset($matches[0][0]) && + (strpos($matches[0][0], self::CORRECT_REQUIRE_DECLARATION) === false) + ) { + $controllersCompilerProblems[] = $controller; + } + } + } + if ($this->useCache()) { + Mage::app()->saveCache(serialize($controllersCompilerProblems), + self::CACHE_KEY, array(self::CACHE_TYPE) + ); + } + } + return $controllersCompilerProblems; + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Entity/Abstract.php b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Entity/Abstract.php new file mode 100644 index 0000000..cd328a5 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Entity/Abstract.php @@ -0,0 +1,116 @@ +useCache(self::CACHE_TYPE) && self::USE_CACHE; + } + + /** + * Get non-core code pool + * + * @return array + */ + protected function _getNonCoreCodePools() + { + return array('local', 'community'); + } + + /** + * Get search area + * + * @return array + */ + protected function _getSearchAreas() + { + return array('global', 'frontend'); + } + + /** + * Skip affirm module + * + * @return string + */ + protected function _getSkipModuleName() + { + return 'Affirm_Affirm'; + } + + /** + * Get core package alias + * + * @return array + */ + protected function _getCorePackagesAlias() + { + return array('Mage_', 'Enterprise_'); + } + + /** + * Get all modules + * + * @return array + */ + protected function _getAllModules() + { + return (array)Mage::getConfig()->getNode('modules')->children(); + } + + /** + * Check if need to skip validation + * + * @param string $modName + * @param Mage_Code_Model_Config_Element $module + * @return bool + */ + protected function _skipValidation($modName, $module) + { + return !$module->is('active') || !in_array((string)$module->codePool, $this->_getNonCoreCodePools()) + || ($modName == $this->_getSkipModuleName()); + } + + /** + * Get module config options + * + * @param string $modName + * @return Mage_Core_Model_Config_Base + */ + protected function _getModuleConfig($modName) + { + $configFile = Mage::getConfig()->getModuleDir('etc', $modName) . DS . 'config.xml'; + $moduleConfig = Mage::getModel('core/config_base'); + $moduleConfig->loadString(''); + $moduleConfigBase = Mage::getModel('core/config_base'); + $moduleConfigBase->loadFile($configFile); + $moduleConfig->extend($moduleConfigBase, true); + return $moduleConfig; + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Event.php b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Event.php new file mode 100644 index 0000000..c69f600 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Model/Compatibility/Tool/Event.php @@ -0,0 +1,100 @@ +_getModuleConfig($modName); + + $searchAreas = $this->_getSearchAreas(); + $observerAffirmEvent = $this->getObserverAffirmEvents(); + foreach ($searchAreas as $area) { + $globalEventObservers = $moduleConfig->getNode()->{$area}->{self::CONFLICT_TYPE . 's'}; + $globalEventObservers = ($globalEventObservers) ? $globalEventObservers->asArray() : ''; + if (!empty($globalEventObservers)) { + foreach ($globalEventObservers as $observer => $observerOptions) { + if (in_array($observer, $observerAffirmEvent)) { + foreach ($observerOptions['observers'] as $option) { + $result[$observer][] = $option; + } + } + } + } + } + return $result; + } + + /** + * Get the same observer declaration + * + * @return array + */ + public function getObserverDeclarationDuplicate() + { + $cache = Mage::app()->loadCache(self::CACHE_KEY); + if ($this->useCache() && $cache) { + $declarationConflicts = unserialize($cache); + } else { + $declarationConflicts = array(); + $modules = (array)Mage::getConfig()->getNode('modules')->children(); + + foreach ($modules as $modName => $module) { + if ($this->_skipValidation($modName, $module)) { + continue; + } + $result = $this->_getConflictWithModule($modName); + if (!empty($result)) { + $declarationConflicts = $result; + } + } + if ($this->useCache()) { + Mage::app()->saveCache(serialize($declarationConflicts), self::CACHE_KEY, array(self::CACHE_TYPE)); + } + } + return $declarationConflicts; + } +} + diff --git a/extension/app/code/community/Affirm/Affirm/Model/Order/Observer.php b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer.php index 02d9728..a9e16a2 100644 --- a/extension/app/code/community/Affirm/Affirm/Model/Order/Observer.php +++ b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer.php @@ -116,7 +116,7 @@ public function preOrder($observer) 'requested_controller' => $request->getRequestedControllerName(), 'requested_action' => $request->getRequestedActionName() ); - Mage::helper('affirm')->getCheckoutSession()->setAffirmOrderRequest(json_encode($orderRequest)); + Mage::helper('affirm')->getCheckoutSession()->setAffirmOrderRequest(serialize($orderRequest)); $this->_callToPreOrderActionAndExit($order, $quote); } } elseif ($this->_isCreateOrderBeforeConf($methodInst)) { @@ -226,7 +226,7 @@ public function preDispatchSaveOrderAction(Varien_Event_Observer $observer) 'POST' => $post, //need post for some cross site issues 'quote_id' => Mage::helper('affirm')->getCheckoutSession()->getQuote()->getId() ); - Mage::helper('affirm')->getCheckoutSession()->setAffirmOrderRequest(json_encode($orderRequest)); + Mage::helper('affirm')->getCheckoutSession()->setAffirmOrderRequest(serialize($orderRequest)); $controller->setFlag('', Mage_Core_Controller_Front_Action::FLAG_NO_DISPATCH, true); $controller->getRequest()->setDispatched(true); return; diff --git a/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterSaveOrder.php b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterSaveOrder.php index 501ef5c..a84a94e 100644 --- a/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterSaveOrder.php +++ b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterSaveOrder.php @@ -44,7 +44,7 @@ public function postDispatchSaveOrder($observer) $response = $observer->getControllerAction()->getResponse(); $session = Mage::helper('affirm')->getCheckoutSession(); $serializedRequest = $session->getAffirmOrderRequest(); - $proxyRequest = json_decode($serializedRequest,true); + $proxyRequest = unserialize($serializedRequest); $checkoutToken = Mage::registry('affirm_token_code'); $lastOrderId = $session->getLastOrderId(); //Return, if order was placed before confirmation diff --git a/extension/app/code/community/Affirm/Affirm/controllers/Adminhtml/Compatibility/ToolController.php b/extension/app/code/community/Affirm/Affirm/controllers/Adminhtml/Compatibility/ToolController.php new file mode 100644 index 0000000..84da6eb --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/controllers/Adminhtml/Compatibility/ToolController.php @@ -0,0 +1,68 @@ +_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Affirm Compatibility Tool')); + + $this->loadLayout(); + $this->_setActiveMenu('system/tools'); + $this->renderLayout(); + } + + /** + * Validate + */ + public function validateAction() + { + $response = new Varien_Object(); + try { + $validationEventResult = $this->getLayout() + ->createBlock('affirm/adminhtml_compatibility_tool_event')->toHtml(); + $response->setValidationEventResult($validationEventResult); + + $validationClassResult = $this->getLayout() + ->createBlock('affirm/adminhtml_compatibility_tool_classRewrites')->toHtml(); + $response->setValidationClassResult($validationClassResult); + + $validationCompilerResult = $this->getLayout() + ->createBlock('affirm/adminhtml_compatibility_tool_compiler')->toHtml(); + $response->setValidationCompilerResult($validationCompilerResult); + $response->setSuccess(true); + } catch (Exception $e) { + Mage::logException($e); + $response->setSuccess(false); + }; + $this->getResponse()->setHeader('Content-type', 'application/json'); + $this->getResponse()->setBody($response->toJson()); + } + + /** + * Is controller allowed + * + * @return bool + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('system/tools/compatibility'); + } +} diff --git a/extension/app/code/community/Affirm/Affirm/controllers/PaymentController.php b/extension/app/code/community/Affirm/Affirm/controllers/PaymentController.php index 7008450..891bfd6 100644 --- a/extension/app/code/community/Affirm/Affirm/controllers/PaymentController.php +++ b/extension/app/code/community/Affirm/Affirm/controllers/PaymentController.php @@ -53,7 +53,7 @@ public function renderPreOrderAction() $string = $this->getLayout()->createBlock('affirm/payment_redirect', 'affirm_redirect') ->setOrder($order)->toHtml(); $serializedRequest = $checkoutSession->getAffirmOrderRequest(); - $proxyRequest = json_decode($serializedRequest,true); + $proxyRequest = unserialize($serializedRequest); //only reserve this order id $modQuote = Mage::getModel('sales/quote')->load($quote->getId()); $modQuote->setReservedOrderId($order->getIncrementId()); @@ -129,7 +129,8 @@ protected function _processConfWithSaveOrderModalCheckout($checkoutToken, $seria $this->_redirect('checkout/onepage/success'); return; } - $proxyRequest = json_decode($serializedRequest,true); + + $proxyRequest = unserialize($serializedRequest); $this->getRequest()->setPost($proxyRequest['POST']); Mage::register('affirm_token_code', $checkoutToken); $this->_forward($proxyRequest['action'], $proxyRequest['controller'], $proxyRequest['module'], $proxyRequest['params']); @@ -150,7 +151,8 @@ protected function _processConfWithSaveOrder($checkoutToken, $serializedRequest) $this->_redirect('checkout/onepage/success'); return; } - $proxyRequest = json_decode($serializedRequest, true); + + $proxyRequest = unserialize($serializedRequest); $this->getRequest()->setPost($proxyRequest['POST']); Mage::register('affirm_token_code', $checkoutToken); $this->_forward($proxyRequest['action'], $proxyRequest['controller'], $proxyRequest['module'], $proxyRequest['params']); diff --git a/extension/app/code/community/Affirm/Affirm/etc/adminhtml.xml b/extension/app/code/community/Affirm/Affirm/etc/adminhtml.xml index 01ae8e5..9360a03 100644 --- a/extension/app/code/community/Affirm/Affirm/etc/adminhtml.xml +++ b/extension/app/code/community/Affirm/Affirm/etc/adminhtml.xml @@ -7,6 +7,12 @@ + + + Affirm Compatibility Tool + 0 + + @@ -21,4 +27,20 @@ + + + + + + + + Affirm Compatibility Tool + 2000 + adminhtml/compatibility_tool + + + + + + diff --git a/extension/app/design/adminhtml/default/default/layout/affirm/affirm.xml b/extension/app/design/adminhtml/default/default/layout/affirm/affirm.xml index 7a21fcb..4fb334f 100644 --- a/extension/app/design/adminhtml/default/default/layout/affirm/affirm.xml +++ b/extension/app/design/adminhtml/default/default/layout/affirm/affirm.xml @@ -7,4 +7,23 @@ + + + + skin_js + js/affirm/affirm.js + + + + + + + + + + + + diff --git a/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool.phtml b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool.phtml new file mode 100644 index 0000000..50ae255 --- /dev/null +++ b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool.phtml @@ -0,0 +1,49 @@ + +
+ + + + + +

getHeader() ?>

+ getRunButtonHtml() ?> +
+
+
+
+
+
+

helper('affirm')->__('Affirm Compatibility Tool'); ?>

+
+
+ + + + + + + + + + + + + +
+

+ +

+
+

+ +

+
+

+ +

+
+
+
+
diff --git a/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/class-rewrites.phtml b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/class-rewrites.phtml new file mode 100644 index 0000000..96c576b --- /dev/null +++ b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/class-rewrites.phtml @@ -0,0 +1,28 @@ +getXmlClassRewrites(); +$codePoolClassRewrites = $this->getCodePoolClassRewrite(); + +foreach ($xmlClassRewrites as $xmlClassRewrite) { + foreach ($xmlClassRewrite as $class => $rewriteOptions) { + if (!empty($rewriteOptions['class'])) { + echo sprintf("[NOTICE]: Class %s was rewritten by the class %s \n", + $class, $rewriteOptions['class']); + } + if (!empty($rewriteOptions['methods'])) { + foreach ($rewriteOptions['methods'] as $method) { + echo sprintf("[WARNING]: Method %s of class %s was rewritten by the class %s \n", + $method, $class, $rewriteOptions['class']); + } + } + } +} + +foreach ($codePoolClassRewrites as $codePoolClassRewrite) { + echo sprintf("[NOTICE]: Class %s was rewritten in community or local pool \n", + $codePoolClassRewrite); +} + +if (!(count($xmlClassRewrites) > 0) || (count($codePoolClassRewrites) > 0)) { + echo sprintf('No important classes and methods that affirm uses were overwritten.'); +} diff --git a/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/compiler.phtml b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/compiler.phtml new file mode 100644 index 0000000..5a77d63 --- /dev/null +++ b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/compiler.phtml @@ -0,0 +1,13 @@ +getCompilerControllerList(); + if (count($controllerList) > 0) { + foreach ($controllerList as $controller) { + echo sprintf("[WARNING]: Controller %s use wrong including statement for class OnepageController.php in the file + %s \n", + basename($controller), $controller); + } + } else { + echo sprintf('No wrong including of OnepageController controller.'); + } + diff --git a/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/event.phtml b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/event.phtml new file mode 100644 index 0000000..cec24dd --- /dev/null +++ b/extension/app/design/adminhtml/default/default/template/affirm/compatibility/tool/event.phtml @@ -0,0 +1,14 @@ +getDuplicateEventList(); + if (count($conflictList) > 0) { + foreach ($conflictList as $eventName => $eventConfigs) { + foreach ($eventConfigs as $eventConfig) { + echo sprintf("[NOTICE]: Method %s in class %s has observer on the event %s \n", + $eventConfig['method'], $eventConfig['class'], $eventName); + } + } + } else { + echo sprintf('No others observers on affirm checkout events.'); + } + diff --git a/modman b/modman index a4362b0..9e6a08c 100644 --- a/modman +++ b/modman @@ -1,6 +1,7 @@ extension/app/code/community/Affirm/Affirm app/code/community/Affirm/Affirm extension/app/design/adminhtml/default/default/layout/affirm/affirm.xml app/design/adminhtml/default/default/layout/affirm/affirm.xml extension/app/design/adminhtml/default/default/template/affirm/affirm app/design/adminhtml/default/default/template/affirm/affirm +extension/app/design/adminhtml/default/default/template/affirm/compatibility app/design/adminhtml/default/default/template/affirm/compatibility extension/app/design/frontend/base/default/layout/affirm/affirm.xml app/design/frontend/base/default/layout/affirm/affirm.xml extension/app/design/frontend/base/default/template/affirm/affirm app/design/frontend/base/default/template/affirm/affirm extension/app/design/frontend/base/default/template/affirm/promo app/design/frontend/base/default/template/affirm/promo