@param \eZ\Publish\API\Repository\Values\User\User|null $user

@return \EzSystems\EzPlatformAdminUi\UI\Dataset\ContentDraftsDataset
498720
public function load(User $user = null): self
    {
        try {
            $contentDrafts = $this->contentService->loadContentDrafts($user);
        } catch (UnauthorizedException $e) {
            // if user has no access content/versionread for one of versions, exception is caught and draft array is empty
            $contentDrafts = [];
        }

        $contentDrafts = array_filter($contentDrafts, function (VersionInfo $version) {
            // Filter out content that has been sent to trash
            return !$version->getContentInfo()->isTrashed();
        });

        $contentTypes = $contentTypeIds = [];
        foreach ($contentDrafts as $contentDraft) {
            $contentTypeIds[] = $contentDraft->getContentInfo()->contentTypeId;
        }

        if (!empty($contentTypeIds)) {
            $contentTypes = $this->contentTypeService->loadContentTypeList(array_unique($contentTypeIds));
        }

        // ContentService::loadContentDrafts returns unsorted list of VersionInfo.
        // Sort results by modification date, descending.
        usort($contentDrafts, function (VersionInfo $a, VersionInfo $b) {
            return $b->modificationDate <=> $a->modificationDate;
        });

        $this->data = array_map(
            function (VersionInfo $versionInfo) use ($contentTypes) {
                return $this->mapContentDraft(
                    $versionInfo,
                    $contentTypes[$versionInfo->getContentInfo()->contentTypeId]
                );
            },
            $contentDrafts
        );

        return $this;
    }
981613
public function prune($user = null)
    {
        if ($user) {
            $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }
624831
public function includeRoles(User $user)
    {
        $roles = $user->roles;
        return $this->collection($roles, new RoleTransformer());
    }
851114
public function roles(User $user)
    {
        if ($this->session->hasValue(Roles::SESSION_KEY)) {
            return $this->session->value(Roles::SESSION_KEY);
        }

        $roles = $this->authorizationProvider->roles($user);
        $this->session->putValue(Roles::SESSION_KEY, $roles);
        return $roles;
    }
1238953
private function getPermissionTable(User $user) {
		$userId = $user->getId();
		if ($this->permissionTable->has($userId)) {
			return $this->permissionTable->get($userId);
		}

		// always allow what guests can do
		$guestGroup = GroupQuery::create()->findOneByIsGuest(true);

		// collect groups from user
		$groups = GroupQuery::create()->filterByUser($user)->find();
		$userGroup = GroupQuery::create()->filterByOwnerId(($userId))->findOne();
		if ($userGroup) {
			$groups[] = $userGroup;
		}
		$groups[] = $guestGroup;

		// ... structure them
		$permissionTable = new Set();
		foreach ($groups as $group) {
			foreach ($group->getActions() as $action) {
				$permissionTable->add($action->getId());
			}
		}

		$this->permissionTable->set($userId, $permissionTable);

		return $this->permissionTable->get($userId);
	}
410191
public function setUser(\Haven\SecurityBundle\Entity\User $user = null) {
        $this->user = $user;

        return $this;
    }
36864
public function findWorkspaceRootsByUser(User $user)
    {
        $builder = new ResourceQueryBuilder();
        $dql = $builder->selectAsArray()
            ->whereParentIsNull()
            ->whereInUserWorkspace($user)
            ->orderByPath()
            ->getDql();
        $query = $this->_em->createQuery($dql);
        $query->setParameters($builder->getParameters());

        return $this->executeQuery($query);
    }
98571
protected function createResourceFromUser(UserEntity $user)
    {
        $resource = new Resource(
            $this->generateReadUrl($user->getUsernameCanonical()),
            array(
                 'username'   => $user->getUsernameCanonical(),
                 'email'      => $user->getEmail(),
                 'last_login' => $user->getLastLogin() ? $user->getLastLogin()->format('c') : null,
            )
        );

        return $resource;
    }
436880
private function serializePicture(User $user)
    {
        if (!empty($user->getPicture())) {
            /** @var PublicFile $file */
            $file = $this->om
                ->getRepository(PublicFile::class)
                ->findOneBy(['url' => $user->getPicture()]);

            if ($file) {
                return $this->fileSerializer->serialize($file);
            }
        }

        return null;
    }
914801
public function user($user = null)
    {
        if ($user !== null) {
            $this->user = $user;
        }

        return $this->user;
    }
536352
public static function getUserAwareChoiceBuilder(FormBuilderInterface $builder, UserInterface $user = null)
    {
        return function (EntityRepository $objectRepository) use ($builder, $user) {
            return $objectRepository->createQueryBuilder('o')
                ->andWhere('o.user = :user')
                ->setParameter('user', $user ?: $builder->getAttribute('user_aware'))
            ;
        };
    }
518246
public function generateAvatar(User $user)
    {
        if ($user->getAvatar()) {
            return $this->uploadDir['web_path'].$user->getAvatar();
        } else {
            return $this->container->getParameter('symfonyid.admin.user.default_avatar');
        }
    }
154105
public function setUser($user)
    {
        $this->removeTarget();

        if ($user) {
            $this->user = (string) $user;
        }

        return $this;
    }
1271813
protected function loadUserThrottles(UserInterface $user)
    {
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
        $queryBuilder
            ->select('t')
            ->from($this->entityName('user'), 't')
            ->where('t.createdAt > :interval')
            ->andWhere('t.user = :user')
            ->setParameters([
                'interval' => Carbon::now()->subSeconds($this->userInterval),
                'user'     => $user
            ]);

        return new Collection($queryBuilder->getQuery()->getResult());
    }
655277
protected function getUserName(User $user): string
    {
        $contentInfo = $this->repository->sudo(
            function (Repository $repository) use ($user): ContentInfo {
                return $this->loadService->loadContent($user->id)->contentInfo;
            }
        );

        return $contentInfo->name;
    }
392209
public function getWorkspaceIdentifier(User $user = null)
    {
        return md5($user ? $user->id : Auth::id());
    }
361846
public function getSettingsByUser($user)
    {
        $userId = $user;
        $userEntity = null;
        if ($user instanceof EntityInterface) {
            $userId = $user->getId();
            $userEntity = $user;
        }
        if (isset($this->settingsByUser[$userId])) {
            return $this->settingsByUser[$user];
        }
        if (empty($userEntity)) {
            $UserRepository = $this->getUserRepository();
            $userEntity = $UserRepository->find($userId);
        }
        
        if (isset($userEntity)) {
            $settingsData = $userEntity->getSettings();
            $this->settingsByUser[$userId] = new SettingsEntity($this);
            $this->settingsByUser[$userId]->setData($settingsData)->spawnAsEntities();
            return $this->settingsByUser[$userId];
        }
        return null;
    }