BxShopifyMenuSubmenu.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Shopify Shopify
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * 'Shopify Submenu' menu.
  13. */
  14. class BxShopifyMenuSubmenu extends BxTemplMenu
  15. {
  16. protected $_sModule;
  17. protected $_oModule;
  18. public function __construct($aObject, $oTemplate = false)
  19. {
  20. parent::__construct($aObject, $oTemplate);
  21. $this->_sModule = 'bx_shopify';
  22. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  23. $aSettings = $this->_oModule->getSettings();
  24. if(!empty($aSettings))
  25. $this->addMarkers(array(
  26. 'domain' => $aSettings['domain']
  27. ));
  28. }
  29. /**
  30. * Check if menu items is visible.
  31. * @param $a menu item array
  32. * @return boolean
  33. */
  34. protected function _isVisible ($a)
  35. {
  36. if(!parent::_isVisible($a))
  37. return false;
  38. $sCheckFuncName = '';
  39. $aCheckFuncParams = array();
  40. switch ($a['name']) {
  41. case 'shopify-dashboard':
  42. $sCheckFuncName = 'isAllowedViewDashboard';
  43. $aCheckFuncParams = array();
  44. break;
  45. }
  46. if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
  47. return true;
  48. return call_user_func_array(array($this->_oModule, $sCheckFuncName), $aCheckFuncParams) === true;
  49. }
  50. }
  51. /** @} */