Last active
February 7, 2018 09:22
-
-
Save KristianH/f9c12acca2601d65521f70fc23f00c0d to your computer and use it in GitHub Desktop.
IntelliSenseHelper for module chain in oxid eShop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author D3 Data Development <[email protected]> | |
* @link http://www.oxidmodule.com | |
*/ | |
class IntelliSenseHelperCreator | |
{ | |
/** | |
* IntelliSenseHelperCreator constructor. | |
* | |
* @param array $modulesArray | |
* @param $modules | |
* | |
* @throws Exception | |
*/ | |
public function __construct(array $modulesArray, $modules) | |
{ | |
if (empty($modulesArray)) { | |
$modulesArray = $this->convertOxconfigEntry($modules); | |
} | |
if (false == is_array($modulesArray)) { | |
throw new Exception('Could not read array:' . print_r($modulesArray, true)); | |
} | |
$output = "<?php" . PHP_EOL; | |
foreach ($modulesArray as $mainClass => $subClasses) { | |
$subClasses = $this->expandSubClasses($subClasses); | |
$first = true; | |
$formerSubClass = ""; | |
foreach ($subClasses as $subClass) { | |
if (strrchr($subClass, '/')) { | |
$subClass = trim(strrchr($subClass, '/'), '/'); | |
} | |
if (strrchr($subClass, '\\')) { | |
$output .= PHP_EOL. "use {$subClass}; " . PHP_EOL; | |
$subClass = trim(strrchr($subClass, '\\'), '\\'); | |
} | |
if ($first) { | |
$output .= "class {$subClass}_parent extends $mainClass {};" . PHP_EOL; | |
$first = false; | |
$formerSubClass = $subClass; | |
continue; | |
} | |
$output .= "class {$subClass}_parent extends $formerSubClass {};" . PHP_EOL; | |
$formerSubClass = $subClass; | |
} | |
} | |
file_put_contents('IntelliSenseHelper.php', $output); | |
} | |
protected function convertOxconfigEntry($modules) | |
{ | |
return unserialize($modules); | |
} | |
protected function expandSubClasses($subClasses) | |
{ | |
return explode("&", $subClasses); | |
} | |
} | |
// get this from oxconfig decoded entry "aModules": | |
// SELECT *, DECODE(oxvarvalue, '$$$$$$$$$$$$$$') FROM oxconfig WHERE oxvarname = 'aModules'; | |
// $$$$$$$$$$$$$$ = https://github.com/OXID-eSales/oxideshop_ce/blob/8f8ec055f536b5136cf52475d52ca5ce275683cb/source/Core/Config.php#L29 | |
$modules = "a:46:{s:12:\"oxviewconfig\";s:217:\"ddoe/visualcms/core/ddoevisualcmsoxviewconfig&oe/oepaypal/core/oepaypaloxviewconfig&fcPayOne/extend/core/fcPayOneViewConf&oxps/paymorrow/core/oxpspaymorrowoxviewconfig&oe/oethemeswitcher/core/oethemeswitcherviewconfig\";s:11:\"oxutilsview\";s:140:\"ddoe/visualcms/core/ddoevisualcmsoxutilsview&_d3modcfg/modules/core/d3_oxutilsview_modcfg&d3/d3importer/modules/core/d3_oxutilsview_importer\";s:7:\"oxtheme\";s:126:\"ddoe/visualcms/core/ddoevisualcmsoxtheme&oe/oethemeswitcher/core/oethemeswitchertheme&_d3modcfg/modules/core/d3_oxtheme_modcfg\";s:9:\"oxcontent\";s:56:\"ddoe/visualcms/application/models/ddoevisualcmsoxcontent\";s:7:\"content\";s:113:\"ddoe/visualcms/application/controllers/ddoevisualcmscontent&oe/oethemeswitcher/controllers/oethemeswitchercontent\";s:12:\"oxcmp_basket\";s:104:\"ddoe/visualcms/application/components/ddoevisualcmscmpbasket&oe/oepaypal/components/oepaypaloxcmp_basket\";s:7:\"oxutils\";s:40:\"ddoe/visualcms/core/ddoevisualcmsoxutils\";s:6:\"oxlang\";s:83:\"ddoe/visualcms/core/ddoevisualcmsoxlang&oe/oethemeswitcher/core/oethemeswitcherlang\";s:17:\"oxwarticledetails\";s:56:\"oe/oepaypal/components/widgets/oepaypaloxwarticledetails\";s:5:\"order\";s:207:\"oe/oepaypal/controllers/oepaypalorder&fcPayOne/extend/application/controllers/fcPayOneOrderView&oxps/paymorrow/controllers/oxpspaymorroworder&d3/d3heidelpay/modules/application/controllers/d3_order_heidelpay\";s:7:\"payment\";s:215:\"oe/oepaypal/controllers/oepaypalpayment&fcPayOne/extend/application/controllers/fcPayOnePaymentView&oxps/paymorrow/controllers/oxpspaymorrowpayment&d3/d3heidelpay/modules/application/controllers/d3_payment_heidelpay\";s:8:\"wrapping\";s:40:\"oe/oepaypal/controllers/oepaypalwrapping\";s:10:\"order_list\";s:48:\"oe/oepaypal/controllers/admin/oepaypalorder_list\";s:16:\"deliveryset_main\";s:54:\"oe/oepaypal/controllers/admin/oepaypaldeliveryset_main\";s:9:\"oxaddress\";s:36:\"oe/oepaypal/models/oepaypaloxaddress\";s:6:\"oxuser\";s:123:\"oe/oepaypal/models/oepaypaloxuser&fcPayOne/extend/application/models/fcPayOneUser&oxps/paymorrow/models/oxpspaymorrowoxuser\";s:7:\"oxorder\";s:189:\"oe/oepaypal/models/oepaypaloxorder&fcPayOne/extend/application/models/fcPayOneOrder&oxps/paymorrow/models/oxpspaymorrowoxorder&d3/d3heidelpay/modules/application/models/d3_oxorder_heidelpay\";s:8:\"oxbasket\";s:129:\"oe/oepaypal/models/oepaypaloxbasket&fcPayOne/extend/application/models/fcPayOneBasket&oxps/paymorrow/models/oxpspaymorrowoxbasket\";s:9:\"oxarticle\";s:36:\"oe/oepaypal/models/oepaypaloxarticle\";s:16:\"oxpaymentgateway\";s:225:\"oe/oepaypal/models/oepaypaloxpaymentgateway&fcPayOne/extend/application/models/fcPayOnePaymentgateway&oxps/paymorrow/models/oxpspaymorrowoxpaymentgateway&d3/d3heidelpay/modules/application/models/d3_oxpaymentgateway_heidelpay\";s:6:\"basket\";s:58:\"fcPayOne/extend/application/controllers/fcPayOneBasketView\";s:8:\"thankyou\";s:129:\"fcPayOne/extend/application/controllers/fcPayOneThankyouView&d3/d3heidelpay/modules/application/controllers/d3_thankyou_heidelpay\";s:12:\"oxbasketitem\";s:169:\"fcPayOne/extend/application/models/fcPayOneBasketitem&oxps/paymorrow/models/oxpspaymorrowoxbasketitem&d3/d3heidelpay/modules/application/models/d3_oxbasketitem_heidelpay\";s:14:\"oxorderarticle\";s:55:\"fcPayOne/extend/application/models/fcPayOneOrderarticle\";s:9:\"oxpayment\";s:95:\"fcPayOne/extend/application/models/fcPayOnePayment&oxps/paymorrow/models/oxpspaymorrowoxpayment\";s:13:\"oxuserpayment\";s:48:\"oxps/paymorrow/models/oxpspaymorrowoxuserpayment\";i:0;s:65:\"fcPayOne/extend/application/controllers/admin/fcPayOneRolesBeMain\";s:8:\"oxconfig\";s:45:\"oe/oethemeswitcher/core/oethemeswitcherconfig\";s:16:\"manufacturerlist\";s:62:\"oe/oethemeswitcher/controllers/oethemeswitchermanufacturerlist\";s:5:\"alist\";s:51:\"oe/oethemeswitcher/controllers/oethemeswitcheralist\";s:7:\"details\";s:53:\"oe/oethemeswitcher/controllers/oethemeswitcherdetails\";s:6:\"review\";s:52:\"oe/oethemeswitcher/controllers/oethemeswitcherreview\";s:3:\"rss\";s:49:\"oe/oethemeswitcher/controllers/oethemeswitcherrss\";s:5:\"start\";s:51:\"oe/oethemeswitcher/controllers/oethemeswitcherstart\";s:3:\"tag\";s:49:\"oe/oethemeswitcher/controllers/oethemeswitchertag\";s:10:\"vendorlist\";s:56:\"oe/oethemeswitcher/controllers/oethemeswitchervendorlist\";s:21:\"oxreverseproxybackend\";s:64:\"oe/oethemeswitcher/core/cache/oethemeswitcherreverseproxybackend\";s:8:\"oxmodule\";s:48:\"_d3modcfg/modules/models/d3_oxmodule_activecheck\";s:13:\"oxshopcontrol\";s:63:\"_d3modcfg/modules/controllers/d3_oxshopcontrol_modcfg_extension\";s:6:\"oxshop\";s:41:\"_d3modcfg/modules/models/d3_oxshop_modcfg\";s:10:\"navigation\";s:62:\"_d3modcfg/modules/controllers/admin/d3_navigation_modcfgupdate\";s:17:\"oxmoduleinstaller\";s:57:\"_d3modcfg/modules/models/d3_oxmoduleinstaller_activecheck\";s:12:\"roles_bemain\";s:63:\"_d3modcfg/modules/controllers/admin/d3_roles_bemain_rolesrights\";s:7:\"oxemail\";s:48:\"d3/d3heidelpay/modules/core/d3_oxemail_heidelpay\";s:16:\"oxinputvalidator\";s:71:\"d3/d3heidelpay/modules/application/models/d3_oxinputvalidator_heidelpay\";s:9:\"d3counter\";s:64:\"d3/d3heidelpay/modules/application/models/d3_d3counter_heidelpay\";}"; | |
$modulesArray = array(); | |
try { | |
$iSHC = new IntelliSenseHelperCreator($modulesArray, $modules); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment