vendor/topthink/think-installer/src/ThinkExtend.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// +----------------------------------------------------------------------

namespace think\composer;

use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;

class ThinkExtend extends LibraryInstaller
{

    public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        parent::install($repo, $package);
        $this->copyExtraFiles($package);
    }

    public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
    {
        parent::update($repo, $initial, $target);
        $this->copyExtraFiles($target);

    }

    protected function copyExtraFiles(PackageInterface $package)
    {
        $extra = $package->getExtra();

        if (!empty($extra['think-config'])) {

            $composerExtra = $this->composer->getPackage()->getExtra();
            $extraDir      = (!empty($composerExtra['app-path']) ? $composerExtra['app-path'] : 'application') . DIRECTORY_SEPARATOR . 'extra';
            $this->filesystem->ensureDirectoryExists($extraDir);

            //配置文件
            foreach ((array) $extra['think-config'] as $name => $config) {
                $target = $extraDir . DIRECTORY_SEPARATOR . $name . '.php';
                $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config;

                if (is_file($target)) {
                    $this->io->write("<info>File {$target} exist!</info>");
                    continue;
                }

                if (!is_file($source)) {
                    $this->io->write("<info>File {$target} not exist!</info>");
                    continue;
                }

                copy($source, $target);
            }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。