Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/304 migration #323

Open
wants to merge 10 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('The statistics value.'))
->setCardinality(1)
->setRequired(TRUE)
// Positive only.
// Positive only.
->setSetting('unsigned', TRUE)
->setSetting('min', 0)
->setDisplayConfigurable('form', TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public function getConfirmText() {
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();

$this->messenger()->addStatus($this->t('content @type: deleted @label.',
[
'@type' => $this->entity->bundle(),
'@label' => $this->entity->label(),
]
$this->messenger()->addStatus($this->t(
'content @type: deleted @label.',
[
'@type' => $this->entity->bundle(),
'@label' => $this->entity->label(),
]
));

$form_state->setRedirectUrl($this->getCancelUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function buildRow(EntityInterface $entity) {
/** @var \Drupal\drupalfr_localize_statistics\Entity\LocalizeStatistics $entity */
$row['id'] = $entity->id();
$row['name'] = Link::createFromRoute(
$entity->label(),
'entity.localize_statistics.edit_form',
['localize_statistics' => $entity->id()]
);
$entity->label(),
'entity.localize_statistics.edit_form',
['localize_statistics' => $entity->id()]
);
$row['value'] = $entity->get('value')->value;
return $row + parent::buildRow($entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class LocalizeStatisticsCron implements LocalizeStatisticsCronInterface {
* The HTTP client factory.
*/
public function __construct(
TimeInterface $time,
StateInterface $state,
EntityTypeManagerInterface $entity_type_manager,
LoggerInterface $logger,
ClientFactory $http_client_factory
) {
TimeInterface $time,
StateInterface $state,
EntityTypeManagerInterface $entity_type_manager,
LoggerInterface $logger,
ClientFactory $http_client_factory
) {
$this->time = $time;
$this->state = $state;
$this->entityTypeManager = $entity_type_manager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class MeetupController extends ControllerBase implements ContainerInjectionInter
* The leaflet service.
*/
public function __construct(
MeetupHelperInterface $meetup_helper,
LeafletService $leaflet_service
) {
MeetupHelperInterface $meetup_helper,
LeafletService $leaflet_service
) {
$this->meetupHelper = $meetup_helper;
$this->leafletService = $leaflet_service;
}
Expand All @@ -50,9 +50,9 @@ public function __construct(
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('drupalfr_meetup.meetup_helper'),
$container->get('leaflet.service')
);
$container->get('drupalfr_meetup.meetup_helper'),
$container->get('leaflet.service')
);
}

/**
Expand All @@ -66,7 +66,7 @@ public function index() {
'#theme' => 'drupalfr_meetup_page',
'#title' => $this->t('Drupal Meetups'),
'#cache' => [
// 15 minutes.
// 15 minutes.
'max-age' => '900',
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
$plugin_definition,
MeetupHelperInterface $drupalfr_meetup_meetup_helper,
LeafletService $leaflet_service
) {
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->meetupHelper = $drupalfr_meetup_meetup_helper;
$this->leafletService = $leaflet_service;
Expand All @@ -64,12 +64,12 @@ public function __construct(
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('drupalfr_meetup.meetup_helper'),
$container->get('leaflet.service')
);
$configuration,
$plugin_id,
$plugin_definition,
$container->get('drupalfr_meetup.meetup_helper'),
$container->get('leaflet.service')
);
}

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ public function build() {
'#theme' => 'drupalfr_meetup_events',
'#events' => $events,
'#cache' => [
// 15 minutes.
// 15 minutes.
'max-age' => '900',
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
$plugin_id,
$plugin_definition,
MeetupHelperInterface $drupalfr_meetup_meetup_helper
) {
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->meetupHelper = $drupalfr_meetup_meetup_helper;
}
Expand All @@ -51,11 +51,11 @@ public function __construct(
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('drupalfr_meetup.meetup_helper')
);
$configuration,
$plugin_id,
$plugin_definition,
$container->get('drupalfr_meetup.meetup_helper')
);
}

/**
Expand All @@ -64,7 +64,7 @@ public static function create(ContainerInterface $container, array $configuratio
public function build() {
$build = [
'#cache' => [
// 15 minutes.
// 15 minutes.
'max-age' => '900',
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public function getEvents() {
}
}
return $events;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity_type.manager')
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
id: drupalfr_node_doc_d7
label: 'Nodes Documents (doc type in D7)'
audit: true
migration_group: drupalfr_d7
migration_tags:
- Drupal 7
- Content
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: doc
process:
# If you are using this file to build a custom migration consider removing
# the nid and vid fields to allow incremental migrations.
# In D7, nodes always have a tnid, but it's zero for untranslated nodes.
# We normalize it to equal the nid in that case.
# @see \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow().
nid: vid
langcode:
plugin: default_value
source: language
default_value: "und"
title: title
uid: node_uid
status: status
created: created
changed: changed
promote: promote
sticky: sticky
revision_uid: revision_uid
revision_log: log
revision_timestamp: timestamp
type:
plugin: default_value
default_value: doc
body:
plugin: sub_process
source: body
process:
value: value
format:
-
plugin: default_value
default_value: basic_html
destination:
plugin: entity:node
default_bundle: doc
migration_dependencies:
required:
- d7_user
- d7_node_type
- drupalfr_nodetypes_d7
optional:
- d7_field_instance
- d7_comment_field_instance
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
id: drupalfr_nodetypes_d7
label: Node type configuration
migration_group: drupalfr_d7
migration_tags:
- Drupal 7
- Configuration
source:
plugin: drupalfr_nodetypes_d7
types:
- doc
constants:
preview: 1 # DRUPAL_OPTIONAL
process:
type: type
name: name
description: description
help: help
title_label: title_label
preview_mode: 'constants/preview'
display_submitted: display_submitted
new_revision: 'options/revision'
create_body: create_body
create_body_label: body_label
'third_party_settings/menu_ui/available_menus': available_menus
'third_party_settings/menu_ui/parent': parent
destination:
plugin: entity:node_type
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
langcode: fr
status: true
dependencies: { }
id: drupalfr_d7
label: Migrate content
description: 'A container for any migrations not explicitly assigned to a group.'
source_type: 'Drupal 7'
module: null
shared_configuration: null
29 changes: 22 additions & 7 deletions www/modules/custom/drupalfr_migrate_d7/drupalfr_migrate_d7.install
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@
/**
* Implements hook_unistall().
*/
function drupalfr_migrate_d7_uninstall() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$files = $file_system->scanDirectory(drupal_get_path('module', 'drupalfr_migrate_d7') . "/config/install", "/.*\.yml/");
foreach ($files as $file) {
\Drupal::configFactory()->getEditable($file->name)->delete();
}
function drupalfr_migrate_d7_uninstall()
{
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$files = $file_system->scanDirectory(drupal_get_path('module', 'drupalfr_migrate_d7').'/config/install', "/.*\.yml/");
foreach ($files as $file) {
\Drupal::configFactory()->getEditable($file->name)->delete();
}

// Uninstall Migration Entities
$group = \Drupal::entityTypeManager()->getStorage('migration_group')->load('drupalfr_d7');
if ($group) {
$group->delete();
}
$entity = \Drupal::entityTypeManager()->getStorage('migration')->load('drupalfr_nodetypes_d7');
if ($entity) {
$entity->delete();
}
$entity = \Drupal::entityTypeManager()->getStorage('migration')->load('drupalfr_node_doc_d7');
if ($entity) {
$entity->delete();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
drupalfr_migrate_d7.entities_form:
path: '/drupalfr_migrate_d7/form/entities'
defaults:
_form: '\Drupal\drupalfr_migrate_d7\Form\DeleteEntitiesForm'
_title: 'EntitiesForm'
requirements:
_access: 'TRUE'