for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ApiPlatform\Core\Composer;
use Composer\Script\Event;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
class ScriptHandler
{
const SWAGGER_UI_DESTINATION = 'web/swagger-ui';
const SWAGGER_UI_SOURCE = 'vendor/swagger-api/swagger-ui/dist';
/**
* Copy swagger ui to the correct directory.
public static function installSwaggerUi()
$fs = new Filesystem();
$cwd = getcwd();
foreach ((new Finder())->in(implode('/', [$cwd, self::SWAGGER_UI_SOURCE])) as $file) {
$destination = implode('/', [$cwd, self::SWAGGER_UI_DESTINATION, $file->getRelativePathname()]);
if ($file->isDir()) {
$fs->mkdir($destination);
continue;
}
$fs->copy($file->getRealPath(), $destination, true);