bundle/Command/SymlinkCommand.php
protected function verifyAndSymlinkFile(string $source, string $destination, OutputInterface $output): void
    {
        if (!$this->fileSystem->exists(dirname($destination))) {
            $this->fileSystem->mkdir(dirname($destination), 0755);
        }

        if ($this->fileSystem->exists($destination) && !is_file($destination)) {
            $output->writeln('<comment>' . basename($destination) . '</comment> already exists in <comment>' . dirname($destination) . '/</comment> and is not a file/symlink. Skipping...');

            return;
        }

        if ($this->forceSymlinks && is_link($destination)) {
            $this->fileSystem->remove($destination);
        }

        if (is_file($destination) && !is_link($destination)) {
            if ($this->fileSystem->exists($destination . '.original')) {
                $output->writeln('Cannot create backup file <comment>' . basename($destination) . '.original</comment> in <comment>' . dirname($destination) . '/</comment>. Skipping...');

                return;
            }

            $this->fileSystem->rename($destination, $destination . '.original');
        }

        if ($this->fileSystem->exists($destination)) {
            if (is_link($destination)) {
                $output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment>. Symlink already exists!');
            } else {
                $output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment> due to an unknown error.');
            }

            return;
        }

        $this->fileSystem->symlink(
            $this->fileSystem->makePathRelative(
                dirname($source),
                realpath(dirname($destination))
            ) . basename($source),
            $destination
        );
    }
protected function verifyAndSymlinkFile(string $source, string $destination, OutputInterface $output): void
    {
        if (!$this->fileSystem->exists(dirname($destination))) {
            $this->fileSystem->mkdir(dirname($destination), 0755);
        }

        if ($this->fileSystem->exists($destination) && !is_file($destination)) {
            $output->writeln('<comment>' . basename($destination) . '</comment> already exists in <comment>' . dirname($destination) . '/</comment> and is not a file/symlink. Skipping...');

            return;
        }

        if ($this->forceSymlinks && is_link($destination)) {
            $this->fileSystem->remove($destination);
        }

        if (is_file($destination) && !is_link($destination)) {
            if ($this->fileSystem->exists($destination . '.original')) {
                $output->writeln('Cannot create backup file <comment>' . basename($destination) . '.original</comment> in <comment>' . dirname($destination) . '/</comment>. Skipping...');

                return;
            }

            $this->fileSystem->rename($destination, $destination . '.original');
        }

        if ($this->fileSystem->exists($destination)) {
            if (is_link($destination)) {
                $output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment>. Symlink already exists!');
            } else {
                $output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment> due to an unknown error.');
            }

            return;
        }

        $this->fileSystem->symlink(
            $this->fileSystem->makePathRelative(
                dirname($source),
                realpath(dirname($destination))
            ) . basename($source),
            $destination
        );
    }
protected function verifyAndSymlinkFile ( string $ source , string $ destination , OutputInterface $ output ) : void { if ( ! $ this -> fileSystem -> exists ( dirname ( $ destination ) ) ) { $ this -> fileSystem -> mkdir ( dirname ( $ destination ) , 0755 ) ; } if ( $ this -> fileSystem -> exists ( $ destination ) && ! is_file ( $ destination ) ) { $ output -> writeln ( '<comment>' . basename ( $ destination ) . '</comment> already exists in <comment>' . dirname ( $ destination ) . '/</comment> and is not a file/symlink. Skipping...' ) ; return ; } if ( $ this -> forceSymlinks && is_link ( $ destination ) ) { $ this -> fileSystem -> remove ( $ destination ) ; } if ( is_file ( $ destination ) && ! is_link ( $ destination ) ) { if ( $ this -> fileSystem -> exists ( $ destination . '.original' ) ) { $ output -> writeln ( 'Cannot create backup file <comment>' . basename ( $ destination ) . '.original</comment> in <comment>' . dirname ( $ destination ) . '/</comment>. Skipping...' ) ; return ; } $ this -> fileSystem -> rename ( $ destination , $ destination . '.original' ) ; } if ( $ this -> fileSystem -> exists ( $ destination ) ) { if ( is_link ( $ destination ) ) { $ output -> writeln ( 'Skipped creating the symlink for <comment>' . basename ( $ destination ) . '</comment> in <comment>' . dirname ( $ destination ) . '/</comment>. Symlink already exists!' ) ; } else { $ output -> writeln ( 'Skipped creating the symlink for <comment>' . basename ( $ destination ) . '</comment> in <comment>' . dirname ( $ destination ) . '/</comment> due to an unknown error.' ) ; } return ; } $ this -> fileSystem -> symlink ( $ this -> fileSystem -> makePathRelative ( dirname ( $ source ) , realpath ( dirname ( $ destination ) ) ) . basename ( $ source ) , $ destination ) ; }
Verify that source file can be symlinked to destination and do symlinking if it can.
Verify that source file can be symlinked to destination and do symlinking if it can .