filesystem = new Filesystem(); $this->file = $container->getParameter('trinity_vars_editor.file'); } protected function getConfig() { if (!empty($this->config)) { return $this->config; } return $this->config = Yaml::parse($this->file); } public function get($key, $default = null, $locale = null) { if (empty($this->file)) { return $default; } if (!$this->filesystem->exists($this->file)) { return $default; } $config = $this->getConfig(); if (empty($config['fieldsets']) || (!empty($config['fieldsets']) && !is_array($config['fieldsets']))) { return $default; } foreach ($config['fieldsets'] as $fieldset) { if (!is_null($locale) && isset($fieldset['tabs'])) { if (isset($fieldset['tabs'][$locale])) { foreach ($fieldset['tabs'][$locale]['vars'] as $var) { if (isset($var['key'], $var['value'])) { if ($var['key'] === $key) { return $var['value']; } } } } } elseif (!empty($fieldset['vars'])) { foreach ($fieldset['vars'] as $var) { if (isset($var['key'], $var['value'])) { if ($var['key'] === $key) { return $var['value']; } } } } } return $default; } }