示例#1
0
 public function symlinkProjects(InputInterface $input, OutputInterface $output)
 {
     $symlink_input = new ArrayInput(array('site:symlink', 'site' => $input->getArgument('site'), 'symlink' => $this->symlink, '--www' => $this->www, '--projects-dir' => $input->getOption('projects-dir')));
     $symlink = new Command\Extension\Symlink();
     $symlink->run($symlink_input, $output);
 }
Extension\Symlink::registerSymlinker(function ($project, $destination, $name, $projects, OutputInterface $output) {
    if (!is_file($project . '/composer.json')) {
        return false;
    }
    $manifest = json_decode(file_get_contents($project . '/composer.json'));
    if (!isset($manifest->type) || $manifest->type != 'nooku-component') {
        return false;
    }
    if (!isset($manifest->{'nooku-component'}->name)) {
        $output->writeln("<comment>[warning]</comment> Found type nooku-component in `" . basename($project) . "` but composer.json is missing the `nooku-component` property. Skipping!");
        return true;
    }
    $component = 'com_' . $manifest->{'nooku-component'}->name;
    if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
        $output->writeln("Symlinking `{$component}` into `{$destination}`");
    }
    $dirs = array(Util::buildTargetPath('/libraries/koowa/components', $destination), Util::buildTargetPath('/media/koowa', $destination));
    foreach ($dirs as $dir) {
        if (!is_dir($dir)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating empty directory `{$dir}`");
            }
            mkdir($dir, 0777, true);
        }
    }
    $code_destination = Util::buildTargetPath('/libraries/koowa/components/' . $component, $destination);
    if (!file_exists($code_destination)) {
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->writeln(" * creating link `{$code_destination}` -> {$project}");
        }
        `ln -sf {$project} {$code_destination}`;
    }
    // Special treatment for media files
    $media = $project . '/resources/assets';
    $target = Util::buildTargetPath('/media/koowa/' . $component, $destination);
    if (is_dir($media) && !file_exists($target)) {
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->writeln(" * creating link `{$target}` -> {$media}");
        }
        `ln -sf {$media} {$target}`;
    }
    return true;
});
Extension\Symlink::registerSymlinker(function ($project, $destination, $name, $projects, OutputInterface $output) {
    if (!is_file($project . '/composer.json')) {
        return false;
    }
    $manifest = json_decode(file_get_contents($project . '/composer.json'));
    if (!isset($manifest->name) || $manifest->name != 'joomlatools/framework') {
        return false;
    }
    // build the folders to symlink into
    $dirs = array(Util::buildTargetPath('/libraries/joomlatools/component', $destination), Util::buildTargetPath('/media/koowa', $destination));
    foreach ($dirs as $dir) {
        if (!is_dir($dir)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating empty directory `{$dir}`");
            }
            mkdir($dir, 0777, true);
        }
    }
    /*
     * Special treatment for media files
     */
    $media = array($project . '/code/libraries/joomlatools/component/koowa/resources/assets' => Util::buildTargetPath('/media/koowa/com_koowa', $destination), $project . '/code/libraries/joomlatools/library/resources/assets' => Util::buildTargetPath('/media/koowa/framework', $destination));
    foreach ($media as $from => $to) {
        if (is_dir($from) && !file_exists($to)) {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                $output->writeln(" * creating link `{$to}` -> {$from}");
            }
            `ln -sf {$from} {$to}`;
        }
    }
    // Let the default symlinker handle the rest
    return false;
});