You are here

public function StorageFactory::get in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x src/StorageFactory.php \Drupal\radioactivity\StorageFactory::get()

Getter for classes which implement IncidentStorageInterface.

Parameters

string $type: The type of storage to get.

Return value

\Drupal\radioactivity\IncidentStorageInterface Instance of the requested storage.

1 call to StorageFactory::get()
StorageFactory::getConfiguredStorage in src/StorageFactory.php
Get the configured incident storage.

File

src/StorageFactory.php, line 49

Class

StorageFactory
Storage factory service.

Namespace

Drupal\radioactivity

Code

public function get($type) {
  switch ($type) {
    case 'rest_local':
      $instance = $this->classResolver
        ->getInstanceFromDefinition('radioactivity.rest_incident_storage');
      $instance
        ->setEndpoint(NULL);
      break;
    case 'rest_remote':
      $instance = $this->classResolver
        ->getInstanceFromDefinition('radioactivity.rest_incident_storage');
      $instance
        ->setEndpoint($this->config
        ->get('endpoint'));
      break;
    case 'default':
    default:
      $instance = $this->classResolver
        ->getInstanceFromDefinition('radioactivity.default_incident_storage');
  }

  /** @var \Drupal\radioactivity\IncidentStorageInterface $instance */
  return $instance;
}