You are here

class Base in DRD Agent 4.0.x

Same name in this branch
  1. 4.0.x src/Crypt/Base.php \Drupal\drd_agent\Crypt\Base
  2. 4.0.x src/Agent/Action/Base.php \Drupal\drd_agent\Agent\Action\Base
  3. 4.0.x src/Agent/Remote/Base.php \Drupal\drd_agent\Agent\Remote\Base
  4. 4.0.x src/Agent/Auth/Base.php \Drupal\drd_agent\Agent\Auth\Base
Same name and namespace in other branches
  1. 8.3 src/Crypt/Base.php \Drupal\drd_agent\Crypt\Base

Provides base encryption functionality.

Hierarchy

Expanded class hierarchy of Base

2 files declare their use of Base
Agent.php in src/Controller/Agent.php
Base.php in src/Agent/Action/Base.php

File

src/Crypt/Base.php, line 12

Namespace

Drupal\drd_agent\Crypt
View source
class Base implements BaseInterface {

  /**
   * {@inheritdoc}
   */
  public static function getInstance(ContainerInterface $container, $method, array $settings) : BaseMethodInterface {
    $classname = "\\Drupal\\drd_agent\\Crypt\\Method\\{$method}";
    return new $classname($container, $settings);
  }

  /**
   * {@inheritdoc}
   */
  public static function getMethods(ContainerInterface $container, $instances = FALSE) : array {
    $methods = [];
    foreach ([
      'MCrypt',
      'OpenSSL',
      'TLS',
    ] as $item) {
      $classname = "\\Drupal\\drd_agent\\Crypt\\Method\\{$item}";

      /* @var BaseMethodInterface $method */
      $method = new $classname($container);
      if ($method instanceof BaseMethodInterface && $method
        ->isAvailable()) {
        if ($instances) {
          $methods[$method
            ->getLabel()] = $method;
        }
        else {
          $methods[$method
            ->getLabel()] = [
            'classname' => $classname,
            'cipher' => $method
              ->getCipherMethods(),
          ];
        }
      }
    }
    return $methods;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Base::getInstance public static function Create instance of a crypt object of given method with provided settings. Overrides BaseInterface::getInstance
Base::getMethods public static function Get a list of crypt methods, either just their ids or instances of each. Overrides BaseInterface::getMethods