CopyToAnother.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Models\Parameter;
  3. use App\Helpers\Utils;
  4. use App\Helpers\ParameterUtils;
  5. class CopyToAnother
  6. {
  7. private $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. private function getCopyToAnotherPopupVarsModalParameter()
  22. {
  23. // dd($this->data['CopyToAnotherPopupVars']);
  24. if (! isset($this->data['CopyToAnotherPopupVars'])) return;
  25. // CopyToAnotherPopupVars 모달 파라메터 얻기
  26. foreach ($this->data['CopyToAnotherPopupVars']['ParameterName'] as $key => $parameterName) {
  27. if ($this->data['FormVars']['Display'][$key.'Button'] == 'd-none') {
  28. $this->data['CopyToAnotherPopupVars']['Parameter'][$key] = '';
  29. continue;
  30. }
  31. $this->data['CopyToAnotherPopupVars']['Parameter'][$key] = (new Modal($parameterName))->getData();
  32. $this->data['CopyToAnotherPopupVars']['BladeRoute'][$key] = 'front.outline.static.'.$this->data['CopyToAnotherPopupVars']['Component'][$key];
  33. }
  34. }
  35. private function converterData()
  36. {
  37. foreach (['FormVars', 'ListVars', 'FooterVars', 'CopyToAnotherPopupVars'] as $varsName) {
  38. if (array_key_exists($varsName, $this->data)) {
  39. ParameterUtils::separateAlignAndFormat($this->data, $varsName);
  40. ParameterUtils::checkDisplayAndCount($this->data, $varsName);
  41. ParameterUtils::mappingKeys($this->data, $varsName);
  42. }
  43. }
  44. $this->getCopyToAnotherPopupVarsModalParameter();
  45. }
  46. }