From f13213cc902091677a3d09297b3c4b60f4296310 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Thu, 18 Feb 2010 16:52:22 +0000 Subject: [PATCH] Add sourceSave() and sourceDelete() methods notifying plugin implementers of a source being saved or deleted. Minor cleanup on sourceForm(). --- CHANGELOG.txt | 2 ++ includes/FeedsSource.inc | 21 ++++++++++++++++++++- plugins/FeedsPlugin.inc | 12 +++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e50d743b..869e0181 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,8 @@ Feeds 6.x 1.0 xxxxx xx, xxxx-xx-xx ---------------------------------- +- alex_b: Add sourceSave() and sourceDelete() methods notifying plugin + implementers of a source being saved or deleted. - #717168 nicholasThompson: Fix feeds UI JS doesn't select labels correctly. - #708228 Scott Reynolds, alex_b: Break FeedsImportBatch into separate classes. NOTE: FeedsFetcher implementations cannot use FeedsImportBatch directly diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc index 320a3643..ca10c67e 100644 --- a/includes/FeedsSource.inc +++ b/includes/FeedsSource.inc @@ -38,7 +38,17 @@ interface FeedsSourceInterface { /** * Validate user entered values submitted by sourceForm(). */ - public function sourceFormValidate(&$values); + public function sourceFormValidate(&$source_config); + + /** + * A source is being deleted. + */ + public function sourceSave(FeedsSource $source); + + /** + * A source is being saved. + */ + public function sourceDelete(FeedsSource $source); } /** @@ -164,6 +174,10 @@ class FeedsSource extends FeedsConfigurable { */ public function save() { $config = $this->getConfig(); + // Alert implementers of FeedsSourceInterface to the fact that we're saving. + foreach ($this->importer->plugin_types as $type) { + $this->importer->$type->sourceSave($this); + } // Store the source property of the fetcher in a separate column so that we // can do fast lookups on it. $source = ''; @@ -206,6 +220,11 @@ class FeedsSource extends FeedsConfigurable { * from database, does not delete configuration itself. */ public function delete() { + // Alert implementers of FeedsSourceInterface to the fact that we're + // deleting. + foreach ($this->importer->plugin_types as $type) { + $this->importer->$type->sourceDelete($this); + } db_query('DELETE FROM {feeds_source} WHERE id = "%s" AND feed_nid = %d', $this->id, $this->feed_nid); } diff --git a/plugins/FeedsPlugin.inc b/plugins/FeedsPlugin.inc index 1d4f3f39..083dcdf3 100644 --- a/plugins/FeedsPlugin.inc +++ b/plugins/FeedsPlugin.inc @@ -67,7 +67,17 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter /** * Validation handler for sourceForm. */ - public function sourceFormValidate(&$values) {} + public function sourceFormValidate(&$source_config) {} + + /** + * A source is being saved. + */ + public function sourceSave(FeedsSource $source) {} + + /** + * A source is being deleted. + */ + public function sourceDelete(FeedsSource $source) {} } /** -- GitLab