@@ 109-130 (lines=22) @@ | ||
106 | * |
|
107 | * @throws \Exception |
|
108 | */ |
|
109 | private function getValue(string $name) |
|
110 | { |
|
111 | if (isset($this->presets[$name])) { |
|
112 | return $this->presets[$name]; |
|
113 | } |
|
114 | ||
115 | // if we use the old flow (sf3), the value can be stored in it's own yml file |
|
116 | if (strpos($name, ':')) { |
|
117 | $nameParts = explode(':', $name); |
|
118 | if (2 !== count($nameParts)) { |
|
119 | throw new \Exception(sprintf('Malformed namespaced configuration name "%s" (expecting "namespace:pagename").', |
|
120 | $name)); |
|
121 | } |
|
122 | list($namespace, $name) = $nameParts; |
|
123 | $path = $this->kernel->locateResource('@' . $namespace . '/Resources/config/pageparts/' . $name . '.yml'); |
|
124 | $value = Yaml::parse(file_get_contents($path)); |
|
125 | ||
126 | return $value; |
|
127 | } |
|
128 | ||
129 | throw new \Exception(sprintf('Non existing pageparts preset "%s".', $name)); |
|
130 | } |
|
131 | } |
|
132 |
@@ 113-133 (lines=21) @@ | ||
110 | * |
|
111 | * @throws \Exception |
|
112 | */ |
|
113 | private function getRawData($name) |
|
114 | { |
|
115 | if (isset($this->presets[$name])) { |
|
116 | return $this->presets[$name]; |
|
117 | } |
|
118 | ||
119 | // if we use the old flow (sf3), the raw data can be stored in it's own yml file |
|
120 | if (strpos($name, ':')) { |
|
121 | $nameParts = explode(':', $name, 2); |
|
122 | if (2 !== count($nameParts)) { |
|
123 | throw new \Exception(sprintf('Malformed namespaced configuration name "%s" (expecting "namespace:pagename").', $name)); |
|
124 | } |
|
125 | list($namespace, $name) = $nameParts; |
|
126 | $path = $this->kernel->locateResource('@'.$namespace.'/Resources/config/pagetemplates/'.$name.'.yml'); |
|
127 | $rawData = Yaml::parse(file_get_contents($path)); |
|
128 | ||
129 | return $rawData; |
|
130 | } |
|
131 | ||
132 | throw new \Exception(sprintf('Non existing template "%s".', $name)); |
|
133 | } |
|
134 | } |
|
135 |