You are here

Update360.php in Lightning Core 8.3

Same filename and directory in other branches
  1. 8.5 src/Update/Update360.php
  2. 8.4 src/Update/Update360.php

File

src/Update/Update360.php
View source
<?php

namespace Drupal\lightning_core\Update;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\lightning_core\ConfigHelper as Config;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * @Update("3.6.0")
 */
final class Update360 implements ContainerInjectionInterface {

  /**
   * The module installer service.
   *
   * @var \Drupal\Core\Extension\ModuleInstallerInterface
   */
  private $moduleInstaller;

  /**
   * Update360 constructor.
   *
   * @param \Drupal\Core\Extension\ModuleInstallerInterface $module_installer
   *   The module installer service.
   */
  public function __construct(ModuleInstallerInterface $module_installer) {
    $this->moduleInstaller = $module_installer;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('module_installer'));
  }

  /**
   * @update
   *
   * @ask Do you want to enable pictures for user accounts?
   */
  public function enableUserPictures() {
    $this->moduleInstaller
      ->install([
      'image',
    ]);
    $config = Config::forModule('lightning_core')
      ->optional();
    $config
      ->getEntity('field_storage_config', 'user.user_picture')
      ->save();
    $config
      ->getEntity('field_config', 'user.user.user_picture')
      ->save();
    $config
      ->getEntity('entity_view_display', 'user.user.compact')
      ->save();
  }

}

Classes

Namesort descending Description
Update360 Plugin annotation @Update("3.6.0");