class WorkspacesEntityRepository

Provides workspace-specific mechanisms for retrieving entities.

Hierarchy

Expanded class hierarchy of WorkspacesEntityRepository

1 string reference to 'WorkspacesEntityRepository'
workspaces.services.yml in core/modules/workspaces/workspaces.services.yml
core/modules/workspaces/workspaces.services.yml
1 service uses WorkspacesEntityRepository
workspaces.entity.repository in core/modules/workspaces/workspaces.services.yml
Drupal\workspaces\WorkspacesEntityRepository

File

core/modules/workspaces/src/WorkspacesEntityRepository.php, line 11

Namespace

Drupal\workspaces
View source
class WorkspacesEntityRepository implements EntityRepositoryInterface {
    public function __construct(EntityRepositoryInterface $inner, WorkspaceManagerInterface $workspaceManager) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function loadEntityByUuid($entity_type_id, $uuid) {
        return $this->inner
            ->loadEntityByUuid($entity_type_id, $uuid);
    }
    
    /**
     * {@inheritdoc}
     */
    public function loadEntityByConfigTarget($entity_type_id, $target) {
        return $this->inner
            ->loadEntityByConfigTarget($entity_type_id, $target);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
        return $this->inner
            ->getTranslationFromContext($entity, $langcode, $context);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getActive($entity_type_id, $entity_id, ?array $contexts = NULL) {
        // When there's no active workspace, the active entity variant is the
        // canonical one.
        if (!$this->workspaceManager
            ->hasActiveWorkspace()) {
            return $this->inner
                ->getCanonical($entity_type_id, $entity_id, $contexts);
        }
        return $this->inner
            ->getActive($entity_type_id, $entity_id, $contexts);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getActiveMultiple($entity_type_id, array $entity_ids, ?array $contexts = NULL) {
        // When there's no active workspace, the active entity variant is the
        // canonical one.
        if (!$this->workspaceManager
            ->hasActiveWorkspace()) {
            return $this->inner
                ->getCanonicalMultiple($entity_type_id, $entity_ids, $contexts);
        }
        return $this->inner
            ->getActiveMultiple($entity_type_id, $entity_ids, $contexts);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCanonical($entity_type_id, $entity_id, ?array $contexts = NULL) {
        return $this->inner
            ->getCanonical($entity_type_id, $entity_id, $contexts);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCanonicalMultiple($entity_type_id, array $entity_ids, ?array $contexts = NULL) {
        return $this->inner
            ->getCanonicalMultiple($entity_type_id, $entity_ids, $contexts);
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title
EntityRepositoryInterface::CONTEXT_ID_LEGACY_CONTEXT_OPERATION Deprecated constant
WorkspacesEntityRepository::getActive public function Retrieves the active entity variant matching the specified context. Overrides EntityRepositoryInterface::getActive
WorkspacesEntityRepository::getActiveMultiple public function Retrieves the active entity variants matching the specified context. Overrides EntityRepositoryInterface::getActiveMultiple
WorkspacesEntityRepository::getCanonical public function Retrieves the canonical entity variant matching the specified context. Overrides EntityRepositoryInterface::getCanonical
WorkspacesEntityRepository::getCanonicalMultiple public function Retrieves the canonical entity variants matching the specified context. Overrides EntityRepositoryInterface::getCanonicalMultiple
WorkspacesEntityRepository::getTranslationFromContext public function Gets the entity translation to be used in the given context. Overrides EntityRepositoryInterface::getTranslationFromContext
WorkspacesEntityRepository::loadEntityByConfigTarget public function Loads an entity by the config target identifier. Overrides EntityRepositoryInterface::loadEntityByConfigTarget
WorkspacesEntityRepository::loadEntityByUuid public function Loads an entity by UUID. Overrides EntityRepositoryInterface::loadEntityByUuid
WorkspacesEntityRepository::__construct public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.