Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
ede61cb8
Commit
ede61cb8
authored
9 years ago
by
twistor
Committed by
Chris Leppanen
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2497507 by twistor: Pass plugin definition to FeedsPlugin objects
parent
b244c044
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
feeds.module
+9
-8
9 additions, 8 deletions
feeds.module
plugins/FeedsPlugin.inc
+42
-3
42 additions, 3 deletions
plugins/FeedsPlugin.inc
with
51 additions
and
11 deletions
feeds.module
+
9
−
8
View file @
ede61cb8
...
...
@@ -1011,22 +1011,21 @@ function feeds_source($importer_id, $feed_nid = 0) {
/**
* Gets an instance of a class for a given plugin and id.
*
* @param $plugin
* @param
string
$plugin
* A string that is the key of the plugin to load.
* @param $id
* @param
string
$id
* A string that is the id of the object.
*
* @return
* @return
FeedsPlugin
* A FeedsPlugin object.
*
* @throws Exception
* If plugin can't be instantiated.
*/
function
feeds_plugin
(
$plugin
,
$id
)
{
ctools_include
(
'plugins'
);
if
(
$class
=
ctools_plugin_load_class
(
'feeds'
,
'plugins'
,
$plugin
,
'handler'
))
{
return
Feeds
Configurable
::
instance
(
$class
,
$id
);
return
Feeds
Plugin
::
instance
(
$class
,
$id
,
ctools_get_plugins
(
'feeds'
,
'plugins'
,
$plugin
)
);
}
$args
=
array
(
'%plugin'
=>
$plugin
,
'@id'
=>
$id
);
if
(
user_access
(
'administer feeds'
))
{
$args
[
'@link'
]
=
url
(
'admin/structure/feeds/'
.
$id
);
...
...
@@ -1035,8 +1034,10 @@ function feeds_plugin($plugin, $id) {
else
{
drupal_set_message
(
t
(
'Missing Feeds plugin %plugin. Please contact your site administrator.'
,
$args
),
'warning'
,
FALSE
);
}
$class
=
ctools_plugin_load_class
(
'feeds'
,
'plugins'
,
'FeedsMissingPlugin'
,
'handler'
);
return
FeedsConfigurable
::
instance
(
$class
,
$id
);
return
FeedsPlugin
::
instance
(
$class
,
$id
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsPlugin.inc
+
42
−
3
View file @
ede61cb8
...
...
@@ -19,6 +19,47 @@ class FeedsResult {}
*/
abstract
class
FeedsPlugin
extends
FeedsConfigurable
implements
FeedsSourceInterface
{
/**
* The plugin definition.
*
* @var array
*/
protected
$pluginDefinition
;
/**
* Constructs a FeedsPlugin object.
*
* @param string $id
* The plugin id.
* @param array $plugin_definition
* The plugin definition.
*/
protected
function
__construct
(
$id
,
array
$plugin_definition
)
{
$this
->
pluginDefinition
=
$plugin_definition
;
parent
::
__construct
(
$id
);
}
/**
* Instantiates a FeedsPlugin object.
*
* Don't use directly, use feeds_plugin() instead.
*
* @see feeds_plugin()
*/
public
static
function
instance
(
$class
,
$id
,
array
$plugin_definition
=
array
())
{
if
(
!
strlen
(
$id
))
{
throw
new
InvalidArgumentException
(
t
(
'Empty configuration identifier.'
));
}
static
$instances
=
array
();
if
(
!
isset
(
$instances
[
$class
][
$id
]))
{
$instances
[
$class
][
$id
]
=
new
$class
(
$id
,
$plugin_definition
);
}
return
$instances
[
$class
][
$id
];
}
/**
* Returns the type of plugin.
*
...
...
@@ -36,9 +77,7 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
* @see ctools_get_plugins()
*/
public
function
pluginDefinition
()
{
$importer
=
feeds_importer
(
$this
->
id
);
$plugin_key
=
$importer
->
config
[
$this
->
pluginType
()][
'plugin_key'
];
return
ctools_get_plugins
(
'feeds'
,
'plugins'
,
$plugin_key
);
return
$this
->
pluginDefinition
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment