name = $preset['name']; $this->group = empty($preset['group'])?null:$preset['group']; $this->plugin = $preset['plugin']; $this->props = $preset['props']; $this->params = empty($preset['params'])?null:$preset['params']; $this->directory = $directory; } /** * * @return string Preset name */ public function getName() { return $this->name; } /** * * @return string Preset logical group */ public function getGroup() { return $this->group; } /** * Get the plugin name, for resolving a plugin instance to use. * * @return string The plugin name/id */ public function getPlugin() { return $this->plugin; } /** * * @param string $prop The property to get * @return mixed The property if it exists, null otherwise */ public function get($prop) { if (!array_key_exists($prop, $this->props)) { return null; } return $this->props[$prop]; } /** * * @param string $prop The parameter to get * @return mixed The parameter if it exists, throws exception otherwise * @throws Exception */ public function getParam($param) { if (!array_key_exists($param, $this->params)) { throw new \Exception("No such param defined in preset: {$param}"); } return $this->params[$param]; } /** * Return the directory containing this preset, for referencing resources * bundled with presets. * * @return string The root directory */ public function getDirectory() { return $this->directory; } public function getResourcePath($file) { return $this->directory.DIRECTORY_SEPARATOR.$file; } }