diff --git a/includes/FeedsConfigurable.inc b/includes/FeedsConfigurable.inc index 8f399f10742826eceb95326b616468076488e8f4..35bf1720bf1c3c28f07103b7e7cfd54a95ca2df0 100644 --- a/includes/FeedsConfigurable.inc +++ b/includes/FeedsConfigurable.inc @@ -6,6 +6,12 @@ * FeedsConfigurable and helper functions. */ +/** + * Used when an object does not exist in the DB or code but should. + */ +class FeedsNotExistingException extends Exception { +} + /** * A configurable class. */ @@ -68,6 +74,17 @@ abstract class FeedsConfigurable { $this->disabled = FALSE; } + /** + * Determine whether this object is persistent. I. e. it is defined either + * in code or in the database. + */ + public function existing() { + if ($this->export_type == FEEDS_EXPORT_NONE) { + throw new FeedsNotExistingException(t('Object is not persistent.')); + } + return $this; + } + /** * Save a configuration. Concrete extending classes must implement a save * operation. @@ -85,12 +102,13 @@ abstract class FeedsConfigurable { * Set configuration. * * @param $config - * Array containing configuration information. Will be filtered by the keys - * returned by configDefaults(). + * Array containing configuration information. Config array will be filtered + * by the keys returned by configDefaults() and populated with default + * values that are not included in $config. */ public function setConfig($config) { - $default_keys = $this->configDefaults(); - $this->config = array_intersect_key($config, $default_keys); + $defaults = $this->configDefaults(); + $this->config = array_intersect_key($config, $defaults) + $defaults; } /**