public function AcsfDuplicationScrubInitializeHandler::handle in Acquia Cloud Site Factory Connector 8
Same name and namespace in other branches
- 8.2 src/Event/AcsfDuplicationScrubInitializeHandler.php \Drupal\acsf\Event\AcsfDuplicationScrubInitializeHandler::handle()
Implements AcsfEventHandler::handle().
Overrides AcsfEventHandler::handle
File
- src/
Event/ AcsfDuplicationScrubInitializeHandler.php, line 16
Class
- AcsfDuplicationScrubInitializeHandler
- Handles initialization operations for the scrub.
Namespace
Drupal\acsf\EventCode
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();
}
}