3 namespace Drupal\pathauto;
5 use Drupal\Core\Field\FieldStorageDefinitionInterface;
6 use Drupal\Core\TypedData\DataDefinition;
7 use Drupal\path\Plugin\Field\FieldType\PathItem;
10 * Extends the default PathItem implementation to generate aliases.
12 class PathautoItem extends PathItem {
17 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
18 $properties = parent::propertyDefinitions($field_definition);
19 $properties['pathauto'] = DataDefinition::create('integer')
20 ->setLabel(t('Pathauto state'))
21 ->setDescription(t('Whether an automated alias should be created or not.'))
23 ->setClass('\Drupal\pathauto\PathautoState');
30 public function postSave($update) {
31 // Only allow the parent implementation to act if pathauto will not create
33 if ($this->pathauto == PathautoState::SKIP) {
34 parent::postSave($update);
36 $this->get('pathauto')->persist();
42 public function isEmpty() {
43 // Make sure that the pathauto state flag does not get lost if just that is
45 return !$this->alias && !$this->get('pathauto')->hasValue();