WorkspaceReferenceItem.php in Multiversion 8
File
src/Plugin/Field/FieldType/WorkspaceReferenceItem.php
View source
<?php
namespace Drupal\multiversion\Plugin\Field\FieldType;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
class WorkspaceReferenceItem extends EntityReferenceItem {
public function applyDefaultValue($notify = TRUE) {
$workspace = \Drupal::service('workspace.manager')
->getActiveWorkspace();
$this
->setValue([
'target_id' => $workspace
->id(),
], $notify);
return $this;
}
}
Classes
Name |
Description |
WorkspaceReferenceItem |
Plugin annotation
@FieldType(
id = "workspace_reference",
label = @Translation("Workspace reference"),
description = @Translation("This field stores a reference to the workspace the entity belongs to."),
no_ui = TRUE
) |