You are here

class MigratePush in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePush
  2. 2.0.x modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php \Drupal\cms_content_sync_migrate_acquia_content_hub\Form\MigratePush

Content Sync advanced debug form.


Expanded class hierarchy of MigratePush

1 file declares its use of MigratePush in modules/cms_content_sync_migrate_acquia_content_hub/
Contains Drush commands for Content Sync.
1 string reference to 'MigratePush'
cms_content_sync_migrate_acquia_content_hub.routing.yml in modules/cms_content_sync_migrate_acquia_content_hub/cms_content_sync_migrate_acquia_content_hub.routing.yml


modules/cms_content_sync_migrate_acquia_content_hub/src/Form/MigratePush.php, line 21


View source
class MigratePush extends MigrationBase {

  public function __construct(EntityManager $acquia_entity_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, FieldTypePluginManagerInterface $field_type_plugin_manager, ConfigFactoryInterface $config_factory, ModuleHandler $moduleHandler, EntityTypeManager $entity_type_manager) {
    parent::__construct($acquia_entity_manager, $entity_type_bundle_info, $field_type_plugin_manager, $config_factory, $moduleHandler, $entity_type_manager);

   * {@inheritdoc}
  public function getFormId() {
    return 'cms_content_sync_migrate_acquia_content_hub.migrate_export';

   * {@inheritdoc}
  public function buildForm(array $form, FormStateInterface $form_state) {
    $this->migrationType = 'push';
    $form = parent::buildForm($form, $form_state);
    $url = Url::fromUri('');
    $link = Link::fromTextAndUrl(t('here'), $url);
    $link = $link
    $link['#attributes'] = [
      'class' => [
    $link = render($link);
    $form['node_push_behavior'] = [
      '#title' => $this
        ->t('Node push behavior'),
      '#description' => $this
        ->t('This configuration allows to define if Nodes should be pushed automatically ("All") or manually ("Manually"). Further information about push behaviors could be found @link.', [
        '@link' => $link,
      '#type' => 'select',
      '#options' => [
        PushIntent::PUSH_AUTOMATICALLY => $this
        PushIntent::PUSH_MANUALLY => $this
      '#default_value' => PushIntent::PUSH_AUTOMATICALLY,
    $form['#attached']['library'][] = 'cms_content_sync_migrate_acquia_content_hub/migrate-form';
    return $form;

   * @param string $pool_id
   * @param string $node_push_behavior
   * @param string $pull_updates_behavior
   * @param bool $force_update
   * @return array|string
  public static function createFlow($pool_id, $node_push_behavior, $pull_updates_behavior, $force_update = FALSE, $override = NULL) {

    // Get Acquia Content Hub configurations.
    $content_hub_configrations = MigratePush::getAcquiaContentHubConfigrations();

    // Create a new flow based on the given Acquia Content Hub configurations.
    foreach ($content_hub_configrations as $entity_type_key => $content_hub_configration) {

      // If no bundles are configured, the entity type can be skipped.
      if (!in_array(TRUE, $content_hub_configration)) {
      foreach ($content_hub_configration as $bundle_key => $bundle) {
        if ($bundle) {

          // @todo More Handler options?
          // General configurations.
          $configurations[$entity_type_key][$bundle_key]['push_configuration'] = [
            'export_deletion_settings' => TRUE,
          $configurations[$entity_type_key][$bundle_key]['push_configuration']['export_pools'] = [];
          $usage = $entity_type_key == 'node' ? Pool::POOL_USAGE_ALLOW : Pool::POOL_USAGE_FORCE;
          $configurations[$entity_type_key][$bundle_key]['push_configuration']['export_pools'][$pool_id] = $usage;

          // Export everything beside nodes as dependencies, but allow overrides.
          if (isset($override[$entity_type_key][$bundle_key]['push_configuration']['behavior'])) {
            $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = $override[$entity_type_key][$bundle_key]['push_configuration']['behavior'];
          elseif ($entity_type_key == 'node') {
            $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = $node_push_behavior;
          else {
            $configurations[$entity_type_key][$bundle_key]['push_configuration']['behavior'] = PushIntent::PUSH_AS_DEPENDENCY;
    if (!empty($configurations)) {
        ->addMessage('The pushing flow has been created, please review your settings.');
      return [
        'flow_id' => Flow::createFlow('Push', 'push_migrated', TRUE, [
          'config' => [
            'cms_content_sync.pool.' . $pool_id,
        ], $configurations, $force_update),
        'flow_configuration' => $configurations,
        'type' => 'push',
    else {
        ->addMessage('Content Sync Pushing Flow has not been created.', 'warning');
      return '';

   * Get Entity Type configurations of the Acquia Content Hub.
   * @return array
  public static function getAcquiaContentHubConfigrations() {
    $entity_types = \Drupal::service('acquia_contenthub.entity_manager')
    $content_hub_configurations = [];
    foreach ($entity_types as $entity_type_key => $entity_type) {
      $contenthub_entity_config_id = \Drupal::service('acquia_contenthub.entity_manager')
      foreach ($entity_type as $bundle_key => $bundle) {
        $content_hub_configurations[$entity_type_key][$bundle_key] = $contenthub_entity_config_id ? $contenthub_entity_config_id
          ->isEnableIndex($bundle_key) : FALSE;
    return $content_hub_configurations;



Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
MigratePush::buildForm public function Form constructor. Overrides MigrationBase::buildForm
MigratePush::createFlow public static function
MigratePush::getAcquiaContentHubConfigrations public static function Get Entity Type configurations of the Acquia Content Hub.
MigratePush::getFormId public function Returns a unique string identifying the form. Overrides MigrationBase::getFormId
MigratePush::__construct public function Constructs a new FieldStorageAddForm object. Overrides MigrationBase::__construct
MigrationBase::$acquiaEntityManager protected property The acquia content hub entity manager.
MigrationBase::$configFactory protected property The configuration factory. Overrides FormBase::$configFactory
MigrationBase::$entityTypeBundleInfo protected property The entity type bundle info manager interface.
MigrationBase::$entityTypeManager protected property The core entity type manager.
MigrationBase::$fieldTypePluginManager protected property The field type plugin manager.
MigrationBase::$moduleHandler protected property The Drupal module handler.
MigrationBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create
MigrationBase::createPools public static function Create the pools based on the user selected terms.
MigrationBase::DEFAULT_POOL constant
MigrationBase::DEFAULT_POOL_MACHINE_NAME constant
MigrationBase::getTermsFromFilter public static function
MigrationBase::submitForm public function Form submission handler. Overrides FormInterface::submitForm
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.