class StructureSyncHelper in Structure Sync 8
Same name and namespace in other branches
- 2.x src/StructureSyncHelper.php \Drupal\structure_sync\StructureSyncHelper
Container of functions for importing and exporting content in structure.
Hierarchy
- class \Drupal\structure_sync\StructureSyncHelper
Expanded class hierarchy of StructureSyncHelper
8 files declare their use of StructureSyncHelper
- BlocksController.php in src/
Controller/ BlocksController.php - BlocksSyncForm.php in src/
Form/ BlocksSyncForm.php - MenuLinksController.php in src/
Controller/ MenuLinksController.php - MenuSyncForm.php in src/
Form/ MenuSyncForm.php - StructureSyncCommands.php in src/
Commands/ StructureSyncCommands.php
File
- src/
StructureSyncHelper.php, line 13
Namespace
Drupal\structure_syncView source
class StructureSyncHelper {
/**
* Function to export taxonomy terms.
*/
public static function exportTaxonomies(array $form = NULL, FormStateInterface $form_state = NULL) {
$taxonomiesController = new TaxonomiesController();
$taxonomiesController
->exportTaxonomies($form, $form_state);
}
/**
* Function to export custom blocks.
*/
public static function exportCustomBlocks(array $form = NULL, FormStateInterface $form_state = NULL) {
$blocksController = new BlocksController();
$blocksController
->exportBlocks($form, $form_state);
}
/**
* Function to export menu links.
*/
public static function exportMenuLinks(array $form = NULL, FormStateInterface $form_state = NULL) {
$menuLinksController = new MenuLinksController();
$menuLinksController
->exportMenuLinks($form, $form_state);
}
/**
* Function to import taxonomy terms.
*
* When this function is used without the designated form, you should assign
* an array with a key value pair for form with key 'style' and value 'full',
* 'safe' or 'force' to apply that import style.
*/
public static function importTaxonomies(array $form, FormStateInterface $form_state = NULL) {
$taxonomiesController = new TaxonomiesController();
$taxonomiesController
->importTaxonomies($form, $form_state);
}
/**
* Function to import custom blocks.
*
* When this function is used without the designated form, you should assign
* an array with a key value pair for form with key 'style' and value 'full',
* 'safe' or 'force' to apply that import style.
*/
public static function importCustomBlocks(array $form, FormStateInterface $form_state = NULL) {
$customBlocksController = new BlocksController();
$customBlocksController
->importBlocks($form, $form_state);
}
/**
* Function to import menu links.
*
* When this function is used without the designated form, you should assign
* an array with a key value pair for form with key 'style' and value 'full',
* 'safe' or 'force' to apply that import style.
*/
public static function importMenuLinks(array $form, FormStateInterface $form_state = NULL) {
$menuLinksController = new MenuLinksController();
$menuLinksController
->importMenuLinks($form, $form_state);
}
/**
* General function for logging messages.
*/
public static function logMessage($message, $type = NULL, $context = []) {
$log = \Drupal::config('structure_sync.data')
->get('log');
if (isset($log) && $log === FALSE) {
return;
}
switch ($type) {
case 'error':
\Drupal::logger('structure_sync')
->error($message, $context);
break;
case 'warning':
\Drupal::logger('structure_sync')
->warning($message, $context);
break;
default:
\Drupal::logger('structure_sync')
->notice($message, $context);
break;
}
}
/**
* Function to start importing taxonomies with the 'full' style.
*/
public static function importTaxonomiesFull(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'full';
StructureSyncHelper::importTaxonomies($form, $form_state);
}
/**
* Function to start importing taxonomies with the 'safe' style.
*/
public static function importTaxonomiesSafe(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'safe';
StructureSyncHelper::importTaxonomies($form, $form_state);
}
/**
* Function to start importing taxonomies with the 'force' style.
*/
public static function importTaxonomiesForce(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'force';
StructureSyncHelper::importTaxonomies($form, $form_state);
}
/**
* Function to start importing custom blocks with the 'full' style.
*/
public static function importCustomBlocksFull(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'full';
StructureSyncHelper::importCustomBlocks($form, $form_state);
}
/**
* Function to start importing custom blocks with the 'safe' style.
*/
public static function importCustomBlocksSafe(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'safe';
StructureSyncHelper::importCustomBlocks($form, $form_state);
}
/**
* Function to start importing custom blocks with the 'force' style.
*/
public static function importCustomBlocksForce(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'force';
StructureSyncHelper::importCustomBlocks($form, $form_state);
}
/**
* Function to start importing menu links with the 'full' style.
*/
public static function importMenuLinksFull(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'full';
StructureSyncHelper::importMenuLinks($form, $form_state);
}
/**
* Function to start importing menu links with the 'safe' style.
*/
public static function importMenuLinksSafe(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'safe';
StructureSyncHelper::importMenuLinks($form, $form_state);
}
/**
* Function to start importing menu links with the 'force' style.
*/
public static function importMenuLinksForce(array &$form, FormStateInterface $form_state = NULL) {
$form['style'] = 'force';
StructureSyncHelper::importMenuLinks($form, $form_state);
}
/**
* Function to get an entity query.
*
* @param string $entityType
* The entity type (for example, node) for which the query object should be
* returned.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* Entity query.
*/
public static function getEntityQuery($entityType) {
return \Drupal::entityQuery($entityType);
}
/**
* Function to get an entity type manager.
*
* @return \Drupal\Core\Entity\EntityTypeManagerInterface
* Entity type manager.
*/
public static function getEntityManager() {
return \Drupal::entityTypeManager();
}
/**
* Function to get an entity field manager.
*
* @return \Drupal\Core\Entity\EntityFieldManagerInterface
* Entity field manager.
*/
public static function getEntityFieldManager() {
return \Drupal::service('entity_field.manager');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StructureSyncHelper:: |
public static | function | Function to export custom blocks. | |
StructureSyncHelper:: |
public static | function | Function to export menu links. | |
StructureSyncHelper:: |
public static | function | Function to export taxonomy terms. | |
StructureSyncHelper:: |
public static | function | Function to get an entity field manager. | |
StructureSyncHelper:: |
public static | function | Function to get an entity type manager. | |
StructureSyncHelper:: |
public static | function | Function to get an entity query. | |
StructureSyncHelper:: |
public static | function | Function to import custom blocks. | |
StructureSyncHelper:: |
public static | function | Function to start importing custom blocks with the 'force' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing custom blocks with the 'full' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing custom blocks with the 'safe' style. | |
StructureSyncHelper:: |
public static | function | Function to import menu links. | |
StructureSyncHelper:: |
public static | function | Function to start importing menu links with the 'force' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing menu links with the 'full' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing menu links with the 'safe' style. | |
StructureSyncHelper:: |
public static | function | Function to import taxonomy terms. | |
StructureSyncHelper:: |
public static | function | Function to start importing taxonomies with the 'force' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing taxonomies with the 'full' style. | |
StructureSyncHelper:: |
public static | function | Function to start importing taxonomies with the 'safe' style. | |
StructureSyncHelper:: |
public static | function | General function for logging messages. |