InfoParserException example


  public function parse($filename) {
    if (!file_exists($filename)) {
      $parsed_info = [];
    }
    else {
      try {
        $parsed_info = Yaml::decode(file_get_contents($filename));
      }
      catch (InvalidDataTypeException $e) {
        throw new InfoParserException("Unable to parse $filename " . $e->getMessage());
      }
      $missing_keys = array_diff($this->getRequiredKeys()array_keys($parsed_info));
      if (!empty($missing_keys)) {
        throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename);
      }
      if (!isset($parsed_info['core_version_requirement'])) {
        if (str_starts_with($filename, 'core/') || str_starts_with($filename$this->root . '/core/')) {
          // Core extensions do not need to specify core compatibility: they are           // by definition compatible so a sensible default is used. Core           // modules are allowed to provide these for testing purposes.           $parsed_info['core_version_requirement'] = \Drupal::VERSION;
        }
// If we get here, then this is our parent theme.     return $current_base_theme;
  }

  /** * {@inheritdoc} */
  protected function createExtensionInfo(Extension $extension) {
    $info = parent::createExtensionInfo($extension);

    if (!isset($info['base theme'])) {
      throw new InfoParserException(sprintf('Missing required key ("base theme") in %s, see https://www.drupal.org/node/3066038', $extension->getPathname()));
    }

    // Remove the base theme when 'base theme: false' is set in a theme     // .info.yml file.     if ($info['base theme'] === FALSE) {
      unset($info['base theme']);
    }

    if (!empty($info['base theme'])) {
      // Add the base theme as a proper dependency.       $info['dependencies'][] = $info['base theme'];
    }
Home | Imprint | This part of the site doesn't use cookies.