diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigAdminImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigAdminImportForm.php index a661849..85a5d10 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigAdminImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigAdminImportForm.php @@ -8,8 +8,9 @@ namespace Drupal\config\Form; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Config\StorageInterface; use Drupal\Core\Lock; -use Drupal; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a configuration import form. @@ -17,6 +18,43 @@ class ConfigAdminImportForm implements FormInterface { /** + * Stores the source storage to retrieve differences from. + * + * @var \Drupal\Core\Config\StorageInterface + */ + protected $sourceStorage; + + /** + * Stores the target storage to compare differences to. + * + * @var \Drupal\Core\Config\StorageInterface + */ + protected $targetStorage; + + /** + * Constructs a \Drupal\config\Form\ConfigAdminImportForm object. + * + * @param \Drupal\Core\Config\StorageInterface $source_storage + * The source storage to retrieve differences from. + * @param \Drupal\Core\Config\StorageInterface $target_storage + * The target storage to compare differences to. + */ + public function __construct(StorageInterface $source_storage, StorageInterface $target_storage) { + $this->sourceStorage = $source_storage; + $this->targetStorage = $target_storage; + } + + /** + * Implements \Drupal\Core\ControllerInterface::create(). + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('config.storage.staging'), + $container->get('config.storage') + ); + } + + /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). */ public function getFormID() { @@ -25,13 +63,10 @@ public function getFormID() { /** * Implements \Drupal\Core\Form\FormInterface::buildForm(). - * */ public function buildForm(array $form, array &$form_state) { - // The source storage to retrieve differences from. - $source_storage = Drupal::service('config.storage.staging'); - // The target storage to compare differences to. - $target_storage = Drupal::service('config.storage'); + $source_storage = $this->sourceStorage; + $target_storage = $this->targetStorage; $form['actions'] = array( '#type' => 'actions', @@ -129,7 +164,7 @@ public function submitForm(array &$form, array &$form_state) { // Once a sync completes, we empty the staging directory. This prevents // changes from being accidentally overwritten by stray files getting // imported later. - $source_storage = Drupal::service('config.storage.staging'); + $source_storage = $this->sourceStorage; foreach ($source_storage->listAll() as $name) { $source_storage->delete($name); }