LicenseWithField.php in Commerce License 8.2
File
tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/LicenseWithField.php
View source
<?php
namespace Drupal\commerce_license_test\Plugin\Commerce\LicenseType;
use Drupal\entity\BundleFieldDefinition;
use Drupal\commerce_license\Entity\LicenseInterface;
class LicenseWithField extends TestLicenseBase {
public function grantLicense(LicenseInterface $license) {
$license
->set('test_field', 'granted');
}
public function revokeLicense(LicenseInterface $license) {
$license
->set('test_field', 'revoked');
}
public function buildFieldDefinitions() {
$fields = parent::buildFieldDefinitions();
$fields['test_field'] = BundleFieldDefinition::create('text')
->setLabel(t('Test field'))
->setDescription(t('A test field that this plugin will set values on.'))
->setCardinality(1);
return $fields;
}
}
Classes
Name |
Description |
LicenseWithField |
License type for testing a field can be set when granting and revoking. |