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/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:

- name: Execute tests
run: |
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --diff
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix
vendor/bin/phpunit -c phpunit.xml.dist
26 changes: 19 additions & 7 deletions src/console/src/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function job(object|string $job, ?string $queue = null, ?string $connecti
$job = is_string($job) ? ApplicationContext::getContainer()->get($job) : $job;

if ($job instanceof ShouldQueue) {
$this->dispatchToQueue($job, $queue ?? $job->queue, $connection ?? $job->connection); /* @phpstan-ignore-line */
$this->dispatchToQueue($job, $queue, $connection);
} else {
$this->dispatchNow($job);
}
Expand Down Expand Up @@ -199,9 +199,15 @@ protected function dispatchToQueue(object $job, ?string $queue, ?string $connect
return;
}

$this->getDispatcher()->dispatch(
$job->onConnection($connection)->onQueue($queue)
);
if ($connection !== null) {
$job->onConnection($connection);
}

if ($queue !== null) {
$job->onQueue($queue);
}

$this->getDispatcher()->dispatch($job);
}

/**
Expand All @@ -220,9 +226,15 @@ protected function dispatchUniqueJobToQueue(object $job, ?string $queue, ?string
return;
}

$this->getDispatcher()->dispatch(
$job->onConnection($connection)->onQueue($queue)
);
if ($connection !== null) {
$job->onConnection($connection);
}

if ($queue !== null) {
$job->onQueue($queue);
}

$this->getDispatcher()->dispatch($job);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/core/src/Context/ApplicationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class ApplicationContext extends HyperfApplicationContext
*/
public static function getContainer(): ContainerContract
{
/* @phpstan-ignore-next-line */
return self::$container;
$container = parent::getContainer();

if (! $container instanceof ContainerContract) {
throw new TypeError('The application container must implement ' . ContainerContract::class . '.');
}

return $container;
}
}
14 changes: 14 additions & 0 deletions src/core/src/View/Compilers/Concerns/CompilesHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Hypervel\View\Compilers\Concerns;

use Hypervel\Foundation\Vite;

trait CompilesHelpers
{
/**
Expand All @@ -21,4 +23,16 @@ protected function compileMethod(string $method): string
{
return "<?php echo method_field{$method}; ?>";
}

/**
* Compile the "vite" statements into valid PHP.
*/
protected function compileVite(?string $arguments): string
{
$arguments ??= '()';

$class = Vite::class;

return "<?php echo app('{$class}'){$arguments}; ?>";
}
}
4 changes: 4 additions & 0 deletions src/foundation/publish/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@

'url' => env('APP_URL', 'http://localhost'),

'frontend_url' => env('FRONTEND_URL', 'http://localhost:3000'),

'asset_url' => env('ASSET_URL', 'https://example.com'),

/*
|--------------------------------------------------------------------------
| Application Timezone
Expand Down
1 change: 1 addition & 0 deletions src/foundation/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ protected function registerCoreContainerAliases(): void
\Hypervel\Queue\Failed\FailedJobProviderInterface::class => ['queue.failer'],
\Hypervel\Validation\Contracts\Factory::class => ['validator'],
\Hypervel\Validation\DatabasePresenceVerifierInterface::class => ['validation.presence'],
\Hypervel\Foundation\Vite::class => ['vite'],
] as $key => $aliases) {
foreach ($aliases as $alias) {
$this->alias($key, $alias);
Expand Down
107 changes: 107 additions & 0 deletions src/foundation/src/Testing/Concerns/InteractsWithContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
use Hypervel\Foundation\Contracts\Application as ApplicationContract;
use Hypervel\Foundation\Testing\DatabaseConnectionResolver;
use Hypervel\Foundation\Testing\Dispatcher\HttpDispatcher as TestingHttpDispatcher;
use Hypervel\Foundation\Vite;
use Hypervel\Support\Facades\Facade;
use Hypervel\Support\HtmlString;
use Mockery;
use Mockery\MockInterface;

trait InteractsWithContainer
{
protected ?ApplicationContract $app = null;

protected $originalVite;

/**
* Register an instance of an object in the container.
*
Expand Down Expand Up @@ -79,6 +84,108 @@ protected function forgetMock(string $abstract): static
return $this;
}

/**
* Register an empty handler for Vite in the container.
*
* @return $this
*/
protected function withoutVite(): static
{
if ($this->originalVite == null) {
$this->originalVite = app(Vite::class);
}

Facade::clearResolvedInstance(Vite::class);

$this->swap(Vite::class, new class extends Vite {
public function __invoke(array|string $entrypoints, ?string $buildDirectory = null): HtmlString
{
return new HtmlString('');
}

public function __call($method, $parameters): string
{
return '';
}

public function __toString(): string
{
return '';
}

public function useIntegrityKey(bool|string $key): static
{
return $this;
}

public function useBuildDirectory(string $path): static
{
return $this;
}

public function useHotFile(string $path): static
{
return $this;
}

public function withEntryPoints(array $entryPoints): static
{
return $this;
}

public function useScriptTagAttributes(callable|array $attributes): static
{
return $this;
}

public function useStyleTagAttributes(callable|array $attributes): static
{
return $this;
}

public function usePreloadTagAttributes(callable|array|false $attributes): static
{
return $this;
}

public function preloadedAssets(): array
{
return [];
}

public function reactRefresh(): ?HtmlString
{
return new HtmlString('');
}

public function content(string $asset, ?string $buildDirectory = null): string
{
return '';
}

public function asset(string $asset, ?string $buildDirectory = null): string
{
return '';
}
});

return $this;
}

/**
* Restore Vite in the container.
*
* @return $this
*/
protected function withVite(): static
{
if ($this->originalVite) {
$this->app->instance(Vite::class, $this->originalVite);
}

return $this;
}

protected function flushApplication(): void
{
$this->app = null;
Expand Down
Loading