You are here

public function ThemeGenerator::__construct in AT Tools 8.3

Same name and namespace in other branches
  1. 8.2 at_theme_generator/src/Theme/ThemeGenerator.php \Drupal\at_theme_generator\Theme\ThemeGenerator::__construct()

Generator constructor.

Parameters

$values:

File

at_theme_generator/src/Theme/ThemeGenerator.php, line 43

Class

ThemeGenerator
Generator form.

Namespace

Drupal\at_theme_generator\Theme

Code

public function __construct($values) {

  // Form state values.
  $this->machine_name = $values['generate']['generate_machine_name'];
  $this->friendly_name = Html::escape(trim($values['generate']['generate_friendly_name']));
  $this->sub_theme_type = $values['generate']['generate_type'];
  $this->clone_source = $values['generate']['generate_clone_source'] ?: '';
  $this->skin_base = $values['generate']['generate_skin_base'] ?: '';
  $this->templates = $values['generate']['options']['generate_templates'];
  $this->block_config = $values['generate']['options']['generate_block_config'];
  $this->layout = $values['generate']['options']['generate_layout'];
  $this->scss = $values['generate']['options']['generate_scss'];
  $this->color = $values['generate']['options']['generate_color'];
  $this->theme_settings_file = $values['generate']['options']['generate_themesettingsfile'];
  $this->dir_option = $values['generate']['options']['generate_directory'];
  $this->dir_option_custom = $values['generate']['options']['generate_directory_custom'] ?: '';
  $this->description = preg_replace('/[^\\p{Latin}\\d\\s\\p{P}]/u', '', Html::escape(trim($values['generate']['options']['generate_description'])));

  // Handle version strings. I don't bother validating this, just spit it out, users want quick results not a headache.
  if (!empty($values['generate']['options']['generate_version'])) {
    $this->version = Html::escape(str_replace(' ', '', trim($values['generate']['options']['generate_version'])));
  }
  else {
    $this->version = '8.x-1.0';
  }

  // Datetime, description.
  $this->datetime = \Drupal::service('date.formatter')
    ->format(REQUEST_TIME, 'custom', 'D jS, M, Y - G:i');
  $this->generic_description = 'Adaptivetheme sub-theme';

  // File operations.
  $this->fileOperations = new FileOperations();
  $this->directoryOperations = new DirectoryOperations();

  // Base variables.
  $this->source = $this
    ->sourceTheme();
  $this->target = $this
    ->targetDirectory();
  $this->info = $this
    ->getInfoYml();
  $this->base_theme_info = $this
    ->getBaseThemeInfoYml();
  $this->layout_library = $this
    ->getLayout();
  $this->config = $this
    ->getConfig();
  $this->clone_source_config = $this
    ->getCloneSourceConfigSettings();

  // Paths.
  $this->at_core_path = drupal_get_path('theme', 'at_core');
  $this->at_generator_path = drupal_get_path('module', 'at_theme_generator');
}