Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Filesystem.php

function Filesystem::symlink

Creates a symbolic link or copy a directory.

Throws

IOException When symlink fails

1 call to Filesystem::symlink()
Filesystem::mirror in vendor/symfony/filesystem/Filesystem.php
Mirrors a directory to another.

File

vendor/symfony/filesystem/Filesystem.php, line 329

Class

Filesystem
Provides basic utility to manipulate the file system.

Namespace

Symfony\Component\Filesystem

Code

public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false) : void {
    self::assertFunctionExists('symlink');
    if ('\\' === \DIRECTORY_SEPARATOR) {
        $originDir = strtr($originDir, '/', '\\');
        $targetDir = strtr($targetDir, '/', '\\');
        if ($copyOnWindows) {
            $this->mirror($originDir, $targetDir);
            return;
        }
    }
    $this->mkdir(\dirname($targetDir));
    if (is_link($targetDir)) {
        if (readlink($targetDir) === $originDir) {
            return;
        }
        $this->remove($targetDir);
    }
    if (!self::box('symlink', $originDir, $targetDir)) {
        $this->linkException($originDir, $targetDir, 'symbolic');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal