class DeveloperApp in Apigee Edge 8
Defines the Developer app entity class.
@\Drupal\apigee_edge\Annotation\EdgeEntityType( id = "developer_app", label =
Plugin annotation
@Translation("Developer App"),
label_collection = @Translation("Developer Apps"),
label_singular = @Translation("developer app"),
label_plural = @Translation("developer apps"),
label_count = @PluralTranslation(
singular = "@count developer app",
plural = "@count developer apps",
),
config_with_labels = "apigee_edge.developer_app_settings",
handlers = {
"storage" = "Drupal\apigee_edge\Entity\Storage\DeveloperAppStorage",
"access" = "Drupal\apigee_edge\Entity\EdgeEntityAccessControlHandler",
"permission_provider" = "Drupal\apigee_edge\Entity\DeveloperAppPermissionProvider",
"form" = {
"default" = "Drupal\apigee_edge\Entity\Form\DeveloperAppCreateForm",
"add" = "Drupal\apigee_edge\Entity\Form\DeveloperAppCreateForm",
"add_for_developer" = "Drupal\apigee_edge\Entity\Form\DeveloperAppCreateFormForDeveloper",
"edit" = "Drupal\apigee_edge\Entity\Form\DeveloperAppEditForm",
"edit_for_developer" = "Drupal\apigee_edge\Entity\Form\DeveloperAppEditFormForDeveloper",
"delete" = "Drupal\apigee_edge\Entity\Form\AppDeleteForm",
"delete_for_developer" = "Drupal\apigee_edge\Entity\Form\DeveloperAppDeleteFormForDeveloper",
"analytics" = "Drupal\apigee_edge\Form\DeveloperAppAnalyticsForm",
"analytics_for_developer" = "Drupal\apigee_edge\Form\DeveloperAppAnalyticsFormForDeveloper",
"add_api_key" = "Drupal\apigee_edge\Form\DeveloperAppApiKeyAddForm",
"delete_api_key" = "Drupal\apigee_edge\Form\DeveloperAppApiKeyDeleteForm",
"revoke_api_key" = "Drupal\apigee_edge\Form\DeveloperAppApiKeyRevokeForm",
},
"list_builder" = "Drupal\apigee_edge\Entity\ListBuilder\AppListBuilder",
"view_builder" = "Drupal\apigee_edge\Entity\AppViewBuilder",
"route_provider" = {
"html" = "Drupal\apigee_edge\Entity\DeveloperAppRouteProvider",
},
},
links = {
"canonical" = "/developer-apps/{developer_app}",
"collection" = "/developer-apps",
"add-form" = "/developer-apps/add",
"edit-form" = "/developer-apps/{developer_app}/edit",
"delete-form" = "/developer-apps/{developer_app}/delete",
"analytics" = "/developer-apps/{developer_app}/analytics",
"canonical-by-developer" = "/user/{user}/apps/{app}",
"collection-by-developer" = "/user/{user}/apps",
"add-form-for-developer" = "/user/{user}/create-app",
"edit-form-for-developer" = "/user/{user}/apps/{app}/edit",
"delete-form-for-developer" = "/user/{user}/apps/{app}/delete",
"analytics-for-developer" = "/user/{user}/apps/{app}/analytics",
"api-keys" = "/user/{user}/apps/{app}/api-keys",
"add-api-key-form" = "/user/{user}/apps/{app}/api-keys/add",
"delete-api-key-form" = "/user/{user}/apps/{app}/api-keys/{consumer_key}/delete",
"revoke-api-key-form" = "/user/{user}/apps/{app}/api-keys/{consumer_key}/revoke",
},
entity_keys = {
"id" = "appId",
},
query_class = "Drupal\apigee_edge\Entity\Query\DeveloperAppQuery",
admin_permission = "administer developer_app",
field_ui_base_route = "apigee_edge.settings.developer_app",
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\apigee_edge\Entity\EdgeEntityBase implements EdgeEntityInterface
- class \Drupal\apigee_edge\Entity\FieldableEdgeEntityBase implements FieldableEdgeEntityInterface uses RevisioningWorkaroundTrait
- class \Drupal\apigee_edge\Entity\AttributesAwareFieldableEdgeEntityBase implements AttributesAwareFieldableEdgeEntityBaseInterface
- class \Drupal\apigee_edge\Entity\App implements AppInterface
- class \Drupal\apigee_edge\Entity\DeveloperApp implements DeveloperAppInterface
- class \Drupal\apigee_edge\Entity\App implements AppInterface
- class \Drupal\apigee_edge\Entity\AttributesAwareFieldableEdgeEntityBase implements AttributesAwareFieldableEdgeEntityBaseInterface
- class \Drupal\apigee_edge\Entity\FieldableEdgeEntityBase implements FieldableEdgeEntityInterface uses RevisioningWorkaroundTrait
- class \Drupal\apigee_edge\Entity\EdgeEntityBase implements EdgeEntityInterface
Expanded class hierarchy of DeveloperApp
16 files declare their use of DeveloperApp
- ApigeeEdgeFunctionalTestTrait.php in tests/
src/ Traits/ ApigeeEdgeFunctionalTestTrait.php - ApigeeMockApiClientHelperTrait.php in tests/
modules/ apigee_mock_api_client/ tests/ src/ Traits/ ApigeeMockApiClientHelperTrait.php - ApiProductAccessTest.php in tests/
src/ FunctionalJavascript/ ApiProductAccessTest.php - AppListBuilderTest.php in tests/
src/ Kernel/ Entity/ ListBuilder/ AppListBuilderTest.php - AppWarningsCheckerTest.php in tests/
src/ Kernel/ Entity/ AppWarningsCheckerTest.php
File
- src/
Entity/ DeveloperApp.php, line 94
Namespace
Drupal\apigee_edge\EntityView source
class DeveloperApp extends App implements DeveloperAppInterface {
/**
* The cached Drupal UID.
*
* Use getOwnerId() to return the correct value.
*
* @var null|int
*/
protected $drupalUserId;
/**
* The decorated developer app entity from the SDK.
*
* @var \Apigee\Edge\Api\Management\Entity\DeveloperApp
*/
protected $decorated;
/**
* DeveloperApp constructor.
*
* @param array $values
* An array of values to set, keyed by property name.
* @param null|string $entity_type
* Type of the entity. It is optional because constructor sets its default
* value.
* @param \Apigee\Edge\Entity\EntityInterface|null $decorated
* The SDK entity that this Drupal entity decorates.
*/
public function __construct(array $values, ?string $entity_type = NULL, ?EdgeEntityInterface $decorated = NULL) {
// Little help to make it easier to initialize a new developer app object
// with a property configured developerId which is required in app
// creation.
// @see DeveloperAppEntityControllerProxy::create()
if (isset($values['drupalUserId'])) {
$this
->setOwnerId($values['drupalUserId']);
}
/** @var \Apigee\Edge\Api\Management\Entity\DeveloperAppInterface $decorated */
$entity_type = $entity_type ?? 'developer_app';
parent::__construct($values, $entity_type, $decorated);
}
/**
* We have to override this.
*
* This is how we could make it compatible with the SDK's
* entity interface that has return type hint.
*/
public function id() : ?string {
return parent::id();
}
/**
* {@inheritdoc}
*/
public function getOwner() {
$owner_id = $this
->getOwnerId();
return $owner_id === NULL ? NULL : User::load($owner_id);
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this
->setOwnerId($account
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
if ($this->drupalUserId === NULL) {
if ($this
->getDeveloperId()) {
$developer = Developer::load($this
->getDeveloperId());
if ($developer) {
/** @var \Drupal\user\UserInterface $account */
$account = user_load_by_mail($developer
->getEmail());
if ($account) {
$this->drupalUserId = $account
->id();
}
}
}
}
return $this->drupalUserId;
}
/**
* Sets the entity owner's user ID.
*
* @param int $uid
* The owner user id.
*
* @return $this
*/
public function setOwnerId($uid) {
$this->drupalUserId = $uid;
$user = User::load($uid);
if ($user) {
$developer = Developer::load($user
->getEmail());
if ($developer) {
$this->decorated
->setDeveloperId($developer
->uuid());
}
else {
// Sanity check, probably someone called this method with invalid data.
throw new InvalidArgumentException("Developer with {$user->getEmail()} email does not exist on Apigee Edge.");
}
}
else {
// Sanity check, probably someone called this method with invalid data.
throw new InvalidArgumentException("User with {$uid} id does not exist.");
}
return $this;
}
/**
* {@inheritdoc}
*/
protected static function decoratedClass() : string {
return EdgeDeveloperApp::class;
}
/**
* {@inheritdoc}
*/
public static function idProperty() : string {
return EdgeDeveloperApp::idProperty();
}
/**
* {@inheritdoc}
*/
public function getAppOwner() : ?string {
return $this
->getDeveloperId();
}
/**
* {@inheritdoc}
*/
public function setAppOwner(string $owner) : void {
$this->decorated
->setDeveloperId($owner);
}
/**
* {@inheritdoc}
*/
public function getDeveloperId() : ?string {
return $this->decorated
->getDeveloperId();
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $definitions */
$definitions = parent::baseFieldDefinitions($entity_type);
$developer_app_singular_label = \Drupal::entityTypeManager()
->getDefinition('developer_app')
->getSingularLabel();
$developer_app_singular_label = mb_convert_case($developer_app_singular_label, MB_CASE_TITLE);
$definitions['displayName']
->setLabel(t('@developer_app name', [
'@developer_app' => $developer_app_singular_label,
]));
$definitions['status']
->setLabel(t('@developer_app status', [
'@developer_app' => $developer_app_singular_label,
]));
$developer_app_settings = \Drupal::config('apigee_edge.developer_app_settings');
foreach ((array) $developer_app_settings
->get('required_base_fields') as $required) {
$definitions[$required]
->setRequired(TRUE);
}
// Hide readonly properties from Manage form display list.
$definitions['developerId']
->setDisplayConfigurable('form', FALSE);
return $definitions;
}
/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel) {
$params = parent::urlRouteParameters($rel);
$link_templates = $this
->linkTemplates();
if (isset($link_templates[$rel])) {
if (strpos($link_templates[$rel], '{user}') !== FALSE) {
$params['user'] = $this
->getOwnerId();
}
if (strpos($link_templates[$rel], '{app}') !== FALSE) {
$params['app'] = $this
->getName();
}
if (strpos($link_templates[$rel], '{developer_app}') === FALSE) {
unset($params['developer_app']);
}
}
return $params;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
App:: |
public | function | ||
App:: |
protected | function |
Return the entity id used in Drupal. Overrides EdgeEntityBase:: |
|
App:: |
public | function |
Gets a field item list. Overrides AttributesAwareFieldableEdgeEntityBase:: |
|
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function |
Gets the label of the entity. Overrides EdgeEntityBase:: |
|
App:: |
protected static | function |
Array of properties that should not be exposed as base fields by default. Overrides FieldableEdgeEntityBase:: |
|
App:: |
protected static | function |
Static mapping between entity properties and Drupal field types. Overrides FieldableEdgeEntityBase:: |
|
App:: |
public | function |
Sets a field value. Overrides FieldableEdgeEntityBase:: |
|
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | Make sure that credentials never gets cached. | |
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public | function | ||
App:: |
public static | function |
Returns all unique ids how an entity can be referenced in Apigee Edge. Overrides EdgeEntityBase:: |
|
App:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: |
|
AttributesAwareFieldableEdgeEntityBase:: |
protected | function | Returns the field-attribute converter service. | |
AttributesAwareFieldableEdgeEntityBase:: |
private | function | Sets attribute value from a field. | |
AttributesAwareFieldableEdgeEntityBase:: |
public | function |
Updates the property value on an entity by field name. Overrides FieldableEdgeEntityBase:: |
|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
DeveloperApp:: |
protected | property |
The decorated developer app entity from the SDK. Overrides App:: |
|
DeveloperApp:: |
protected | property | The cached Drupal UID. | |
DeveloperApp:: |
public static | function |
Provides base field definitions for an entity type. Overrides App:: |
1 |
DeveloperApp:: |
protected static | function |
The FQCN of the decorated class from the PHP API Client. Overrides EdgeEntityBase:: |
|
DeveloperApp:: |
public | function |
Returns the id of the app owner from the app entity. Overrides AppInterface:: |
|
DeveloperApp:: |
public | function | ||
DeveloperApp:: |
public | function |
Returns the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
DeveloperApp:: |
public | function |
Returns the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
DeveloperApp:: |
public | function |
We have to override this. Overrides EdgeEntityBase:: |
|
DeveloperApp:: |
public static | function | ||
DeveloperApp:: |
public | function |
Sets the app owner's property value on an app. Overrides AppInterface:: |
|
DeveloperApp:: |
public | function |
Sets the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
DeveloperApp:: |
public | function |
Sets the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
DeveloperApp:: |
protected | function |
Gets an array of placeholders for this entity. Overrides EntityBase:: |
|
DeveloperApp:: |
public | function |
DeveloperApp constructor. Overrides App:: |
|
EdgeEntityBase:: |
public static | function |
Creates a Drupal entity from an SDK Entity. Overrides EdgeEntityInterface:: |
|
EdgeEntityBase:: |
public | function |
Returns the decorated SDK entity. Overrides EdgeEntityInterface:: |
2 |
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function |
List of unique ids how an entity can be referenced in Apigee Edge. Overrides EdgeEntityInterface:: |
|
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public | function |
Checks data value access. Overrides AccessibleInterface:: |
1 |
EntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
protected static | function | Invalidates an entity's cache tags upon delete. | 1 |
EntityBase:: |
protected | function | Invalidates an entity's cache tags upon save. | 1 |
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface:: |
16 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityInterface:: |
3 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
FieldableEdgeEntityBase:: |
protected | property | Local cache for field definitions. | |
FieldableEdgeEntityBase:: |
protected | property | Local cache for for fields. | |
FieldableEdgeEntityBase:: |
protected | property | Whether entity validation was performed. | |
FieldableEdgeEntityBase:: |
protected | property | Whether entity validation is required before saving the entity. | |
FieldableEdgeEntityBase:: |
public static | function |
Provides field definitions for a specific bundle. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
protected | function | Converts a field value to a property value. | |
FieldableEdgeEntityBase:: |
private static | function | Returns whether an entity property is blacklisted to be exposed as field. | |
FieldableEdgeEntityBase:: |
protected static | function | Attempts to create a base field definition from a type. | |
FieldableEdgeEntityBase:: |
public | function |
Gets the definition of a contained field. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Gets an array of all field item lists. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
protected | function | Returns the field value from the current object. | |
FieldableEdgeEntityBase:: |
public | function | ||
FieldableEdgeEntityBase:: |
protected static | function | Parses the properties and its types from the parent class. | |
FieldableEdgeEntityBase:: |
public | function |
Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Reacts to changes to a field. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: |
|
FieldableEdgeEntityBase:: |
private static | function | Returns the type of the field that should represent an entity property. | |
FieldableEdgeEntityBase:: |
public | function |
Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
|
FieldableEdgeEntityBase:: |
public | function |
Validates the currently set values. Overrides FieldableEntityInterface:: |
|
FieldableEdgeEntityBase:: |
public | function |
Overrides EntityBase:: |
|
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function | ||
RevisioningWorkaroundTrait:: |
public | function |