Customcmstabs.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © 2016 Magento. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Smartwave\Porto\Model\Config\Backend;
  7. /**
  8. * Backend for serialized array data
  9. */
  10. class Customcmstabs extends \Magento\Framework\App\Config\Value
  11. {
  12. protected $_customtabs = null;
  13. /**
  14. * @param \Magento\Framework\Model\Context $context
  15. * @param \Magento\Framework\Registry $registry
  16. * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  17. * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
  18. * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty
  19. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  20. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  21. * @param array $data
  22. */
  23. public function __construct(
  24. \Magento\Framework\Model\Context $context,
  25. \Magento\Framework\Registry $registry,
  26. \Magento\Framework\App\Config\ScopeConfigInterface $config,
  27. \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
  28. \Smartwave\Porto\Helper\Customtabs $customtabs,
  29. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  30. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  31. array $data = []
  32. ) {
  33. $this->_customtabs = $customtabs;
  34. parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
  35. }
  36. /**
  37. * Process data after load
  38. *
  39. * @return void
  40. */
  41. protected function _afterLoad()
  42. {
  43. $value = $this->getValue();
  44. $arr = unserialize($value);
  45. $this->setValue($arr);
  46. }
  47. /**
  48. * Prepare data before save
  49. *
  50. * @return void
  51. */
  52. public function beforeSave()
  53. {
  54. $value = $this->getValue();
  55. unset($value['__empty']);
  56. $arr = serialize($value);
  57. $this->setValue($arr);
  58. }
  59. }