entity_share_client.drush.inc in Entity Share 8.2
File
modules/entity_share_client/entity_share_client.drush.inc
View source
<?php
declare (strict_types=1);
use Drupal\entity_share_client\Drush8Io;
function entity_share_client_drush_command() {
$items['entity-share-client-pull'] = [
'description' => 'Pull the content of a channel of a remote website.',
'core' => [
'8+',
],
'aliases' => [],
'arguments' => [
'remote_id' => 'The remote website id to import from.',
'channel_id' => 'The remote channel id to import.',
],
'options' => [
'update' => 'Use this option to fetch only new and updated entities.',
],
'examples' => [
'drush entity-share-client-pull content_hub articles_fr' => 'Import the channel articles_fr from the content_hub website',
'drush entity-share-client-pull content_hub articles_fr --update' => 'Pull only new and changed entities from articles_fr channel.',
],
];
return $items;
}
function drush_entity_share_client_pull($remote_id = '', $channel_id = '') {
$args = func_get_args();
if (count($args) < 2) {
return drush_set_error('DRUSH_ARGUMENTS_ERROR', dt('Usage: drush entity-share-client-pull <remote_id> <channel_id>'));
}
try {
$update = drush_get_option('update');
if ($update) {
\Drupal::service('entity_share_client.cli')
->ioPullUpdates($remote_id, $channel_id, new Drush8Io(), 'dt');
}
else {
\Drupal::service('entity_share_client.cli')
->ioPull($remote_id, $channel_id, new Drush8Io(), 'dt');
}
} catch (Exception $e) {
return drush_set_error('DRUSH_EXECUTION_ERROR', $e
->getMessage());
}
}