cc-1.0.x-dev/modules/cc_account/src/Entity/CcAccountType.php
modules/cc_account/src/Entity/CcAccountType.php
<?php
namespace Drupal\cc_account\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\EntityStorageInterface;
/**
* Defines the cryptocurrency account type configuration entity.
*
* @ConfigEntityType(
* id = "cc_account_type",
* label = @Translation("Cryptocurrency account type"),
* label_collection = @Translation("Cryptocurrency account types"),
* label_singular = @Translation("cryptocurrency account type"),
* label_plural = @Translation("cryptocurrency account types"),
* label_count = @PluralTranslation(
* singular = "@count cryptocurrency account type",
* plural = "@count cryptocurrency account types",
* ),
* handlers = {
* "list_builder" = "Drupal\cc_account\CcAccountTypeListBuilder",
* "form" = {
* "add" = "Drupal\cc_account\Form\CcAccountTypeForm",
* "edit" = "Drupal\cc_account\Form\CcAccountTypeForm",
* "delete" = "Drupal\Core\Entity\EntityDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
* },
* "access" = "Drupal\cc_account\Access\CcAccountTypeAccessControlHandler",
* },
* admin_permission = "administer cc account types",
* bundle_of = "cc_account",
* config_prefix = "type",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid",
* },
* links = {
* "add-form" = "/admin/structure/account-types/add",
* "edit-form" = "/admin/structure/account-types/{cc_account_type}/edit",
* "delete-form" = "/admin/structure/account-types/{cc_account_type}/delete",
* "collection" = "/admin/structure/account-types"
* },
* config_export = {
* "id",
* "label",
* "description",
* },
* )
*/
class CcAccountType extends ConfigEntityBundleBase implements CcAccountTypeInterface {
/**
* The machine name of this cryptocurrency account type.
*
* @var string
*/
protected $id;
/**
* The human-readable name of the cryptocurrency account type.
*
* @var string
*/
protected $label;
/**
* A brief description of the cryptocurrency account type.
*
* @var string
*/
protected $description;
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if (!$update) {
// Clear the account type cache to reflect the new account type.
\Drupal::service('entity_type.bundle.info')->clearCachedBundles();
}
}
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Clear the account type cache to reflect the account type removal.
\Drupal::service('entity_type.bundle.info')->clearCachedBundles();
}
}
