Find all content for a given user and replace him by another.

@param User $from
@param User $to

@return int
430972
public function replaceManager(User $from, User $to)
    {
        $teams = $this->teamRepo->findByTeamManager($from);

        if (count($teams) > 0) {
            foreach ($teams as $team) {
                $team->setTeamManager($to);
            }

            $this->om->flush();
        }

        return count($teams);
    }
357201
public function replaceEntryUserUser(User $from, User $to)
    {
        $entryUsers = $this->entryUserRepo->findByUser($from);

        if (count($entryUsers) > 0) {
            foreach ($entryUsers as $entryUser) {
                $entryUser->setUser($to);
            }

            $this->om->flush();
        }

        return count($entryUsers);
    }
780934
public static function createFrom(self $from, $to = null)
    {
        $request = $to ?: new static;

        $files = $from->files->all();

        $files = is_array($files) ? array_filter($files) : $files;

        $request->initialize(
            $from->query->all(),
            $from->request->all(),
            $from->attributes->all(),
            $from->cookies->all(),
            $files,
            $from->server->all(),
            $from->getContent()
        );

        $request->headers->replace($from->headers->all());

        $request->setJson($from->json());

        if ($session = $from->getSession()) {
            $request->setLaravelSession($session);
        }

        $request->setUserResolver($from->getUserResolver());

        $request->setRouteResolver($from->getRouteResolver());

        return $request;
    }
1267243
public function getLikeCountByDate($from, $to = null): int
    {
        return Like::countByDate($this, $from, $to);
    }
581690
public static function rename($from, $to)
    {
        $object = get_class(self::$driver);

        return $object::rename($from, $to);
    }
300067
public function replaceUser(User $from, User $to)
    {
        $ldapUsers = $this->messageRepo->findByUser($from);

        if (count($ldapUsers) > 0) {
            foreach ($ldapUsers as $ldapUser) {
                $ldapUser->setUser($to);
            }

            $this->om->flush();
        }

        return count($ldapUsers);
    }
869054
public function replaceUser(User $from, User $to)
    {
        $papers = $this->repository->findBy(['user' => $from]);

        if (count($papers) > 0) {
            foreach ($papers as $paper) {
                $paper->setUser($to);
            }

            $this->om->flush();
        }

        return count($papers);
    }
297928
public function relPath($from,$to) {
		$expFrom = explode('/',$from);
		$expTo = explode('/',$to);
		$max=max(count($expFrom),count($expTo));
		$rel = [];
		$base=TRUE;
		for ($i=0;$i<$max;$i++) {
			if ($base && isset($expTo[$i]) && isset($expFrom[$i])
				&& $expTo[$i] === $expFrom[$i])
				continue;
			else
				$base=FALSE;
			if (!empty($expFrom[$i]))
				array_unshift($rel,'..');
			if (!empty($expTo[$i]))
				array_push($rel,$expTo[$i]);
		}
		return implode('/',$rel);
	}
290468
public function getPartialSum( $from, $to )
	{
		for( $i=$from; $i<=$to; $i++ )
			$sum += $this->getValue( $i );
		return $sum;
	}
1144101
public function replaceUser(User $from, User $to)
    {
        $items = $this->repository->findBy(['creator' => $from]);

        if (count($items) > 0) {
            foreach ($items as $item) {
                $item->setCreator($to);
            }

            $this->om->flush();
        }

        return count($items);
    }
689563
public function replaceUser(User $from, User $to)
    {
        $notificationUserParameters = $this->notificationUserParametersRepository->findByUser($from);

        if (count($notificationUserParameters) > 0) {
            foreach ($notificationUserParameters as $notificationUserParameter) {
                $notificationUserParameter->setUser($to);
            }

            $this->em->flush();
        }

        return count($notificationUserParameters);
    }
222267
public static function replaceString($from, $to, $subject, $limit = 100000)
    {
        $from = '/' . preg_quote($from, '/') . '/';
        return preg_replace($from, $to, $subject, $limit);
    }
166628
public function ipInRange($ip, $from, $to)
    {
        $ip = $this->getIpNumberFromAddress($ip);
        $from = $this->getIpNumberFromAddress($from);
        $to = $this->getIpNumberFromAddress($to);

        return (!$ip || !$from || !$to) ? false : ($ip <= $to && $from <= $ip);
    }
151768
public function humanizedChanges($from, $to)
    {
        if (!$from) {
            return _t('SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.UPLOADEDFILE', "Uploaded file");
        }

        $fromRecord = Versioned::get_version(get_class($this->owner), $this->owner->ID, $from);
        $toRecord = Versioned::get_version(get_class($this->owner), $this->owner->ID, $to);

        $diff = new DataDifferencer($fromRecord, $toRecord);
        $changes = $diff->changedFieldNames();

        $k = array_search('LastEdited', $changes);

        if ($k !== false) {
            unset($changes[$k]);
        }

        $output = array();

        foreach ($changes as $change) {
            $human = $change;

            if ($change == "ParentID") {
                // updated folder ID
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.MOVEDFOLDER',
                    "Moved file"
                );
            } elseif ($change == 'Title') {
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDTITLE',
                    "Updated title to "
                ) . $fromRecord->Title;
            } elseif ($change == 'Name') {
                $human = _t(
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDFILE',
                    "Renamed file to "
                ) . $fromRecord->Filename;
            } elseif ($change == 'File') {
                // check to make sure the files are actually different
                if ($fromRecord->getHash() != $toRecord->getHash()) {
                    $human = _t(
                        'SilverStripe\\AssetAdmin\\Controller\\AssetAdminFile.RENAMEDFILE',
                        "Replaced file"
                    );
                } else {
                    $human = false;
                }
            } else {
                $human = false;
            }

            if ($human) {
                $output[] = $human;
            }
        }

        return implode(", ", $output);
    }
141710
public function rename($from, $to)
    {
        if (is_null($key = $this->search($from))) {
            return false;
        }

        $this->items[$key] = $this->getSlugFromName($to);

        return true;
    }
504400
public function replaceAbilityProgressUser(User $from, User $to)
    {
        $abilityyProgresses = $this->abilityProgressRepo->findByUser($from);

        if (count($abilityyProgresses) > 0) {
            foreach ($abilityyProgresses as $abilityyProgress) {
                $abilityyProgress->setUser($to);
            }

            $this->om->flush();
        }

        return count($abilityyProgresses);
    }
565186
public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*'))
    {
        return $this->find($arg, $operator, $fields)->limit($from, $to);
    }