You are here

public function StylePluginManager::processDefinition in Styles API 8

Performs extra processing on plugin definitions.

By default we add defaults for the type to the definition. If a type has additional processing logic they can do that by replacing or extending the method.

Overrides DefaultPluginManager::processDefinition

File

src/Plugin/Style/StylePluginManager.php, line 64
Contains \Drupal\styles_api\Plugin\Style\StylePluginManager.

Class

StylePluginManager
Plugin type manager for all styles.

Namespace

Drupal\styles_api\Plugin\Style

Code

public function processDefinition(&$definition, $plugin_id) {
  parent::processDefinition($definition, $plugin_id);

  // Add the module or theme path to the 'path'.
  if ($this->moduleHandler
    ->moduleExists($definition['provider'])) {
    $definition['provider_type'] = 'module';
    $base_path = $this->moduleHandler
      ->getModule($definition['provider'])
      ->getPath();
  }
  elseif ($this->themeHandler
    ->themeExists($definition['provider'])) {
    $definition['provider_type'] = 'theme';
    $base_path = $this->themeHandler
      ->getTheme($definition['provider'])
      ->getPath();
  }
  else {
    $base_path = '';
  }
  $definition['configuration']['path'] = !empty($definition['configuration']['path']) ? $base_path . '/' . $definition['configuration']['path'] : $base_path;

  // Add the path to the icon filename.
  if (!empty($definition['icon'])) {
    $definition['icon'] = $definition['path'] . '/' . $definition['icon'];
  }
}