Skip to content

Commit 3ad1e9a

Browse files
committed
Initialize StaticSiteGeneration (SSG) feature
1 parent d824d53 commit 3ad1e9a

File tree

7 files changed

+167
-16
lines changed

7 files changed

+167
-16
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/*
3+
* This file is part of the Symfony package.
4+
*
5+
* (c) Fabien Potencier <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Symfony\Bundle\FrameworkBundle\Command;
12+
13+
use Symfony\Component\Console\Attribute\AsCommand;
14+
use Symfony\Component\Console\Command\Command;
15+
16+
/**
17+
* @author Thomas Bibaut
18+
* @author Mathias Arlaud <[email protected]>
19+
* @author Hugo Alliaume <[email protected]>
20+
*/
21+
#[AsCommand(name: 'static-site-generation:generate', description: 'Generates the static site')]
22+
final class StaticSiteGenerationGenerateCommand extends Command
23+
{
24+
// TODO
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
17+
/**
18+
* @author Thomas Bibaut
19+
* @author Mathias Arlaud <[email protected]>
20+
* @author Hugo Alliaume <[email protected]>
21+
*/
22+
readonly class StaticSiteGenerationPass implements CompilerPassInterface
23+
{
24+
public function process(ContainerBuilder $container)
25+
{
26+
// TODO: ...
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\StaticSiteGeneration;
13+
14+
/**
15+
* Classes implementing this interface are able to provide parameters for the static site generation.
16+
*
17+
* @author Thomas Bibaut
18+
* @author Mathias Arlaud <[email protected]>
19+
* @author Hugo Alliaume <[email protected]>
20+
*/
21+
interface ParamsProviderInterface
22+
{
23+
/**
24+
* @return iterable<array<string, mixed>>
25+
*/
26+
public function provideParams(): iterable;
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\StaticSiteGeneration;
13+
14+
/**
15+
* @author Thomas Bibaut
16+
* @author Mathias Arlaud <[email protected]>
17+
* @author Hugo Alliaume <[email protected]>
18+
*/
19+
final readonly class StaticPagesGenerator implements StaticPagesGeneratorInterface
20+
{
21+
public function __construct(
22+
23+
) {
24+
}
25+
26+
public function generate(): void
27+
{
28+
// TODO: ...
29+
}
30+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\StaticSiteGeneration;
13+
14+
/**
15+
* @author Thomas Bibaut
16+
* @author Mathias Arlaud <[email protected]>
17+
* @author Hugo Alliaume <[email protected]>
18+
*/
19+
interface StaticPagesGeneratorInterface
20+
{
21+
public function generate(): void;
22+
}

src/Symfony/Component/Routing/Attribute/Route.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ class Route
2828
private array $aliases = [];
2929

3030
/**
31-
* @param string|array<string,string>|null $path The route path (i.e. "/user/login")
32-
* @param string|null $name The route name (i.e. "app_user_login")
33-
* @param array<string|\Stringable> $requirements Requirements for the route attributes, @see https://symfony.com/doc/current/routing.html#parameters-validation
34-
* @param array<string, mixed> $options Options for the route (i.e. ['prefix' => '/api'])
35-
* @param array<string, mixed> $defaults Default values for the route attributes and query parameters
36-
* @param string|null $host The host for which this route should be active (i.e. "localhost")
37-
* @param string|string[] $methods The list of HTTP methods allowed by this route
38-
* @param string|string[] $schemes The list of schemes allowed by this route (i.e. "https")
39-
* @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
40-
* @param int|null $priority The priority of the route if multiple ones are defined for the same path
41-
* @param string|null $locale The locale accepted by the route
42-
* @param string|null $format The format returned by the route (i.e. "json", "xml")
43-
* @param bool|null $utf8 Whether the route accepts UTF-8 in its parameters
44-
* @param bool|null $stateless Whether the route is defined as stateless or stateful, @see https://symfony.com/doc/current/routing.html#stateless-routes
45-
* @param string|null $env The env in which the route is defined (i.e. "dev", "test", "prod")
46-
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
31+
* @param string|array<string,string>|null $path The route path (i.e. "/user/login")
32+
* @param string|null $name The route name (i.e. "app_user_login")
33+
* @param array<string|\Stringable> $requirements Requirements for the route attributes, @see https://symfony.com/doc/current/routing.html#parameters-validation
34+
* @param array<string, mixed> $options Options for the route (i.e. ['prefix' => '/api'])
35+
* @param array<string, mixed> $defaults Default values for the route attributes and query parameters
36+
* @param string|null $host The host for which this route should be active (i.e. "localhost")
37+
* @param string|string[] $methods The list of HTTP methods allowed by this route
38+
* @param string|string[] $schemes The list of schemes allowed by this route (i.e. "https")
39+
* @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
40+
* @param int|null $priority The priority of the route if multiple ones are defined for the same path
41+
* @param string|null $locale The locale accepted by the route
42+
* @param string|null $format The format returned by the route (i.e. "json", "xml")
43+
* @param bool|null $utf8 Whether the route accepts UTF-8 in its parameters
44+
* @param bool|null $stateless Whether the route is defined as stateless or stateful, @see https://symfony.com/doc/current/routing.html#stateless-routes
45+
* @param string|null $env The env in which the route is defined (i.e. "dev", "test", "prod")
46+
* @param string|DeprecatedAlias|(string|DeprecatedAlias)[] $alias The list of aliases for this route
47+
* @param bool|array{ params?: string|iterable<array<string, mixed>>} $staticGeneration The static generation configuration
4748
*/
4849
public function __construct(
4950
string|array|null $path = null,
@@ -62,6 +63,7 @@ public function __construct(
6263
?bool $stateless = null,
6364
private ?string $env = null,
6465
string|DeprecatedAlias|array $alias = [],
66+
private bool|array $staticGeneration = false,
6567
) {
6668
if (\is_array($path)) {
6769
$this->localizedPaths = $path;
@@ -224,6 +226,16 @@ public function setAliases(string|DeprecatedAlias|array $aliases): void
224226
{
225227
$this->aliases = \is_array($aliases) ? $aliases : [$aliases];
226228
}
229+
230+
public function getStaticGeneration(): bool|array
231+
{
232+
return $this->staticGeneration;
233+
}
234+
235+
public function setStaticGeneration(bool|array $staticGeneration): void
236+
{
237+
$this->staticGeneration = $staticGeneration;
238+
}
227239
}
228240

229241
if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {

src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,11 @@ final public function stateless(bool $stateless = true): static
169169

170170
return $this;
171171
}
172+
173+
final public function staticGeneration(true|array $options = true): static
174+
{
175+
// TODO: ...
176+
177+
return $this;
178+
}
172179
}

0 commit comments

Comments
 (0)