Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_drupal_d5
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_drupal_d5
Commits
dc5d4bde
Commit
dc5d4bde
authored
2 years ago
by
Kurucz István
Browse files
Options
Downloads
Patches
Plain Diff
own FilterFormat source plugin, source: \Drupal\filter\Plugin\migrate\source\d6\FilterFormat
parent
75da9df2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/migrate/source/d5/FilterFormat.php
+99
-0
99 additions, 0 deletions
src/Plugin/migrate/source/d5/FilterFormat.php
with
99 additions
and
0 deletions
src/Plugin/migrate/source/d5/FilterFormat.php
0 → 100644
+
99
−
0
View file @
dc5d4bde
<?php
namespace
Drupal\migrate_drupal_d5\Plugin\migrate\source\d5
;
use
Drupal\migrate_drupal
\Plugin\migrate\source\DrupalSqlBase
;
use
Drupal\migrate\Row
;
/**
* Drupal 5 filter source from database.
*
* For available configuration keys, refer to the parent classes.
*
* @see \Drupal\migrate\Plugin\migrate\source\SqlBase
* @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
* @see \Drupal\filter\Plugin\migrate\source\d6\FilterFormat
*
* @MigrateSource(
* id = "d5_filter_format",
* source_module = "filter"
* )
*/
class
FilterFormat
extends
DrupalSqlBase
{
/**
* {@inheritdoc}
*/
public
function
query
()
{
return
$this
->
select
(
'filter_formats'
,
'f'
)
->
fields
(
'f'
);
}
/**
* {@inheritdoc}
*/
public
function
fields
()
{
return
[
'format'
=>
$this
->
t
(
'Format ID.'
),
'name'
=>
$this
->
t
(
'The name of the format.'
),
'cache'
=>
$this
->
t
(
'Whether the format is cacheable.'
),
'roles'
=>
$this
->
t
(
'The role IDs which can use the format.'
),
'filters'
=>
$this
->
t
(
'The filters configured for the format.'
),
];
}
/**
* {@inheritdoc}
*/
public
function
prepareRow
(
Row
$row
)
{
$filters
=
[];
$roles
=
$row
->
getSourceProperty
(
'roles'
);
$row
->
setSourceProperty
(
'roles'
,
array_values
(
array_filter
(
explode
(
','
,
$roles
))));
$format
=
$row
->
getSourceProperty
(
'format'
);
// Find filters for this row.
$results
=
$this
->
select
(
'filters'
,
'f'
)
->
fields
(
'f'
,
[
'module'
,
'delta'
,
'weight'
])
->
condition
(
'format'
,
$format
)
->
execute
();
foreach
(
$results
as
$raw_filter
)
{
$module
=
$raw_filter
[
'module'
];
$delta
=
$raw_filter
[
'delta'
];
$filter
=
[
'module'
=>
$module
,
'delta'
=>
$delta
,
'weight'
=>
$raw_filter
[
'weight'
],
'settings'
=>
[],
];
// Load the filter settings for the filter module, modules can use
// hook_migration_d6_filter_formats_prepare_row() to add theirs.
if
(
$raw_filter
[
'module'
]
==
'filter'
)
{
if
(
!
$delta
)
{
if
(
$setting
=
$this
->
variableGet
(
"allowed_html_
$format
"
,
NULL
))
{
$filter
[
'settings'
][
'allowed_html'
]
=
$setting
;
}
if
(
$setting
=
$this
->
variableGet
(
"filter_html_help_
$format
"
,
NULL
))
{
$filter
[
'settings'
][
'filter_html_help'
]
=
$setting
;
}
if
(
$setting
=
$this
->
variableGet
(
"filter_html_nofollow_
$format
"
,
NULL
))
{
$filter
[
'settings'
][
'filter_html_nofollow'
]
=
$setting
;
}
}
elseif
(
$delta
==
3
&&
(
$setting
=
$this
->
variableGet
(
"filter_url_length_
$format
"
,
NULL
)))
{
$filter
[
'settings'
][
'filter_url_length'
]
=
$setting
;
}
}
$filters
[]
=
$filter
;
}
$row
->
setSourceProperty
(
'filters'
,
$filters
);
return
parent
::
prepareRow
(
$row
);
}
/**
* {@inheritdoc}
*/
public
function
getIds
()
{
$ids
[
'format'
][
'type'
]
=
'integer'
;
return
$ids
;
}
}
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