21 const CACHE_ID =
'ui_component_configuration_data';
38 private $readerFactory;
58 private $componentName;
65 private $argumentInterpreter;
76 ReaderFactory $readerFactory,
81 $this->readerFactory = $readerFactory;
84 $this->componentName = $componentName;
85 $this->argumentInterpreter = $argumentInterpreter;
86 $this->cacheId = static::CACHE_ID .
'_' . $componentName;
94 private function initData()
96 $data = $this->cache->load($this->cacheId);
97 if (
false === $data) {
99 $reader = $this->readerFactory->create(
100 [
'fileName' => sprintf(self::SEARCH_PATTERN, $this->componentName)]
102 $data = $reader->read();
103 $this->cache->save($this->serializer->serialize($data), $this->cacheId);
105 $data = $this->serializer->unserialize($data);
110 $this->
merge([$this->componentName => $data]);
111 $this->data = $this->evaluateComponentArguments($this->data);
123 $this->data = array_replace_recursive($this->
get(), $config);
133 public function get(
$path =
null, $default =
null)
135 if (empty($this->data)) {
138 if (
$path ===
null) {
141 $keys = explode(
'/',
$path);
143 foreach ($keys as $key) {
144 if (is_array($data) && array_key_exists($key, $data)) {
159 private function evaluateComponentArguments($components)
161 foreach ($components as &$component) {
164 $this->argumentInterpreter->evaluate($argument);
166 $component[Converter::DATA_COMPONENTS_KEY] = $this->evaluateComponentArguments(
167 $component[Converter::DATA_COMPONENTS_KEY]
__construct( $componentName, ReaderFactory $readerFactory, CacheInterface $cache, SerializerInterface $serializer, InterpreterInterface $argumentInterpreter)
const DATA_ATTRIBUTES_KEY