Configure the shared folders.

@param  string  $projectPath
@param  string  $projectDirectory
@return static
197687
public function configureSharedFolders($projectPath, $projectDirectory)
    {
        $folders = [
            [
                'map' => $projectPath,
                'to' => "/home/vagrant/{$projectDirectory}",
            ],
        ];

        if (isset($this->attributes['folders']) && ! empty($this->attributes['folders'])) {
            foreach ($this->attributes['folders'] as $index => $user_folder) {
                if (isset($user_folder['map']) && empty($folders[$index]['map'])) {
                    $folders[$index]['map'] = dirname($projectPath).'/'.basename($user_folder['map']);
                }

                if (isset($user_folder['to'])) {
                    $folders[$index]['to'] = $user_folder['to'];
                }

                if (isset($user_folder['type'])) {
                    $folders[$index]['type'] = $user_folder['type'];
                }
            }
        }

        $this->update(['folders' => $folders]);

        return $this;
    }
896613
protected function createSingleFolderIfNotExists($fullPath) {
        $tempDir = codemonkey_pathTempDir;
        if (file_exists($tempDir.$fullPath) && is_dir($tempDir.$fullPath)) {
            return;
        }
        mkdir($tempDir.$fullPath);
        chmod($tempDir.$fullPath, 0775);
    }
1242481
private static function getDocsFiles(string $projectRootDirectory): array
    {
        $files = [];
        $dir   = $projectRootDirectory . '/docs';
        if (!is_dir($dir)) {
            return $files;
        }
        $directory = new \RecursiveDirectoryIterator($dir);
        $recursive = new \RecursiveIteratorIterator($directory);
        $regex     = new \RegexIterator(
            $recursive,
            '/^.+\.md/i',
            \RecursiveRegexIterator::GET_MATCH
        );
        foreach ($regex as $file) {
            if ('' !== $file[0]) {
                $files[] = $file[0];
            }
        }

        return $files;
    }
289458
public function addPublicDirectory(string $package, string $path) : self
    {
        $this->publicDirectories->put($package, $path);

        return $this;
    }
931112
public function configure(Binder $binder, string $projectPath = null)
    {
        $args = $this->parseArgs();
        $binder->bindConstant('argv')
               ->to($args);
        foreach ($args as $name => $value) {
            if (substr($name, 0, 5) !== 'argv.') {
                $name = 'argv.' . $name;
            }

            $binder->bindConstant($name)
                   ->to($value);
        }

        $request = new ConsoleRequest($args, $_SERVER);
        $binder->bind(Request::class)
               ->toInstance($request);
        $binder->bind(ConsoleRequest::class)
               ->toInstance($request);
        if (null !== $this->userInput) {
            $binder->bind($this->userInput)
                   ->toProviderClass(UserInputProvider::class)
                   ->asSingleton();
            $binder->bind($this->userInput)
                   ->named('stubbles.console.input.instance')
                   ->to($this->userInput);
            $binder->bindConstant('stubbles.console.input.class')
                   ->to($this->userInput);
        }
    }
191339
public function copyToDirectory(string $newDirectoryPath): self
    {
        $newDirectoryPath = normalize_path($newDirectoryPath);

        if (is_dir($newDirectoryPath)) {
            if (is_writeable($newDirectoryPath)) {
                $newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
                $this->copy($newFolderPath);
            }
            throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') is not writable',
                FolderException::NOT_WRITEABLE);
        }
        throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') does not exist',
            FolderException::DONT_EXIST);
    }
186273
public function setProject($project)
    {
        if ($project instanceof Project) {
            $this->project = $project->getSlug();

            return $this;
        }

        $this->project = (string) $project;

        return $this;
    }
486147
public function setProject(Project $project)
    {
        $this->project = $project;
        if ($this->project != null) {
            $this->project->addBuildListener($this);
        }
    }
854893
public static function initialize($projectId, $apiKey) {
        if(!isset(self::$client)) {
            self::$client = new Client($projectId, $apiKey);
        }
        return self::$client;
    }
826324
public function getPath(string $filePath): PathTransfer
    {
        $rootPath = $this->getRootApplicationDirectoryPathByFilePath($filePath);
        $corePath = $this->getCorePath($filePath);
        $projectPath = $this->getProjectPath($filePath);

        $pathTransfer = new PathTransfer();

        $pathTransfer->setRootPath($rootPath);
        $pathTransfer->setCorePath($corePath);
        $pathTransfer->setProjectPath($projectPath);

        return $pathTransfer;
    }
114326
def create_project_config_path(
    path, mode=0o777, parents=False, exist_ok=False
):
    """"""
    # FIXME check default directory mode
    project_path = Path(path).absolute().joinpath(RENKU_HOME)
    project_path.mkdir(mode=mode, parents=parents, exist_ok=exist_ok)
    return str(project_path)
1116435
private function buildPathes(string $projectPath): array
    {
        if (substr($projectPath, -1) !== DIRECTORY_SEPARATOR) {
            $projectPath .= DIRECTORY_SEPARATOR;
        }

        $pathes = [];
        foreach ($this->pathTypes as $pathType) {
            $pathes['stubbles.' . $pathType . '.path'] = $projectPath . $pathType;
        }

        return $pathes;
    }
1314640
public function save()
    {
        if ($path = $this->getProjectPath()) {
            $path .= '/' . $this->getOutputFile();
            file_put_contents($path, serialize($this->getContainer()));
        } else {
            throw new \RuntimeException('No project path provided.');
        }
        return $this;
    }
22568
public function maybeConfigure(Project $project)
    {
        if ($this->proxyConfigured) {
            return;
        }

        $id = null;

        // DataType configured in ProjectConfigurator
        //        if ( is_a($this->wrappedObject, "DataType") )
        //            return;

        if ($this->attributes || (isset($this->characters) && $this->characters != '')) {
            ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project);

            if (isset($this->attributes["id"])) {
                $id = $this->attributes["id"];
            }

            if (isset($this->characters) && $this->characters != '') {
                ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters);
            }
            if ($id !== null) {
                $project->addReference($id, $this->wrappedObject);
            }
        }

        /*if ( is_array($this->children) && !empty($this->children) ) {
            // Configure all child of this object ...
            foreach ($this->children as $child) {
                $child->maybeConfigure($project);
                ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag()));
            }
        }*/

        $this->proxyConfigured = true;
    }
166603
public function mapDirectory($directory, Project $project)
    {
        if (!file_exists($directory . '/.git')) {
            throw new \InvalidArgumentException('Not a Git repository: ' . $directory);
        }
        $projectConfig = [
            'id' => $project->id,
        ];
        if ($host = parse_url($project->getUri(), PHP_URL_HOST)) {
            $projectConfig['host'] = $host;
        }
        $this->writeCurrentProjectConfig($projectConfig, $directory, true);
        $this->ensureGitRemote($directory, $project->getGitUrl());
    }
859950
public function setPath(string $path): self
    {
        parent::setPath($path);
        $this->directory = new Directory(\dirname($path));

        return $this;
    }
427055
public function mkdir($path)
    {
        $info = $this->info($path);
        if ($info->isDir()) {
            return $this;
        }

        if (!mkdir($info->getStreamUrl(), $this->dirMode, true)) {
            throw new RuntimeException(sprintf(
                'Failed to create directory "%s": %s',
                $path, $this->getLastPhpError()
            ));
        }

        return $this;
    }