function public function ProviderBase::processDefinition

8.x-3.x ProviderBase.php public ProviderBase::processDefinition(array &$definition, $plugin_id)

Overrides ProviderInterface::processDefinition


in 8.x-3.18, will be removed in a future release.

3 methods override ProviderBase::processDefinition()
ApiProviderBase::processDefinition in src/Plugin/Provider/ApiProviderBase.php
Broken::processDefinition in src/Plugin/Provider/Broken.php
Custom::processDefinition in src/Plugin/Provider/Custom.php
Processes the provider plugin definition upon discovery.


CDN Provider base class.



Source src/Plugin/Provider/ProviderBase.php (line 663)

public function processDefinition(array &$definition, $plugin_id) {
  // Due to code recursion and the need to keep this code in place for BC
  // reasons, this deprecated message should only be logged and not shown.

  // Process API data.
  if ($api = $this->getApi()) {
    $provider_path = ProviderManager::FILE_PATH;
    file_prepare_directory($provider_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);

    // Use manually imported API data, if it exists.
    if (file_exists("$provider_path/$plugin_id.json") && ($imported_data = file_get_contents("$provider_path/$plugin_id.json"))) {
      $definition['imported'] = TRUE;
      try {
        $json = Json::decode($imported_data);
      catch (\Exception $e) {
        // Intentionally left blank.
    // Otherwise, attempt to request API data if the provider has specified
    // an "api" URL to use.
    else {
      $json = Bootstrap::request($api)->getData();

    if (!isset($json)) {
      $json = [];
      $definition['error'] = TRUE;

    $this->processApi($json, $definition);