Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScheduleDesignUpdate.php
Go to the documentation of this file.
1 <?php
7 
9 
17 {
21  const CODE_CUSTOM_DESIGN_FROM = 'custom_design_from';
22  const CODE_CUSTOM_DESIGN_TO = 'custom_design_to';
29  protected $arrayManager;
30 
35  {
36  $this->arrayManager = $arrayManager;
37  }
38 
43  public function modifyMeta(array $meta)
44  {
45  //return $meta;
46  return $this->customizeDateRangeField($meta);
47  }
48 
53  public function modifyData(array $data)
54  {
55  return $data;
56  }
57 
65  protected function customizeDateRangeField(array $meta)
66  {
67  if ($this->getGroupCodeByField($meta, self::CODE_CUSTOM_DESIGN_FROM)
68  !== $this->getGroupCodeByField($meta, self::CODE_CUSTOM_DESIGN_TO)
69  ) {
70  return $meta;
71  }
72 
73  $fromFieldPath = $this->arrayManager->findPath(self::CODE_CUSTOM_DESIGN_FROM, $meta, null, 'children');
74  $toFieldPath = $this->arrayManager->findPath(self::CODE_CUSTOM_DESIGN_TO, $meta, null, 'children');
75  $fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
76  $toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
77 
78  $meta = $this->arrayManager->merge(
79  $fromFieldPath . self::META_CONFIG_PATH,
80  $meta,
81  [
82  'label' => __('Schedule Update From'),
83  'additionalClasses' => 'admin__field-date',
84  ]
85  );
86  $meta = $this->arrayManager->merge(
87  $toFieldPath . self::META_CONFIG_PATH,
88  $meta,
89  [
90  'label' => __('To'),
91  'scopeLabel' => null,
92  'additionalClasses' => 'admin__field-date',
93  ]
94  );
95  $meta = $this->arrayManager->merge(
96  $fromContainerPath . self::META_CONFIG_PATH,
97  $meta,
98  [
99  'label' => __('Schedule Update From'),
100  'additionalClasses' => 'admin__control-grouped-date',
101  'breakLine' => false,
102  'component' => 'Magento_Ui/js/form/components/group',
103  ]
104  );
105  $meta = $this->arrayManager->set(
106  $fromContainerPath . '/children/' . self::CODE_CUSTOM_DESIGN_TO,
107  $meta,
108  $this->arrayManager->get($toFieldPath, $meta)
109  );
110 
111  return $this->arrayManager->remove($toContainerPath, $meta);
112  }
113 }
__()
Definition: __.php:13