You are here

class DeployProcessorBatch in Deploy - Content Staging 7.3

Same name and namespace in other branches
  1. 7.2 plugins/DeployProcessorBatch.inc \DeployProcessorBatch

Processor class using the Batch API

Hierarchy

Expanded class hierarchy of DeployProcessorBatch

1 string reference to 'DeployProcessorBatch'
deploy_deploy_processors in ./deploy.deploy.inc
Implements hook_deploy_processors().

File

plugins/DeployProcessorBatch.inc, line 10
Batch API plugin for deploy Processor.

View source
class DeployProcessorBatch extends DeployProcessorMemory {

  /**
   * Batch operations to execute.
   *
   * @var array
   */
  public $operations = array();

  /**
   * {@inheritdoc}
   */
  protected function processOperations(array $operations = array()) {
    if (!empty($operations)) {
      foreach ($this->aggregator as $entity) {
        foreach ($operations as $operation) {
          $this->operations[] = array(
            $operation['callback'],
            array(
              $this->aggregator->plan->name,
              $entity,
            ),
          );
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function deploy($deployment_key, DeployEndpoint $endpoint, $lock_name = NULL) {
    deploy_log($deployment_key, DEPLOY_STATUS_PROCESSING);
    foreach ($this->aggregator as $entity) {
      $entity_info = entity_get_info($entity->__metadata['type']);
      $id_key = $entity_info['entity keys']['id'];
      $entity->__metadata['id'] = $entity->{$id_key};
      $entity->__metadata['deployment_key'] = $deployment_key;
      $entity->__metadata['plan_name'] = $this->aggregator->plan->name;
      $entity->__metadata['endpoint_name'] = $endpoint->name;
      $entity->__metadata['lock_name'] = $lock_name;
      $this->operations[] = array(
        'deploy_queue_worker_deploy',
        array(
          $entity,
        ),
      );
    }
  }

  /**
   * {@inheritdoc}
   */
  public function publish($deployment_key, DeployEndpoint $endpoint, $lock_name = NULL) {
    foreach ($this->aggregator as $entity) {
      $entity_info = entity_get_info($entity->__metadata['type']);
      $id_key = $entity_info['entity keys']['id'];
      $entity->__metadata['id'] = $entity->{$id_key};
      $entity->__metadata['deployment_key'] = $deployment_key;
      $entity->__metadata['plan_name'] = $this->aggregator->plan->name;
      $entity->__metadata['endpoint_name'] = $endpoint->name;
      $entity->__metadata['lock_name'] = $lock_name;
      $this->operations[] = array(
        'deploy_queue_worker_publish',
        array(
          $entity,
        ),
      );
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postProcess(array $operations = array()) {
    $this
      ->processOperations($operations);
    $batch = array(
      'title' => t('Deploying %plan', array(
        '%plan' => $this->aggregator->plan->title,
      )),
      'operations' => $this->operations,
      'finished' => 'deploy_batch_finished_operation',
    );
    batch_set($batch);
    if (drupal_is_cli() && function_exists('drush_main')) {

      // Drush has its own batch processor.
      $batch =& batch_get();
      $batch['progressive'] = FALSE;
      drush_backend_batch_process();
    }
    else {
      batch_process('admin/structure/deploy');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeployProcessorBatch::$operations public property Batch operations to execute.
DeployProcessorBatch::deploy public function Main processing method that should hand over the aggregator to the endpoint to deploy all the entities. Overrides DeployProcessorMemory::deploy
DeployProcessorBatch::postProcess public function Runs all postprocess operations. Overrides DeployProcessorMemory::postProcess
DeployProcessorBatch::processOperations protected function Overrides DeployProcessorMemory::processOperations
DeployProcessorBatch::publish public function Processing method that should hand over the aggregator to the endpoint to publish all deployed entities. This method will only be called after successful deployments. Overrides DeployProcessorMemory::publish
DeployProcessorMemory::$aggregator public property The aggregator containing the entities to be processed.
DeployProcessorMemory::$config public property Configuration options.
DeployProcessorMemory::configForm public function Configuration form. Overrides DeployProcessor::configForm
DeployProcessorMemory::preProcess public function Runs all preprocess operations. Overrides DeployProcessor::preProcess
DeployProcessorMemory::__construct public function Constructor for a deploy processor. Overrides DeployProcessor::__construct