BodyCopy.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Models\Parameter;
  3. use App\Helpers\Utils;
  4. use App\Helpers\ParameterUtils;
  5. class BodyCopy
  6. {
  7. protected $data;
  8. public function __construct($para_name, $themeDir = null, $popupOptions = false)
  9. {
  10. if ($themeDir && $themeDir !== 'empty') {
  11. $this->data = Utils::getThemeParamFile($para_name, '.json', $themeDir, $popupOptions);
  12. } else {
  13. $this->data = Utils::getParamFile($para_name, '.json', $popupOptions);
  14. }
  15. $this->converterData();
  16. }
  17. public function getData()
  18. {
  19. return $this->data;
  20. }
  21. protected function getBodyCopyPopupVarsModalParameter()
  22. {
  23. if (! isset($this->data['BodyCopyPopupVars'])) return;
  24. // BodyCopyPopupVars 모달 파라메터 얻기
  25. foreach ($this->data['BodyCopyPopupVars']['ParameterName'] as $key => $parameterName) {
  26. if ($this->data['FormVars']['Display'][$key.'Button'] == 'd-none') {
  27. $this->data['BodyCopyPopupVars']['Parameter'][$key] = '';
  28. continue;
  29. }
  30. $componentArr = explode('.', $this->data['BodyCopyPopupVars']['Component'][$key]);
  31. $themeDir = $this->data['BodyCopyPopupVars']['ThemeDir'][$key] ?? null;
  32. if (array_shift($componentArr) === 'theme') {
  33. $this->data['BodyCopyPopupVars']['Component'][$key] = implode('.', $componentArr);
  34. $url = ParameterUtils::BladeRouteFor($themeDir) . '.resources.views.modal.';
  35. } else {
  36. $url = 'front.outline.static.';
  37. }
  38. $this->data['BodyCopyPopupVars']['BladeRoute'][$key] = $url . $this->data['BodyCopyPopupVars']['Component'][$key];
  39. $this->data['BodyCopyPopupVars']['Parameter'][$key] = (new Modal($parameterName, $themeDir))->getData();
  40. // dump($this->data['BodyCopyPopupVars']);
  41. }
  42. }
  43. protected function converterData()
  44. {
  45. foreach (['FormVars', 'ListVars', 'FooterVars', 'BodyCopyPopupVars'] as $varsName) {
  46. if (array_key_exists($varsName, $this->data)) {
  47. ParameterUtils::separateAlignAndFormat($this->data, $varsName);
  48. ParameterUtils::checkDisplayAndCount($this->data, $varsName);
  49. ParameterUtils::mappingKeys($this->data, $varsName);
  50. }
  51. }
  52. $this->getBodyCopyPopupVarsModalParameter();
  53. }
  54. }