/** * Get the extensions * * @param string $group The extension group * * @return ExtensionInterface[] */ public function getExtensions($group = '') { if (key_exists($group, $this->extensions)) { return $this->extensions[$group]; } $this->extensions[$group] = []; $fs = $this->rootFolder; if (is_string($this->rootFolder)) { // It is only the path $fs = new Local($this->rootFolder); } if (!$fs instanceof AbstractAdapter) { return []; } foreach ($fs->listContents($group, true) as $file) { if (strpos($file['path'], 'extension.yml') === false) { continue; } $path = $fs->applyPathPrefix($file['path']); if (key_exists($path, $this->loadedFiles)) { // We have loaded it already $this->extensions[$group][] = $this->loadedFiles[$path]; continue; } $extension = new Extension(); $this->loadedFiles[$path] = $extension; $this->extensions[$group][] = $extension; $config = Yaml::parse($fs->read($file['path'])['contents'], Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); if (key_exists('listeners', $config)) { $this->createListeners($extension, $config['listeners']); } if (key_exists('queryhandlers', $config)) { $this->createQueryHandlers($extension, $config['queryhandlers']); } } return $this->extensions[$group]; }
/** * @inheritdoc */ public function applyPathPrefix($path) { $prefixedPath = parent::applyPathPrefix($path); return rtrim($prefixedPath, DIRECTORY_SEPARATOR); }
public function testApplyPathPrefix() { $this->adapter->setPathPrefix(''); $this->assertEquals('', $this->adapter->applyPathPrefix('')); }