* @deprecated New services must be registered using Dependency Injection Container */ abstract class Configurable implements PhpSerializable, TaoLoggerAwareInterface { use LoggerAwareTrait; /** @var array */ private $options = []; /** * public constructor to allow the object to be recreated from php code * * @param array $options * @deprecated New services must be registered using Dependency Injection Container */ public function __construct($options = []) { $this->setOptions($options); } /** * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function setOption($name, $value) { $this->options[$name] = $value; } /** * Set options * * @param array $options * @return void * @throws \common_exception_Error * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function setOptions(array $options) { if (!is_array($options)) { if (is_object($options) && method_exists($options, 'toArray')) { $options = $options->toArray(); } else { throw new \common_exception_Error('Options submitted to ' . get_called_class() . ' must be an array or implement toArray'); } } $this->options = $options; } /** * Returns whenever or not the option is defined * * @param string $name * @return boolean * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function hasOption($name) { return isset($this->options[$name]); } /** * Get an option value by name * * If the option is not set a default value will be returned. * * @param string $name * @param mixed|null $default Default value to return if option is not set. * @return mixed * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function getOption($name, $default = null) { return $this->options[$name] ?? $default; } /** * Get all options * * @return array * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function getOptions() { return $this->options; } /** * (non-PHPdoc) * @see \oat\oatbox\PhpSerializable::__toPhpCode() * @deprecated Use \oat\generis\model\DependencyInjection\ServiceOptions instead */ public function __toPhpCode() { $options = $this->getOptions(); $params = empty($options) ? '' : \common_Utils::toHumanReadablePhpString($options); return 'new ' . get_class($this) . '(' . $params . ')'; } }