You are here

final class ManagementApiEdgeEntityControllerProxy in Apigee Edge 8

Management API specific default entity controller implementation.

Hierarchy

Expanded class hierarchy of ManagementApiEdgeEntityControllerProxy

3 files declare their use of ManagementApiEdgeEntityControllerProxy
ApiProductStorage.php in src/Entity/Storage/ApiProductStorage.php
DeveloperStorage.php in src/Entity/Storage/DeveloperStorage.php
TeamStorage.php in modules/apigee_edge_teams/src/Entity/Storage/TeamStorage.php

File

src/Entity/Controller/ManagementApiEdgeEntityControllerProxy.php, line 32

Namespace

Drupal\apigee_edge\Entity\Controller
View source
final class ManagementApiEdgeEntityControllerProxy implements EdgeEntityControllerInterface {

  /**
   * The decorated controller from the SDK.
   *
   * @var \Apigee\Edge\Controller\EntityCrudOperationsControllerInterface|\Apigee\Edge\Controller\NonPaginatedEntityListingControllerInterface|\Apigee\Edge\Controller\PaginatedEntityListingControllerInterface
   */
  private $controller;

  /**
   * ManagementApiEntityControllerBase constructor.
   *
   * @param object $controller
   *   A controller from the SDK with CRUDL capabilities. It gets
   *   validated whether it implements the required interfaces.
   */
  public function __construct($controller) {
    if (!$controller instanceof EntityCrudOperationsControllerInterface) {
      throw new InvalidArgumentException(sprintf('Controller must implement %s interface.', EntityCrudOperationsControllerInterface::class));
    }
    if (!$controller instanceof NonPaginatedEntityListingControllerInterface && !$controller instanceof PaginatedEntityListingControllerInterface) {
      throw new InvalidArgumentException(sprintf('Controller must implement either %s or %s interfaces.', NonPaginatedEntityListingControllerInterface::class, PaginatedEntityListingControllerInterface::class));
    }
    $this->controller = $controller;
  }

  /**
   * {@inheritdoc}
   */
  public function create(EntityInterface $entity) : void {
    $this->controller
      ->create($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function load(string $id) : EntityInterface {
    return $this->controller
      ->load($id);
  }

  /**
   * {@inheritdoc}
   */
  public function update(EntityInterface $entity) : void {
    $this->controller
      ->update($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function delete(string $id) : void {

    // Ignore returned entity object by Apigee Edge.
    $this->controller
      ->delete($id);
  }

  /**
   * {@inheritdoc}
   */
  public function loadAll() : array {

    // Luckily we solved in the PHP API client that even on paginated endpoints
    // all entities can be retrieved with one single method call.
    return $this->controller
      ->getEntities();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ManagementApiEdgeEntityControllerProxy::$controller private property The decorated controller from the SDK.
ManagementApiEdgeEntityControllerProxy::create public function Creates an entity in Apigee Edge. Overrides EdgeEntityControllerInterface::create
ManagementApiEdgeEntityControllerProxy::delete public function Removes an entity from Apigee Edge. Overrides EdgeEntityControllerInterface::delete
ManagementApiEdgeEntityControllerProxy::load public function Loads an entity from Apigee Edge. Overrides EdgeEntityControllerInterface::load
ManagementApiEdgeEntityControllerProxy::loadAll public function Loads _all_ entities from Apigee Edge. Overrides EdgeEntityControllerInterface::loadAll
ManagementApiEdgeEntityControllerProxy::update public function Updates an entity in Apigee Edge. Overrides EdgeEntityControllerInterface::update
ManagementApiEdgeEntityControllerProxy::__construct public function ManagementApiEntityControllerBase constructor.