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
ca14c6f6
Commit
ca14c6f6
authored
15 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
Push static caching for mapping targets into map().
parent
dacc63c0
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
plugins/FeedsNodeProcessor.inc
+27
-28
27 additions, 28 deletions
plugins/FeedsNodeProcessor.inc
plugins/FeedsProcessor.inc
+6
-1
6 additions, 1 deletion
plugins/FeedsProcessor.inc
with
33 additions
and
29 deletions
plugins/FeedsNodeProcessor.inc
+
27
−
28
View file @
ca14c6f6
...
@@ -226,34 +226,33 @@ class FeedsNodeProcessor extends FeedsProcessor {
...
@@ -226,34 +226,33 @@ class FeedsNodeProcessor extends FeedsProcessor {
* Static cached, may be called multiple times in a page load.
* Static cached, may be called multiple times in a page load.
*/
*/
public
function
getMappingTargets
()
{
public
function
getMappingTargets
()
{
static
$targets
;
$targets
=
array
(
if
(
empty
(
$targets
))
{
'title'
=>
array
(
$targets
=
array
(
'name'
=>
t
(
'Title'
),
'title'
=>
array
(
),
'name'
=>
t
(
'Title'
),
'status'
=>
array
(
),
'name'
=>
t
(
'Published status'
),
'status'
=>
array
(
),
'name'
=>
t
(
'Published status'
),
'created'
=>
array
(
),
'name'
=>
t
(
'Published date'
),
'created'
=>
array
(
),
'name'
=>
t
(
'Published date'
),
// Using 'teaser' instead of 'body' forces entire content above the break.
),
'body'
=>
array
(
// Using 'teaser' instead of 'body' forces entire content above the break.
'name'
=>
t
(
'Body'
),
'body'
=>
array
(
),
'name'
=>
t
(
'Body'
),
'url'
=>
array
(
),
'name'
=>
t
(
'URL'
),
'url'
=>
array
(
'optional_unique'
=>
TRUE
,
'name'
=>
t
(
'URL'
),
),
'optional_unique'
=>
TRUE
,
'guid'
=>
array
(
),
'name'
=>
t
(
'GUID'
),
'guid'
=>
array
(
'optional_unique'
=>
TRUE
,
'name'
=>
t
(
'GUID'
),
),
'optional_unique'
=>
TRUE
,
);
),
);
self
::
loadMappers
();
self
::
loadMappers
();
drupal_alter
(
'feeds_node_processor_targets'
,
$targets
,
$this
->
config
[
'content_type'
]);
drupal_alter
(
'feeds_node_processor_targets'
,
$targets
,
$this
->
config
[
'content_type'
]);
}
return
$targets
;
return
$targets
;
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsProcessor.inc
+
6
−
1
View file @
ca14c6f6
...
@@ -51,6 +51,12 @@ abstract class FeedsProcessor extends FeedsPlugin {
...
@@ -51,6 +51,12 @@ abstract class FeedsProcessor extends FeedsPlugin {
* Execute mapping on an item.
* Execute mapping on an item.
*/
*/
protected
function
map
(
$source_item
,
$target_item
=
NULL
)
{
protected
function
map
(
$source_item
,
$target_item
=
NULL
)
{
// Static cache $targets as getMappingTargets() may be an expensive method.
static
$targets
;
if
(
empty
(
$targets
))
{
$targets
=
$this
->
getMappingTargets
();
}
$parser
=
feeds_importer
(
$this
->
id
)
->
parser
;
$parser
=
feeds_importer
(
$this
->
id
)
->
parser
;
if
(
empty
(
$target_item
))
{
if
(
empty
(
$target_item
))
{
$target_item
=
array
();
$target_item
=
array
();
...
@@ -65,7 +71,6 @@ abstract class FeedsProcessor extends FeedsPlugin {
...
@@ -65,7 +71,6 @@ abstract class FeedsProcessor extends FeedsPlugin {
If the mapping specifies a callback method, use the callback instead of
If the mapping specifies a callback method, use the callback instead of
setTargetElement().
setTargetElement().
*/
*/
$targets
=
$this
->
getMappingTargets
();
foreach
(
$this
->
config
[
'mappings'
]
as
$mapping
)
{
foreach
(
$this
->
config
[
'mappings'
]
as
$mapping
)
{
$value
=
$parser
->
getSourceElement
(
$source_item
,
$mapping
[
'source'
]);
$value
=
$parser
->
getSourceElement
(
$source_item
,
$mapping
[
'source'
]);
...
...
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