final class OrganizationController in Apigee Edge 8
Definition of the Organization controller service.
This integrates the Management API's Organization controller from the SDK's with Drupal.
We created this to speed up entity controllers that have to use pagination when list entities from Apigee Edge. There is no need to load the same organization profile multiple times in the same page request when all entities are being loaded from Apigee Edge.
All paginated entity controllers should use this service.
Hierarchy
- class \Drupal\apigee_edge\Entity\Controller\OrganizationController implements OrganizationControllerInterface
Expanded class hierarchy of OrganizationController
See also
\Apigee\Edge\Controller\PaginationHelperTrait::listEntities()
\Drupal\apigee_edge\Entity\Controller\DeveloperController
1 string reference to 'OrganizationController'
1 service uses OrganizationController
File
- src/
Entity/ Controller/ OrganizationController.php, line 44
Namespace
Drupal\apigee_edge\Entity\ControllerView source
final class OrganizationController implements OrganizationControllerInterface {
/**
* The internal entity cache.
*
* @var \Apigee\Edge\Api\Management\Entity\OrganizationInterface[]
*/
private $cache = [];
/**
* Local cache for the decorated organization controller from the SDK.
*
* @var \Apigee\Edge\Api\Management\Controller\OrganizationController|null
*
* @see decorated()
*/
private $instance;
/**
* The SDK connector service.
*
* @var \Drupal\apigee_edge\SDKConnectorInterface
*/
private $connector;
/**
* OrganizationController constructor.
*
* @param \Drupal\apigee_edge\SDKConnectorInterface $connector
* The SDK connector service.
*/
public function __construct(SDKConnectorInterface $connector) {
$this->connector = $connector;
}
/**
* Returns the decorated organization controller from the SDK.
*
* @return \Apigee\Edge\Api\Management\Controller\OrganizationControllerInterface
* The initialized organization controller.
*/
private function decorated() : EdgeOrganizationControllerInterface {
if ($this->instance === NULL) {
$this->instance = new EdgeOrganizationController($this->connector
->getClient());
}
return $this->instance;
}
/**
* {@inheritdoc}
*/
public function create(EntityInterface $entity) : void {
$this
->decorated()
->create($entity);
$this->cache[$entity
->id()] = $entity;
}
/**
* {@inheritdoc}
*/
public function delete(string $entity_id) : EntityInterface {
$entity = $this
->decorated()
->delete($entity_id);
unset($this->cache[$entity_id]);
return $entity;
}
/**
* {@inheritdoc}
*/
public function load(string $entity_id) : EntityInterface {
if (!isset($this->cache[$entity_id])) {
$this->cache[$entity_id] = $this
->decorated()
->load($entity_id);
}
return $this->cache[$entity_id];
}
/**
* {@inheritdoc}
*/
public function update(EntityInterface $entity) : void {
$this
->decorated()
->update($entity);
$this->cache[$entity
->id()] = $entity;
}
/**
* {@inheritdoc}
*/
public function getEntities() : array {
$entities = $this
->decorated()
->getEntities();
foreach ($entities as $id => $entity) {
$this->cache[$id] = $entities;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OrganizationController:: |
private | property | The internal entity cache. | |
OrganizationController:: |
private | property | The SDK connector service. | |
OrganizationController:: |
private | property | Local cache for the decorated organization controller from the SDK. | |
OrganizationController:: |
public | function | ||
OrganizationController:: |
private | function | Returns the decorated organization controller from the SDK. | |
OrganizationController:: |
public | function | ||
OrganizationController:: |
public | function | ||
OrganizationController:: |
public | function | ||
OrganizationController:: |
public | function | ||
OrganizationController:: |
public | function | OrganizationController constructor. |