class AcsfDuplicationScrubInitializeHandler in Acquia Cloud Site Factory Connector 8
Same name and namespace in other branches
- 8.2 src/Event/AcsfDuplicationScrubInitializeHandler.php \Drupal\acsf\Event\AcsfDuplicationScrubInitializeHandler
Handles initialization operations for the scrub.
Hierarchy
- class \Drupal\acsf\Event\AcsfEventHandler
- class \Drupal\acsf\Event\AcsfDuplicationScrubInitializeHandler
Expanded class hierarchy of AcsfDuplicationScrubInitializeHandler
File
- src/
Event/ AcsfDuplicationScrubInitializeHandler.php, line 11
Namespace
Drupal\acsf\EventView source
class AcsfDuplicationScrubInitializeHandler extends AcsfEventHandler {
/**
* Implements AcsfEventHandler::handle().
*/
public function handle() {
drush_print(dt('Entered @class', [
'@class' => get_class($this),
]));
if (!$this
->isComplete()) {
$site = AcsfSite::load();
$site
->clean();
\Drupal::config('system.site')
->set('name', $this->event->context['site_name'])
->save();
$state_storage = \Drupal::state();
$state_storage
->delete('acsf_duplication_scrub_status');
$state_storage
->set('install_time', time());
// As a preparatory step, remove any corrupt file entries that may prevent
// duplication from succeeding. Specifically, remove any file with an
// empty URI string.
$fids = \Drupal::entityQuery('file')
->condition('uri', '')
->execute();
$files = File::loadMultiple($fids);
foreach ($files as $file) {
try {
$file
->delete();
} catch (\Exception $e) {
// OK, we'll live with not scrubbing this.
}
}
$this
->setComplete();
}
}
/**
* Returns if this step has already completed.
*/
public function isComplete() {
return \Drupal::service('acsf.variable_storage')
->get('acsf_site_duplication_step_initialize_complete', FALSE);
}
/**
* Sets a flag to indicate that this step has completed.
*/
protected function setComplete() {
\Drupal::service('acsf.variable_storage')
->set('acsf_site_duplication_step_initialize_complete', TRUE, 'acsf_duplication_scrub');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcsfDuplicationScrubInitializeHandler:: |
public | function |
Implements AcsfEventHandler::handle(). Overrides AcsfEventHandler:: |
|
AcsfDuplicationScrubInitializeHandler:: |
public | function | Returns if this step has already completed. | |
AcsfDuplicationScrubInitializeHandler:: |
protected | function | Sets a flag to indicate that this step has completed. | |
AcsfEventHandler:: |
public | property | The time that the handler was completed. | |
AcsfEventHandler:: |
public | property | Any messages triggered by the handler. | |
AcsfEventHandler:: |
public | property | The time that the handler was started. | |
AcsfEventHandler:: |
public | function | Constructor. | 1 |