From 15847c32c2e5159b2a6f959a55e41d7902b463da Mon Sep 17 00:00:00 2001 From: dece Date: Sat, 14 Oct 2023 14:08:55 +0200 Subject: [PATCH] Remove admin bundle, roll our own CRUD controllers --- composer.json | 1 - composer.lock | 252 +----------------- config/bundles.php | 1 - config/packages/security.yaml | 1 - config/packages/uid.yaml | 4 - src/Controller/Admin/DashboardController.php | 34 --- .../Admin/EpisodeCrudController.php | 40 --- src/Controller/Admin/Field/FileField.php | 80 ------ .../Admin/PodcastCrudController.php | 36 --- symfony.lock | 21 -- templates/admin/field/file.html.twig | 11 - 11 files changed, 1 insertion(+), 480 deletions(-) delete mode 100644 config/packages/uid.yaml delete mode 100644 src/Controller/Admin/DashboardController.php delete mode 100644 src/Controller/Admin/EpisodeCrudController.php delete mode 100644 src/Controller/Admin/Field/FileField.php delete mode 100644 src/Controller/Admin/PodcastCrudController.php delete mode 100644 templates/admin/field/file.html.twig diff --git a/composer.json b/composer.json index 5343024..99cc3ec 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ "doctrine/doctrine-bundle": "^2.9", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.15", - "easycorp/easyadmin-bundle": "^4", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpdoc-parser": "^1.20", "sensio/framework-extra-bundle": "^6.1", diff --git a/composer.lock b/composer.lock index a6b6600..c8a15a2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c83180ca22904f1cd45ca0b405d8500e", + "content-hash": "24fab26692524d95cb0fec16c9be8ea6", "packages": [ { "name": "doctrine/annotations", @@ -1396,100 +1396,6 @@ }, "time": "2022-05-23T21:33:49+00:00" }, - { - "name": "easycorp/easyadmin-bundle", - "version": "v4.7.6", - "source": { - "type": "git", - "url": "https://github.com/EasyCorp/EasyAdminBundle.git", - "reference": "60e04377612ce4d63ad833209127541caaf7e93b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/EasyCorp/EasyAdminBundle/zipball/60e04377612ce4d63ad833209127541caaf7e93b", - "reference": "60e04377612ce4d63ad833209127541caaf7e93b", - "shasum": "" - }, - "require": { - "doctrine/doctrine-bundle": "^2.5", - "doctrine/orm": "^2.10", - "ext-json": "*", - "php": ">=8.0.2", - "symfony/asset": "^5.4|^6.0", - "symfony/cache": "^5.4|^6.0", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/deprecation-contracts": "^3.0", - "symfony/doctrine-bridge": "^5.4|^6.0", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/filesystem": "^5.4|^6.0", - "symfony/form": "^5.4|^6.0", - "symfony/framework-bundle": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/intl": "^5.4|^6.0", - "symfony/property-access": "^5.4|^6.0", - "symfony/security-bundle": "^5.4|^6.0", - "symfony/string": "^5.4|^6.0", - "symfony/translation": "^5.4|^6.0", - "symfony/twig-bundle": "^5.4|^6.0", - "symfony/uid": "^5.4|^6.0", - "symfony/validator": "^5.4|^6.0" - }, - "require-dev": { - "doctrine/doctrine-fixtures-bundle": "^3.4", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-phpunit": "^1.2", - "phpstan/phpstan-strict-rules": "^1.4", - "phpstan/phpstan-symfony": "^1.2", - "psr/log": "^1.0", - "symfony/browser-kit": "^5.4|^6.0", - "symfony/css-selector": "^5.4|^6.0", - "symfony/debug-bundle": "^5.4|^6.0", - "symfony/dom-crawler": "^5.4|^6.0", - "symfony/phpunit-bridge": "^5.4|^6.0" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "EasyCorp\\Bundle\\EasyAdminBundle\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Project Contributors", - "homepage": "https://github.com/EasyCorp/EasyAdminBundle/graphs/contributors" - } - ], - "description": "Admin generator for Symfony applications", - "homepage": "https://github.com/EasyCorp/EasyAdminBundle", - "keywords": [ - "admin", - "backend", - "generator" - ], - "support": { - "issues": "https://github.com/EasyCorp/EasyAdminBundle/issues", - "source": "https://github.com/EasyCorp/EasyAdminBundle/tree/v4.7.6" - }, - "funding": [ - { - "url": "https://github.com/javiereguiluz", - "type": "github" - } - ], - "time": "2023-09-07T06:13:39+00:00" - }, { "name": "egulias/email-validator", "version": "4.0.1", @@ -5267,88 +5173,6 @@ ], "time": "2023-07-28T09:04:16+00:00" }, - { - "name": "symfony/polyfill-uuid", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-uuid.git", - "reference": "9c44518a5aff8da565c8a55dbe85d2769e6f630e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/9c44518a5aff8da565c8a55dbe85d2769e6f630e", - "reference": "9c44518a5aff8da565c8a55dbe85d2769e6f630e", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-uuid": "*" - }, - "suggest": { - "ext-uuid": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Uuid\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Grégoire Pineau", - "email": "lyrixx@lyrixx.info" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for uuid functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "uuid" - ], - "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-26T09:26:14+00:00" - }, { "name": "symfony/process", "version": "v6.2.13", @@ -6809,80 +6633,6 @@ ], "time": "2023-02-14T08:44:56+00:00" }, - { - "name": "symfony/uid", - "version": "v6.2.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/uid.git", - "reference": "d30c72a63897cfa043e1de4d4dd2ffa9ecefcdc0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/uid/zipball/d30c72a63897cfa043e1de4d4dd2ffa9ecefcdc0", - "reference": "d30c72a63897cfa043e1de4d4dd2ffa9ecefcdc0", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/polyfill-uuid": "^1.15" - }, - "require-dev": { - "symfony/console": "^5.4|^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Uid\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Grégoire Pineau", - "email": "lyrixx@lyrixx.info" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to generate and represent UIDs", - "homepage": "https://symfony.com", - "keywords": [ - "UID", - "ulid", - "uuid" - ], - "support": { - "source": "https://github.com/symfony/uid/tree/v6.2.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-02-14T08:44:56+00:00" - }, { "name": "symfony/validator", "version": "v6.2.13", diff --git a/config/bundles.php b/config/bundles.php index 8f6d413..887a0e3 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -12,5 +12,4 @@ return [ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], - EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], ]; diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 291bd6d..bb1c2c4 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -25,7 +25,6 @@ security: role_hierarchy: ROLE_ADMIN: ROLE_USER access_control: - - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/manage, roles: ROLE_USER } when@test: diff --git a/config/packages/uid.yaml b/config/packages/uid.yaml deleted file mode 100644 index 0152094..0000000 --- a/config/packages/uid.yaml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - uid: - default_uuid_version: 7 - time_based_uuid_version: 7 diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php deleted file mode 100644 index 74feb3b..0000000 --- a/src/Controller/Admin/DashboardController.php +++ /dev/null @@ -1,34 +0,0 @@ -container->get(AdminUrlGenerator::class); - return $this->redirect($adminUrlGenerator->setController(PodcastCrudController::class)->generateUrl()); - } - - public function configureDashboard(): Dashboard - { - return Dashboard::new()->setTitle('LSBC'); - } - - public function configureMenuItems(): iterable - { - yield MenuItem::linkToCrud('Podcasts', 'fas fa-list', Podcast::class); - yield MenuItem::linkToCrud('Episodes', 'fas fa-list', Episode::class); - } -} diff --git a/src/Controller/Admin/EpisodeCrudController.php b/src/Controller/Admin/EpisodeCrudController.php deleted file mode 100644 index 84ef132..0000000 --- a/src/Controller/Admin/EpisodeCrudController.php +++ /dev/null @@ -1,40 +0,0 @@ -add('podcast'); - } - - public function configureFields(string $pageName): iterable - { - return [ - TextField::new('title'), - TextEditorField::new('description'), - AssociationField::new('podcast'), - DateTimeField::new('publicationDate'), - FileField::new('audioFilename') - ->setUploadDir(Constants::BASE_PUBLIC_DIR . Constants::FILES_BASE_PATH) - ->setBasePath(Constants::FILES_BASE_PATH), - ]; - } -} diff --git a/src/Controller/Admin/Field/FileField.php b/src/Controller/Admin/Field/FileField.php deleted file mode 100644 index 2bca6c3..0000000 --- a/src/Controller/Admin/Field/FileField.php +++ /dev/null @@ -1,80 +0,0 @@ - - */ -final class FileField implements FieldInterface -{ - use FieldTrait; - - public const OPTION_BASE_PATH = 'basePath'; - public const OPTION_UPLOAD_DIR = 'uploadDir'; - public const OPTION_UPLOADED_FILE_NAME_PATTERN = 'uploadedFileNamePattern'; - - /** - * @param TranslatableInterface|string|false|null $label - */ - public static function new(string $propertyName, $label = null): self - { - return (new self()) - ->setProperty($propertyName) - ->setLabel($label) - ->setTemplatePath('admin/field/file.html.twig') - ->setFormType(FileUploadType::class) - ->addCssClass('field-file') - ->addJsFiles(Asset::fromEasyAdminAssetPackage('field-file-upload.js')) - ->setTextAlign(TextAlign::CENTER) - ->setCustomOption(self::OPTION_BASE_PATH, null) - ->setCustomOption(self::OPTION_UPLOAD_DIR, null) - ->setCustomOption(self::OPTION_UPLOADED_FILE_NAME_PATTERN, '[name].[extension]'); - } - - public function setBasePath(string $path): self - { - $this->setCustomOption(self::OPTION_BASE_PATH, $path); - - return $this; - } - - /** - * Relative to project's root directory (e.g. use 'public/uploads/' for `/public/uploads/`) - * Default upload dir: `/public/uploads/images/`. - */ - public function setUploadDir(string $uploadDirPath): self - { - $this->setCustomOption(self::OPTION_UPLOAD_DIR, $uploadDirPath); - - return $this; - } - - /** - * @param string|\Closure $patternOrCallable - * - * If it's a string, uploaded files will be renamed according to the given pattern. - * The pattern can include the following special values: - * [day] [month] [year] [timestamp] - * [name] [slug] [extension] [contenthash] - * [randomhash] [uuid] [ulid] - * (e.g. [year]/[month]/[day]/[slug]-[contenthash].[extension]) - * - * If it's a callable, you will be passed the Symfony's UploadedFile instance and you must - * return a string with the new filename. - * (e.g. fn(UploadedFile $file) => sprintf('upload_%d_%s.%s', random_int(1, 999), $file->getFilename(), $file->guessExtension())) - */ - public function setUploadedFileNamePattern($patternOrCallable): self - { - $this->setCustomOption(self::OPTION_UPLOADED_FILE_NAME_PATTERN, $patternOrCallable); - - return $this; - } -} - diff --git a/src/Controller/Admin/PodcastCrudController.php b/src/Controller/Admin/PodcastCrudController.php deleted file mode 100644 index 60d67da..0000000 --- a/src/Controller/Admin/PodcastCrudController.php +++ /dev/null @@ -1,36 +0,0 @@ -setUploadDir(Constants::BASE_PUBLIC_DIR . Constants::IMAGES_BASE_PATH) - ->setBasePath(Constants::IMAGES_BASE_PATH), - ]; - } - - -} diff --git a/symfony.lock b/symfony.lock index caf600c..5ef3ac8 100644 --- a/symfony.lock +++ b/symfony.lock @@ -35,15 +35,6 @@ "migrations/.gitignore" ] }, - "easycorp/easyadmin-bundle": { - "version": "4.6", - "recipe": { - "repo": "github.com/symfony/recipes", - "branch": "main", - "version": "3.0", - "ref": "b131e6cbfe1b898a508987851963fff485986285" - } - }, "phpunit/phpunit": { "version": "9.6", "recipe": { @@ -248,18 +239,6 @@ "templates/base.html.twig" ] }, - "symfony/uid": { - "version": "6.2", - "recipe": { - "repo": "github.com/symfony/recipes", - "branch": "main", - "version": "6.2", - "ref": "d294ad4add3e15d7eb1bae0221588ca89b38e558" - }, - "files": [ - "config/packages/uid.yaml" - ] - }, "symfony/validator": { "version": "6.2", "recipe": { diff --git a/templates/admin/field/file.html.twig b/templates/admin/field/file.html.twig deleted file mode 100644 index 4a3c780..0000000 --- a/templates/admin/field/file.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} -{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} -{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} -{% set files = field.formattedValue %} -{% if files is not iterable %} - {% set files = [files] %} -{% endif %} - -{% for file in files %} - {{ file }} -{% endfor %}