Resolve a `<a...>...</a>` tag from a user entity (or null)
If null is passed, we return a placeholder that makes it clear the user has been deleted

@param \Concrete\Core\Entity\User\User|null $user

@return string
330996
protected function getUserLink(User $user = null)
    {
        if (!$user) {
            return '<strong>' . t('Deleted User') . '</strong>';
        }

        $link = $this->getUrlResolver()->resolve(['/dashboard/users/search', $user->getUserID()]);
        $name = h($user->getUserName());
        return "<a href='$link'><strong>$name</strong></a>";
    }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
476560
public function create(User $user)
    {
        /* handle encode */
        $user = $this->encode($user);

        $this->getEm()->persist($user);
        $this->getEm()->flush();

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

            return;
        }

        if ($this->_user === false) {
            if (($session = $this->getSession()) && $session->id) {
                $this->_user = auth()->who($session);
            } else {
                $this->_user = null;
            }
        }

        return $this->_user;
    }
619191
public static function last($user = null)
    {
        if (!User::isValid($user)) {
            throw new InvalidParamException('User Invalid.');
        }
        return static::find()->createdBy($user)->orderByCreatedAt(SORT_DESC)->one();
    }
202372
protected function _getCurrentUser($user = null)
    {
        $this->_setCurrentUser($user);

        if (!$this->_currentUserInstance &&
            isset($this->_currentUserViewVar) &&
            !empty($this->viewVars[$this->_currentUserViewVar])
        ) {
            $this->_currentUserInstance = $this->viewVars[$this->_currentUserViewVar];
        }

        return $this->_currentUserInstance;
    }
456597
public function setUser($user)
    {

        // Clear cache
        $this->user = null;

        // Find element
        if (!$user = $this->findUserElement($user)) {
            // Clear property / cache
            $this->userId = $this->user = null;
        } else {
            // Set property
            $this->userId = $user->getId();

            // Set cache
            $this->user = $user;
        }

        return $this;
    }
879088
public function getUserEndorsement($user) {
        return $this->endorsements->filter(function($e) use ($user) {
                    return $e->getUser() == $user;
                })->first();
    }
701028
public function removeUser(User $user)
    {
        if ($this->users->contains($user)) {
            $this->users->removeElement($user);
        }

        return $this;
    }
843976
public function prune($user = null)
    {
        if ($user) {
            $this->addUsingAlias(UserPeer::ID, $user->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }
912596
protected static function filterUser($user)
    {
        if ($user !== null && ! is_string($user)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid user-info; user must be a string argument; received %s',
                (is_object($user) ? get_class($user) : gettype($user))
            ));
        }

        return $user;
    }
427745
public function getUser($user)
    {
        $params = [
            'name' => $user,
        ];

        $body = $this->request(self::URI_AUTH_USER_GET, $params);
        if ($this->pretty && isset($body['roles'])) {
            return $body['roles'];
        }

        return $body;
    }
691440
public function detachMember(User $user,
        /** @noinspection PhpUnusedParameterInspection */
                                   MemberTag $memberTag,
                                   $memberId)
    {
        return $user->selected_context->id === $memberId;
    }
375885
private function resolvePull($user, $repo, $reference)
    {
        if (!$pull = $this->parseRefAsPull($reference)) {
            return null;
        }

        $api = $this->client->api('pull_request');
        $params = [$user, $repo, $pull];

        $data = $this->callGitHub([$api, 'show'], $params);
        return $data['head']['sha'] ?? null;
    }
99982
public function getSession(UserInterface $user = null)
    {
        $repository = $this->get('symcloud_storage.session_repository');

        return $repository->loginByName($user ?: $this->getUser(), 'HEAD');
    }
1173382
public function persistUser(User $user)
    {
        $this->objectManager->persist($user);
        $this->objectManager->flush();

        return $user;
    }
754150
public function deleted(User $user)
    {
        \DB::table((new Revision())->getTable())->insert([
            [
                'revisionable_type' => $user->getMorphClass(),
                'revisionable_id' => $user->id,
                'key' => 'deleted_at',
                'old_value' => $user,
                'new_value' => new \DateTime(),
                'user_id' => (\Auth::check() ? \Auth::user()->id : null),
                'created_at' => new \DateTime(),
                'updated_at' => new \DateTime(),
            ]
        ]);
    }