Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
U
UVF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Reena Raghavan
UVF
Commits
73b3be1b
Commit
73b3be1b
authored
Nov 11, 2022
by
Reena Raghavan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Term.php File added (Taxonomy Term)
parent
e37b46e1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
179 additions
and
3 deletions
+179
-3
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.article.yml
...migrate/config/install/migrate_plus.migration.article.yml
+3
-0
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.custom_taxonomy_term.yml
...g/install/migrate_plus.migration.custom_taxonomy_term.yml
+34
-0
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Article.php
.../custom/uvf_migrate/src/Plugin/migrate/source/Article.php
+11
-2
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Term.php
...les/custom/uvf_migrate/src/Plugin/migrate/source/Term.php
+70
-0
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Vocabulary.php
...stom/uvf_migrate/src/Plugin/migrate/source/Vocabulary.php
+58
-0
web/modules/custom/uvf_migrate/uvf_migrate.install
web/modules/custom/uvf_migrate/uvf_migrate.install
+3
-1
No files found.
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.article.yml
View file @
73b3be1b
id
:
article
id
:
article
label
:
Migrate Article
label
:
Migrate Article
migration_group
:
my_custom_migrate
migration_group
:
my_custom_migrate
source_type
:
Database
source
:
source
:
plugin
:
article
plugin
:
article
...
@@ -13,7 +14,9 @@ destination:
...
@@ -13,7 +14,9 @@ destination:
process
:
process
:
nid
:
nid
nid
:
nid
title
:
title
title
:
title
body
:
body_value
migration_dependencies
:
migration_dependencies
:
required
:
{}
required
:
{}
dependencies
:
{}
dependencies
:
{}
\ No newline at end of file
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.custom_taxonomy_term.yml
0 → 100644
View file @
73b3be1b
id
:
custom_taxonomy_term
label
:
Migrate taxonomy terms
migration_group
:
my_custom_migrate
source_type
:
Database
source
:
plugin
:
custom_taxonomy_term
key
:
migrate
destination
:
plugin
:
entity:taxonomy_term
default_bundle
:
tags
process
:
tid
:
tid
vid
:
plugin
:
migration_lookup
migration
:
custom_taxonomy_vocabulary
source
:
vid
name
:
name
description__value
:
description__value
weight
:
weight
parent_target_id
:
-
plugin
:
migration_lookup
migration
:
custom_taxonomy_term
changed
:
timestamp
migration_dependencies
:
required
:
{}
dependencies
:
enforced
:
module
:
{}
\ No newline at end of file
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Article.php
View file @
73b3be1b
...
@@ -26,8 +26,17 @@ class Article extends SqlBase
...
@@ -26,8 +26,17 @@ class Article extends SqlBase
*/
*/
public
function
query
()
public
function
query
()
{
{
$query
=
$this
->
select
(
'node_field_data'
,
'ar'
)
// $query = $this->select('node_field_data', 'ar')
->
fields
(
'ar'
,
[
'nid'
,
'title'
]);
// ->fields('ar', ['nid','title']);
// return $query;
$query
=
$this
->
select
(
'node_field_data'
,
'ar'
);
$query
->
fields
(
'ar'
,
[
'nid'
,
'title'
]);
$query
->
addField
(
'nb'
,
'body_value'
);
$query
->
leftjoin
(
'node__body'
,
'nb'
,
'ar.nid = nb.entity_id'
);
$query
->
condition
(
'ar.type'
,
'article'
);
return
$query
;
return
$query
;
...
...
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Term.php
0 → 100644
View file @
73b3be1b
<?php
/**
* @file
* Contains \Drupal\uvf_migrate\Plugin\migrate\source\Term.
*/
namespace
Drupal\uvf_migrate\Plugin\migrate\source
;
use
Drupal\migrate\Row
;
use
Drupal\migrate\Plugin\migrate\source\SqlBase
;
/**
* Drupal 9 taxonomy terms source from database.
*
* @todo Support term_relation, term_synonym table if possible.
*
* @MigrateSource(
* id = "custom_taxonomy_term",
* source_provider = "taxonomy"
* )
*/
class
Term
extends
SqlBase
{
/**
* {@inheritdoc}
*/
public
function
query
()
{
$query
=
$this
->
select
(
'taxonomy_term_field_data'
,
'td'
)
->
fields
(
'td'
,
[
'tid'
,
'vid'
,
'name'
,
'description__value'
,
'weight'
]);
$query
->
addField
(
'tp'
,
'parent_target_id'
);
$query
->
leftjoin
(
'taxonomy_term__parent'
,
'tp'
,
'td.tid = tp.entity_id'
);
$query
->
distinct
();
return
$query
;
}
/**
* {@inheritdoc}
*/
public
function
fields
()
{
return
[
'tid'
=>
$this
->
t
(
'The term ID.'
),
'vid'
=>
$this
->
t
(
'Existing term VID'
),
'name'
=>
$this
->
t
(
'The name of the term.'
),
'description__value'
=>
$this
->
t
(
'The term description.'
),
'weight'
=>
$this
->
t
(
'Weight'
),
'parent_target_id'
=>
$this
->
t
(
"The Drupal term IDs of the term's parents."
),
];
}
/**
* {@inheritdoc}
*/
public
function
getIds
()
{
$ids
[
'tid'
][
'type'
]
=
'integer'
;
return
$ids
;
}
}
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Vocabulary.php
0 → 100644
View file @
73b3be1b
<?php
/**
* @file
* Contains \Drupal\uvf_migrate\Plugin\migrate\source\Vocabulary.
*/
namespace
Drupal\uvf_migrate\Plugin\migrate\source
;
use
Drupal\migrate\Row
;
use
Drupal\migrate\Plugin\migrate\source\SqlBase
;
/**
* Drupal 9 vocabularies source from database.
*
* @MigrateSource(
* id = "custom_taxonomy_vocabulary",
* source_provider = "taxonomy"
* )
*/
class
Vocabulary
extends
SqlBase
{
/**
* {@inheritdoc}
*/
public
function
query
()
{
$query
=
$this
->
select
(
'taxonomy_term_field_data'
,
'v'
)
->
fields
(
'v'
,
[
'tid'
,
'name'
,
'description__value'
,
'weight'
]);
return
$query
;
}
/**
* {@inheritdoc}
*/
public
function
fields
()
{
return
[
'tid'
=>
$this
->
t
(
'The vocabulary ID.'
),
'name'
=>
$this
->
t
(
'The name of the vocabulary.'
),
'description__value'
=>
$this
->
t
(
'The description of the vocabulary.'
),
'weight'
=>
$this
->
t
(
'The weight of the vocabulary in relation to other vocabularies.'
),
];
}
/**
* {@inheritdoc}
*/
public
function
getIds
()
{
$ids
[
'tid'
][
'type'
]
=
'integer'
;
return
$ids
;
}
}
web/modules/custom/uvf_migrate/uvf_migrate.install
View file @
73b3be1b
...
@@ -10,7 +10,9 @@
...
@@ -10,7 +10,9 @@
*/
*/
function
uvf_migrate_uninstall
()
{
function
uvf_migrate_uninstall
()
{
$configs
=
[
$configs
=
[
'migrate_plus.migration.article'
'migrate_plus.migration.article'
,
'migrate_plus.migration.custom_taxonomy_term'
,
'migrate_plus.migration.custom_taxonomy_vocabulary'
];
];
foreach
(
$configs
as
$config
){
foreach
(
$configs
as
$config
){
$delete
=
\Drupal
::
database
()
->
delete
(
'config'
)
$delete
=
\Drupal
::
database
()
->
delete
(
'config'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment