deploy_individual-8.x-1.x-dev/deploy_individual.module
deploy_individual.module
<?php
/**
* @file
* UI module to deploy content entities individually.
*/
use Drupal\Core\Url;
/**
* Implements hook_toolbar().
*/
function deploy_individual_toolbar() {
$items = [];
if (\Drupal::moduleHandler()->moduleExists('deploy')) {
$items['deploy_individual'] = [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Deploy individual content'),
'#url' => Url::fromRoute('entity.replication.individual.add_form'),
'#attributes' => [
'title' => t('Deploy individual content'),
'class' => ['toolbar-icon', 'toolbar-icon-deploy', 'use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode([
'width' => '50%',
]),
],
],
'#wrapper_attributes' => [
'class' => ['deploy-toolbar-tab'],
],
'#attached' => [
'library' => [
'deploy/drupal.deploy.toolbar',
],
],
];
}
return $items;
}
/**
* Implements hook_entity_type_alter().
*
* Add form entity.
*/
function deploy_individual_entity_type_alter(array &$entity_types) {
if (!empty($entity_types['replication']) && \Drupal::moduleHandler()->moduleExists('deploy')) {
/** @var \Drupal\Core\Entity\EntityTypeInterface $replication */
$replication = $entity_types['replication'];
$replication->setFormClass('add_individual', 'Drupal\deploy_individual\Entity\Form\IndividualReplicationForm');
}
}
