*/ class ManageableFeature extends TestRunnerFeature { /** @var string */ protected $label; /** @var string */ protected $description; const OPTION_ID = 'identifier'; const OPTION_DESCRIPTION = 'description'; const OPTION_ACTIVE = 'active'; const OPTION_LABEL = 'label'; const OPTION_ENABLED_BY_DEFAULT = 'enabledByDefault'; const OPTION_PLUGIN_IDS = 'pluginIds'; /** * ManageableFeature constructor. * @param array $options * @throws \common_exception_InconsistentData */ public function __construct(array $options) { $missedOptions = array_diff_key([ self::OPTION_ID => self::OPTION_ID, self::OPTION_DESCRIPTION => self::OPTION_DESCRIPTION, self::OPTION_LABEL => self::OPTION_LABEL, self::OPTION_ACTIVE => self::OPTION_ACTIVE, self::OPTION_ENABLED_BY_DEFAULT => self::OPTION_ENABLED_BY_DEFAULT, self::OPTION_PLUGIN_IDS => self::OPTION_PLUGIN_IDS, ], $options); if (!empty($missedOptions)) { throw new \common_exception_InconsistentData('Required options missed in ' . static::class . ': ' . implode(',', array_keys($missedOptions))); } $this->id = $options[self::OPTION_ID]; $this->label = $options[self::OPTION_LABEL]; $this->description = $options[self::OPTION_DESCRIPTION]; $this->active = $options[self::OPTION_ACTIVE]; $this->isEnabledByDefault = $options[self::OPTION_ENABLED_BY_DEFAULT]; $this->pluginsIds = $options[self::OPTION_PLUGIN_IDS]; } /** * @inheritdoc */ public function getLabel() { return $this->label; } /** * @inheritdoc */ public function getDescription() { return $this->description; } /** * @return TestPlugin[] */ protected function getAllPlugins() { $pluginService = $this->getServiceLocator()->get(TestPluginService::SERVICE_ID); return $pluginService->getAllPlugins(); } /** * @return string * @throws \common_exception_Error */ public function __toPhpCode() { return 'new ' . get_class($this) . '([' . PHP_EOL . ' \'' . self::OPTION_ID . '\'=>' . \common_Utils::toPHPVariableString($this->getId()) . ',' . PHP_EOL . ' \'' . self::OPTION_DESCRIPTION . '\'=>__(' . \common_Utils::toPHPVariableString($this->getDescription()) . '),' . PHP_EOL . ' \'' . self::OPTION_LABEL . '\'=>__(' . \common_Utils::toPHPVariableString($this->getLabel()) . '),' . PHP_EOL . ' \'' . self::OPTION_ACTIVE . '\'=>' . \common_Utils::toPHPVariableString($this->isActive()) . ',' . PHP_EOL . ' \'' . self::OPTION_ENABLED_BY_DEFAULT . '\'=>' . \common_Utils::toPHPVariableString($this->isEnabledByDefault()) . ',' . PHP_EOL . ' \'' . self::OPTION_PLUGIN_IDS . '\'=>' . \common_Utils::toPHPVariableString($this->getPluginsIds()) . ',' . PHP_EOL . '])'; } }