Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
php_version: '8.4'
craft_version: '6'
node_version: '22'
jobs: '["ecs", "prettier", "phpstan", "tests", "rector"]'
jobs: '["ecs", "prettier", "phpstan", "tests"]'
working_directory: 'yii2-adapter'
notify_slack: true
slack_subteam: <!subteam^SGFL9NKNZ>
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/laravel-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,44 @@ jobs:
- name: Run Pint
run: pint --parallel --test --verbose

rector:
name: 'Code Quality / Rector'
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPOSER_AUTH_JSON: |
{
"http-basic": {
"repo.packagist.com": {
"username": "${{ secrets.packagist_username }}",
"password": "${{ secrets.packagist_token }}"
}
}
}

- name: Set version
run: composer config version "6.x-dev"

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Run Rector
run: vendor/bin/rector process --dry-run --ansi

phpstan:
name: 'Code Quality / Phpstan'
runs-on: ubuntu-latest
Expand Down
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@
"psr-4": {
"CraftCms\\Cms\\Tests\\": "tests/",
"CraftCms\\Cms\\Database\\": "database/",
"CraftCms\\Yii2Adapter\\Tests\\": "yii2-adapter/tests-laravel/"
"CraftCms\\Yii2Adapter\\Tests\\": "yii2-adapter/tests-laravel/",
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"scripts": {
Expand All @@ -118,7 +121,19 @@
"phpstan": "phpstan --memory-limit=1G",
"rector": "rector",
"tests": "./vendor/bin/pest --compact",
"tests-adapter": "./vendor/bin/pest --configuration ./yii2-adapter/phpunit.xml.dist --test-directory ./yii2-adapter/tests-laravel"
"tests-adapter": "./vendor/bin/pest --configuration ./yii2-adapter/phpunit.xml.dist --test-directory ./yii2-adapter/tests-laravel",
"post-autoload-dump": [
"@clear",
"@prepare"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@build",
"@php vendor/bin/testbench serve --ansi"
]
},
"config": {
"sort-packages": true,
Expand Down
1 change: 1 addition & 0 deletions src/Database/Migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ public function createTables(): void
$table->char('uid', 36)->default('0');
});

Schema::dropIfExists(Table::MIGRATIONS);
app(Migrator::class)
->getRepository()
->createRepository();
Expand Down
14 changes: 10 additions & 4 deletions src/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Inertia\Middleware;
use Override;

class HandleInertiaRequests extends Middleware
{
Expand All @@ -33,7 +34,7 @@ class HandleInertiaRequests extends Middleware
*
* @see https://inertiajs.com/asset-versioning
*/
#[\Override]
#[Override]
public function version(Request $request): ?string
{
return parent::version($request);
Expand All @@ -46,15 +47,20 @@ public function version(Request $request): ?string
*
* @return array<string, mixed>
*/
#[\Override]
#[Override]
public function share(Request $request): array
{
$currentSite = Sites::getCurrentSite();
$isInstalled = Cms::isInstalled();

if (! $isInstalled) {
return parent::share($request);
}

$currentSite = Sites::getCurrentSite();
$updates = app(Updates::class);
$nav = app(Navigation::class);

if ($isInstalled && ! $updates->isCraftUpdatePending()) {
if (! $updates->isCraftUpdatePending()) {
Comment on lines -52 to +63
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianjhanson I had to return early here if not installed because the installer was throwing exceptions that there was no site.

Might want to double-check what is needed for the installer here or if just doing parent::share is enough

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the installer needs any of this stuff at the moment so this should be good. I've made a similar change in my branches but apparently forgot to commit it 🤦

$currentUser = Craft::$app->getUser()->getIdentity();

if (! $currentUser) {
Expand Down
9 changes: 8 additions & 1 deletion src/Translation/I18N.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,14 @@ public function translate(string|Stringable $message, array $parameters = [], ?s
* Translate it using Laravel's translations.
*/
if ($translation === (string) $message) {
return __($message, $parameters, $locale);
$result = __($message, $parameters, $locale);

// We're dealing with a message that's equal to a translation file (for example 'site')
if (is_array($result)) {
return $translation;
}

return $result;
}

return $translation;
Expand Down
24 changes: 24 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,27 @@ providers:
- CraftCms\Cms\Providers\CraftServiceProvider
- CraftCms\Yii2Adapter\Yii2ServiceProvider
- Laravel\Wayfinder\WayfinderServiceProvider

seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
welcome: true
start: /admin
install: false # We run the Craft install in DatabaseSeeder
user: 1
guard: craft
sync:
- from: resources
to: public/vendor/craft
- from: storage
to: workbench/storage
reverse: true
build:
- migrate-fresh
discovers:
web: true
commands: true
config: true
factories: true
seeders: true
3 changes: 3 additions & 0 deletions workbench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
.env.dusk
storage
Empty file added workbench/app/Models/.gitkeep
Empty file.
27 changes: 27 additions & 0 deletions workbench/app/Providers/WorkbenchServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Workbench\App\Providers;

use Illuminate\Support\ServiceProvider;

class WorkbenchServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
#[\Override]
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
17 changes: 17 additions & 0 deletions workbench/bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

use function Orchestra\Testbench\default_skeleton_path;

return Application::configure(basePath: $APP_BASE_PATH ?? default_skeleton_path())
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
)
->withMiddleware(function (Middleware $middleware): void {})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();
5 changes: 5 additions & 0 deletions workbench/bootstrap/providers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
//
];
Loading
Loading