Skip to content

Add installation command, fix config overwrites #6649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,10 @@
if ($this->app['config']->get('api-platform.graphql.enabled')) {
$this->registerGraphQl($this->app);
}

if ($this->app->runningInConsole()) {
$this->commands([Console\InstallCommand::class]);

Check warning on line 1060 in src/Laravel/ApiPlatformProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/ApiPlatformProvider.php#L1059-L1060

Added lines #L1059 - L1060 were not covered by tests
}
}

private function registerGraphQl(Application $app): void
Expand Down Expand Up @@ -1210,11 +1214,11 @@
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/config/api-platform.php' => $this->app->configPath('api-platform.php'),
], 'laravel-assets');
], 'api-platform-config');

Check warning on line 1217 in src/Laravel/ApiPlatformProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/ApiPlatformProvider.php#L1217

Added line #L1217 was not covered by tests

$this->publishes([
__DIR__.'/public' => $this->app->publicPath('vendor/api-platform'),
], 'laravel-assets');
], ['api-platform-assets', 'public']);

Check warning on line 1221 in src/Laravel/ApiPlatformProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/ApiPlatformProvider.php#L1221

Added line #L1221 was not covered by tests
}

$this->loadViewsFrom(__DIR__.'/resources/views', 'api-platform');
Expand Down
45 changes: 45 additions & 0 deletions src/Laravel/Console/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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.
*/

declare(strict_types=1);

namespace ApiPlatform\Laravel\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'api-platform:install')]
class InstallCommand extends Command
{
/**
* @var string
*/
protected $signature = 'api-platform:install';

/**
* @var string
*/
protected $description = 'Install all of the API Platform resources';

/**
* Execute the console command.
*/
public function handle(): void

Check warning on line 35 in src/Laravel/Console/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Console/InstallCommand.php#L35

Added line #L35 was not covered by tests
{
$this->comment('Publishing API Platform Assets...');
$this->callSilent('vendor:publish', ['--tag' => 'api-platform-assets']);

Check warning on line 38 in src/Laravel/Console/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Console/InstallCommand.php#L37-L38

Added lines #L37 - L38 were not covered by tests

$this->comment('Publishing API Platform Configuration...');
$this->callSilent('vendor:publish', ['--tag' => 'api-platform-config']);

Check warning on line 41 in src/Laravel/Console/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Console/InstallCommand.php#L40-L41

Added lines #L40 - L41 were not covered by tests

$this->info('API Platform installed successfully.');

Check warning on line 43 in src/Laravel/Console/InstallCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Console/InstallCommand.php#L43

Added line #L43 was not covered by tests
}
}
Loading