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
4049eef2
Commit
4049eef2
authored
Nov 21, 2022
by
Reena Raghavan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSV Import added
parent
73b3be1b
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1249 additions
and
2 deletions
+1249
-2
composer.json
composer.json
+8
-0
composer.lock
composer.lock
+805
-1
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.article_csv_import.yml
...fig/install/migrate_plus.migration.article_csv_import.yml
+33
-0
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.files.yml
...f_migrate/config/install/migrate_plus.migration.files.yml
+33
-0
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.portfolio_csv_import.yml
...g/install/migrate_plus.migration.portfolio_csv_import.yml
+51
-0
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.users.yml
...f_migrate/config/install/migrate_plus.migration.users.yml
+30
-0
web/modules/custom/uvf_migrate/src/Plugin/migrate/process/FileExists.php
...tom/uvf_migrate/src/Plugin/migrate/process/FileExists.php
+96
-0
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Files.php
...es/custom/uvf_migrate/src/Plugin/migrate/source/Files.php
+91
-0
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Users.php
...es/custom/uvf_migrate/src/Plugin/migrate/source/Users.php
+97
-0
web/modules/custom/uvf_migrate/uvf_migrate.install
web/modules/custom/uvf_migrate/uvf_migrate.install
+5
-1
No files found.
composer.json
View file @
4049eef2
...
@@ -19,11 +19,19 @@
...
@@ -19,11 +19,19 @@
"php"
:
">=7.4"
,
"php"
:
">=7.4"
,
"
composer/installers
"
:
"
^1.9
"
,
"
composer/installers
"
:
"
^1.9
"
,
"
cweagans/composer-patches
"
:
"
^1.7
"
,
"
cweagans/composer-patches
"
:
"
^1.7
"
,
"
drupal/color_field
"
:
"
^2.5
"
,
"
drupal/core-composer-scaffold
"
:
"
^9.4
"
,
"
drupal/core-composer-scaffold
"
:
"
^9.4
"
,
"
drupal/core-recommended
"
:
"
^9.4
"
,
"
drupal/core-recommended
"
:
"
^9.4
"
,
"
drupal/csv_importer
"
:
"
^1.14
"
,
"
drupal/custom_sql_migrate_source_plugin
"
:
"
^1.3
"
,
"
drupal/custom_sql_migrate_source_plugin
"
:
"
^1.3
"
,
"
drupal/geofield
"
:
"
^1.47
"
,
"
drupal/geofield_map
"
:
"
^3.0
"
,
"
drupal/metatag
"
:
"
^1.22
"
,
"
drupal/migrate_plus
"
:
"
^6.0
"
,
"
drupal/migrate_plus
"
:
"
^6.0
"
,
"
drupal/migrate_source_csv
"
:
"
^3.5
"
,
"
drupal/migrate_tools
"
:
"
^6.0
"
,
"
drupal/migrate_tools
"
:
"
^6.0
"
,
"
drupal/paragraphs
"
:
"
^1.15
"
,
"
drupal/webform
"
:
"
^6.1
"
,
"
drush/drush
"
:
"
^11.0
"
,
"
drush/drush
"
:
"
^11.0
"
,
"
vlucas/phpdotenv
"
:
"
^5.1
"
,
"
vlucas/phpdotenv
"
:
"
^5.1
"
,
"
webflo/drupal-finder
"
:
"
^1.2
"
"
webflo/drupal-finder
"
:
"
^1.2
"
...
...
composer.lock
View file @
4049eef2
This diff is collapsed.
Click to expand it.
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.article_csv_import.yml
0 → 100644
View file @
4049eef2
id
:
article_csv_import
label
:
Import articles
migration_tags
:
-
CSV
migration_group
:
my_custom_migrate
source
:
plugin
:
csv
path
:
public://import-sources/article.csv
ids
:
[
nid
]
delimiter
:
'
,'
enclosure
:
'
"'
header_row_count
:
2
keys
:
-
nid
process
:
langcode
:
langcode
type
:
type
status
:
status
uid
:
uid
title
:
title
created
:
created
changed
:
changed
default_langcode
:
default_langcode
path
:
path
body
:
body
field_image
:
field_image
field_tags
:
field_tags
destination
:
plugin
:
entity:node
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.files.yml
0 → 100644
View file @
4049eef2
id
:
files
label
:
Migrate Files
migration_group
:
my_custom_migrate
source_type
:
Database
source
:
plugin
:
files
key
:
migrate
destination
:
plugin
:
'
entity:file'
source_base_path
:
https://drupal9-old.lndo.site
source_path_property
:
uri
urlencode
:
true
destination_path_property
:
uri
process
:
filename
:
filename
uri
:
uri
filemime
:
filemime
status
:
status
created
:
timestamp
changed
:
timestamp
uid
:
uid
alt
:
alt
migration_dependencies
:
required
:
{}
dependencies
:
enforced
:
module
:
{}
\ No newline at end of file
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.portfolio_csv_import.yml
0 → 100644
View file @
4049eef2
id
:
portfolio_csv_import
label
:
Import Portfolio
migration_tags
:
-
CSV
migration_group
:
my_custom_migrate
source
:
plugin
:
csv
path
:
public://import-sources/portfolio.csv
ids
:
[
nid
]
delimiter
:
'
,'
enclosure
:
'
"'
header_row_count
:
2
keys
:
-
nid
process
:
langcode
:
langcode
type
:
type
status
:
status
uid
:
uid
title
:
title
created
:
created
changed
:
changed
default_langcode
:
default_langcode
metatag
:
metatag
path
:
path
menu_link
:
menu_link
content_translation_source
:
content_translation_source
content_translation_outdated
:
content_translation_outdated
field_aply_type
:
field_aply_type
field_author_simple
:
field_author_simple
field_background_foto
:
field_background_foto
field_broadcast_article_ref
:
field_broadcast_article_ref
field_content
:
field_content
field_country
:
field_country
field_co_founders_simple
:
field_co_founders_simple
field_founding_amount
:
field_founding_amount
field_founding_status
:
field_founding_status
field_founding_year
:
field_founding_year
field_github_legend
:
field_github_legend
field_github_url
:
field_github_url
field_graduated
:
field_graduated
field_localization
:
field_localization
field_organization
:
field_organization
field_theme
:
field_theme
field_thumbnail
:
field_thumbnail
destination
:
plugin
:
entity:node
web/modules/custom/uvf_migrate/config/install/migrate_plus.migration.users.yml
0 → 100644
View file @
4049eef2
id
:
users
label
:
Migrate Users
migration_group
:
my_custom_migrate
source_type
:
Database
source
:
plugin
:
users
key
:
migrate
destination
:
plugin
:
entity:user
process
:
uid
:
uid
name
:
name
pass
:
pass
mail
:
mail
created
:
created
status
:
status
field_first_name
:
field_first_name
field_last_name
:
field_last_name
field_job_role
:
field_job_role
field_mailing_address
:
field_mailing_address
migration_dependencies
:
required
:
{}
dependencies
:
enforced
:
module
:
{}
\ No newline at end of file
web/modules/custom/uvf_migrate/src/Plugin/migrate/process/FileExists.php
0 → 100644
View file @
4049eef2
<?php
namespace
Drupal\uvf_migrate\Plugin\migrate\process
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\migrate\MigrateExecutableInterface
;
use
Drupal\migrate\MigrateSkipRowException
;
use
Drupal\migrate\ProcessPluginBase
;
use
Drupal\migrate\Row
;
use
GuzzleHttp\Client
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Checks to see if a file exists.
*
* @MigrateProcessPlugin(
* id = "file_exists"
* )
*/
class
FileExists
extends
ProcessPluginBase
implements
ContainerFactoryPluginInterface
{
/**
* The Guzzle HTTP Client service.
*
* @var \GuzzleHttp\Client
*/
protected
$httpClient
;
/**
* Constructs a download process plugin.
*
* @param array $configuration
* The plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \GuzzleHttp\Client $http_client
* The HTTP client.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
Client
$http_client
)
{
$configuration
+=
[
'guzzle_options'
=>
[],
];
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
httpClient
=
$http_client
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'http_client'
)
);
}
/**
* {@inheritdoc}
*/
public
function
transform
(
$value
,
MigrateExecutableInterface
$migrate_executable
,
Row
$row
,
$destination_property
)
{
// Verify that the image exists.
try
{
$this
->
httpClient
->
get
(
$value
,
$this
->
configuration
[
'guzzle_options'
]
);
}
catch
(
\Exception
$e
)
{
// Guzzle throws an exception for anything but 200.
throw
new
MigrateSkipRowException
(
'Skipping file: "'
.
$value
.
'".'
);
}
return
$value
;
}
}
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Files.php
0 → 100644
View file @
4049eef2
<?php
namespace
Drupal\uvf_migrate\Plugin\migrate\source
;
use
Drupal\migrate\Plugin\migrate\source\SqlBase
;
use
Drupal\migrate\Row
;
/**
* Source plugin for Files (images, docs).
*
* @MigrateSource(
* id = "files"
* )
*/
class
Files
extends
SqlBase
{
/**
* {@inheritdoc}
*/
public
function
query
()
{
$file_types
=
[
'image/jpeg'
,
'image/png'
,
'image/gif'
,
'text/plain'
,
'application/pdf'
,
'application/msword'
,
'application/vnd.ms-excel'
,
'application/vnd.ms-powerpoint'
,
'application/vnd.download'
,
'application/octet-stream'
,
];
return
$this
->
select
(
'file_managed'
)
->
fields
(
'file_managed'
,
array_keys
(
$this
->
fields
()))
// Ignore unpublished files.
->
condition
(
'status'
,
'1'
,
'='
)
// Only interested in image files.
->
condition
(
'filemime'
,
$file_types
,
'IN'
);
}
/**
* {@inheritdoc}
*/
public
function
fields
()
{
$fields
=
[
'fid'
=>
$this
->
t
(
'File ID'
),
'uid'
=>
$this
->
t
(
'User ID'
),
'filename'
=>
$this
->
t
(
'File name'
),
'uri'
=>
$this
->
t
(
'File URI'
),
'filemime'
=>
$this
->
t
(
'File MIME type'
),
'created'
=>
$this
->
t
(
'File created date UNIX timestamp'
),
];
return
$fields
;
}
/**
* {@inheritdoc}
*/
public
function
getIds
()
{
return
[
'fid'
=>
[
'type'
=>
'integer'
,
],
];
}
/**
* {@inheritdoc}
*/
public
function
prepareRow
(
Row
$row
)
{
// Set the destination uri.
$row
->
setSourceProperty
(
'destination_uri'
,
sprintf
(
'public://%s'
,
$row
->
getSourceProperty
(
'filename'
))
);
// Update filepath to remove public:// directory portion.
$original_path
=
$row
->
getSourceProperty
(
'uri'
);
$new_path
=
str_replace
(
'public://'
,
'https://drupal9-new.lndo.site/sites/default/files/'
,
$original_path
);
$row
->
setSourceProperty
(
'filepath'
,
$new_path
);
return
parent
::
prepareRow
(
$row
);
}
}
web/modules/custom/uvf_migrate/src/Plugin/migrate/source/Users.php
0 → 100644
View file @
4049eef2
<?php
namespace
Drupal\uvf_migrate\Plugin\migrate\source
;
use
Drupal\migrate\Row
;
use
Drupal\migrate\Plugin\migrate\source\SqlBase
;
/**
* Drupal 9 user source from database.
*
* @MigrateSource(
* id = "users",
* source_module = "user"
* )
*/
class
Users
extends
SqlBase
{
/**
* {@inheritdoc}
*/
public
function
query
()
{
// return $this->select('users_field_data', 'u')
// ->fields('u')
// ->condition('u.uid', 0, '>');
$query
=
$this
->
select
(
'users_field_data'
,
'u'
);
$query
->
fields
(
'u'
,
[
'uid'
,
'name'
,
'pass'
,
'mail'
,
'created'
,
'status'
,]);
$query
->
condition
(
'u.uid'
,
0
,
'>'
);
return
$query
;
}
/**
* {@inheritdoc}
*/
public
function
fields
()
{
$fields
=
$this
->
baseFields
();
$fields
[
'field_first_name'
]
=
$this
->
t
(
'First Name'
);
$fields
[
'field_last_name'
]
=
$this
->
t
(
'First Name'
);
$fields
[
'field_job_role'
]
=
$this
->
t
(
'First Name'
);
$fields
[
'field_mailing_address'
]
=
$this
->
t
(
'First Name'
);
return
$fields
;
}
/**
* {@inheritdoc}
*/
public
function
prepareRow
(
Row
$row
)
{
// $roles = $this->select('users_roles', 'ur')
// ->fields('ur', ['rid'])
// ->condition('ur.uid', $row->getSourceProperty('uid'))
// ->execute()
// ->fetchCol();
// $row->setSourceProperty('roles', $roles);
// $row->setSourceProperty(
// 'data',
// unserialize($row->getSourceProperty('data'))
// );
$uid
=
$row
->
getSourceProperty
(
'uid'
);
$row
->
setSourceProperty
(
'uid'
,
$uid
);
return
parent
::
prepareRow
(
$row
);
}
/**
* {@inheritdoc}
*/
public
function
getIds
()
{
return
[
'uid'
=>
[
'type'
=>
'integer'
,
'alias'
=>
'u'
,
],
];
}
/**
* {@inheritdoc}
*/
protected
function
baseFields
()
{
$fields
=
array
(
'uid'
=>
$this
->
t
(
'User ID'
),
'name'
=>
$this
->
t
(
'Username'
),
'pass'
=>
$this
->
t
(
'Password'
),
'mail'
=>
$this
->
t
(
'Email'
),
'created'
=>
$this
->
t
(
'Created On'
),
'status'
=>
$this
->
t
(
'Status'
)
);
return
$fields
;
}
}
web/modules/custom/uvf_migrate/uvf_migrate.install
View file @
4049eef2
...
@@ -12,7 +12,11 @@ function uvf_migrate_uninstall() {
...
@@ -12,7 +12,11 @@ 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_term'
,
'migrate_plus.migration.custom_taxonomy_vocabulary'
'migrate_plus.migration.custom_taxonomy_vocabulary'
,
'migrate_plus.migration.files.yml'
,
'migrate_plus.migration.users.yml'
,
'migrate_plus.migration.article_csv_import.yml'
,
'migrate_plus.migration.portfolio_csv_import.yml'
];
];
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