-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,376 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,13 @@ | |
APP_ENV=dev | ||
APP_SECRET=28de35e787e86cb435f0312627623283 | ||
###< symfony/framework-bundle ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml | ||
# | ||
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4" | ||
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" | ||
DATABASE_URL="postgresql://sylius_stack:[email protected]:5432/sylius_stack?serverVersion=16&charset=utf8" | ||
###< doctrine/doctrine-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SyliusUi. | ||
* | ||
* (c) Monofony | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\DataFixtures; | ||
|
||
use App\Story\DefaultBooksStory; | ||
use Doctrine\Bundle\FixturesBundle\Fixture; | ||
use Doctrine\Persistence\ObjectManager; | ||
|
||
class AppFixtures extends Fixture | ||
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
DefaultBooksStory::load(); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity; | ||
|
||
use App\Repository\BookRepository; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Sylius\Component\Resource\Annotation\SyliusCrudRoutes; | ||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
|
||
#[ORM\Entity(repositoryClass: BookRepository::class)] | ||
#[SyliusCrudRoutes( | ||
alias: 'app.book', | ||
path: '/admin/books', | ||
section: 'admin', | ||
redirect: 'update', | ||
templates: '@SyliusAdminUi/crud', | ||
grid: 'app_book', | ||
vars: [ | ||
'all' => [ | ||
'subheader' => 'app.ui.manage_your_books', | ||
], | ||
], | ||
)] | ||
class Book implements ResourceInterface | ||
{ | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue] | ||
#[ORM\Column(type: 'integer')] | ||
private ?int $id = null; | ||
|
||
#[ORM\Column(type: 'string', length: 255)] | ||
private ?string $title = null; | ||
|
||
#[ORM\Column(type: 'string', length: 255)] | ||
private ?string $authorName = null; | ||
|
||
#[ORM\Column(type: 'datetime_immutable')] | ||
private \DateTimeImmutable $createdAt; | ||
|
||
public function __construct() | ||
{ | ||
$this->createdAt = new \DateTimeImmutable(); | ||
} | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getTitle(): ?string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function setTitle(string $title): self | ||
{ | ||
$this->title = $title; | ||
|
||
return $this; | ||
} | ||
|
||
public function getAuthorName(): ?string | ||
{ | ||
return $this->authorName; | ||
} | ||
|
||
public function setAuthorName(string $authorName): self | ||
{ | ||
$this->authorName = $authorName; | ||
|
||
return $this; | ||
} | ||
|
||
public function getCreatedAt(): ?\DateTimeImmutable | ||
{ | ||
return $this->createdAt; | ||
} | ||
|
||
public function setCreatedAt(\DateTimeImmutable $createdAt): self | ||
{ | ||
$this->createdAt = $createdAt; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Factory; | ||
|
||
use App\Entity\Book; | ||
use App\Repository\BookRepository; | ||
use Doctrine\Persistence\Proxy; | ||
use Zenstruck\Foundry\Persistence\PersistentObjectFactory; | ||
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; | ||
use \Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; | ||
|
||
/** | ||
* @template TModel of Book | ||
* @template-extends PersistentObjectFactory<TModel> | ||
* | ||
* @method static Book|Proxy createOne(array $attributes = []) | ||
* @method static Book[]|Proxy[] createMany(int $number, array|callable $attributes = []) | ||
* @method static Book[]|Proxy[] createSequence(array|callable $sequence) | ||
* @method static Book|Proxy find(object|array|mixed $criteria) | ||
* @method static Book|Proxy findOrCreate(array $attributes) | ||
* @method static Book|Proxy first(string $sortedField = 'id') | ||
* @method static Book|Proxy last(string $sortedField = 'id') | ||
* @method static Book|Proxy random(array $attributes = []) | ||
* @method static Book|Proxy randomOrCreate(array $attributes = []) | ||
* @method static Book[]|Proxy[] all() | ||
* @method static Book[]|Proxy[] findBy(array $attributes) | ||
* @method static Book[]|Proxy[] randomSet(int $number, array $attributes = []) | ||
* @method static Book[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) | ||
* @method static BookRepository|ProxyRepositoryDecorator repository() | ||
* @method Book|Proxy create(array|callable $attributes = []) | ||
*/ | ||
final class BookFactory extends PersistentProxyObjectFactory | ||
{ | ||
public function withTitle(string $title): self | ||
{ | ||
return $this->with(['title' => $title]); | ||
} | ||
|
||
public function withAuthorName(string $authorName): self | ||
{ | ||
return $this->with(['authorName' => $authorName]); | ||
} | ||
|
||
public static function class(): string | ||
{ | ||
return Book::class; | ||
} | ||
|
||
/** | ||
* @return array<string, mixed>|callable | ||
*/ | ||
protected function defaults(): array|callable | ||
{ | ||
return [ | ||
'title' => ucfirst(self::faker()->words(3, true)), | ||
'authorName' => self::faker()->firstName() . ' ' . self::faker()->lastName(), | ||
]; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Repository; | ||
|
||
use App\Entity\Book; | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\ResourceRepositoryTrait; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
|
||
/** | ||
* @extends ServiceEntityRepository<Book> | ||
* | ||
* @method Book|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method Book|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method Book[] findAll() | ||
* @method Book[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
*/ | ||
class BookRepository extends ServiceEntityRepository implements RepositoryInterface | ||
{ | ||
use ResourceRepositoryTrait; | ||
|
||
public function __construct(ManagerRegistry $registry) | ||
{ | ||
parent::__construct($registry, Book::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Story; | ||
|
||
use App\Factory\BookFactory; | ||
use Zenstruck\Foundry\Story; | ||
|
||
final class DefaultBooksStory extends Story | ||
{ | ||
public function build(): void | ||
{ | ||
BookFactory::new() | ||
->withTitle('1984') | ||
->withAuthorName('George Orwell') | ||
; | ||
|
||
BookFactory::createMany(20); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
###> doctrine/doctrine-bundle ### | ||
database: | ||
ports: | ||
- "${POSTGRES_PORT:-5432}:5432" | ||
###< doctrine/doctrine-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
###> doctrine/doctrine-bundle ### | ||
database: | ||
image: postgres:${POSTGRES_VERSION:-16}-alpine | ||
environment: | ||
POSTGRES_DB: ${POSTGRES_DB:-sylius_stack} | ||
# You should definitely change the password in production | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-sylius_stack} | ||
POSTGRES_USER: ${POSTGRES_USER:-sylius_stack} | ||
volumes: | ||
- database_data:/var/lib/postgresql/data:rw | ||
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! | ||
# - ./docker/db/data:/var/lib/postgresql/data:rw | ||
###< doctrine/doctrine-bundle ### | ||
|
||
volumes: | ||
###> doctrine/doctrine-bundle ### | ||
database_data: | ||
###< doctrine/doctrine-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
doctrine: | ||
dbal: | ||
url: '%env(resolve:DATABASE_URL)%' | ||
|
||
# IMPORTANT: You MUST configure your server version, | ||
# either here or in the DATABASE_URL env var (see .env file) | ||
#server_version: '16' | ||
|
||
profiling_collect_backtrace: '%kernel.debug%' | ||
use_savepoints: true | ||
orm: | ||
auto_generate_proxy_classes: true | ||
enable_lazy_ghost_objects: true | ||
report_fields_where_declared: true | ||
validate_xml_mapping: true | ||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware | ||
auto_mapping: true | ||
mappings: | ||
App: | ||
type: attribute | ||
is_bundle: false | ||
dir: '%kernel.project_dir%/app/Entity' | ||
prefix: 'App\Entity' | ||
alias: App | ||
|
||
when@test: | ||
doctrine: | ||
dbal: | ||
# "TEST_TOKEN" is typically set by ParaTest | ||
dbname_suffix: '_test%env(default::TEST_TOKEN)%' | ||
|
||
when@prod: | ||
doctrine: | ||
orm: | ||
auto_generate_proxy_classes: false | ||
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' | ||
query_cache_driver: | ||
type: pool | ||
pool: doctrine.system_cache_pool | ||
result_cache_driver: | ||
type: pool | ||
pool: doctrine.result_cache_pool | ||
|
||
framework: | ||
cache: | ||
pools: | ||
doctrine.result_cache_pool: | ||
adapter: cache.app | ||
doctrine.system_cache_pool: | ||
adapter: cache.system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
doctrine_migrations: | ||
migrations_paths: | ||
# namespace is arbitrary but should be different from App\Migrations | ||
# as migrations classes should NOT be autoloaded | ||
'DoctrineMigrations': '%kernel.project_dir%/migrations' | ||
enable_profiler: false |
Oops, something went wrong.