chore: complete update
This commit is contained in:
63
examples/StaticPageExample.php
Normal file
63
examples/StaticPageExample.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Examples;
|
||||
|
||||
use App\Framework\Attributes\Route;
|
||||
use App\Framework\Attributes\StaticPage;
|
||||
use App\Framework\Router\Result\ViewResult;
|
||||
|
||||
/**
|
||||
* Beispiel-Controller für die Verwendung des StaticPage-Attributs
|
||||
*/
|
||||
class StaticPageExampleController
|
||||
{
|
||||
/**
|
||||
* Startseite - wird als statische Seite generiert
|
||||
*/
|
||||
#[Route('/')]
|
||||
#[StaticPage]
|
||||
public function home(): ViewResult
|
||||
{
|
||||
return new ViewResult(template: 'home');
|
||||
}
|
||||
|
||||
/**
|
||||
* Über uns - wird als statische Seite generiert mit benutzerdefiniertem Pfad
|
||||
*/
|
||||
#[Route('/about')]
|
||||
#[StaticPage(outputPath: 'ueber-uns')]
|
||||
public function about(): ViewResult
|
||||
{
|
||||
return new ViewResult(template: 'about');
|
||||
}
|
||||
|
||||
/**
|
||||
* Kontaktseite - wird als statische Seite generiert, aber nur wenn prerender=true
|
||||
*/
|
||||
#[Route('/contact')]
|
||||
#[StaticPage(prerender: true)]
|
||||
public function contact(): ViewResult
|
||||
{
|
||||
return new ViewResult(template: 'contact');
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin-Bereich - wird NICHT als statische Seite generiert, da kein StaticPage-Attribut
|
||||
*/
|
||||
#[Route('/admin')]
|
||||
public function admin(): ViewResult
|
||||
{
|
||||
return new ViewResult(template: 'admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamische Seite - wird NICHT als statische Seite generiert, da prerender=false
|
||||
*/
|
||||
#[Route('/dynamic')]
|
||||
#[StaticPage(prerender: false)]
|
||||
public function dynamic(): ViewResult
|
||||
{
|
||||
return new ViewResult(template: 'dynamic');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user