Skip to content

Commit

Permalink
Initialize StaticSiteGeneration (SSG) feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Feb 13, 2025
1 parent d824d53 commit 432ae67
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Command;

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

/**
* @author Thomas Bibaut
* @author Mathias Arlaud <[email protected]>
* @author Hugo Alliaume <[email protected]>
*/
#[AsCommand(name: 'static-site-generation:generate', description: 'Set a secret in the vault')]
final class StaticSiteGenerationGenerateCommand extends Command
{
// TODO
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @author Thomas Bibaut
* @author Mathias Arlaud <[email protected]>
* @author Hugo Alliaume <[email protected]>
*/
readonly class StaticSiteGenerationPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
// TODO: ...
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\StaticSiteGeneration;

/**
* Classes implementing this interface are able to provide parameters for the static site generation.
*
* @author Thomas Bibaut
* @author Mathias Arlaud <[email protected]>
* @author Hugo Alliaume <[email protected]>
*/
interface ParamsProviderInterface
{
/**
* @return iterable<array<string, mixed>>
*/
public function provideParams(): iterable;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\StaticSiteGeneration;

/**
* @author Thomas Bibaut
* @author Mathias Arlaud <[email protected]>
* @author Hugo Alliaume <[email protected]>
*/
final readonly class StaticPagesGenerator implements StaticPagesGeneratorInterface
{
public function __construct(

) {
}

public function generate(): void
{
// TODO: ...
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\StaticSiteGeneration;

/**
* @author Thomas Bibaut
* @author Mathias Arlaud <[email protected]>
* @author Hugo Alliaume <[email protected]>
*/
interface StaticPagesGeneratorInterface
{
public function generate(): void;
}
44 changes: 28 additions & 16 deletions src/Symfony/Component/Routing/Attribute/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ class Route
private array $aliases = [];

/**
* @param string|array<string,string>|null $path The route path (i.e. "/user/login")
* @param string|null $name The route name (i.e. "app_user_login")
* @param array<string|\Stringable> $requirements Requirements for the route attributes, @see https://symfony.com/doc/current/routing.html#parameters-validation
* @param array<string, mixed> $options Options for the route (i.e. ['prefix' => '/api'])
* @param array<string, mixed> $defaults Default values for the route attributes and query parameters
* @param string|null $host The host for which this route should be active (i.e. "localhost")
* @param string|string[] $methods The list of HTTP methods allowed by this route
* @param string|string[] $schemes The list of schemes allowed by this route (i.e. "https")
* @param string|null $condition An expression that must evaluate to true for the route to be matched, @see https://symfony.com/doc/current/routing.html#matching-expressions
* @param int|null $priority The priority of the route if multiple ones are defined for the same path
* @param string|null $locale The locale accepted by the route
* @param string|null $format The format returned by the route (i.e. "json", "xml")
* @param bool|null $utf8 Whether the route accepts UTF-8 in its parameters
* @param bool|null $stateless Whether the route is defined as stateless or stateful, @see https://symfony.com/doc/current/routing.html#stateless-routes
* @param string|null $env The env in which the route is defined (i.e. "dev", "test", "prod")
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
* @param string|array<string,string>|null $path The route path (i.e. "/user/login")
* @param string|null $name The route name (i.e. "app_user_login")
* @param array<string|\Stringable> $requirements Requirements for the route attributes, @see https://symfony.com/doc/current/routing.html#parameters-validation
* @param array<string, mixed> $options Options for the route (i.e. ['prefix' => '/api'])
* @param array<string, mixed> $defaults Default values for the route attributes and query parameters
* @param string|null $host The host for which this route should be active (i.e. "localhost")
* @param string|string[] $methods The list of HTTP methods allowed by this route
* @param string|string[] $schemes The list of schemes allowed by this route (i.e. "https")
* @param string|null $condition An expression that must evaluate to true for the route to be matched, @see https://symfony.com/doc/current/routing.html#matching-expressions
* @param int|null $priority The priority of the route if multiple ones are defined for the same path
* @param string|null $locale The locale accepted by the route
* @param string|null $format The format returned by the route (i.e. "json", "xml")
* @param bool|null $utf8 Whether the route accepts UTF-8 in its parameters
* @param bool|null $stateless Whether the route is defined as stateless or stateful, @see https://symfony.com/doc/current/routing.html#stateless-routes
* @param string|null $env The env in which the route is defined (i.e. "dev", "test", "prod")
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
* @param bool|array{ params?: string|iterable<array<string, mixed>>} $staticGeneration The static generation configuration
*/
public function __construct(
string|array|null $path = null,
Expand All @@ -62,6 +63,7 @@ public function __construct(
?bool $stateless = null,
private ?string $env = null,
string|DeprecatedAlias|array $alias = [],
private bool|array $staticGeneration = false,
) {
if (\is_array($path)) {
$this->localizedPaths = $path;
Expand Down Expand Up @@ -224,6 +226,16 @@ public function setAliases(string|DeprecatedAlias|array $aliases): void
{
$this->aliases = \is_array($aliases) ? $aliases : [$aliases];
}

public function getStaticGeneration(): bool|array
{
return $this->staticGeneration;
}

public function setStaticGeneration(bool|array $staticGeneration): void
{
$this->staticGeneration = $staticGeneration;
}
}

if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,11 @@ final public function stateless(bool $stateless = true): static

return $this;
}

final public function staticGeneration(true|array $options = true): static
{
// TODO: ...

return $this;
}
}

0 comments on commit 432ae67

Please sign in to comment.