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


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