X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fworkspaces%2Fsrc%2FEntityTypeInfo.php;fp=web%2Fcore%2Fmodules%2Fworkspaces%2Fsrc%2FEntityTypeInfo.php;h=3b91f84e519ef75a99c4462b7cfca51a7dd16a48;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/workspaces/src/EntityTypeInfo.php b/web/core/modules/workspaces/src/EntityTypeInfo.php new file mode 100644 index 000000000..3b91f84e5 --- /dev/null +++ b/web/core/modules/workspaces/src/EntityTypeInfo.php @@ -0,0 +1,73 @@ +entityTypeManager = $entity_type_manager; + $this->workspaceManager = $workspace_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity_type.manager'), + $container->get('workspaces.manager') + ); + } + + /** + * Adds the "EntityWorkspaceConflict" constraint to eligible entity types. + * + * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types + * An associative array of all entity type definitions, keyed by the entity + * type name. Passed by reference. + * + * @see hook_entity_type_build() + */ + public function entityTypeBuild(array &$entity_types) { + foreach ($entity_types as $entity_type) { + if ($this->workspaceManager->isEntityTypeSupported($entity_type)) { + $entity_type->addConstraint('EntityWorkspaceConflict'); + } + } + } + +}