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

@param User $from
@param User $to

@return int
487228
public function replaceCategoryManager(User $from, User $to)
    {
        $categories = $this->categoryRepo->findAllCategoriesByManager($from);

        if (count($categories) > 0) {
            foreach ($categories as $category) {
                $category->removeManager($from);
                $category->addManager($to);
            }

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

        return count($categories);
    }
37580
public function translate(string $from, string $to) : Text
    {
        return $this->pipe(
            function (string $value) use ($from, $to) : string {
                return strtr($value, $from, $to);
            }
        );
    }
1143789
public function replaceEntryUser(User $from, User $to)
    {
        $entries = $this->entryRepo->findByUser($from);

        if (count($entries) > 0) {
            foreach ($entries as $entry) {
                $entry->setUser($to);
            }

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

        return count($entries);
    }
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);
    }
564080
protected function status($from, $to)
    {
        $from = str_replace(base_path(), '', realpath($from));
        $to = str_replace(base_path(), '', realpath($to));
        $this->line("<info>Copied File</info> <comment>[{$from}]</comment> <info>To</info> <comment>[{$to}]</comment>");
    }
980839
public function replaceUser(User $from, User $to)
    {
        $contributions = $this->contributionRepository->findByContributor($from);

        if (count($contributions) > 0) {
            foreach ($contributions as $contribution) {
                $contribution->setContributor($to);
            }

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

        return count($contributions);
    }
862546
public function replaceCasUserUser(User $from, User $to)
    {
        $casUsers = $this->om->getRepository("Claroline\AuthenticationBundle\Entity\Cas\CasUser")->findByUser($from);

        if (count($casUsers) > 0) {
            foreach ($casUsers as $casUser) {
                $casUser->setUser($to);
            }

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

        return count($casUsers);
    }
667323
public function replacePostAuthor(User $from, User $to)
    {
        $posts = $this->repo->findByAuthor($from);

        if (count($posts) > 0) {
            foreach ($posts as $post) {
                $post->setAuthor($to);
            }

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

        return count($posts);
    }
571854
public function setFrom(\WobbleCode\UserBundle\Document\User $from)
    {
        $this->from = $from;
        return $this;
    }
681335
protected function publishItem($from, $to)
    {
        if ($this->files->isFile($from)) {
            return $this->publishFile($from, $to);
        } elseif ($this->files->isDirectory($from)) {
            return $this->publishDirectory($from, $to);
        }

        $this->error("Can't locate path: <{$from}>");
    }
359003
protected function replace($from, $to)
    {
        if ($this->file->getExtension() === 'json') {
            $from = addslashes($from);
        }

        file_put_contents(
            $this->file->getRealPath(),
            str_replace($from, $to, $this->file->getContents())
        );
    }
80929
function copyAsUser($from, $to)
    {
        copy($from, $to);

        $this->chown($to, user());
    }
857617
static function str_replace_first($from, $to, $content)
    {
        $from = '/'.preg_quote($from, '/').'/';
        return preg_replace($from, $to, $content, 1);
    }
992026
public function move($from, $to)
    {
        return $this->filesystem->move(
            $this->path($from),
            $this->path($to)
        );
    }
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);
    }
222267
public static function replaceString($from, $to, $subject, $limit = 100000)
    {
        $from = '/' . preg_quote($from, '/') . '/';
        return preg_replace($from, $to, $subject, $limit);
    }
562459
public function replaceUser(User $from, User $to)
    {
        $portfolioUsers = $this->repo->findByUser($from);

        if (count($portfolioUsers) > 0) {
            foreach ($portfolioUsers as $portfolioUser) {
                $portfolioUser->setUser($to);
            }

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

        return count($portfolioUsers);
    }