From b809ee9c88b153da4fe960bc94627a23a454c7e3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 13 Mar 2022 21:12:20 +0100 Subject: [PATCH] use murph/murph-core instead of the core directory --- assets/css/admin.scss | 2 +- assets/js/admin.js | 2 +- composer.json | 57 +- config/packages/doctrine.yaml | 2 +- config/packages/translation.yaml | 2 +- config/packages/twig.yaml | 2 +- config/routes/annotations.yaml | 2 +- config/services.yaml | 14 +- core/Analytic/DateRangeAnalytic.php | 204 ------ core/Annotation/UrlGenerator.php | 20 - core/Authenticator/LoginFormAuthenticator.php | 96 --- core/Bundle/CoreBundle.php | 24 - core/Cache/SymfonyCacheManager.php | 73 -- core/Command/UserCreateCommand.php | 108 --- core/Controller/.gitignore | 0 .../Account/AccountAdminController.php | 150 ---- core/Controller/Admin/AdminController.php | 41 -- core/Controller/Admin/Crud/CrudController.php | 342 --------- .../Analytic/AnalyticController.php | 38 - core/Controller/Auth/AuthController.php | 155 ---- .../Dashboard/DashboardAdminController.php | 27 - .../FileManagerAdminController.php | 438 ------------ .../Redirect/RedirectAdminController.php | 154 ---- .../NavigationSettingAdminController.php | 81 --- .../Setting/SettingAdminController.php | 99 --- core/Controller/Site/MenuAdminController.php | 82 --- .../Site/NavigationAdminController.php | 142 ---- core/Controller/Site/NodeAdminController.php | 310 -------- core/Controller/Site/PageAdminController.php | 136 ---- core/Controller/Site/PageController.php | 57 -- core/Controller/Site/SitemapController.php | 40 -- core/Controller/Site/TreeAdminController.php | 87 --- core/Controller/Task/TaskAdminController.php | 62 -- core/Controller/User/UserAdminController.php | 131 ---- core/Crud/CrudConfiguration.php | 330 --------- .../Exception/CrudConfigurationException.php | 12 - core/Crud/Field/ButtonField.php | 41 -- core/Crud/Field/DateField.php | 25 - core/Crud/Field/DatetimeField.php | 25 - core/Crud/Field/Field.php | 92 --- core/Crud/Field/ImageField.php | 27 - core/Crud/Field/TextField.php | 24 - core/DependencyInjection/Configuration.php | 138 ---- core/DependencyInjection/CoreExtension.php | 28 - core/Doctrine/Timestampable.php | 59 -- core/Entity/.gitignore | 0 core/Entity/Analytic/Referer.php | 103 --- core/Entity/Analytic/View.php | 151 ---- core/Entity/EntityInterface.php | 7 - core/Entity/FileInformation.php | 48 -- core/Entity/NavigationSetting.php | 111 --- core/Entity/Redirect.php | 211 ------ core/Entity/Setting.php | 92 --- core/Entity/Site/Menu.php | 146 ---- core/Entity/Site/Navigation.php | 243 ------- core/Entity/Site/Node.php | 676 ------------------ core/Entity/Site/Page/Block.php | 82 --- core/Entity/Site/Page/ChoiceBlock.php | 21 - core/Entity/Site/Page/CollectionBlock.php | 21 - core/Entity/Site/Page/FileBlock.php | 27 - core/Entity/Site/Page/Page.php | 276 ------- core/Entity/Site/Page/TextBlock.php | 12 - core/Event/Account/PasswordRequestEvent.php | 28 - .../EntityManager/EntityManagerEvent.php | 33 - core/Event/Page/PageEditEvent.php | 44 -- core/Event/Setting/NavigationSettingEvent.php | 35 - core/Event/Setting/SettingEvent.php | 35 - core/Event/Task/TaskInitEvent.php | 37 - core/Event/Task/TaskRunRequestedEvent.php | 44 -- core/EventListener/AnalyticListener.php | 153 ---- core/EventListener/RedirectListener.php | 50 -- .../PasswordRequestEventSubscriber.php | 69 -- .../EntityManagerEventSubscriber.php | 52 -- .../NavigationSettingEventSubscriber.php | 32 - .../RequestSecurityEventSubscriber.php | 69 -- .../SettingEventSubscriber.php | 32 - .../Site/ForcedDomainEventSubscriber.php | 53 -- .../Site/MenuEventSubscriber.php | 107 --- .../Site/NavigationEventSubscriber.php | 46 -- .../Site/NodeEventSubscriber.php | 183 ----- .../Site/Page/BlockEventSubscriber.php | 59 -- .../Site/Page/PageEventSubscriber.php | 56 -- .../Site/SiteEventSubscriber.php | 53 -- .../Task/CacheCleanTaskEventSubscriber.php | 36 - .../Task/TaskEventSubscriber.php | 33 - core/Factory/Analytic/RefererFactory.php | 22 - core/Factory/Analytic/ViewFactory.php | 22 - core/Factory/FactoryInterface.php | 12 - core/Factory/FileInformationFactory.php | 16 - core/Factory/NavigationSettingFactory.php | 26 - core/Factory/RedirectFactory.php | 14 - core/Factory/SettingFactory.php | 22 - core/Factory/Site/MenuFactory.php | 26 - core/Factory/Site/NavigationFactory.php | 19 - core/Factory/Site/NodeFactory.php | 30 - core/Factory/Site/Page/PageFactory.php | 22 - core/Factory/UserFactory.php | 38 - core/File/FileAttribute.php | 30 - core/FileManager/FsFileManager.php | 321 --------- core/Form/FileManager/DirectoryCreateType.php | 40 -- core/Form/FileManager/DirectoryRenameType.php | 40 -- .../FileInformationAttributeType.php | 49 -- core/Form/FileManager/FileInformationType.php | 34 - core/Form/FileManager/FilePickerType.php | 37 - core/Form/FileManager/FileRenameType.php | 40 -- core/Form/FileManager/FileUploadType.php | 64 -- core/Form/FileUploadHandler.php | 35 - core/Form/Filter/RedirectFilterType.php | 146 ---- core/Form/RedirectType.php | 182 ----- core/Form/Site/MenuType.php | 51 -- .../Site/NavigationAdditionalDomainType.php | 55 -- core/Form/Site/NavigationType.php | 109 --- core/Form/Site/NodeAttributeType.php | 49 -- core/Form/Site/NodeMoveType.php | 62 -- core/Form/Site/NodeParameterType.php | 63 -- core/Form/Site/NodeSitemapParametersType.php | 82 --- core/Form/Site/NodeType.php | 320 --------- core/Form/Site/Page/ChoiceBlockType.php | 32 - core/Form/Site/Page/CollectionBlockType.php | 50 -- core/Form/Site/Page/FileBlockType.php | 32 - core/Form/Site/Page/FilePickerBlockType.php | 33 - core/Form/Site/Page/Filter/PageFilterType.php | 73 -- core/Form/Site/Page/ImageBlockType.php | 25 - core/Form/Site/Page/PageType.php | 133 ---- core/Form/Site/Page/TextBlockType.php | 32 - core/Form/Site/Page/TextareaBlockType.php | 21 - core/Form/Type/CollectionType.php | 41 -- core/Form/UserType.php | 78 -- core/Maker/MakeCrudController.php | 119 --- core/Maker/MakeFactory.php | 82 --- core/Maker/MakeRepositoryQuery.php | 85 --- core/Manager/EntityManager.php | 98 --- core/Manager/TranslatableEntityManager.php | 20 - core/Notification/MailNotifier.php | 236 ------ core/Repository/.gitignore | 0 .../Repository/Analytic/RefererRepository.php | 21 - .../Analytic/RefererRepositoryQuery.php | 28 - core/Repository/Analytic/ViewRepository.php | 21 - .../Analytic/ViewRepositoryQuery.php | 28 - core/Repository/FileInformationRepository.php | 21 - .../FileInformationRepositoryQuery.php | 14 - .../NavigationSettingRepository.php | 21 - .../NavigationSettingRepositoryQuery.php | 18 - core/Repository/RedirectRepository.php | 21 - core/Repository/RedirectRepositoryQuery.php | 15 - core/Repository/RepositoryQuery.php | 126 ---- core/Repository/SettingRepository.php | 21 - core/Repository/SettingRepositoryQuery.php | 18 - core/Repository/Site/MenuRepository.php | 15 - core/Repository/Site/MenuRepositoryQuery.php | 19 - core/Repository/Site/NavigationRepository.php | 15 - .../Site/NavigationRepositoryQuery.php | 37 - core/Repository/Site/NodeRepository.php | 40 -- core/Repository/Site/Page/BlockRepository.php | 15 - .../Site/Page/BlockRepositoryQuery.php | 19 - core/Repository/Site/Page/PageRepository.php | 15 - .../Site/Page/PageRepositoryQuery.php | 77 -- core/Resources/assets/css/admin.scss | 557 --------------- core/Resources/assets/js/admin.js | 26 - .../js/components/file-manager/FileIcon.vue | 86 --- .../components/file-manager/FileManager.vue | 30 - .../js/components/file-manager/Files.vue | 378 ---------- core/Resources/assets/js/modules/analytics.js | 53 -- core/Resources/assets/js/modules/batch.js | 23 - .../assets/js/modules/checkbox-checker.js | 31 - core/Resources/assets/js/modules/choices.js | 8 - .../Resources/assets/js/modules/datepicker.js | 30 - core/Resources/assets/js/modules/dbclick.js | 7 - .../assets/js/modules/document-selector.js | 42 -- core/Resources/assets/js/modules/editor.js | 626 ---------------- .../assets/js/modules/file-manager.js | 17 - .../assets/js/modules/file-picker.js | 82 --- core/Resources/assets/js/modules/form-ajax.js | 79 -- .../assets/js/modules/form-collection.js | 84 --- .../assets/js/modules/form-confirm.js | 15 - .../Resources/assets/js/modules/form-error.js | 23 - core/Resources/assets/js/modules/form-file.js | 11 - core/Resources/assets/js/modules/modal.js | 73 -- core/Resources/assets/js/modules/panel.js | 47 -- core/Resources/assets/js/modules/password.js | 82 --- .../Resources/assets/js/modules/push-state.js | 44 -- .../assets/js/modules/rest-choices.js | 27 - core/Resources/assets/js/modules/sortable.js | 33 - .../assets/js/modules/table-fixed.js | 24 - .../assets/js/modules/table-selectable.js | 121 ---- core/Resources/assets/js/modules/toast.js | 11 - core/Resources/assets/js/modules/tooltip.js | 5 - .../maker/controller/CrudController.tpl.php | 137 ---- core/Resources/maker/factory/Factory.tpl.php | 14 - .../maker/repository/RepositoryQuery.tpl.php | 15 - core/Resources/translations/messages.fr.yaml | 224 ------ .../views/account/admin/edit.html.twig | 228 ------ .../views/admin/crud/_form.html.twig | 12 - .../admin/crud/_form_translations.html.twig | 33 - .../views/admin/crud/_form_widget.html.twig | 3 - .../views/admin/crud/_show.html.twig | 1 - .../Resources/views/admin/crud/edit.html.twig | 95 --- .../views/admin/crud/field/button.html.twig | 7 - .../views/admin/crud/field/date.html.twig | 8 - .../views/admin/crud/field/image.html.twig | 3 - .../views/admin/crud/field/text.html.twig | 7 - .../views/admin/crud/filter.html.twig | 21 - .../views/admin/crud/index.html.twig | 313 -------- core/Resources/views/admin/crud/new.html.twig | 71 -- .../Resources/views/admin/crud/show.html.twig | 68 -- core/Resources/views/admin/layout.html.twig | 55 -- .../views/admin/macros/menu.html.twig | 1 - .../views/admin/module/_menu_item.html.twig | 15 - .../admin/module/_menu_section.html.twig | 5 - .../views/admin/module/account.html.twig | 15 - .../views/admin/module/flashes.html.twig | 49 -- .../views/admin/module/menu.html.twig | 73 -- .../views/admin/module/metas.html.twig | 4 - core/Resources/views/analytic/stats.html.twig | 138 ---- core/Resources/views/auth/2fa.html.twig | 76 -- core/Resources/views/auth/login.html.twig | 95 --- .../views/auth/resetting_request.html.twig | 76 -- .../views/auth/resetting_update.html.twig | 113 --- .../views/file_manager/_form.html.twig | 1 - .../file_manager/directory_new.html.twig | 33 - .../file_manager/directory_rename.html.twig | 33 - .../views/file_manager/file_rename.html.twig | 33 - .../views/file_manager/index.html.twig | 16 - .../views/file_manager/info.html.twig | 229 ------ .../views/file_manager/upload.html.twig | 33 - .../form/bootstrap_4_form_theme.html.twig | 203 ------ .../mail/account/resetting_request.html.twig | 11 - core/Resources/views/mail/base.html.twig | 48 -- core/Resources/views/mail/raw.html.twig | 1 - core/Resources/views/pager/sliding.html.twig | 76 -- .../redirect/redirect_admin/_form.html.twig | 45 -- .../redirect_admin/field/rule.html.twig | 23 - .../navigation_setting_admin/_form.html.twig | 5 - .../navigation_setting_admin/edit.html.twig | 20 - .../setting/setting_admin/_form.html.twig | 5 - .../setting/setting_admin/edit.html.twig | 20 - .../setting/setting_admin/index.html.twig | 65 -- .../site/navigation_admin/_form.html.twig | 72 -- .../site/navigation_admin/_show.html.twig | 102 --- .../site/navigation_admin/index.html.twig | 14 - .../site/navigation_admin/show.html.twig | 8 - .../views/site/node_admin/_form.html.twig | 364 ---------- .../views/site/node_admin/edit.html.twig | 22 - .../views/site/node_admin/move.html.twig | 21 - .../views/site/node_admin/new.html.twig | 21 - .../views/site/node_admin/urls.html.twig | 27 - .../views/site/page_admin/_form.html.twig | 51 -- .../site/page_admin/fields/nodes.html.twig | 8 - .../views/site/sitemap/sitemap.xml.twig | 10 - .../site/tree_admin/navigation.html.twig | 290 -------- .../views/task/task_admin/_form.html.twig | 5 - .../views/task/task_admin/index.html.twig | 56 -- .../views/task/task_admin/run.html.twig | 19 - .../views/user/user_admin/_form.html.twig | 12 - .../views/user/user_admin/_show.html.twig | 25 - .../views/user/user_admin/edit.html.twig | 15 - .../views/user/user_admin/index.html.twig | 1 - .../views/user/user_admin/new.html.twig | 1 - .../views/user/user_admin/show.html.twig | 1 - core/Router/RedirectBuilder.php | 55 -- core/Router/RedirectMatcher.php | 64 -- core/Router/SiteRouteLoader.php | 137 ---- core/Security/TokenGenerator.php | 13 - core/Setting/NavigationSettingManager.php | 100 --- core/Setting/SettingManager.php | 72 -- core/Site/ControllerConfiguration.php | 38 - core/Site/ControllerLocator.php | 42 -- core/Site/PageConfiguration.php | 51 -- core/Site/PageLocator.php | 48 -- core/Site/RoleConfiguration.php | 38 - core/Site/RoleLocator.php | 42 -- core/Site/SiteRequest.php | 81 --- core/Site/SiteStore.php | 64 -- core/Sitemap/SitemapBuilder.php | 133 ---- core/Slugify/CodeSlugify.php | 32 - core/Slugify/RouteParameterSlugify.php | 32 - core/Slugify/Slugify.php | 31 - core/String/FileInformationBuilder.php | 61 -- core/String/StringBuilder.php | 47 -- core/String/UrlBuilder.php | 65 -- core/Twig/Extension/CrudExtension.php | 71 -- .../Extension/FileInformationExtension.php | 66 -- core/Twig/Extension/RoutingExtension.php | 125 ---- core/Twig/Extension/SettingExtension.php | 45 -- core/Twig/Extension/StringExtension.php | 32 - core/Twig/Extension/UrlExtension.php | 34 - symfony.lock | 3 + 287 files changed, 18 insertions(+), 19739 deletions(-) delete mode 100644 core/Analytic/DateRangeAnalytic.php delete mode 100644 core/Annotation/UrlGenerator.php delete mode 100644 core/Authenticator/LoginFormAuthenticator.php delete mode 100644 core/Bundle/CoreBundle.php delete mode 100644 core/Cache/SymfonyCacheManager.php delete mode 100644 core/Command/UserCreateCommand.php delete mode 100644 core/Controller/.gitignore delete mode 100644 core/Controller/Account/AccountAdminController.php delete mode 100644 core/Controller/Admin/AdminController.php delete mode 100644 core/Controller/Admin/Crud/CrudController.php delete mode 100644 core/Controller/Analytic/AnalyticController.php delete mode 100644 core/Controller/Auth/AuthController.php delete mode 100644 core/Controller/Dashboard/DashboardAdminController.php delete mode 100644 core/Controller/FileManager/FileManagerAdminController.php delete mode 100644 core/Controller/Redirect/RedirectAdminController.php delete mode 100644 core/Controller/Setting/NavigationSettingAdminController.php delete mode 100644 core/Controller/Setting/SettingAdminController.php delete mode 100644 core/Controller/Site/MenuAdminController.php delete mode 100644 core/Controller/Site/NavigationAdminController.php delete mode 100644 core/Controller/Site/NodeAdminController.php delete mode 100644 core/Controller/Site/PageAdminController.php delete mode 100644 core/Controller/Site/PageController.php delete mode 100644 core/Controller/Site/SitemapController.php delete mode 100644 core/Controller/Site/TreeAdminController.php delete mode 100644 core/Controller/Task/TaskAdminController.php delete mode 100644 core/Controller/User/UserAdminController.php delete mode 100644 core/Crud/CrudConfiguration.php delete mode 100644 core/Crud/Exception/CrudConfigurationException.php delete mode 100644 core/Crud/Field/ButtonField.php delete mode 100644 core/Crud/Field/DateField.php delete mode 100644 core/Crud/Field/DatetimeField.php delete mode 100644 core/Crud/Field/Field.php delete mode 100644 core/Crud/Field/ImageField.php delete mode 100644 core/Crud/Field/TextField.php delete mode 100644 core/DependencyInjection/Configuration.php delete mode 100644 core/DependencyInjection/CoreExtension.php delete mode 100644 core/Doctrine/Timestampable.php delete mode 100644 core/Entity/.gitignore delete mode 100644 core/Entity/Analytic/Referer.php delete mode 100644 core/Entity/Analytic/View.php delete mode 100644 core/Entity/EntityInterface.php delete mode 100644 core/Entity/FileInformation.php delete mode 100644 core/Entity/NavigationSetting.php delete mode 100644 core/Entity/Redirect.php delete mode 100644 core/Entity/Setting.php delete mode 100644 core/Entity/Site/Menu.php delete mode 100644 core/Entity/Site/Navigation.php delete mode 100644 core/Entity/Site/Node.php delete mode 100644 core/Entity/Site/Page/Block.php delete mode 100644 core/Entity/Site/Page/ChoiceBlock.php delete mode 100644 core/Entity/Site/Page/CollectionBlock.php delete mode 100644 core/Entity/Site/Page/FileBlock.php delete mode 100644 core/Entity/Site/Page/Page.php delete mode 100644 core/Entity/Site/Page/TextBlock.php delete mode 100644 core/Event/Account/PasswordRequestEvent.php delete mode 100644 core/Event/EntityManager/EntityManagerEvent.php delete mode 100644 core/Event/Page/PageEditEvent.php delete mode 100644 core/Event/Setting/NavigationSettingEvent.php delete mode 100644 core/Event/Setting/SettingEvent.php delete mode 100644 core/Event/Task/TaskInitEvent.php delete mode 100644 core/Event/Task/TaskRunRequestedEvent.php delete mode 100644 core/EventListener/AnalyticListener.php delete mode 100644 core/EventListener/RedirectListener.php delete mode 100644 core/EventSubscriber/Account/PasswordRequestEventSubscriber.php delete mode 100644 core/EventSubscriber/EntityManagerEventSubscriber.php delete mode 100644 core/EventSubscriber/NavigationSettingEventSubscriber.php delete mode 100644 core/EventSubscriber/RequestSecurityEventSubscriber.php delete mode 100644 core/EventSubscriber/SettingEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/ForcedDomainEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/MenuEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/NavigationEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/NodeEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/Page/BlockEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/Page/PageEventSubscriber.php delete mode 100644 core/EventSubscriber/Site/SiteEventSubscriber.php delete mode 100644 core/EventSubscriber/Task/CacheCleanTaskEventSubscriber.php delete mode 100644 core/EventSubscriber/Task/TaskEventSubscriber.php delete mode 100644 core/Factory/Analytic/RefererFactory.php delete mode 100644 core/Factory/Analytic/ViewFactory.php delete mode 100644 core/Factory/FactoryInterface.php delete mode 100644 core/Factory/FileInformationFactory.php delete mode 100644 core/Factory/NavigationSettingFactory.php delete mode 100644 core/Factory/RedirectFactory.php delete mode 100644 core/Factory/SettingFactory.php delete mode 100644 core/Factory/Site/MenuFactory.php delete mode 100644 core/Factory/Site/NavigationFactory.php delete mode 100644 core/Factory/Site/NodeFactory.php delete mode 100644 core/Factory/Site/Page/PageFactory.php delete mode 100644 core/Factory/UserFactory.php delete mode 100644 core/File/FileAttribute.php delete mode 100644 core/FileManager/FsFileManager.php delete mode 100644 core/Form/FileManager/DirectoryCreateType.php delete mode 100644 core/Form/FileManager/DirectoryRenameType.php delete mode 100644 core/Form/FileManager/FileInformationAttributeType.php delete mode 100644 core/Form/FileManager/FileInformationType.php delete mode 100644 core/Form/FileManager/FilePickerType.php delete mode 100644 core/Form/FileManager/FileRenameType.php delete mode 100644 core/Form/FileManager/FileUploadType.php delete mode 100644 core/Form/FileUploadHandler.php delete mode 100644 core/Form/Filter/RedirectFilterType.php delete mode 100644 core/Form/RedirectType.php delete mode 100644 core/Form/Site/MenuType.php delete mode 100644 core/Form/Site/NavigationAdditionalDomainType.php delete mode 100644 core/Form/Site/NavigationType.php delete mode 100644 core/Form/Site/NodeAttributeType.php delete mode 100644 core/Form/Site/NodeMoveType.php delete mode 100644 core/Form/Site/NodeParameterType.php delete mode 100644 core/Form/Site/NodeSitemapParametersType.php delete mode 100644 core/Form/Site/NodeType.php delete mode 100644 core/Form/Site/Page/ChoiceBlockType.php delete mode 100644 core/Form/Site/Page/CollectionBlockType.php delete mode 100644 core/Form/Site/Page/FileBlockType.php delete mode 100644 core/Form/Site/Page/FilePickerBlockType.php delete mode 100644 core/Form/Site/Page/Filter/PageFilterType.php delete mode 100644 core/Form/Site/Page/ImageBlockType.php delete mode 100644 core/Form/Site/Page/PageType.php delete mode 100644 core/Form/Site/Page/TextBlockType.php delete mode 100644 core/Form/Site/Page/TextareaBlockType.php delete mode 100644 core/Form/Type/CollectionType.php delete mode 100644 core/Form/UserType.php delete mode 100644 core/Maker/MakeCrudController.php delete mode 100644 core/Maker/MakeFactory.php delete mode 100644 core/Maker/MakeRepositoryQuery.php delete mode 100644 core/Manager/EntityManager.php delete mode 100644 core/Manager/TranslatableEntityManager.php delete mode 100644 core/Notification/MailNotifier.php delete mode 100644 core/Repository/.gitignore delete mode 100644 core/Repository/Analytic/RefererRepository.php delete mode 100644 core/Repository/Analytic/RefererRepositoryQuery.php delete mode 100644 core/Repository/Analytic/ViewRepository.php delete mode 100644 core/Repository/Analytic/ViewRepositoryQuery.php delete mode 100644 core/Repository/FileInformationRepository.php delete mode 100644 core/Repository/FileInformationRepositoryQuery.php delete mode 100644 core/Repository/NavigationSettingRepository.php delete mode 100644 core/Repository/NavigationSettingRepositoryQuery.php delete mode 100644 core/Repository/RedirectRepository.php delete mode 100644 core/Repository/RedirectRepositoryQuery.php delete mode 100644 core/Repository/RepositoryQuery.php delete mode 100644 core/Repository/SettingRepository.php delete mode 100644 core/Repository/SettingRepositoryQuery.php delete mode 100644 core/Repository/Site/MenuRepository.php delete mode 100644 core/Repository/Site/MenuRepositoryQuery.php delete mode 100644 core/Repository/Site/NavigationRepository.php delete mode 100644 core/Repository/Site/NavigationRepositoryQuery.php delete mode 100644 core/Repository/Site/NodeRepository.php delete mode 100644 core/Repository/Site/Page/BlockRepository.php delete mode 100644 core/Repository/Site/Page/BlockRepositoryQuery.php delete mode 100644 core/Repository/Site/Page/PageRepository.php delete mode 100644 core/Repository/Site/Page/PageRepositoryQuery.php delete mode 100644 core/Resources/assets/css/admin.scss delete mode 100644 core/Resources/assets/js/admin.js delete mode 100644 core/Resources/assets/js/components/file-manager/FileIcon.vue delete mode 100644 core/Resources/assets/js/components/file-manager/FileManager.vue delete mode 100644 core/Resources/assets/js/components/file-manager/Files.vue delete mode 100644 core/Resources/assets/js/modules/analytics.js delete mode 100644 core/Resources/assets/js/modules/batch.js delete mode 100644 core/Resources/assets/js/modules/checkbox-checker.js delete mode 100644 core/Resources/assets/js/modules/choices.js delete mode 100644 core/Resources/assets/js/modules/datepicker.js delete mode 100644 core/Resources/assets/js/modules/dbclick.js delete mode 100644 core/Resources/assets/js/modules/document-selector.js delete mode 100644 core/Resources/assets/js/modules/editor.js delete mode 100644 core/Resources/assets/js/modules/file-manager.js delete mode 100644 core/Resources/assets/js/modules/file-picker.js delete mode 100644 core/Resources/assets/js/modules/form-ajax.js delete mode 100644 core/Resources/assets/js/modules/form-collection.js delete mode 100644 core/Resources/assets/js/modules/form-confirm.js delete mode 100644 core/Resources/assets/js/modules/form-error.js delete mode 100644 core/Resources/assets/js/modules/form-file.js delete mode 100644 core/Resources/assets/js/modules/modal.js delete mode 100644 core/Resources/assets/js/modules/panel.js delete mode 100644 core/Resources/assets/js/modules/password.js delete mode 100644 core/Resources/assets/js/modules/push-state.js delete mode 100644 core/Resources/assets/js/modules/rest-choices.js delete mode 100644 core/Resources/assets/js/modules/sortable.js delete mode 100644 core/Resources/assets/js/modules/table-fixed.js delete mode 100644 core/Resources/assets/js/modules/table-selectable.js delete mode 100644 core/Resources/assets/js/modules/toast.js delete mode 100644 core/Resources/assets/js/modules/tooltip.js delete mode 100644 core/Resources/maker/controller/CrudController.tpl.php delete mode 100644 core/Resources/maker/factory/Factory.tpl.php delete mode 100644 core/Resources/maker/repository/RepositoryQuery.tpl.php delete mode 100644 core/Resources/translations/messages.fr.yaml delete mode 100644 core/Resources/views/account/admin/edit.html.twig delete mode 100644 core/Resources/views/admin/crud/_form.html.twig delete mode 100644 core/Resources/views/admin/crud/_form_translations.html.twig delete mode 100644 core/Resources/views/admin/crud/_form_widget.html.twig delete mode 100644 core/Resources/views/admin/crud/_show.html.twig delete mode 100644 core/Resources/views/admin/crud/edit.html.twig delete mode 100644 core/Resources/views/admin/crud/field/button.html.twig delete mode 100644 core/Resources/views/admin/crud/field/date.html.twig delete mode 100644 core/Resources/views/admin/crud/field/image.html.twig delete mode 100644 core/Resources/views/admin/crud/field/text.html.twig delete mode 100644 core/Resources/views/admin/crud/filter.html.twig delete mode 100644 core/Resources/views/admin/crud/index.html.twig delete mode 100644 core/Resources/views/admin/crud/new.html.twig delete mode 100644 core/Resources/views/admin/crud/show.html.twig delete mode 100644 core/Resources/views/admin/layout.html.twig delete mode 100644 core/Resources/views/admin/macros/menu.html.twig delete mode 100644 core/Resources/views/admin/module/_menu_item.html.twig delete mode 100644 core/Resources/views/admin/module/_menu_section.html.twig delete mode 100644 core/Resources/views/admin/module/account.html.twig delete mode 100644 core/Resources/views/admin/module/flashes.html.twig delete mode 100644 core/Resources/views/admin/module/menu.html.twig delete mode 100644 core/Resources/views/admin/module/metas.html.twig delete mode 100644 core/Resources/views/analytic/stats.html.twig delete mode 100644 core/Resources/views/auth/2fa.html.twig delete mode 100644 core/Resources/views/auth/login.html.twig delete mode 100644 core/Resources/views/auth/resetting_request.html.twig delete mode 100644 core/Resources/views/auth/resetting_update.html.twig delete mode 100644 core/Resources/views/file_manager/_form.html.twig delete mode 100644 core/Resources/views/file_manager/directory_new.html.twig delete mode 100644 core/Resources/views/file_manager/directory_rename.html.twig delete mode 100644 core/Resources/views/file_manager/file_rename.html.twig delete mode 100644 core/Resources/views/file_manager/index.html.twig delete mode 100644 core/Resources/views/file_manager/info.html.twig delete mode 100644 core/Resources/views/file_manager/upload.html.twig delete mode 100644 core/Resources/views/form/bootstrap_4_form_theme.html.twig delete mode 100644 core/Resources/views/mail/account/resetting_request.html.twig delete mode 100644 core/Resources/views/mail/base.html.twig delete mode 100644 core/Resources/views/mail/raw.html.twig delete mode 100644 core/Resources/views/pager/sliding.html.twig delete mode 100644 core/Resources/views/redirect/redirect_admin/_form.html.twig delete mode 100644 core/Resources/views/redirect/redirect_admin/field/rule.html.twig delete mode 100644 core/Resources/views/setting/navigation_setting_admin/_form.html.twig delete mode 100644 core/Resources/views/setting/navigation_setting_admin/edit.html.twig delete mode 100644 core/Resources/views/setting/setting_admin/_form.html.twig delete mode 100644 core/Resources/views/setting/setting_admin/edit.html.twig delete mode 100644 core/Resources/views/setting/setting_admin/index.html.twig delete mode 100644 core/Resources/views/site/navigation_admin/_form.html.twig delete mode 100644 core/Resources/views/site/navigation_admin/_show.html.twig delete mode 100644 core/Resources/views/site/navigation_admin/index.html.twig delete mode 100644 core/Resources/views/site/navigation_admin/show.html.twig delete mode 100644 core/Resources/views/site/node_admin/_form.html.twig delete mode 100644 core/Resources/views/site/node_admin/edit.html.twig delete mode 100644 core/Resources/views/site/node_admin/move.html.twig delete mode 100644 core/Resources/views/site/node_admin/new.html.twig delete mode 100644 core/Resources/views/site/node_admin/urls.html.twig delete mode 100644 core/Resources/views/site/page_admin/_form.html.twig delete mode 100644 core/Resources/views/site/page_admin/fields/nodes.html.twig delete mode 100644 core/Resources/views/site/sitemap/sitemap.xml.twig delete mode 100644 core/Resources/views/site/tree_admin/navigation.html.twig delete mode 100644 core/Resources/views/task/task_admin/_form.html.twig delete mode 100644 core/Resources/views/task/task_admin/index.html.twig delete mode 100644 core/Resources/views/task/task_admin/run.html.twig delete mode 100644 core/Resources/views/user/user_admin/_form.html.twig delete mode 100644 core/Resources/views/user/user_admin/_show.html.twig delete mode 100644 core/Resources/views/user/user_admin/edit.html.twig delete mode 100644 core/Resources/views/user/user_admin/index.html.twig delete mode 100644 core/Resources/views/user/user_admin/new.html.twig delete mode 100644 core/Resources/views/user/user_admin/show.html.twig delete mode 100644 core/Router/RedirectBuilder.php delete mode 100644 core/Router/RedirectMatcher.php delete mode 100644 core/Router/SiteRouteLoader.php delete mode 100644 core/Security/TokenGenerator.php delete mode 100644 core/Setting/NavigationSettingManager.php delete mode 100644 core/Setting/SettingManager.php delete mode 100644 core/Site/ControllerConfiguration.php delete mode 100644 core/Site/ControllerLocator.php delete mode 100644 core/Site/PageConfiguration.php delete mode 100644 core/Site/PageLocator.php delete mode 100644 core/Site/RoleConfiguration.php delete mode 100644 core/Site/RoleLocator.php delete mode 100644 core/Site/SiteRequest.php delete mode 100644 core/Site/SiteStore.php delete mode 100644 core/Sitemap/SitemapBuilder.php delete mode 100644 core/Slugify/CodeSlugify.php delete mode 100644 core/Slugify/RouteParameterSlugify.php delete mode 100644 core/Slugify/Slugify.php delete mode 100644 core/String/FileInformationBuilder.php delete mode 100644 core/String/StringBuilder.php delete mode 100644 core/String/UrlBuilder.php delete mode 100644 core/Twig/Extension/CrudExtension.php delete mode 100644 core/Twig/Extension/FileInformationExtension.php delete mode 100644 core/Twig/Extension/RoutingExtension.php delete mode 100644 core/Twig/Extension/SettingExtension.php delete mode 100644 core/Twig/Extension/StringExtension.php delete mode 100644 core/Twig/Extension/UrlExtension.php diff --git a/assets/css/admin.scss b/assets/css/admin.scss index 96a0afb..790ff01 100644 --- a/assets/css/admin.scss +++ b/assets/css/admin.scss @@ -1,6 +1,6 @@ /* Custom variables */ -@import "../../core/Resources/assets/css/admin.scss"; +@import "../../vendor/murph/murph-core/src/core/Resources/assets/css/admin.scss"; /* Custom CSS */ diff --git a/assets/js/admin.js b/assets/js/admin.js index da5f170..e32d857 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -1 +1 @@ -import '../../core/Resources/assets/js/admin.js' +import '../../vendor/murph/murph-core/src/core/Resources/assets/js/admin.js' diff --git a/composer.json b/composer.json index 1172189..4c9945b 100644 --- a/composer.json +++ b/composer.json @@ -7,59 +7,7 @@ "prefer-stable": true, "require": { "php": ">=8.0.0", - "ext-ctype": "*", - "ext-iconv": "*", - "bjeavons/zxcvbn-php": "^1.3", - "cocur/slugify": "^4.1", - "composer/package-versions-deprecated": "1.11.99.1", - "doctrine/annotations": "^1.0", - "doctrine/doctrine-bundle": "^2.5", - "doctrine/doctrine-migrations-bundle": "^3.2", - "doctrine/orm": "^2.11", - "friendsofsymfony/jsrouting-bundle": "^2.8", - "jaybizzle/crawler-detect": "^1.2", - "knplabs/doctrine-behaviors": "^2.6", - "knplabs/knp-paginator-bundle": "^5.8", - "liip/imagine-bundle": "^2.7", - "matomo/device-detector": "^5.0", - "phpdocumentor/reflection-docblock": "^5.3", - "scheb/2fa-google-authenticator": "^5.13", - "scheb/2fa-qr-code": "^5.13", - "sensio/framework-extra-bundle": "^6.2", - "sensiolabs/ansi-to-html": "^1.2", - "spe/filesize-extension-bundle": "~2.0.0", - "stof/doctrine-extensions-bundle": "^1.7", - "symfony/apache-pack": "^1.0", - "symfony/asset": "5.4.*", - "symfony/console": "5.4.*", - "symfony/dotenv": "5.4.*", - "symfony/event-dispatcher": "5.4.*", - "symfony/expression-language": "5.4.*", - "symfony/finder": "5.4.*", - "symfony/flex": "^1.3.1", - "symfony/form": "5.4.*", - "symfony/framework-bundle": "5.4.*", - "symfony/http-client": "5.4.*", - "symfony/intl": "5.4.*", - "symfony/mailer": "5.4.*", - "symfony/mime": "5.4.*", - "symfony/monolog-bundle": "^3.1", - "symfony/notifier": "5.4.*", - "symfony/process": "5.4.*", - "symfony/property-access": "5.4.*", - "symfony/property-info": "5.4.*", - "symfony/proxy-manager-bridge": "5.4.*", - "symfony/security-bundle": "5.4.*", - "symfony/serializer": "5.4.*", - "symfony/string": "5.4.*", - "symfony/translation": "5.4.*", - "symfony/twig-bundle": "^5.2", - "symfony/validator": "5.4.*", - "symfony/web-link": "5.4.*", - "symfony/webpack-encore-bundle": "^1.11", - "symfony/yaml": "5.4.*", - "twig/extra-bundle": "^2.12|^3.3", - "twig/twig": "^2.12|^3.3" + "murph/murph-core": "^1.0" }, "require-dev": { "symfony/browser-kit": "^5.4", @@ -83,8 +31,7 @@ }, "autoload": { "psr-4": { - "App\\": "src/", - "App\\Core\\": "core/" + "App\\": "src/" } }, "autoload-dev": { diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 103af1c..c54a4a2 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -13,7 +13,7 @@ doctrine: App\Core\Entity: is_bundle: false type: annotation - dir: '%kernel.project_dir%/core/Entity' + dir: '%kernel.project_dir%/vendor/murph/murph-core/src/core/Entity' prefix: 'App\Core\Entity' alias: App\Core\Entity App\Entity: diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml index be89150..55811cb 100644 --- a/config/packages/translation.yaml +++ b/config/packages/translation.yaml @@ -3,6 +3,6 @@ framework: translator: default_path: '%kernel.project_dir%/translations' paths: - - '%kernel.project_dir%/core/Resources/translations' + - '%kernel.project_dir%/vendor/murph/murph-core/src/core/Resources/translations' fallbacks: - en diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index da46d6e..d516d0f 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -3,4 +3,4 @@ twig: form_themes: ['@Core/form/bootstrap_4_form_theme.html.twig'] paths: '%kernel.project_dir%/templates/core/': Core - '%kernel.project_dir%/core/Resources/views/': Core + '%kernel.project_dir%/vendor/murph/murph-core/src/core/Resources/views/': Core diff --git a/config/routes/annotations.yaml b/config/routes/annotations.yaml index 1f569cf..9e6d593 100644 --- a/config/routes/annotations.yaml +++ b/config/routes/annotations.yaml @@ -3,7 +3,7 @@ controllers: type: annotation core_controllers: - resource: ../../core/Controller/ + resource: ../../vendor/murph/murph-core/src/core/Controller/ type: annotation kernel: diff --git a/config/services.yaml b/config/services.yaml index 4d04c70..3255329 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -14,10 +14,10 @@ services: # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\Core\: - resource: '../core/' + resource: '../vendor/murph/murph-core/src/core/' exclude: - - '../core/DependencyInjection/' - - '../core/Entity/' + - '../vendor/murph/murph-core/src/core/DependencyInjection/' + - '../vendor/murph/murph-core/src/core/Entity/' App\Core\EventListener\RedirectListener: tags: @@ -36,11 +36,11 @@ services: - '../src/Tests/' App\Core\Maker\: - resource: '../core/Maker/' + resource: '../vendor/murph/murph-core/src/core/Maker/' tags: ['maker.command'] App\Core\Controller\: - resource: '../core/Controller/' + resource: '../vendor/murph/murph-core/src/core/Controller/' tags: ['controller.service_arguments'] App\Controller\: @@ -58,8 +58,8 @@ services: calls: - [ setAnnotationReader, [ "@annotation_reader" ] ] - App\UrlGenerator\FooUrlGenerator: - public: true + # App\UrlGenerator\FooUrlGenerator: + # public: true # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones diff --git a/core/Analytic/DateRangeAnalytic.php b/core/Analytic/DateRangeAnalytic.php deleted file mode 100644 index 15f46ae..0000000 --- a/core/Analytic/DateRangeAnalytic.php +++ /dev/null @@ -1,204 +0,0 @@ - - */ -class DateRangeAnalytic -{ - protected ViewRepositoryQuery $viewQuery; - protected RefererRepositoryQuery $refererQuery; - protected ?Node $node; - protected ?\DateTime $from; - protected ?\DateTime $to; - protected bool $reload = true; - protected array $cache = []; - - public function __construct(ViewRepositoryQuery $viewQuery, RefererRepositoryQuery $refererQuery) - { - $this->viewQuery = $viewQuery; - $this->refererQuery = $refererQuery; - } - - public function getViews(): array - { - $entities = $this->getEntities('view'); - $this->reload = false; - - if ($entities) { - $first = $entities[0]; - $last = $entities[count($entities) - 1]; - - $diff = $first->getDate()->diff($last->getDate()); - - if ($diff->days >= 90) { - $format = 'Y-m'; - } else { - $format = 'Y-m-d'; - } - } - - $datas = []; - - foreach ($entities as $entity) { - $index = $entity->getDate()->format($format); - - if (!isset($datas[$index])) { - $datas[$index] = 0; - } - - $datas[$index] += $entity->getViews(); - } - - return $datas; - } - - public function getPathViews(): array - { - $entities = $this->getEntities('view'); - $this->reload = false; - - $datas = []; - - foreach ($entities as $entity) { - $index = $entity->getPath(); - - if (!isset($datas[$index])) { - $datas[$index] = [ - 'views' => 0, - 'desktopViews' => 0, - 'mobileViews' => 0, - ]; - } - - $datas[$index]['views'] += $entity->getViews(); - $datas[$index]['desktopViews'] += $entity->getDesktopViews(); - $datas[$index]['mobileViews'] += $entity->getMobileViews(); - } - - uasort($datas, function($a, $b) { - if ($a['views'] > $b['views']) { - return -1; - } - - if ($a['views'] < $b['views']) { - return 1; - } - - return 0; - }); - - return $datas; - } - - public function getReferers(): array - { - $entities = $this->getEntities('referer'); - $this->reload = false; - - $datas = []; - - foreach ($entities as $entity) { - $index = parse_url($entity->getUri(), PHP_URL_HOST); - - if (!isset($datas[$index])) { - $datas[$index] = [ - 'views' => 0, - 'uris' => [], - ]; - } - - $datas[$index]['views'] += $entity->getViews(); - - $path = parse_url($entity->getUri(), PHP_URL_PATH); - - if (empty($path)) { - $path = '/'; - } - - if (!isset($datas[$index]['uris'][$path])) { - $datas[$index]['uris'][$path] = 0; - } - - $datas[$index]['uris'][$path] += $entity->getViews(); - } - - uasort($datas, function($a, $b) { - if ($a['views'] > $b['views']) { - return -1; - } - - if ($a['views'] < $b['views']) { - return 1; - } - - return 0; - }); - - return $datas; - } - - public function setDateRange(?\DateTime $from, ?\DateTime $to): self - { - $this->from = $from; - $this->to = $to; - $this->reload = true; - - return $this; - } - - public function setNode(?Node $node): self - { - $this->node = $node; - $this->reload = true; - - return $this; - } - - protected function getEntities(string $type): array - { - if ('view' === $type) { - $query = $this->viewQuery->create(); - } elseif ('referer' === $type) { - $query = $this->refererQuery->create(); - } else { - throw new \InvalidArgumentException('Invalid type'); - } - - if (!$this->reload && isset($this->cache[$type])) { - return $this->cache[$type]; - } - - if (null !== $this->from) { - $query - ->andWhere('.date >= :from') - ->setParameter(':from', $this->from) - ; - } - - if (null !== $this->to) { - $query - ->andWhere('.date <= :to') - ->setParameter(':to', $this->to) - ; - } - - if (null !== $this->node) { - $query - ->andWhere('.node = :node') - ->setParameter(':node', $this->node->getId()) - ; - } - - $this->cache[$type] = $query->orderBy('.date')->find(); - - return $this->cache[$type]; - } -} diff --git a/core/Annotation/UrlGenerator.php b/core/Annotation/UrlGenerator.php deleted file mode 100644 index c3ebae2..0000000 --- a/core/Annotation/UrlGenerator.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @Annotation - */ -class UrlGenerator -{ - public string $service; - - public string $method; - - public array $options = []; -} diff --git a/core/Authenticator/LoginFormAuthenticator.php b/core/Authenticator/LoginFormAuthenticator.php deleted file mode 100644 index 193c61f..0000000 --- a/core/Authenticator/LoginFormAuthenticator.php +++ /dev/null @@ -1,96 +0,0 @@ -entityManager = $entityManager; - $this->urlGenerator = $urlGenerator; - $this->csrfTokenManager = $csrfTokenManager; - $this->passwordEncoder = $passwordEncoder; - } - - public function supports(Request $request) - { - return 'auth_login' === $request->attributes->get('_route') && $request->isMethod('POST'); - } - - public function getCredentials(Request $request) - { - $credentials = [ - 'email' => $request->request->get('_username'), - 'password' => $request->request->get('_password'), - 'csrf_token' => $request->request->get('_csrf_token'), - ]; - - $request->getSession()->set(Security::LAST_USERNAME, $credentials['email']); - - return $credentials; - } - - public function getUser($credentials, UserProviderInterface $userProvider) - { - $token = new CsrfToken('authenticate', $credentials['csrf_token']); - - if (!$this->csrfTokenManager->isTokenValid($token)) { - throw new InvalidCsrfTokenException(); - } - - $user = $this->entityManager->getRepository(User::class)->findOneBy(['email' => $credentials['email']]); - - if (!$user) { - // fail authentication with a custom error - throw new CustomUserMessageAuthenticationException('Email could not be found.'); - } - - return $user; - } - - public function checkCredentials($credentials, UserInterface $user) - { - return $this->passwordEncoder->isPasswordValid($user, $credentials['password']); - } - - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) - { - if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) { - return new RedirectResponse($targetPath); - } - - return new RedirectResponse($this->urlGenerator->generate('admin_dashboard_index')); - } - - protected function getLoginUrl() - { - return $this->urlGenerator->generate('auth_login'); - } -} diff --git a/core/Bundle/CoreBundle.php b/core/Bundle/CoreBundle.php deleted file mode 100644 index 034a544..0000000 --- a/core/Bundle/CoreBundle.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class SymfonyCacheManager -{ - protected KernelInterface $kernel; - protected HttpClientInterface $httpClient; - protected UrlGeneratorInterface $urlGenerator; - - public function __construct(KernelInterface $kernel, HttpClientInterface $httpClient, UrlGeneratorInterface $urlGenerator) - { - $this->kernel = $kernel; - $this->httpClient = $httpClient; - $this->urlGenerator = $urlGenerator; - } - - public function cleanRouting() - { - $finder = new Finder(); - $finder - ->in($this->kernel->getCacheDir()) - ->depth('== 0') - ->name('url_*.php*') - ; - - $pingUrl = $this->urlGenerator->generate('_ping', [], UrlGeneratorInterface::ABSOLUTE_URL); - - foreach ($finder as $file) { - unlink((string) $file->getPathname()); - } - - try { - // Hack: used to regenerate cache of url generator - $this->httpClient->request('POST', $pingUrl); - } catch (ClientException $e) { - } catch (TransportException $e) { - } - } - - public function cleanAll(OutputInterface $output = null) - { - $application = new Application($this->kernel); - $application->setAutoExit(false); - - if (null === $output) { - $output = new BufferedOutput(); - } - - $input = new ArrayInput([ - 'command' => 'cache:warmup', - '-e' => $this->kernel->getEnvironment(), - ]); - - $application->run($input, $output); - } -} diff --git a/core/Command/UserCreateCommand.php b/core/Command/UserCreateCommand.php deleted file mode 100644 index 598bfaf..0000000 --- a/core/Command/UserCreateCommand.php +++ /dev/null @@ -1,108 +0,0 @@ -userFactory = $userFactory; - $this->entityManager = $entityManager; - $this->tokenGenerator = $tokenGenerator; - - parent::__construct(); - } - - protected function configure() - { - $this - ->setDescription(self::$defaultDescription) - ->addArgument('email', InputArgument::OPTIONAL, 'E-mail') - ->addOption('is-admin', null, InputOption::VALUE_NONE, 'Add the admin role') - ->addOption('is-writer', null, InputOption::VALUE_NONE, 'Add the write role') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = new SymfonyStyle($input, $output); - $helper = $this->getHelper('question'); - - $emailQuestion = new Question('E-mail: '); - $emailQuestion->setValidator(function ($value) { - if (empty($value)) { - throw new \RuntimeException('The email must not be empty.'); - } - - return $value; - }); - - $passwordQuestion = new Question('Password (leave empty to generate a random password): '); - $passwordQuestion->setHidden(true); - - $isAdminDefault = $input->getOption('is-admin'); - $isWriterDefault = $input->getOption('is-writer'); - - $isAdminQuestionLabel = sprintf('Administrator [%s] ', $isAdminDefault ? 'Y/n' : 'y/N'); - $isWriterQuestionLabel = sprintf('Writer [%s] ', $isWriterDefault ? 'Y/n' : 'y/N'); - - $isAdminQuestion = new ConfirmationQuestion($isAdminQuestionLabel, $isAdminDefault); - $isWriterQuestion = new ConfirmationQuestion($isWriterQuestionLabel, $isWriterDefault); - - $io->section('Authentication'); - - $email = $input->getArgument('email'); - - if (empty($email)) { - $email = $helper->ask($input, $output, $emailQuestion); - } - - $password = $helper->ask($input, $output, $passwordQuestion); - - $showPassword = empty($password); - - if ($showPassword) { - $password = mb_substr($this->tokenGenerator->generateToken(), 0, 18); - $io->info(sprintf('Password: %s', $password)); - } else { - $io->newLine(); - } - - $io->section('Roles'); - - $isAdmin = $helper->ask($input, $output, $isAdminQuestion); - $isWriter = $helper->ask($input, $output, $isWriterQuestion); - - $user = $this->userFactory->create($email, $password); - $user->setIsAdmin($isAdmin); - $user->setIsWriter($isWriter); - - $this->entityManager->create($user); - - $io->newLine(); - $io->success('User created!'); - - return Command::SUCCESS; - } -} diff --git a/core/Controller/.gitignore b/core/Controller/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/core/Controller/Account/AccountAdminController.php b/core/Controller/Account/AccountAdminController.php deleted file mode 100644 index 5ea4b6e..0000000 --- a/core/Controller/Account/AccountAdminController.php +++ /dev/null @@ -1,150 +0,0 @@ -getUser(); - - return $this->render('@Core/account/admin/edit.html.twig', [ - 'account' => $account, - ]); - } - - /** - * @Route("/2fa", name="admin_account_2fa") - */ - public function twoFactorAuthentication( - Request $request, - GoogleAuthenticatorInterface $totpAuthenticatorService, - EntityManager $entityManager - ): Response { - if ($request->isMethod('GET')) { - return $this->redirectToRoute('admin_account'); - } - - $account = $this->getUser(); - $csrfToken = $request->request->get('_csrf_token'); - $enable = (bool) $request->request->get('enable'); - $code = $request->request->get('code', ''); - $secret = $request->request->get('secret', ''); - $qrCodeContent = null; - - if ($this->isCsrfTokenValid('2fa', $csrfToken)) { - if ($enable && !$account->isTotpAuthenticationEnabled()) { - if (empty($secret)) { - $secret = $totpAuthenticatorService->generateSecret(); - - $account->setTotpSecret($secret); - - $qrCodeContent = $totpAuthenticatorService->getQRContent($account); - } else { - $account->setTotpSecret($secret); - - $qrCodeContent = $totpAuthenticatorService->getQRContent($account); - - if (!$totpAuthenticatorService->checkCode($account, $code)) { - $this->addFlash('error', 'The code is not valid.'); - } else { - $this->addFlash('success', 'Double authentication enabled.'); - - $entityManager->update($account); - - return $this->redirectToRoute('admin_account'); - } - } - } - - if (!$enable && $account->isTotpAuthenticationEnabled()) { - $account->setTotpSecret(null); - - $entityManager->update($account); - - $this->addFlash('success', 'Double authentication disabled.'); - - return $this->redirectToRoute('admin_account'); - } - } - - return $this->render('@Core/account/admin/edit.html.twig', [ - 'account' => $account, - 'twoFaKey' => $secret, - 'twoFaQrCodeContent' => $qrCodeContent, - ]); - } - - /** - * @Route("/password", name="admin_account_password", methods={"POST"}) - */ - public function password( - Request $request, - UserRepository $repository, - TokenGeneratorInterface $tokenGenerator, - UserPasswordEncoderInterface $encoder, - EntityManager $entityManager - ): Response { - $account = $this->getUser(); - $csrfToken = $request->request->get('_csrf_token'); - - if ($this->isCsrfTokenValid('password', $csrfToken)) { - $password = $request->request->get('password'); - - if (!$encoder->isPasswordValid($account, $password)) { - $this->addFlash('error', 'The form is not valid.'); - - return $this->redirectToRoute('admin_account'); - } - - $password1 = $request->request->get('password1'); - $password2 = $request->request->get('password2'); - - $zxcvbn = new Zxcvbn(); - $strength = $zxcvbn->passwordStrength($password1, []); - - if (4 === $strength['score'] && $password1 === $password2) { - $account - ->setPassword($encoder->encodePassword($account, $password1)) - ->setConfirmationToken($tokenGenerator->generateToken()) - ; - - $entityManager->update($account); - - $this->addFlash('success', 'Password updated.'); - - return $this->redirectToRoute('admin_account'); - } - } - - $this->addFlash('error', 'The form is not valid.'); - - return $this->redirectToRoute('admin_account'); - } - - /** - * {@inheritdoc} - */ - protected function getSection(): string - { - return 'account'; - } -} diff --git a/core/Controller/Admin/AdminController.php b/core/Controller/Admin/AdminController.php deleted file mode 100644 index 2b18a27..0000000 --- a/core/Controller/Admin/AdminController.php +++ /dev/null @@ -1,41 +0,0 @@ -coreParameters = $parameters->get('core'); - } - - /** - * @Route("/_ping", name="_ping") - */ - public function ping() - { - return $this->json(true); - } - - /** - * {@inheritdoc} - */ - protected function render(string $view, array $parameters = [], Response $response = null): Response - { - $parameters['section'] = $this->getSection(); - $parameters['site_name'] = $this->coreParameters['site']['name']; - $parameters['site_logo'] = $this->coreParameters['site']['logo']; - $parameters['murph_version'] = defined('MURPH_VERSION') ? MURPH_VERSION : null; - - return parent::render($view, $parameters, $response); - } - - abstract protected function getSection(): string; -} diff --git a/core/Controller/Admin/Crud/CrudController.php b/core/Controller/Admin/Crud/CrudController.php deleted file mode 100644 index 57f6688..0000000 --- a/core/Controller/Admin/Crud/CrudController.php +++ /dev/null @@ -1,342 +0,0 @@ - - */ -abstract class CrudController extends AdminController -{ - protected array $filters = []; - protected array $sort = [ - 'label' => null, - 'direction' => null, - ]; - - abstract protected function getConfiguration(): CrudConfiguration; - - protected function doIndex(int $page = 1, RepositoryQuery $query, Request $request, Session $session): Response - { - $configuration = $this->getConfiguration(); - - $this->applySort('index', $query, $request); - $this->updateFilters($request, $session); - - $pager = $query - ->usefilters($this->filters) - ->paginate($page, $configuration->getmaxperpage('index')) - ; - - return $this->render($this->getConfiguration()->getView('index'), [ - 'configuration' => $configuration, - 'pager' => $pager, - 'sort' => $this->sort, - 'filters' => [ - 'show' => null !== $configuration->getForm('filter'), - 'isEmpty' => empty($this->filters), - ], - ]); - } - - protected function doNew(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeCreate = null): Response - { - $configuration = $this->getConfiguration(); - - $this->prepareEntity($entity); - - $form = $this->createForm($configuration->getForm('new'), $entity, $configuration->getFormOptions('new')); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - if (null !== $beforeCreate) { - call_user_func_array($beforeCreate, [$entity, $form, $request]); - } - - $entityManager->create($entity); - $this->addFlash('success', 'The data has been saved.'); - - return $this->redirectToRoute($configuration->getPageRoute('edit'), array_merge( - ['entity' => $entity->getId()], - $configuration->getPageRouteParams('edit') - )); - } - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->render($configuration->getView('new'), [ - 'form' => $form->createView(), - 'configuration' => $configuration, - 'entity' => $entity, - ]); - } - - protected function doShow(EntityInterface $entity): Response - { - $configuration = $this->getConfiguration(); - - return $this->render($configuration->getView('show'), [ - 'entity' => $entity, - 'configuration' => $configuration, - ]); - } - - protected function doEdit(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null): Response - { - $configuration = $this->getConfiguration(); - - $this->prepareEntity($entity); - - $form = $this->createForm($configuration->getForm('edit'), $entity, $configuration->getFormOptions('edit')); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - if (null !== $beforeUpdate) { - call_user_func_array($beforeUpdate, [$entity, $form, $request]); - } - - $entityManager->update($entity); - $this->addFlash('success', 'The data has been saved.'); - - return $this->redirectToRoute($configuration->getPageRoute('edit'), array_merge( - ['entity' => $entity->getId()], - $configuration->getPageRouteParams('edit') - )); - } - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->render($configuration->getView('edit'), [ - 'form' => $form->createView(), - 'configuration' => $configuration, - 'entity' => $entity, - ]); - } - - protected function doSort(int $page = 1, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response - { - $configuration = $this->getConfiguration(); - $context = $request->query->get('context', 'index'); - - if (!$configuration->getIsSortableCollection($context)) { - throw $this->createNotFoundException(); - } - - $this->applySort($context, $query, $request); - $this->updateFilters($request, $session); - - $pager = $query - ->useFilters($this->filters) - ->paginate($page, $configuration->getMaxPerPage($context)) - ; - - if ($this->isCsrfTokenValid('sort', $request->query->get('_token'))) { - $items = $request->request->get('items', []); - $setter = 'set'.$configuration->getSortableCollectionProperty(); - $orderStart = ($page - 1) * $configuration->getMaxPerPage($context); - - foreach ($pager as $key => $entity) { - if (isset($items[$key + 1])) { - $entity->{$setter}($items[$key + 1] + $orderStart); - - $entityManager->update($entity); - } - } - - $this->addFlash('success', 'The data has been saved.'); - } else { - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->json([]); - } - - protected function doBatch(int $page = 1, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response - { - $configuration = $this->getConfiguration(); - $datas = $request->request->get('batch', []); - - $context = $datas['context'] ?? 'index'; - $target = $datas['target'] ?? null; - $action = $datas['action'] ?? null; - $token = $datas['_token'] ?? null; - $items = $datas['items'] ?? []; - $batchAction = $configuration->getBatchAction($context, $action); - - if (empty($context) || empty($action) || empty($target)) { - return $this->json([]); - } - - if (!$this->isCsrfTokenValid('batch', $token) || empty($batchAction)) { - $this->addFlash('warning', 'The form is not valid.'); - - return $this->json([]); - } - - $callback = $batchAction['callback']; - - $this->applySort($context, $query, $request); - $this->updateFilters($request, $session); - - $query->useFilters($this->filters); - - if ('selection' === $target) { - $isSelection = true; - $pager = $query->paginate($page, $configuration->getMaxPerPage($context)); - } else { - $isSelection = false; - $pager = $query->find(); - } - - foreach ($pager as $key => $entity) { - if (($isSelection && isset($items[$key + 1])) || !$isSelection) { - $callback($entity, $entityManager); - } - } - - $this->addFlash('success', 'Batch action done.'); - - return $this->json([]); - } - - protected function doDelete(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeDelete = null): Response - { - $configuration = $this->getConfiguration(); - - if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) { - if (null !== $beforeDelete) { - call_user_func($beforeDelete, $entity); - } - - $entityManager->delete($entity); - - $this->addFlash('success', 'The data has been removed.'); - } - - return $this->redirectToRoute($configuration->getPageRoute('index')); - } - - protected function doFilter(Session $session): Response - { - $configuration = $this->getConfiguration(); - $type = $configuration->getForm('filter'); - - if (null === $type) { - throw $this->createNotFoundException(); - } - - $form = $this->createForm($type); - $form->submit($session->get($form->getName(), [])); - - return $this->render($configuration->getView('filter'), [ - 'form' => $form->createView(), - 'configuration' => $configuration, - ]); - } - - protected function updateFilters(Request $request, Session $session) - { - $configuration = $this->getConfiguration(); - $type = $configuration->getForm('filter'); - - if (null === $type) { - return; - } - - $form = $this->createForm($type); - - if ($request->query->has($form->getName())) { - $filters = $request->query->get($form->getName()); - - if ('0' === $filters) { - $filters = []; - } - } elseif ($session->has($form->getName())) { - $filters = $session->get($form->getName()); - } else { - $filters = []; - } - - $form->submit($filters); - - if (empty($filters)) { - $this->filters = $filters; - $session->set($form->getName(), $filters); - } elseif ($form->isValid()) { - $this->filters = $form->getData(); - $session->set($form->getName(), $filters); - } - } - - protected function prepareEntity(EntityInterface $entity) - { - $configuration = $this->getConfiguration(); - - if ($configuration->isI18n()) { - foreach ($configuration->getLocales() as $locale) { - $entity->addTranslation($entity->translate($locale, false)); - } - } - } - - protected function applySort(string $context, RepositoryQuery $query, Request $request) - { - $configuration = $this->getConfiguration(); - - if ($configuration->getIsSortableCollection($context)) { - $query->orderBy(sprintf('.%s', $configuration->getSortableCollectionProperty())); - - return; - } - - $defaultSort = $configuration->getDefaultSort($context); - - $name = $request->query->get('_sort', $defaultSort['label'] ?? null); - $direction = strtolower($request->query->get('_sort_direction', $defaultSort['direction'] ?? 'asc')); - - if (!in_array($direction, ['asc', 'desc'])) { - $direction = 'asc'; - } - - foreach ($configuration->getFields($context) as $label => $field) { - $sortOption = $field['options']['sort'] ?? null; - - if (null === $sortOption) { - continue; - } - - if ($sortOption[0] !== $name) { - continue; - } - - $sorter = $sortOption[1]; - - if (is_string($sorter)) { - $query->orderBy($sorter, $direction); - } else { - call_user_func_array($sorter, [$query, $direction]); - } - - $this->sort = [ - 'label' => $label, - 'direction' => $direction, - ]; - - return; - } - } -} diff --git a/core/Controller/Analytic/AnalyticController.php b/core/Controller/Analytic/AnalyticController.php deleted file mode 100644 index 6d2fd88..0000000 --- a/core/Controller/Analytic/AnalyticController.php +++ /dev/null @@ -1,38 +0,0 @@ -createNotFoundException(); - } - - $analytic - ->setDateRange(new \DateTime('now - '.$range), new \DateTime()) - ->setNode($node) - ; - - return $this->render('@Core/analytic/stats.html.twig', [ - 'range' => $range, - 'views' => $analytic->getViews(), - 'pathViews' => $analytic->getPathViews(), - 'referers' => $analytic->getReferers(), - 'node' => $node, - ]); - } -} diff --git a/core/Controller/Auth/AuthController.php b/core/Controller/Auth/AuthController.php deleted file mode 100644 index 054ce3a..0000000 --- a/core/Controller/Auth/AuthController.php +++ /dev/null @@ -1,155 +0,0 @@ -coreParameters = $parameters->get('core'); - } - - /** - * @Route("/login", name="auth_login") - */ - public function login(AuthenticationUtils $authenticationUtils): Response - { - if ($this->getUser()) { - return $this->redirectToRoute('admin_dashboard_index'); - } - - $error = $authenticationUtils->getLastAuthenticationError(); - $lastUsername = $authenticationUtils->getLastUsername(); - - return $this->render('@Core/auth/login.html.twig', [ - 'last_username' => $lastUsername, - 'error' => $error, - 'site_name' => $this->coreParameters['site']['name'], - 'site_logo' => $this->coreParameters['site']['logo'], - ]); - } - - /** - * @Route("/resetting/request", name="auth_resetting_request") - */ - public function requestResetting(Request $request, UserRepository $repository, EventDispatcherInterface $eventDispatcher): Response - { - if ($this->getUser()) { - return $this->redirectToRoute('admin_dashboard_index'); - } - - if ($request->isMethod('POST')) { - $csrfToken = $request->request->get('_csrf_token'); - - if (!$this->isCsrfTokenValid('resetting_request', $csrfToken)) { - throw $this->createAccessDeniedException(); - } - - $username = trim((string) $request->request->get('username')); - - if (!$username) { - throw $this->createAccessDeniedException(); - } - - $account = $repository->findOneByEmail($username); - - if ($account) { - $requestedAt = $account->getPasswordRequestedAt(); - - if (null === $requestedAt || $requestedAt->getTimestamp() < (time() - 3600 / 2)) { - $eventDispatcher->dispatch(new PasswordRequestEvent($account), PasswordRequestEvent::EVENT); - } - } - } - - return $this->render('@Core/auth/resetting_request.html.twig', [ - 'email_sent' => $request->isMethod('POST'), - 'site_name' => $this->coreParameters['site']['name'], - 'site_logo' => $this->coreParameters['site']['logo'], - ]); - } - - /** - * @Route("/resetting/update/{token}", name="auth_resetting_update") - */ - public function requestUpdate( - string $token, - Request $request, - UserRepository $repository, - TokenGeneratorInterface $tokenGenerator, - UserPasswordEncoderInterface $encoder, - EntityManager $entityManager - ): Response { - if ($this->getUser()) { - return $this->redirectToRoute('admin_dashboard_index'); - } - - $account = $repository->findOneByConfirmationToken($token); - $passwordUpdated = false; - $expired = true; - - if ($account) { - $requestedAt = $account->getPasswordRequestedAt(); - $expired = (null === $requestedAt || ($requestedAt->getTimestamp() < (time() - 3600 * 2))); - } - - if ($request->isMethod('POST') && !$expired) { - $csrfToken = $request->request->get('_csrf_token'); - - if ($this->isCsrfTokenValid('resetting_update', $csrfToken)) { - $password = $request->request->get('password'); - $password2 = $request->request->get('password2'); - - $zxcvbn = new Zxcvbn(); - $strength = $zxcvbn->passwordStrength($password, []); - - if (4 === $strength['score'] && $password === $password2) { - $account - ->setPassword($encoder->encodePassword( - $account, - $password - )) - ->setConfirmationToken($tokenGenerator->generateToken()) - ->setPasswordRequestedAt(new \DateTime('now')) - ; - - $entityManager->update($account); - - $passwordUpdated = true; - } - } - } - - return $this->render('@Core/auth/resetting_update.html.twig', [ - 'password_updated' => $passwordUpdated, - 'token' => $token, - 'expired' => $expired, - 'site_name' => $this->coreParameters['site']['name'], - 'site_logo' => $this->coreParameters['site']['logo'], - ]); - } - - /** - * @Route("/logout", name="auth_logout") - */ - public function logout() - { - throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall'); - } -} diff --git a/core/Controller/Dashboard/DashboardAdminController.php b/core/Controller/Dashboard/DashboardAdminController.php deleted file mode 100644 index eb33ba8..0000000 --- a/core/Controller/Dashboard/DashboardAdminController.php +++ /dev/null @@ -1,27 +0,0 @@ -render('@Core/dashboard/index.html.twig', [ - ]); - } - - protected function getSection(): string - { - return 'dashboard'; - } -} diff --git a/core/Controller/FileManager/FileManagerAdminController.php b/core/Controller/FileManager/FileManagerAdminController.php deleted file mode 100644 index ff768b2..0000000 --- a/core/Controller/FileManager/FileManagerAdminController.php +++ /dev/null @@ -1,438 +0,0 @@ -render('@Core/file_manager/index.html.twig'); - } - - /** - * @Route("/api/directory", name="admin_file_manager_api_directory", options={"expose"=true}) - */ - public function directory(FsFileManager $manager, Request $request): Response - { - $options = [ - 'sort' => $request->query->get('_sort', 'name'), - 'sort_direction' => $request->query->get('_sort_direction', 'asc'), - ]; - - $files = $manager->list($request->query->get('directory', '/'), $options); - - return $this->json($files); - } - - /** - * @Route("/info/{tab}/{context}/{ajax}", name="admin_file_manager_info", options={"expose"=true}) - */ - public function info( - FsFileManager $manager, - Request $request, - EntityManager $entityManager, - TranslatorInterface $translator, - string $context = 'crud', - string $tab = 'information', - bool $ajax = false - ): Response { - $splInfo = $manager->getSplInfo($request->query->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - $fileInfo = $manager->getFileInformation($request->query->get('file')); - $path = $manager->getPathUri().'/'.$splInfo->getRelativePathname(); - - $form = $this->createForm(FileInformationType::class, $fileInfo); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $entityManager->update($fileInfo); - - if (!$request->isXmlHttpRequest()) { - $this->addFlash('success', 'The data has been saved.'); - } else { - return $this->json([ - '_error' => 0, - '_message' => $translator->trans('The data has been saved.'), - '_level' => 'success', - '_dispatch' => 'file_manager.info.update.success', - ]); - } - } else { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('warning', 'The form is not valid.'); - } else { - return $this->json([ - '_error' => 1, - '_message' => $translator->trans('The form is not valid.'), - '_level' => 'warning', - '_dispatch' => 'file_manager.info.update.error', - ]); - } - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'data-modal' => $this->generateUrl('admin_file_manager_info', [ - 'file' => $request->query->get('file'), - 'tab' => 'attributes', - ]), - 'path' => $splInfo->getRelativePath(), - ]); - } - - return $this->render('@Core/file_manager/info.html.twig', [ - 'splInfo' => $splInfo, - 'path' => $path, - 'isLocked' => $manager->isLocked($splInfo->getRelativePathname()), - 'tab' => $tab, - 'form' => $form->createView(), - 'context' => $context, - 'ajax' => $ajax, - ]); - } - - /** - * @Route("/directory/new/{ajax}", name="admin_file_manager_directory_new", options={"expose"=true}, methods={"GET", "POST"}) - */ - public function directoryNew(FsFileManager $manager, Request $request, TranslatorInterface $translator, bool $ajax = false): Response - { - $splInfo = $manager->getSplInfo($request->query->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - if (!$splInfo->isDir()) { - throw $this->createNotFoundException(); - } - - if ($manager->isLocked($request->query->get('file'))) { - return $this->render('@Core/file_manager/directory_new.html.twig', [ - 'locked' => true, - ]); - } - - $form = $this->createForm(DirectoryCreateType::class); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $status = $manager->createDirectory($form->get('name')->getData(), $request->query->get('file')); - - if (true === $status) { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('success', 'Directory created.'); - } else { - return $this->json([ - '_error' => 0, - '_message' => $translator->trans('Directory created.'), - '_level' => 'success', - '_dispatch' => 'file_manager.directory.new.success', - ]); - } - } else { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('warning', 'Directory not created.'); - } else { - return $this->json([ - '_error' => 1, - '_message' => $translator->trans('Directory not created.'), - '_level' => 'warning', - '_dispatch' => 'file_manager.directory.new.error', - ]); - } - } - } else { - $this->addFlash('warning', 'Unauthorized char(s).'); - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'path' => $splInfo->getRelativePathname(), - ]); - } - - return $this->render('@Core/file_manager/directory_new.html.twig', [ - 'form' => $form->createView(), - 'file' => $request->query->get('file'), - 'ajax' => $ajax, - 'locked' => false, - ]); - } - - /** - * @Route("/directory/rename/{ajax}", name="admin_file_manager_directory_rename", methods={"GET", "POST"}) - */ - public function directoryRename(FsFileManager $manager, Request $request, TranslatorInterface $translator, bool $ajax = false): Response - { - $splInfo = $manager->getSplInfo($request->query->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - if (!$splInfo->isDir()) { - throw $this->createNotFoundException(); - } - - if ($manager->isLocked($request->query->get('file'))) { - return $this->render('@Core/file_manager/directory_rename.html.twig', [ - 'locked' => true, - ]); - } - - $form = $this->createForm(DirectoryRenameType::class, [ - 'name' => $splInfo->getFilename(), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $status = $manager->renameDirectory($form->get('name')->getData(), $request->query->get('file')); - - if (true === $status) { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('success', 'Directory renamed.'); - } else { - return $this->json([ - '_error' => 0, - '_message' => $translator->trans('Directory renamed.'), - '_level' => 'success', - '_dispatch' => 'file_manager.directory.rename.success', - ]); - } - } else { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('warning', 'Directory not renamed.'); - } else { - return $this->json([ - '_error' => 1, - '_message' => $translator->trans('Directory not renamed.'), - '_level' => 'warning', - '_dispatch' => 'file_manager.directory.rename.error', - ]); - } - } - } else { - $this->addFlash('warning', 'Unauthorized char(s).'); - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'path' => $splInfo->getRelativePath(), - ]); - } - - return $this->render('@Core/file_manager/directory_rename.html.twig', [ - 'form' => $form->createView(), - 'file' => $request->query->get('file'), - 'locked' => false, - 'ajax' => $ajax, - ]); - } - - /** - * @Route("/file/rename/{ajax}", name="admin_file_manager_file_rename", methods={"GET", "POST"}) - */ - public function fileRename(FsFileManager $manager, Request $request, TranslatorInterface $translator, bool $ajax = false): Response - { - $splInfo = $manager->getSplInfo($request->query->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - if ($splInfo->isDir()) { - throw $this->createNotFoundException(); - } - - if ($manager->isLocked($request->query->get('file'))) { - return $this->render('@Core/file_manager/file_rename.html.twig', [ - 'locked' => true, - ]); - } - - $form = $this->createForm(FileRenameType::class, [ - 'name' => preg_replace(sprintf('/\.%s/', $splInfo->getExtension()), '', $splInfo->getFilename()), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $status = $manager->renameFile($form->get('name')->getData(), $request->query->get('file')); - - if (true === $status) { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('success', 'File renamed.'); - } else { - return $this->json([ - '_error' => 0, - '_message' => $translator->trans('File renamed.'), - '_level' => 'success', - '_dispatch' => 'file_manager.file.rename.success', - ]); - } - } else { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('warning', 'File not renamed.'); - } else { - return $this->json([ - '_error' => 1, - '_message' => $translator->trans('File not renamed.'), - '_level' => 'warning', - '_dispatch' => 'file_manager.file.rename.error', - ]); - } - } - } else { - $this->addFlash('warning', 'Unauthorized char(s).'); - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'path' => $splInfo->getRelativePath(), - ]); - } - - return $this->render('@Core/file_manager/file_rename.html.twig', [ - 'form' => $form->createView(), - 'file' => $request->query->get('file'), - 'exention' => $splInfo->getExtension(), - 'locked' => false, - 'ajax' => $ajax, - ]); - } - - /** - * @Route("/upload/{ajax}", name="admin_file_manager_upload", options={"expose"=true}, methods={"GET", "POST"}) - */ - public function upload(FsFileManager $manager, Request $request, TranslatorInterface $translator, bool $ajax = false): Response - { - $splInfo = $manager->getSplInfo($request->query->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - if (!$splInfo->isDir()) { - throw $this->createAccessDeniedException(); - } - - if ($manager->isLocked($request->query->get('file'))) { - return $this->render('@Core/file_manager/upload.html.twig', [ - 'locked' => true, - ]); - } - $form = $this->createForm(FileUploadType::class, null, [ - 'mimes' => $manager->getMimes(), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - if ($form->get('files')->getData()) { - $manager->upload( - $form->get('files')->getData(), - $request->query->get('file') - ); - } - - if ($form->get('directory')->getData()) { - $manager->upload( - $form->get('directory')->getData(), - $request->query->get('file'), - $_FILES['file_upload']['full_path']['directory'] ?? [] - ); - } - - if (!$request->isXmlHttpRequest()) { - $this->addFlash('success', 'Files uploaded.'); - } else { - return $this->json([ - '_error' => 0, - '_message' => $translator->trans('Files uploaded.'), - '_level' => 'success', - '_dispatch' => 'file_manager.file.new.success', - ]); - } - } else { - if (!$request->isXmlHttpRequest()) { - $this->addFlash('warning', 'Unauthorized file type(s).'); - } else { - return $this->json([ - '_error' => 1, - '_message' => $translator->trans('Unauthorized file type(s).'), - '_level' => 'warning', - '_dispatch' => 'file_manager.file.new.error', - ]); - } - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'path' => $splInfo->getRelativePathname(), - ]); - } - - return $this->render('@Core/file_manager/upload.html.twig', [ - 'form' => $form->createView(), - 'file' => $request->query->get('file'), - 'locked' => false, - 'ajax' => $ajax, - ]); - } - - /** - * @Route("/delete", name="admin_file_manager_delete", methods={"DELETE"}) - */ - public function delete(FsFileManager $manager, Request $request): Response - { - $path = $request->request->get('file'); - $splInfo = $manager->getSplInfo($request->request->get('file')); - - if (!$splInfo) { - throw $this->createNotFoundException(); - } - - if ($this->isCsrfTokenValid('delete', $request->request->get('_token'))) { - if ($manager->delete($path)) { - $this->addFlash('success', 'The data has been removed.'); - } else { - $this->addFlash('warning', 'The data has not been removed.'); - } - } - - return $this->redirectToRoute('admin_file_manager_index', [ - 'path' => $splInfo->getRelativePath(), - ]); - } - - protected function getSection(): string - { - return 'file_manager'; - } -} diff --git a/core/Controller/Redirect/RedirectAdminController.php b/core/Controller/Redirect/RedirectAdminController.php deleted file mode 100644 index 2916a3c..0000000 --- a/core/Controller/Redirect/RedirectAdminController.php +++ /dev/null @@ -1,154 +0,0 @@ -doIndex($page, $query, $request, $session); - } - - /** - * @Route("/admin/redirect/new", name="admin_redirect_new", methods={"GET", "POST"}) - */ - public function new(Factory $factory, EntityManager $entityManager, Request $request): Response - { - return $this->doNew($factory->create(), $entityManager, $request); - } - - /** - * @Route("/admin/redirect/show/{entity}", name="admin_redirect_show", methods={"GET"}) - */ - public function show(Entity $entity): Response - { - return $this->doShow($entity); - } - - /** - * @Route("/admin/redirect/filter", name="admin_redirect_filter", methods={"GET"}) - */ - public function filter(Session $session): Response - { - return $this->doFilter($session); - } - - /** - * @Route("/admin/redirect/edit/{entity}", name="admin_redirect_edit", methods={"GET", "POST"}) - */ - public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doEdit($entity, $entityManager, $request); - } - - /** - * @Route("/admin/redirect/sort/{page}", name="admin_redirect_sort", methods={"POST"}, requirements={"page":"\d+"}) - */ - public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response - { - return $this->doSort($page, $query, $entityManager, $request, $session); - } - - /** - * @Route("/admin/redirect/batch/{page}", name="admin_redirect_batch", methods={"POST"}, requirements={"page":"\d+"}) - */ - public function batch(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response - { - return $this->doBatch($page, $query, $entityManager, $request, $session); - } - - /** - * @Route("/admin/redirect/delete/{entity}", name="admin_redirect_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doDelete($entity, $entityManager, $request); - } - - protected function getConfiguration(): CrudConfiguration - { - return CrudConfiguration::create() - ->setPageTitle('index', 'Redirects') - ->setPageTitle('edit', '{label}') - ->setPageTitle('new', 'New redirect') - - ->setPageRoute('index', 'admin_redirect_index') - ->setPageRoute('new', 'admin_redirect_new') - ->setPageRoute('edit', 'admin_redirect_edit') - ->setPageRoute('sort', 'admin_redirect_sort') - ->setPageRoute('batch', 'admin_redirect_batch') - ->setPageRoute('delete', 'admin_redirect_delete') - ->setPageRoute('filter', 'admin_redirect_filter') - - ->setForm('edit', Type::class, []) - ->setForm('new', Type::class) - ->setForm('filter', FilterType::class) - - ->setView('form', '@Core/redirect/redirect_admin/_form.html.twig') - ->setMaxPerPage('index', 100) - ->setIsSortableCollection('index', true) - - ->setAction('index', 'show', false) - ->setAction('edit', 'show', false) - - ->setField('index', 'Label', Field\TextField::class, [ - 'property' => 'label', - 'attr' => ['class' => 'col-4'], - ]) - ->setField('index', 'Rule', Field\TextField::class, [ - 'view' => '@Core/redirect/redirect_admin/field/rule.html.twig', - 'attr' => ['class' => 'col-6'], - ]) - ->setField('index', 'Enabled', Field\ButtonField::class, [ - 'property_builder' => function(EntityInterface $entity) { - return $entity->getIsEnabled() ? 'Yes' : 'No'; - }, - 'attr' => ['class' => 'col-1'], - 'button_attr_builder' => function(EntityInterface $entity) { - return ['class' => 'btn btn-sm btn-'.($entity->getIsEnabled() ? 'success' : 'primary')]; - }, - ]) - ->setField('index', 'Type', Field\ButtonField::class, [ - 'property' => 'redirectCode', - 'attr' => ['class' => 'col-1'], - 'button_attr' => ['class' => 'btn btn-sm btn-light border-secondary font-weight-bold'], - ]) - ->setBatchAction('index', 'enable', 'Enable', function (EntityInterface $entity, EntityManager $manager) { - $entity->setIsEnabled(true); - - $manager->update($entity); - }) - ->setBatchAction('index', 'disable', 'Disable', function (EntityInterface $entity, EntityManager $manager) { - $entity->setIsEnabled(false); - - $manager->update($entity); - }) - ->setBatchAction('index', 'delete', 'Delete', function (EntityInterface $entity, EntityManager $manager) { - $manager->delete($entity); - }) - ; - } - - protected function getSection(): string - { - return 'site_navigation'; - } -} diff --git a/core/Controller/Setting/NavigationSettingAdminController.php b/core/Controller/Setting/NavigationSettingAdminController.php deleted file mode 100644 index 24ecca0..0000000 --- a/core/Controller/Setting/NavigationSettingAdminController.php +++ /dev/null @@ -1,81 +0,0 @@ -createFormBuilder($entity); - $event = new NavigationSettingEvent([ - 'builder' => $builder, - 'entity' => $entity, - 'options' => [], - ]); - - $eventDispatcher->dispatch($event, NavigationSettingEvent::FORM_INIT_EVENT); - - $form = $builder->getForm(); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $entityManager->update($entity); - $this->addFlash('success', 'The data has been saved.'); - - return $this->redirectToRoute('admin_site_navigation_show', [ - 'entity' => $entity->getNavigation()->getId(), - ]); - } - - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->render('@Core/setting/navigation_setting_admin/edit.html.twig', [ - 'form' => $form->createView(), - 'entity' => $entity, - 'options' => $event->getData()['options'], - ]); - } - - /** - * @Route("/delete/{entity}", name="admin_navigation_setting_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) { - $entityManager->delete($entity); - - $this->addFlash('success', 'The data has been removed.'); - } - - return $this->redirectToRoute('admin_site_navigation_show', [ - 'entity' => $entity->getNavigation()->getId(), - ]); - } - - public function getSection(): string - { - return ''; - } -} diff --git a/core/Controller/Setting/SettingAdminController.php b/core/Controller/Setting/SettingAdminController.php deleted file mode 100644 index afcb82e..0000000 --- a/core/Controller/Setting/SettingAdminController.php +++ /dev/null @@ -1,99 +0,0 @@ -dispatch(new SettingEvent(), SettingEvent::INIT_EVENT); - - $pager = $query - ->orderBy('.section, .label') - ->paginate($page) - ; - - return $this->render('@Core/setting/setting_admin/index.html.twig', [ - 'pager' => $pager, - ]); - } - - /** - * @Route("/edit/{entity}", name="admin_setting_edit") - */ - public function edit( - Entity $entity, - EntityManager $entityManager, - EventDispatcherInterface $eventDispatcher, - Request $request - ): Response { - $builder = $this->createFormBuilder($entity); - $event = new SettingEvent([ - 'builder' => $builder, - 'entity' => $entity, - 'options' => [], - ]); - - $eventDispatcher->dispatch($event, SettingEvent::FORM_INIT_EVENT); - - $form = $builder->getForm(); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $entityManager->update($entity); - $this->addFlash('success', 'The data has been saved.'); - - return $this->redirectToRoute('admin_setting_index'); - } - - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->render('@Core/setting/setting_admin/edit.html.twig', [ - 'form' => $form->createView(), - 'entity' => $entity, - 'options' => $event->getData()['options'], - ]); - } - - /** - * @Route("/delete/{entity}", name="admin_setting_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) { - $entityManager->delete($entity); - - $this->addFlash('success', 'The data has been removed.'); - } - - return $this->redirectToRoute('admin_setting_index'); - } - - public function getSection(): string - { - return 'setting'; - } -} diff --git a/core/Controller/Site/MenuAdminController.php b/core/Controller/Site/MenuAdminController.php deleted file mode 100644 index a542434..0000000 --- a/core/Controller/Site/MenuAdminController.php +++ /dev/null @@ -1,82 +0,0 @@ -create($navigation); - $form = $this->createForm(EntityType::class, $entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $entityManager->create($entity); - - $this->addFlash('success', 'The data has been saved.'); - } else { - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->redirectToRoute('admin_site_tree_navigation', [ - 'navigation' => $navigation->getId(), - ]); - } - - /** - * @Route("/edit/{entity}", name="admin_site_menu_edit", methods={"POST"}) - */ - public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response - { - $form = $this->createForm(EntityType::class, $entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $entityManager->update($entity); - $this->addFlash('success', 'The data has been saved.'); - } else { - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->redirectToRoute('admin_site_tree_navigation', [ - 'navigation' => $entity->getNavigation()->getId(), - ]); - } - - /** - * @Route("/delete/{entity}", name="admin_site_menu_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) { - $entityManager->delete($entity); - - $this->addFlash('success', 'The data has been removed.'); - } - - return $this->redirectToRoute('admin_site_tree_navigation', [ - 'navigation' => $entity->getNavigation()->getId(), - ]); - } - - public function getSection(): string - { - return ''; - } -} diff --git a/core/Controller/Site/NavigationAdminController.php b/core/Controller/Site/NavigationAdminController.php deleted file mode 100644 index b1676d8..0000000 --- a/core/Controller/Site/NavigationAdminController.php +++ /dev/null @@ -1,142 +0,0 @@ -doIndex($page, $query, $request, $session); - } - - /** - * @Route("/admin/site/navigation/new", name="admin_site_navigation_new", methods={"GET", "POST"}) - */ - public function new(Factory $factory, EntityManager $entityManager, Request $request): Response - { - return $this->doNew($factory->create(), $entityManager, $request); - } - - /** - * @Route("/admin/site/navigation/show/{entity}", name="admin_site_navigation_show", methods={"GET"}) - */ - public function show( - Entity $entity, - EventDispatcherInterface $eventDispatcher, - NavigationSettingRepositoryQuery $settingQuery - ): Response { - $eventDispatcher->dispatch(new NavigationSettingEvent([ - 'navigation' => $entity, - ]), NavigationSettingEvent::INIT_EVENT); - - $settings = $settingQuery - ->where('.navigation = :navigation') - ->orderBy('.section, .label') - ->setParameter(':navigation', $entity->getId()) - ->paginate(1, 1000) - ; - - $this->getConfiguration()->addViewData('show', 'settings', $settings); - - return $this->doShow($entity); - } - - /** - * @Route("/admin/site/navigation/filter", name="admin_site_navigation_filter", methods={"GET"}) - */ - public function filter(Session $session): Response - { - return $this->doFilter($session); - } - - /** - * @Route("/admin/site/navigation/edit/{entity}", name="admin_site_navigation_edit", methods={"GET", "POST"}) - */ - public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doEdit($entity, $entityManager, $request); - } - - /** - * @Route("/admin/site/navigation/sort/{page}", name="admin_site_navigation_sort", methods={"POST"}, requirements={"page":"\d+"}) - */ - public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1, ): Response - { - return $this->doSort($page, $query, $entityManager, $request, $session); - } - - /** - * @Route("/admin/site/navigation/delete/{entity}", name="admin_site_navigation_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doDelete($entity, $entityManager, $request); - } - - protected function getConfiguration(): CrudConfiguration - { - return CrudConfiguration::create() - ->setPageTitle('index', 'Navigations') - ->setPageTitle('edit', '{label}') - ->setPageTitle('new', 'New navigation') - ->setPageTitle('show', '{label}') - - ->setPageRoute('index', 'admin_site_navigation_index') - ->setPageRoute('new', 'admin_site_navigation_new') - ->setPageRoute('edit', 'admin_site_navigation_edit') - ->setPageRoute('show', 'admin_site_navigation_show') - ->setPageRoute('sort', 'admin_site_navigation_sort') - ->setPageRoute('delete', 'admin_site_navigation_delete') - ->setPageRoute('filter', 'admin_site_navigation_filter') - ->setPageRoute('redirects', 'admin_redirect_index') - - ->setForm('edit', Type::class, []) - ->setForm('new', Type::class) - - ->setView('index', '@Core/site/navigation_admin/index.html.twig') - ->setView('show', '@Core/site/navigation_admin/show.html.twig') - ->setView('show_entity', '@Core/site/navigation_admin/_show.html.twig') - ->setView('form', '@Core/site/navigation_admin/_form.html.twig') - - ->setIsSortableCollection('index', true) - - ->setField('index', 'Label', Field\TextField::class, [ - 'property' => 'label', - 'attr' => ['class' => 'miw-200'], - ]) - ->setField('index', 'Domain', Field\ButtonField::class, [ - 'property' => 'domain', - 'button_attr' => ['class' => 'btn btn-light'], - 'attr' => ['class' => 'miw-200'], - ]) - ->setField('index', 'Locale', Field\ButtonField::class, [ - 'property' => 'locale', - 'button_attr' => ['class' => 'btn btn-light'], - ]) - ; - } - - protected function getSection(): string - { - return 'site_navigation'; - } -} diff --git a/core/Controller/Site/NodeAdminController.php b/core/Controller/Site/NodeAdminController.php deleted file mode 100644 index 5149078..0000000 --- a/core/Controller/Site/NodeAdminController.php +++ /dev/null @@ -1,310 +0,0 @@ -create($node->getMenu()); - $form = $this->createForm(EntityType::class, $entity, [ - 'pages' => $pageLocator->getPages(), - 'controllers' => $controllerLocator->getControllers(), - 'roles' => $roleLocator->getRoles(), - 'navigation' => $node->getMenu()->getNavigation(), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $position = $form->get('position')->getData(); - - $parent = 'above' === $position ? $node : $node->getParent(); - $entity->setParent($parent); - - if ('above' === $position) { - $nodeRepository->persistAsLastChild($entity, $node); - } else { - if ('after' === $position) { - $nodeRepository->persistAsNextSiblingOf($entity, $node); - } elseif ('before' === $position) { - $nodeRepository->persistAsPrevSiblingOf($entity, $node); - } - } - - $this->handlePageAssociation( - $form->get('pageAction')->getData(), - $form->get('pageEntity')->getData(), - $form->get('pageType')->getData(), - $entity, - $pageFactory, - $pageLocator - ); - - $entityManager->create($entity); - - $this->addFlash('success', 'The data has been saved.'); - - return $this->redirect($this->generateUrl('admin_site_tree_navigation', [ - 'navigation' => $node->getMenu()->getNavigation()->getId(), - 'data-modal' => $this->generateUrl('admin_site_node_edit', ['entity' => $entity->getId()]), - ]).sprintf('#node-%d', $entity->getId())); - } - $this->addFlash('warning', 'The form is not valid.'); - - return $this->redirect($this->generateUrl('admin_site_tree_navigation', [ - 'navigation' => $entity->getMenu()->getNavigation()->getId(), - ]).sprintf('#node-%d', $entity->getId())); - } - - return $this->render('@Core/site/node_admin/new.html.twig', [ - 'form' => $form->createView(), - 'node' => $node, - 'entity' => $entity, - 'tab' => 'content', - ]); - } - - /** - * @Route("/edit/{entity}/{tab}", name="admin_site_node_edit") - */ - public function edit( - Entity $entity, - EntityManager $entityManager, - PageFactory $pageFactory, - PageLocator $pageLocator, - ControllerLocator $controllerLocator, - RoleLocator $roleLocator, - Request $request, - string $tab = 'content' - ): Response { - $form = $this->createForm(EntityType::class, $entity, [ - 'pages' => $pageLocator->getPages(), - 'controllers' => $controllerLocator->getControllers(), - 'roles' => $roleLocator->getRoles(), - 'navigation' => $entity->getMenu()->getNavigation(), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isValid()) { - $this->handlePageAssociation( - $form->get('pageAction')->getData(), - $form->get('pageEntity')->getData(), - $form->get('pageType')->getData(), - $entity, - $pageFactory, - $pageLocator - ); - - $entityManager->update($entity); - - $this->addFlash('success', 'The data has been saved.'); - } else { - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->redirect($this->generateUrl('admin_site_tree_navigation', [ - 'navigation' => $entity->getMenu()->getNavigation()->getId(), - 'data-modal' => $this->generateUrl('admin_site_node_edit', ['entity' => $entity->getId()]), - ]).sprintf('#node-%d', $entity->getId())); - } - - $page = $entity->getPage(); - - if ($page !== null) { - $pageConfiguration = $pageLocator->getPages()[get_class($page)] ?? null; - } else { - $pageConfiguration = null; - } - - return $this->render('@Core/site/node_admin/edit.html.twig', [ - 'form' => $form->createView(), - 'entity' => $entity, - 'page' => $page, - 'pageConfiguration' => $pageConfiguration, - 'tab' => $tab, - ]); - } - - /** - * @Route("/urls/{entity}", name="admin_site_node_urls") - */ - public function urls(Entity $entity, SitemapBuilder $builder): Response - { - return $this->render('@Core/site/node_admin/urls.html.twig', [ - 'entity' => $entity, - 'urls' => $builder->getNodeUrls($entity), - ]); - } - - /** - * @Route("/move/{entity}", name="admin_site_node_move") - */ - public function move( - Entity $entity, - EntityManager $entityManager, - NodeRepository $nodeRepository, - Request $request - ): Response { - $form = $this->createForm(NodeMoveType::class, null, [ - 'menu' => $entity->getMenu(), - ]); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->get('node')->getData()->getId() === $entity->getId()) { - $form->get('node')->addError(new FormError('Élement de référence invalide.')); - } - - if ($form->isValid()) { - $position = $form->get('position')->getData(); - $node = $form->get('node')->getData(); - - $parent = 'above' === $position ? $node : $node->getParent(); - $entity->setParent($parent); - - if ('above' === $position) { - $nodeRepository->persistAsLastChild($entity, $node); - $entityManager->flush(); - } else { - if ('after' === $position) { - $nodeRepository->persistAsNextSiblingOf($entity, $node); - } elseif ('before' === $position) { - $nodeRepository->persistAsPrevSiblingOf($entity, $node); - } - - $entityManager->flush(); - } - - $this->addFlash('success', 'The data has been saved.'); - } else { - $this->addFlash('warning', 'The form is not valid.'); - } - - return $this->redirect($this->generateUrl('admin_site_tree_navigation', [ - 'navigation' => $entity->getMenu()->getNavigation()->getId(), - ]).sprintf('#node-%d', $entity->getId())); - } - - return $this->render('@Core/site/node_admin/move.html.twig', [ - 'form' => $form->createView(), - 'entity' => $entity, - ]); - } - - /** - * @Route("/toggle/visibility/{entity}", name="admin_site_node_toggle_visibility", methods={"POST"}) - */ - public function toggleVisibility(Entity $entity, EntityManager $entityManager, Request $request): Response - { - if ($this->isCsrfTokenValid('toggle_visibility'.$entity->getId(), $request->request->get('_token'))) { - $entity->setIsVisible(!$entity->getIsVisible()); - - $entityManager->update($entity); - - $this->addFlash('success', 'The data has been saved.'); - } - - return $this->redirect($this->generateUrl('admin_site_tree_navigation', [ - 'navigation' => $entity->getMenu()->getNavigation()->getId(), - ]).sprintf('#node-%d', $entity->getId())); - } - - /** - * @Route("/delete/{entity}", name="admin_site_node_delete", methods={"DELETE"}) - */ - public function delete( - Entity $entity, - NodeRepository $nodeRepository, - EventDispatcherInterface $eventDispatcher, - Request $request - ): Response { - if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) { - $eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_DELETE_EVENT); - $nodeRepository->removeFromTree($entity); - $nodeRepository->reorder($entity->getMenu()->getRootNode()); - $eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT); - - $this->addFlash('success', 'Donnée supprimée.'); - } - - return $this->redirectToRoute('admin_site_tree_navigation', [ - 'navigation' => $entity->getMenu()->getNavigation()->getId(), - ]); - } - - protected function handlePageAssociation( - string $pageAction, - ?Page $pageEntity, - string $pageType, - Entity $entity, - PageFactory $pageFactory, - PageLocator $pageLocator - ) { - if ('new' === $pageAction) { - $pageConfiguration = $pageLocator->getPage($pageType); - $page = $pageFactory->create($pageType, $entity->getLabel()); - $page->setTemplate($pageConfiguration->getTemplates()[0]['file']); - - $entity - ->setPage($page) - ->setAliasNode(null) - ; - } elseif ('existing' === $pageAction) { - if ($pageEntity) { - $entity->setPage($pageEntity); - } else { - $this->addFlash('info', 'Aucun changement de page effectué.'); - } - $entity->setAliasNode(null); - } elseif ('alias' === $pageAction) { - $entity->setPage(null); - } elseif ('none' === $pageAction) { - $entity - ->setPage(null) - ->setAliasNode(null) - ; - } - } -} diff --git a/core/Controller/Site/PageAdminController.php b/core/Controller/Site/PageAdminController.php deleted file mode 100644 index cb0a794..0000000 --- a/core/Controller/Site/PageAdminController.php +++ /dev/null @@ -1,136 +0,0 @@ -doIndex($page, $query, $request, $session); - } - - /** - * @Route("/admin/site/page/show/{entity}", name="admin_site_page_show", methods={"GET"}) - */ - public function show(Entity $entity): Response - { - return $this->doShow($entity); - } - - /** - * @Route("/admin/site/page/filter", name="admin_site_page_filter", methods={"GET"}) - */ - public function filter(Session $session): Response - { - return $this->doFilter($session); - } - - /** - * @Route("/admin/site/page/edit/{entity}", name="admin_site_page_edit", methods={"GET", "POST"}) - */ - public function edit( - int $entity, - EntityManager $entityManager, - RepositoryQuery $repositoryQuery, - PageLocator $pageLocator, - EventDispatcherInterface $eventDispatcher, - Request $request - ): Response { - $entity = $repositoryQuery->filterById($entity)->findOne(); - - $event = new PageEditEvent($entity); - $eventDispatcher->dispatch($event, PageEditEvent::FORM_INIT_EVENT); - - $this->getConfiguration()->setFormOptions('edit', [ - 'page_configuration' => $pageLocator->getPage(get_class($entity)), - 'page_builder_options' => $event->getPageBuilderOptions(), - ]); - - return $this->doEdit($entity, $entityManager, $request); - } - - /** - * @Route("/admin/site/page/delete/{entity}", name="admin_site_page_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doDelete($entity, $entityManager, $request); - } - - /** - * @Route("/admin/site/page/batch/{page}", name="admin_site_page_batch", methods={"POST"}, requirements={"page":"\d+"}) - */ - public function batch(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response - { - return $this->doBatch($page, $query, $entityManager, $request, $session); - } - - protected function getConfiguration(): CrudConfiguration - { - return CrudConfiguration::create() - ->setPageTitle('index', 'Pages') - ->setPageTitle('edit', '{name}') - ->setPageTitle('show', '{name}') - - ->setPageRoute('index', 'admin_site_page_index') - ->setPageRoute('edit', 'admin_site_page_edit') - ->setPageRoute('delete', 'admin_site_page_delete') - ->setPageRoute('filter', 'admin_site_page_filter') - ->setPageRoute('batch', 'admin_site_page_batch') - - ->setForm('edit', Type::class, []) - ->setForm('filter', FilterType::class) - ->setView('form', '@Core/site/page_admin/_form.html.twig') - - ->setAction('index', 'new', false) - ->setAction('index', 'show', false) - ->setAction('edit', 'show', false) - - ->setField('index', 'Name', Field\TextField::class, [ - 'property' => 'name', - 'sort' => ['name', '.name'], - 'attr' => ['class' => 'col-4'], - ]) - ->setField('index', 'Elements', Field\TextField::class, [ - 'view' => '@Core/site/page_admin/fields/nodes.html.twig', - 'sort' => ['navigation', function (RepositoryQuery $query, $direction) { - $query - ->leftJoin('.nodes', 'node') - ->leftJoin('node.menu', 'menu') - ->leftJoin('menu.navigation', 'navigation') - ->orderBy('navigation.label', $direction) - ; - }], - 'attr' => ['class' => 'col-6'], - ]) - ->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) { - $manager->delete($entity); - }) - ; - } - - protected function getSection(): string - { - return 'site_page'; - } -} diff --git a/core/Controller/Site/PageController.php b/core/Controller/Site/PageController.php deleted file mode 100644 index 3a081b7..0000000 --- a/core/Controller/Site/PageController.php +++ /dev/null @@ -1,57 +0,0 @@ -siteRequest = $siteRequest; - $this->siteStore = $siteStore; - } - - public function show(): Response - { - if (!$this->siteRequest->getPage()) { - throw $this->createNotFoundException(); - } - - return $this->defaultRender($this->siteRequest->getPage()->getTemplate()); - } - - protected function defaultRender(string $view, array $parameters = [], Response $response = null): Response - { - $parameters = array_merge($this->getDefaultRenderParameters(), $parameters); - - if (null === $response) { - $contentType = $this->siteRequest->getNode()->getContentType(); - - $response = new Response(null, 200, [ - 'Content-Type' => $contentType ?? 'text/html', - ]); - } - - return parent::render($view, $parameters, $response); - } - - protected function getDefaultRenderParameters(): array - { - return [ - '_node' => $this->siteRequest->getNode(), - '_page' => $this->siteRequest->getPage(), - '_menu' => $this->siteRequest->getMenu(), - '_navigation' => $this->siteRequest->getNavigation(), - '_domain' => $this->siteRequest->getDomain(), - '_locale' => $this->siteRequest->getNavigation()->getLocale(), - '_store' => $this->siteStore, - ]; - } -} diff --git a/core/Controller/Site/SitemapController.php b/core/Controller/Site/SitemapController.php deleted file mode 100644 index ea1fe29..0000000 --- a/core/Controller/Site/SitemapController.php +++ /dev/null @@ -1,40 +0,0 @@ -whereDomain($request->getHost()) - ->find() - ; - - $items = []; - - foreach ($navigations as $navigation) { - $items = array_merge( - $items, - $builder->build($navigation) - ); - } - - $response = new Response(); - $response->headers->set('Content-Type', 'text/xml'); - - return $this->render('@Core/site/sitemap/sitemap.xml.twig', [ - 'items' => $items, - ], $response); - } -} diff --git a/core/Controller/Site/TreeAdminController.php b/core/Controller/Site/TreeAdminController.php deleted file mode 100644 index 934d900..0000000 --- a/core/Controller/Site/TreeAdminController.php +++ /dev/null @@ -1,87 +0,0 @@ -has('site_tree_last_navigation')) { - $navigation = $navigationQuery->create() - ->filterById((int) $session->get('site_tree_last_navigation')) - ->findOne() - ; - } - - if (null === $navigation) { - $navigation = $navigationQuery->create() - ->orderBy('.sortOrder') - ->findOne() - ; - } - - if (null === $navigation) { - $this->addFlash('warning', 'You must add a navigation.'); - - return $this->redirectToRoute('admin_site_navigation_new'); - } - - return $this->redirectToRoute('admin_site_tree_navigation', [ - 'navigation' => $navigation->getId(), - ]); - } - - /** - * @Route("/navigation/{navigation}", name="admin_site_tree_navigation") - */ - public function navigation( - Navigation $navigation, - NavigationRepositoryQuery $navigationQuery, - MenuFactory $menuFactory, - Session $session - ): Response { - $navigations = $navigationQuery->create() - ->orderBy('.sortOrder') - ->find() - ; - - $session->set('site_tree_last_navigation', $navigation->getId()); - - $forms = [ - 'menu' => $this->createForm(MenuType::class, $menuFactory->create())->createView(), - 'menus' => [], - ]; - - foreach ($navigation->getMenus() as $menu) { - $forms['menus'][$menu->getId()] = $this->createForm(MenuType::class, $menu)->createView(); - } - - return $this->render('@Core/site/tree_admin/navigation.html.twig', [ - 'navigation' => $navigation, - 'navigations' => $navigations, - 'forms' => $forms, - ]); - } - - public function getSection(): string - { - return 'site_tree'; - } -} diff --git a/core/Controller/Task/TaskAdminController.php b/core/Controller/Task/TaskAdminController.php deleted file mode 100644 index 1b18573..0000000 --- a/core/Controller/Task/TaskAdminController.php +++ /dev/null @@ -1,62 +0,0 @@ -dispatch($event, TaskInitEvent::INIT_EVENT); - - return $this->render('@Core/task/task_admin/index.html.twig', [ - 'pager' => $event->getTasks(), - ]); - } - - /** - * @Route("/run/{task}", name="admin_task_run", methods={"GET"}) - */ - public function run( - string $task, - Request $request, - EventDispatcherInterface $eventDispatcher - ): Response { - if (!$this->isCsrfTokenValid('task_run', $request->query->get('_token'))) { - throw $this->createAccessDeniedException(); - } - - $output = new BufferedOutput(); - $event = new TaskRunRequestedEvent($task, $request->query, $output); - $eventDispatcher->dispatch($event, TaskRunRequestedEvent::RUN_REQUEST_EVENT); - - $converter = new AnsiToHtmlConverter(new SolarizedTheme()); - $content = $converter->convert($output->fetch()); - - return $this->render('@Core/task/task_admin/run.html.twig', [ - 'output' => $content, - ]); - } - - public function getSection(): string - { - return 'task'; - } -} diff --git a/core/Controller/User/UserAdminController.php b/core/Controller/User/UserAdminController.php deleted file mode 100644 index b63b29a..0000000 --- a/core/Controller/User/UserAdminController.php +++ /dev/null @@ -1,131 +0,0 @@ -doIndex($page, $query, $request, $session); - } - - /** - * @Route("/admin/user/new", name="admin_user_new", methods={"GET", "POST"}) - */ - public function new(Factory $factory, EntityManager $entityManager, Request $request, TokenGenerator $tokenGenerator): Response - { - return $this->doNew($factory->create(null, $tokenGenerator->generateToken()), $entityManager, $request); - } - - /** - * @Route("/admin/user/show/{entity}", name="admin_user_show", methods={"GET"}) - */ - public function show(Entity $entity): Response - { - return $this->doShow($entity); - } - - /** - * @Route("/admin/user/filter", name="admin_user_filter", methods={"GET"}) - */ - public function filter(Session $session): Response - { - return $this->doFilter($session); - } - - /** - * @Route("/admin/user/edit/{entity}", name="admin_user_edit", methods={"GET", "POST"}) - */ - public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doEdit($entity, $entityManager, $request); - } - - /** - * @Route("/admin/user/delete/{entity}", name="admin_user_delete", methods={"DELETE"}) - */ - public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response - { - return $this->doDelete($entity, $entityManager, $request); - } - - /** - * @Route("/admin/user/resetting_request/{entity}", name="admin_user_resetting_request", methods={"POST"}) - */ - public function requestResetting(Entity $entity, EventDispatcherInterface $eventDispatcher, Request $request): Response - { - if ($this->isCsrfTokenValid('resetting_request'.$entity->getId(), $request->request->get('_token'))) { - $eventDispatcher->dispatch(new PasswordRequestEvent($entity), PasswordRequestEvent::EVENT); - - $this->addFlash('success', 'E-mail sent.'); - } - - return $this->redirectToRoute('admin_user_edit', [ - 'entity' => $entity->getId(), - ]); - } - - protected function getConfiguration(): CrudConfiguration - { - return CrudConfiguration::create() - ->setPageTitle('index', 'Users') - ->setPageTitle('edit', '{username}') - ->setPageTitle('new', 'New user') - ->setPageTitle('show', '{username}') - - ->setPageRoute('index', 'admin_user_index') - ->setPageRoute('new', 'admin_user_new') - ->setPageRoute('edit', 'admin_user_edit') - ->setPageRoute('show', 'admin_user_show') - ->setPageRoute('delete', 'admin_user_delete') - ->setPageRoute('filter', 'admin_user_filter') - - ->setForm('edit', Type::class, []) - ->setForm('new', Type::class) - - ->setView('form', '@Core/user/user_admin/_form.html.twig') - ->setView('index', '@Core/user/user_admin/index.html.twig') - ->setView('new', '@Core/user/user_admin/new.html.twig') - ->setView('show', '@Core/user/user_admin/show.html.twig') - ->setView('show_entity', '@Core/user/user_admin/_show.html.twig') - ->setView('edit', '@Core/user/user_admin/edit.html.twig') - - ->setDefaultSort('index', 'username') - - ->setField('index', 'E-mail', Field\TextField::class, [ - 'property' => 'email', - 'sort' => ['email', '.email'], - 'attr' => ['class' => 'miw-200'], - ]) - ->setField('index', 'Display name', Field\TextField::class, [ - 'property' => 'displayName', - 'sort' => ['displayName', '.displayName'], - 'attr' => ['class' => 'miw-200'], - ]) - ; - } - - protected function getSection(): string - { - return 'user'; - } -} diff --git a/core/Crud/CrudConfiguration.php b/core/Crud/CrudConfiguration.php deleted file mode 100644 index bfe9121..0000000 --- a/core/Crud/CrudConfiguration.php +++ /dev/null @@ -1,330 +0,0 @@ - - */ -class CrudConfiguration -{ - protected array $pageTitles = []; - protected array $pageRoutes = []; - protected array $pageRouteParams = []; - protected array $actions = []; - protected array $batchActions = []; - protected array $actionTitles = []; - protected array $forms = []; - protected array $formOptions = []; - protected array $views = []; - protected array $viewDatas = []; - protected array $fields = []; - protected array $maxPerPage = []; - protected array $locales = []; - protected array $defaultSort = []; - protected array $isSortableCollection = []; - protected string $sortableCollectionProperty = 'sortOrder'; - protected ?string $defaultLocale = null; - protected bool $showActions = true; - - protected static $self; - - public static function create() - { - if (null === self::$self) { - self::$self = new self(); - } - - return self::$self; - } - - /* -- */ - - public function setPageTitle(string $page, string $title): self - { - $this->pageTitles[$page] = $title; - - return $this; - } - - public function getPageTitle(string $page, ?string $default = null): ?string - { - return $this->pageTitles[$page] ?? $default; - } - - /* -- */ - - public function setPageRoute(string $page, string $route): self - { - $this->pageRoutes[$page] = $route; - - return $this; - } - - public function getPageRoute(string $page): ?string - { - return $this->pageRoutes[$page]; - } - - public function setPageRouteParams(string $page, array $params): self - { - $this->pageRouteParams[$page] = $params; - - return $this; - } - - public function getPageRouteParams(string $page): array - { - return $this->pageRouteParams[$page] ?? []; - } - - /* -- */ - - public function setForm(string $context, string $form, array $options = []): self - { - $this->forms[$context] = $form; - - return $this; - } - - public function getForm(string $context): ?string - { - return $this->forms[$context] ?? null; - } - - public function setFormOptions(string $context, array $options = []): self - { - $this->formOptions[$context] = $options; - - return $this; - } - - public function getFormOptions(string $context): array - { - return $this->formOptions[$context] ?? []; - } - - /* -- */ - - public function setAction(string $page, string $action, bool $enabled): self - { - if (!isset($this->actions[$page])) { - $this->actions[$page] = []; - } - - $this->actions[$page][$action] = $enabled; - - return $this; - } - - public function getAction(string $page, string $action, bool $default = true) - { - return $this->actions[$page][$action] ?? $default; - } - - public function setBatchAction(string $page, string $action, string $label, callable $callback): self - { - if (!isset($this->batchActions[$page])) { - $this->batchActions[$page] = []; - } - - $this->batchActions[$page][$action] = [ - 'label' => $label, - 'callback' => $callback, - ]; - - return $this; - } - - public function getBatchActions(string $page) - { - return $this->batchActions[$page] ?? []; - } - - public function getBatchAction(string $page, string $action) - { - return $this->batchActions[$page][$action] ?? null; - } - - public function hasBatchAction(string $page) - { - return !empty($this->batchActions[$page]); - } - - /* -- */ - - public function setActionTitle(string $page, string $action, string $title): self - { - if (!isset($this->actionTitles[$page])) { - $this->actionTitles[$page] = []; - } - - $this->actions[$page][$action] = $title; - - return $this; - } - - public function getActionTitle(string $page, string $action, ?string $default = null): ?string - { - return $this->actionTitles[$page][$action] ?? $default; - } - - /* -- */ - - public function setView(string $context, string $view): self - { - $this->views[$context] = $view; - - return $this; - } - - public function getView(string $context, ?string $default = null) - { - if (null === $default) { - $default = sprintf('@Core/admin/crud/%s.html.twig', $context); - } - - return $this->views[$context] ?? $default; - } - - public function addViewData(string $context, string $name, $value): self - { - if (!isset($this->viewDatas[$context])) { - $this->viewDatas[$context] = []; - } - - $this->viewDatas[$context][$name] = $value; - - return $this; - } - - public function setViewDatas(string $context, array $datas): self - { - foreach ($datas as $name => $value) { - $this->addViewData($name, $value); - } - - return $this; - } - - public function getViewDatas(string $context): array - { - return $this->viewDatas[$context] ?? []; - } - - /* -- */ - - public function setField(string $context, string $label, string $field, array $options): self - { - if (!isset($this->fields[$context])) { - $this->fields[$context] = []; - } - - $this->fields[$context][$label] = [ - 'field' => $field, - 'options' => $options, - ]; - - return $this; - } - - public function getFields(string $context): array - { - return $this->fields[$context] ?? []; - } - - /* -- */ - - public function setMaxPerPage(string $page, int $max) - { - $this->maxPerPage[$page] = $max; - - return $this; - } - - public function getMaxPerPage(string $page, int $default = 20) - { - return $this->maxPerPage[$page] ?? $default; - } - - /* -- */ - - public function setI18n(array $locales, string $defaultLocale): self - { - $this->locales = $locales; - $this->defaultLocale = $defaultLocale; - - return $this; - } - - public function getLocales(): array - { - return $this->locales; - } - - public function getDefaultLocale(): ?string - { - return $this->defaultLocale; - } - - public function isI18n(): bool - { - return !empty($this->locales); - } - - /* -- */ - - public function setDefaultSort(string $context, string $label, string $direction = 'asc'): self - { - $this->defaultSort[$context] = [ - 'label' => $label, - 'direction' => $direction, - ]; - - return $this; - } - - public function getDefaultSort(string $context) - { - return $this->defaultSort[$context] ?? null; - } - - public function setIsSortableCollection(string $page, bool $isSortableCollection): self - { - $this->isSortableCollection[$page] = $isSortableCollection; - - return $this; - } - - public function getIsSortableCollection(string $page): bool - { - return $this->isSortableCollection[$page] ?? false; - } - - public function setSortableCollectionProperty(string $sortableCollectionProperty): self - { - $this->sortableCollectionProperty = $sortableCollectionProperty; - - return $this; - } - - public function getSortableCollectionProperty(): string - { - return $this->sortableCollectionProperty; - } - - public function setShowActions(bool $showActions): self - { - $this->showActions = $showActions; - - return $this; - } - - public function getShowActions(): bool - { - return $this->showActions; - } -} diff --git a/core/Crud/Exception/CrudConfigurationException.php b/core/Crud/Exception/CrudConfigurationException.php deleted file mode 100644 index 17990c7..0000000 --- a/core/Crud/Exception/CrudConfigurationException.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -class CrudConfigurationException extends \Exception -{ -} diff --git a/core/Crud/Field/ButtonField.php b/core/Crud/Field/ButtonField.php deleted file mode 100644 index fcd4961..0000000 --- a/core/Crud/Field/ButtonField.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -class ButtonField extends Field -{ - public function buildView(Environment $twig, $entity, array $options, ?string $locale = null) - { - if (isset($options['button_attr_builder']) && is_callable($options['button_attr_builder'])) { - $options['button_attr'] = (array) call_user_func($options['button_attr_builder'], $entity, $options); - } - - return parent::buildView($twig, $entity, $options, $locale); - } - - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'view' => '@Core/admin/crud/field/button.html.twig', - 'button_attr' => [], - 'button_attr_builder' => null, - 'button_tag' => 'button', - ]); - - $resolver->setAllowedTypes('button_attr', ['array']); - $resolver->setAllowedTypes('button_tag', ['string']); - $resolver->setAllowedTypes('button_attr_builder', ['null', 'callable']); - - return $resolver; - } -} diff --git a/core/Crud/Field/DateField.php b/core/Crud/Field/DateField.php deleted file mode 100644 index f97da96..0000000 --- a/core/Crud/Field/DateField.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class DateField extends Field -{ - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'view' => '@Core/admin/crud/field/date.html.twig', - 'format' => 'Y-m-d', - ]); - - return $resolver; - } -} diff --git a/core/Crud/Field/DatetimeField.php b/core/Crud/Field/DatetimeField.php deleted file mode 100644 index 99aa739..0000000 --- a/core/Crud/Field/DatetimeField.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class DatetimeField extends Field -{ - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'view' => '@Core/admin/crud/field/date.html.twig', - 'format' => 'Y-m-d H:i:s', - ]); - - return $resolver; - } -} diff --git a/core/Crud/Field/Field.php b/core/Crud/Field/Field.php deleted file mode 100644 index 42256e8..0000000 --- a/core/Crud/Field/Field.php +++ /dev/null @@ -1,92 +0,0 @@ - - */ -abstract class Field -{ - public function buildView(Environment $twig, $entity, array $options, ?string $locale = null) - { - return $twig->render($this->getView($options), [ - 'entity' => $entity, - 'value' => $this->getValue($entity, $options, $locale), - 'options' => $options, - ]); - } - - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - $resolver->setDefaults([ - 'property' => null, - 'property_builder' => null, - 'view' => null, - 'raw' => false, - 'sort' => null, - 'href' => null, - 'href_attr' => [], - 'attr' => [], - ]); - - $resolver->setRequired('view'); - $resolver->setAllowedTypes('property', ['null', 'string']); - $resolver->setAllowedTypes('view', 'string'); - $resolver->setAllowedTypes('attr', 'array'); - $resolver->setAllowedTypes('href', ['null', 'string', 'callable']); - $resolver->setAllowedTypes('href_attr', 'array', 'callable'); - $resolver->setAllowedTypes('raw', 'boolean'); - $resolver->setAllowedTypes('property_builder', ['null', 'callable']); - $resolver->setAllowedValues('sort', function($value) { - if ($value === null) { - return true; - } - - if (!is_array($value)) { - return false; - } - - $isValidParam1 = !empty($value[0]) && is_string($value[0]); - $isValidParam2 = !empty($value[1]) && (is_string($value[1]) || is_callable($value[1])); - - return $isValidParam1 && $isValidParam2; - }); - - return $resolver; - } - - protected function getValue($entity, array $options, ?string $locale = null) - { - if (null !== $options['property']) { - $propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()->getPropertyAccessor(); - - try { - $value = $propertyAccessor->getValue($entity, $options['property']); - } catch (NoSuchPropertyException $e) { - if (null !== $locale) { - $value = $propertyAccessor->getValue($entity->translate($locale), $options['property']); - } else { - throw $e; - } - } - } elseif (null !== $options['property_builder']) { - $value = call_user_func($options['property_builder'], $entity, $options); - } else { - $value = null; - } - - return $value; - } - - protected function getView(array $options) - { - return $options['view']; - } -} diff --git a/core/Crud/Field/ImageField.php b/core/Crud/Field/ImageField.php deleted file mode 100644 index bbecab8..0000000 --- a/core/Crud/Field/ImageField.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -class ImageField extends Field -{ - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'view' => '@Core/admin/crud/field/image.html.twig', - 'image_attr' => [], - ]); - - $resolver->setAllowedTypes('image_attr', ['array']); - - return $resolver; - } -} diff --git a/core/Crud/Field/TextField.php b/core/Crud/Field/TextField.php deleted file mode 100644 index 50366b2..0000000 --- a/core/Crud/Field/TextField.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class TextField extends Field -{ - public function configureOptions(OptionsResolver $resolver): OptionsResolver - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'view' => '@Core/admin/crud/field/text.html.twig', - ]); - - return $resolver; - } -} diff --git a/core/DependencyInjection/Configuration.php b/core/DependencyInjection/Configuration.php deleted file mode 100644 index 9d6b419..0000000 --- a/core/DependencyInjection/Configuration.php +++ /dev/null @@ -1,138 +0,0 @@ -getRootNode() - ->children() - ->arrayNode('site') - ->children() - ->scalarNode('name') - ->defaultValue('Murph') - ->isRequired() - ->cannotBeEmpty() - ->end() - ->scalarNode('logo') - ->defaultValue('build/images/core/logo.svg') - ->isRequired() - ->cannotBeEmpty() - ->end() - ->arrayNode('controllers') - ->prototype('array') - ->children() - ->scalarNode('name') - ->cannotBeEmpty() - ->end() - ->scalarNode('action') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('security') - ->children() - ->arrayNode('roles') - ->prototype('array') - ->children() - ->scalarNode('name') - ->cannotBeEmpty() - ->end() - ->scalarNode('role') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('pages') - ->prototype('array') - ->children() - ->scalarNode('name') - ->isRequired() - ->cannotBeEmpty() - ->end() - ->arrayNode('templates') - ->prototype('array') - ->children() - ->scalarNode('name') - ->cannotBeEmpty() - ->end() - ->scalarNode('file') - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('file_manager') - ->children() - ->arrayNode('mimes') - ->scalarPrototype() - ->end() - ->defaultValue($defaultMimetypes) - ->end() - ->scalarNode('path') - ->defaultValue('%kernel.project_dir%/public/uploads') - ->cannotBeEmpty() - ->end() - ->scalarNode('path_uri') - ->defaultValue('/uploads') - ->cannotBeEmpty() - ->end() - ->arrayNode('path_locked') - ->scalarPrototype() - ->end() - ->defaultValue($defaultLocked) - ->end() - ->end() - ->end() - ->end(); - - return $treeBuilder; - } -} diff --git a/core/DependencyInjection/CoreExtension.php b/core/DependencyInjection/CoreExtension.php deleted file mode 100644 index 4708e21..0000000 --- a/core/DependencyInjection/CoreExtension.php +++ /dev/null @@ -1,28 +0,0 @@ -getConfiguration($configs, $container); - $config = $this->processConfiguration($configuration, $configs); - - $container->setParameter('core', $config); - } - - /** - * {@inheritdoc} - */ - public function getConfiguration(array $configs, ContainerBuilder $container) - { - return new Configuration(); - } -} diff --git a/core/Doctrine/Timestampable.php b/core/Doctrine/Timestampable.php deleted file mode 100644 index 41ff4b9..0000000 --- a/core/Doctrine/Timestampable.php +++ /dev/null @@ -1,59 +0,0 @@ -createdAt = new \DateTime(); - $this->updatedAt = new \DateTime(); - } - - /** - * @ORM\PreUpdate - */ - public function onPreUpdate(): void - { - $this->updatedAt = new \DateTime(); - } - - public function setCreatedAt(?\DateTime $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getCreatedAt(): ?\DateTime - { - return $this->createdAt; - } - - public function setUpdatedAt(?\DateTime $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getUpdatedAt(): ?\DateTime - { - return $this->updatedAt; - } -} diff --git a/core/Entity/.gitignore b/core/Entity/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/core/Entity/Analytic/Referer.php b/core/Entity/Analytic/Referer.php deleted file mode 100644 index 0eeb73c..0000000 --- a/core/Entity/Analytic/Referer.php +++ /dev/null @@ -1,103 +0,0 @@ -id; - } - - public function getNode(): ?Node - { - return $this->node; - } - - public function setNode(?Node $node): self - { - $this->node = $node; - - return $this; - } - - public function getUri(): ?string - { - return $this->uri; - } - - public function setUri(string $uri): self - { - $this->uri = $uri; - - return $this; - } - - public function getViews(): ?int - { - return $this->views; - } - - public function setViews(int $views): self - { - $this->views = $views; - - return $this; - } - - public function addView(): self - { - ++$this->views; - - return $this; - } - - public function getDate(): ?\DateTimeInterface - { - return $this->date; - } - - public function setDate(\DateTimeInterface $date): self - { - $this->date = $date; - - return $this; - } -} diff --git a/core/Entity/Analytic/View.php b/core/Entity/Analytic/View.php deleted file mode 100644 index 25dd681..0000000 --- a/core/Entity/Analytic/View.php +++ /dev/null @@ -1,151 +0,0 @@ -id; - } - - public function getNode(): ?Node - { - return $this->node; - } - - public function setNode(?Node $node): self - { - $this->node = $node; - - return $this; - } - - public function getPath(): ?string - { - return $this->path; - } - - public function setPath(string $path): self - { - $this->path = $path; - - return $this; - } - - public function getViews(): ?int - { - return $this->views; - } - - public function setViews(int $views): self - { - $this->views = $views; - - return $this; - } - - public function addView(): self - { - ++$this->views; - - return $this; - } - - public function getDesktopViews(): ?int - { - return $this->desktopViews; - } - - public function setDesktopViews(int $desktopViews): self - { - $this->desktopViews = $desktopViews; - - return $this; - } - - public function addDesktopView(): self - { - ++$this->desktopViews; - - return $this; - } - - public function getMobileViews(): ?int - { - return $this->mobileViews; - } - - public function setMobileViews(int $mobileViews): self - { - $this->mobileViews = $mobileViews; - - return $this; - } - - public function addMobileView(): self - { - ++$this->mobileViews; - - return $this; - } - - public function getDate(): ?\DateTimeInterface - { - return $this->date; - } - - public function setDate(\DateTimeInterface $date): self - { - $this->date = $date; - - return $this; - } -} diff --git a/core/Entity/EntityInterface.php b/core/Entity/EntityInterface.php deleted file mode 100644 index 0f8ecd3..0000000 --- a/core/Entity/EntityInterface.php +++ /dev/null @@ -1,7 +0,0 @@ -id; - } - - public function setId(string $id): self - { - $this->id = $id; - - return $this; - } - - public function getAttributes() - { - return (array) json_decode($this->attributes, true); - } - - public function setAttributes($attributes): self - { - $this->attributes = json_encode($attributes); - - return $this; - } -} diff --git a/core/Entity/NavigationSetting.php b/core/Entity/NavigationSetting.php deleted file mode 100644 index 21d37d7..0000000 --- a/core/Entity/NavigationSetting.php +++ /dev/null @@ -1,111 +0,0 @@ -id; - } - - public function getSection(): ?string - { - return $this->section; - } - - public function setSection(string $section): self - { - $this->section = $section; - - return $this; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(string $label): self - { - $this->label = $label; - - return $this; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(string $code): self - { - $this->code = $code; - - return $this; - } - - public function getValue() - { - return json_decode($this->value, true); - } - - public function setValue($value): self - { - $this->value = json_encode($value); - - return $this; - } - - public function getNavigation(): ?Navigation - { - return $this->navigation; - } - - public function setNavigation(?Navigation $navigation): self - { - $this->navigation = $navigation; - - return $this; - } -} diff --git a/core/Entity/Redirect.php b/core/Entity/Redirect.php deleted file mode 100644 index 0b1bcb4..0000000 --- a/core/Entity/Redirect.php +++ /dev/null @@ -1,211 +0,0 @@ -id; - } - - public function getScheme(): ?string - { - return $this->scheme; - } - - public function setScheme(string $scheme): self - { - $this->scheme = $scheme; - - return $this; - } - - public function getDomain(): ?string - { - return $this->domain; - } - - public function setDomain(string $domain): self - { - $this->domain = $domain; - - return $this; - } - - public function getDomainType(): ?string - { - return $this->domainType; - } - - public function setDomainType(string $domainType): self - { - $this->domainType = $domainType; - - return $this; - } - - public function getRule(): ?string - { - return $this->rule; - } - - public function setRule(string $rule): self - { - $this->rule = $rule; - - return $this; - } - - public function getRuleType(): ?string - { - return $this->ruleType; - } - - public function setRuleType(string $ruleType): self - { - $this->ruleType = $ruleType; - - return $this; - } - - public function getLocation(): ?string - { - return $this->location; - } - - public function setLocation(string $location): self - { - $this->location = $location; - - return $this; - } - - public function getRedirectCode(): ?int - { - return $this->redirectCode; - } - - public function setRedirectCode(int $redirectCode): self - { - $this->redirectCode = $redirectCode; - - return $this; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(string $label): self - { - $this->label = $label; - - return $this; - } - - public function getSortOrder(): ?int - { - return $this->sortOrder; - } - - public function setSortOrder(?int $sortOrder): self - { - $this->sortOrder = $sortOrder; - - return $this; - } - - public function getIsEnabled(): ?bool - { - return $this->isEnabled; - } - - public function setIsEnabled(bool $isEnabled): self - { - $this->isEnabled = $isEnabled; - - return $this; - } - - public function getReuseQueryString(): ?bool - { - return $this->reuseQueryString; - } - - public function setReuseQueryString(bool $reuseQueryString): self - { - $this->reuseQueryString = $reuseQueryString; - - return $this; - } -} diff --git a/core/Entity/Setting.php b/core/Entity/Setting.php deleted file mode 100644 index 2e3a9a0..0000000 --- a/core/Entity/Setting.php +++ /dev/null @@ -1,92 +0,0 @@ -id; - } - - public function getSection(): ?string - { - return $this->section; - } - - public function setSection(string $section): self - { - $this->section = $section; - - return $this; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(string $label): self - { - $this->label = $label; - - return $this; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(string $code): self - { - $this->code = $code; - - return $this; - } - - public function getValue() - { - return json_decode($this->value, true); - } - - public function setValue($value): self - { - $this->value = json_encode($value); - - return $this; - } -} diff --git a/core/Entity/Site/Menu.php b/core/Entity/Site/Menu.php deleted file mode 100644 index 7728c36..0000000 --- a/core/Entity/Site/Menu.php +++ /dev/null @@ -1,146 +0,0 @@ -nodes = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(string $label): self - { - $this->label = $label; - - return $this; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(string $code): self - { - $this->code = $code; - - return $this; - } - - public function getNavigation(): ?Navigation - { - return $this->navigation; - } - - public function setNavigation(?Navigation $navigation): self - { - $this->navigation = $navigation; - - return $this; - } - - /** - * @return Collection|Node[] - */ - public function getNodes(): Collection - { - return $this->nodes; - } - - public function addNode(Node $node): self - { - if (!$this->nodes->contains($node)) { - $this->nodes[] = $node; - $node->setMenu($this); - } - - return $this; - } - - public function removeNode(Node $node): self - { - if ($this->nodes->removeElement($node)) { - // set the owning side to null (unless already changed) - if ($node->getMenu() === $this) { - $node->setMenu(null); - } - } - - return $this; - } - - public function getRootNode(): ?Node - { - return $this->rootNode; - } - - public function setRootNode(?Node $rootNode): self - { - $this->rootNode = $rootNode; - - return $this; - } - - public function getRouteName(): string - { - return $this->getNavigation()->getRouteName().'_'.($this->getCode() ? $this->getCode() : $this->getId()); - } -} diff --git a/core/Entity/Site/Navigation.php b/core/Entity/Site/Navigation.php deleted file mode 100644 index 084f357..0000000 --- a/core/Entity/Site/Navigation.php +++ /dev/null @@ -1,243 +0,0 @@ -menus = new ArrayCollection(); - $this->navigationSettings = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(string $label): self - { - $this->label = $label; - - return $this; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(string $code): self - { - $this->code = $code; - - return $this; - } - - public function getDomain(): ?string - { - return $this->domain; - } - - public function setDomain(string $domain): self - { - $this->domain = $domain; - - return $this; - } - - public function getForceDomain(): ?bool - { - return $this->forceDomain; - } - - public function setForceDomain(bool $forceDomain): self - { - $this->forceDomain = $forceDomain; - - return $this; - } - - public function getAdditionalDomains(): array - { - return (array) json_decode($this->additionalDomains, true); - } - - public function setAdditionalDomains(array $additionalDomains): self - { - $this->additionalDomains = json_encode($additionalDomains); - - return $this; - } - - /** - * @return Collection|Menu[] - */ - public function getMenus(): Collection - { - return $this->menus; - } - - public function addMenu(Menu $menu): self - { - if (!$this->menus->contains($menu)) { - $this->menus[] = $menu; - $menu->setNavigation($this); - } - - return $this; - } - - public function removeMenu(Menu $menu): self - { - if ($this->menus->removeElement($menu)) { - // set the owning side to null (unless already changed) - if ($menu->getNavigation() === $this) { - $menu->setNavigation(null); - } - } - - return $this; - } - - public function getMenu(string $code): ?Menu - { - foreach ($this->menus as $menu) { - if ($menu->getCode() === $code) { - return $menu; - } - } - - return $menu; - } - - public function getRouteName(): string - { - return $this->getCode() ? $this->getCode() : 'navigation_'.$this->getId(); - } - - public function getLocale(): ?string - { - return $this->locale; - } - - public function setLocale(string $locale): self - { - $this->locale = $locale; - - return $this; - } - - public function getSortOrder(): ?int - { - return $this->sortOrder; - } - - public function setSortOrder(?int $sortOrder): self - { - $this->sortOrder = $sortOrder; - - return $this; - } - - /** - * @return Collection|NavigationSetting[] - */ - public function getNavigationSettings(): Collection - { - return $this->navigationSettings; - } - - public function addNavigationSetting(NavigationSetting $navigationSetting): self - { - if (!$this->navigationSettings->contains($navigationSetting)) { - $this->navigationSettings[] = $navigationSetting; - $navigationSetting->setNavigation($this); - } - - return $this; - } - - public function removeNavigationSetting(NavigationSetting $navigationSetting): self - { - if ($this->navigationSettings->removeElement($navigationSetting)) { - // set the owning side to null (unless already changed) - if ($navigationSetting->getNavigation() === $this) { - $navigationSetting->setNavigation(null); - } - } - - return $this; - } -} diff --git a/core/Entity/Site/Node.php b/core/Entity/Site/Node.php deleted file mode 100644 index 0d6c3a7..0000000 --- a/core/Entity/Site/Node.php +++ /dev/null @@ -1,676 +0,0 @@ -children = new ArrayCollection(); - $this->aliasNodes = new ArrayCollection(); - $this->analyticViews = new ArrayCollection(); - $this->analyticReferers = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getMenu(): ?Menu - { - return $this->menu; - } - - public function setMenu(?Menu $menu): self - { - $this->menu = $menu; - - return $this; - } - - public function getTreeLeft(): ?int - { - return $this->treeLeft; - } - - public function setTreeLeft(int $treeLeft): self - { - $this->treeLeft = $treeLeft; - - return $this; - } - - public function getTreeLevel(): ?int - { - return $this->treeLevel; - } - - public function setTreeLevel(int $treeLevel): self - { - $this->treeLevel = $treeLevel; - - return $this; - } - - public function getTreeRight(): ?int - { - return $this->treeRight; - } - - public function setTreeRight(int $treeRight): self - { - $this->treeRight = $treeRight; - - return $this; - } - - public function getTreeRoot(): ?self - { - return $this->treeRoot; - } - - public function setTreeRoot(?self $treeRoot): self - { - $this->treeRoot = $treeRoot; - - return $this; - } - - public function getParent(): ?self - { - return $this->parent; - } - - public function setParent(?self $parent): self - { - $this->parent = $parent; - - return $this; - } - - /** - * @return Collection|Node[] - */ - public function getChildren(array $criteria = []): Collection - { - if (null === $this->children) { - $this->children = new ArrayCollection(); - } - - if (!empty($criteria)) { - $children = new ArrayCollection(); - - foreach ($this->children as $child) { - $add = true; - - if (isset($criteria['visible']) && $child->getIsVisible() !== $criteria['visible']) { - $add = false; - } - - if ($add) { - $children->add($child); - } - } - - return $children; - } - - return $this->children; - } - - public function addChild(Node $child): self - { - if (!$this->children->contains($child)) { - $this->children[] = $child; - $child->setParent($this); - } - - return $this; - } - - public function removeChild(Node $child): self - { - if ($this->children->removeElement($child)) { - // set the owning side to null (unless already changed) - if ($child->getParent() === $this) { - $child->setParent(null); - } - } - - return $this; - } - - public function getAllChildren(array $criteria = []): ArrayCollection - { - $children = []; - - $getChildren = function (Node $node) use (&$children, &$getChildren) { - foreach ($node->getChildren() as $nodeChildren) { - $children[] = $nodeChildren; - - $getChildren($nodeChildren); - } - }; - - $getChildren($this); - - usort($children, function ($a, $b) { - return $a->getTreeLeft() < $b->getTreeLeft() ? -1 : 1; - }); - - if (!empty($criteria)) { - foreach ($children as $key => $child) { - if (isset($criteria['visible']) && $child->getIsVisible() !== $criteria['visible']) { - unset($children[$key]); - } - } - } - - return new ArrayCollection($children); - } - - public function getLabel(): ?string - { - return $this->label; - } - - public function setLabel(?string $label): self - { - $this->label = $label; - - return $this; - } - - public function getUrl(): ?string - { - return $this->url; - } - - public function setUrl(?string $url): self - { - $this->url = $url; - - return $this; - } - - public function hasExternalUrl(): bool - { - $string = u($this->getUrl()); - - return $string->startsWith('http://') || $string->startsWith('https://'); - } - - public function hasAppUrl(): bool - { - $string = u($this->getUrl()); - - foreach (['tel:', 'fax:', 'mailto:'] as $prefix) { - if ($string->startsWith($prefix)) { - return true; - } - } - - return false; - } - - public function getIsVisible(): ?bool - { - return $this->isVisible; - } - - public function setIsVisible(bool $isVisible): self - { - $this->isVisible = $isVisible; - - return $this; - } - - public function getDisableUrl(): ?bool - { - return $this->disableUrl; - } - - public function setDisableUrl(bool $disableUrl): self - { - $this->disableUrl = $disableUrl; - - return $this; - } - - public function getTreeLabel() - { - $prefix = str_repeat('-', ($this->getTreeLevel() - 1) * 5); - - return trim($prefix.' '.$this->getLabel()); - } - - public function getPage(): ?Page - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getPage(); - } - - return $this->page; - } - - public function setPage(?Page $page): self - { - $this->page = $page; - - return $this; - } - - public function getRouteName(): string - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getRouteName(); - } - - return $this->getMenu()->getRouteName().'_'.($this->getCode() ? $this->getCode() : $this->getId()); - } - - public function getCode(): ?string - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getCode(); - } - - return $this->code; - } - - public function setCode(?string $code): self - { - $this->code = $code; - - return $this; - } - - public function getParameters(): ?array - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getParameters(); - } - - if (!is_array($this->parameters)) { - $this->parameters = []; - } - - return $this->parameters; - } - - public function setParameters(array $parameters): self - { - $this->parameters = $parameters; - - return $this; - } - - public function getAttributes(): ?array - { - if (!is_array($this->attributes)) { - $this->attributes = []; - } - - return $this->attributes; - } - - public function setAttributes(array $attributes): self - { - $this->attributes = $attributes; - - return $this; - } - - public function getController(): ?string - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getController(); - } - - return $this->controller; - } - - public function setController(?string $controller): self - { - $this->controller = $controller; - - return $this; - } - - public function getSitemapParameters(): ?array - { - if ($this->getAliasNode()) { - return $this->getAliasNode()->getSitemapParameters(); - } - - if (!is_array($this->sitemapParameters)) { - $this->sitemapParameters = [ - 'isVisible' => false, - 'priority' => 0, - 'changeFrequency' => 'daily', - ]; - } - - return $this->sitemapParameters; - } - - public function setSitemapParameters(?array $sitemapParameters): self - { - $this->sitemapParameters = $sitemapParameters; - - return $this; - } - - public function getAliasNode(): ?self - { - return $this->aliasNode; - } - - public function setAliasNode(?self $aliasNode): self - { - $this->aliasNode = $aliasNode; - - return $this; - } - - /** - * @return Collection|self[] - */ - public function getAliasNodes(): Collection - { - return $this->aliasNodes; - } - - public function addAliasNode(self $aliasNode): self - { - if (!$this->aliasNodes->contains($aliasNode)) { - $this->aliasNodes[] = $aliasNode; - $aliasNode->setAliasNode($this); - } - - return $this; - } - - public function removeAliasNode(self $aliasNode): self - { - if ($this->aliasNodes->removeElement($aliasNode)) { - // set the owning side to null (unless already changed) - if ($aliasNode->getAliasNode() === $this) { - $aliasNode->setAliasNode(null); - } - } - - return $this; - } - - public function getContentType(): ?string - { - return $this->contentType; - } - - public function setContentType(?string $contentType): self - { - $this->contentType = $contentType; - - return $this; - } - - public function getEnableAnalytics(): ?bool - { - return $this->enableAnalytics; - } - - public function setEnableAnalytics(bool $enableAnalytics): self - { - $this->enableAnalytics = $enableAnalytics; - - return $this; - } - - /** - * @return Collection|View[] - */ - public function getAnalyticViews(): Collection - { - return $this->analyticViews; - } - - public function addAnalyticView(View $view): self - { - if (!$this->analyticViews->contains($view)) { - $this->analyticViews[] = $view; - $view->setNode($this); - } - - return $this; - } - - public function removeAnalyticView(View $view): self - { - if ($this->analyticViews->removeElement($view)) { - // set the owning side to null (unless already changed) - if ($view->getNode() === $this) { - $view->setNode(null); - } - } - - return $this; - } - - /** - * @return Collection|Referer[] - */ - public function getAnalyticReferers(): Collection - { - return $this->analyticReferers; - } - - public function addAnalyticReferer(Referer $referer): self - { - if (!$this->analyticReferers->contains($referer)) { - $this->analyticReferers[] = $referer; - $referer->setNode($this); - } - - return $this; - } - - public function removeAnalyticReferer(Referer $referer): self - { - if ($this->analyticReferers->removeElement($referer)) { - // set the owning side to null (unless already changed) - if ($referer->getNode() === $this) { - $referer->setNode(null); - } - } - - return $this; - } - - public function getSecurityRoles(): array - { - return !is_array($this->securityRoles) ? [] : $this->securityRoles; - } - - public function setSecurityRoles(array $securityRoles): self - { - $this->securityRoles = $securityRoles; - - return $this; - } - - public function getSecurityOperator(): ?string - { - return $this->securityOperator; - } - - public function setSecurityOperator(string $securityOperator): self - { - $this->securityOperator = $securityOperator; - - return $this; - } -} diff --git a/core/Entity/Site/Page/Block.php b/core/Entity/Site/Page/Block.php deleted file mode 100644 index 978bd01..0000000 --- a/core/Entity/Site/Page/Block.php +++ /dev/null @@ -1,82 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getValue() - { - return $this->value; - } - - public function setValue($value): self - { - $this->value = $value; - - return $this; - } - - public function getPage(): ?Page - { - return $this->page; - } - - public function setPage(?Page $page): self - { - $this->page = $page; - - return $this; - } -} diff --git a/core/Entity/Site/Page/ChoiceBlock.php b/core/Entity/Site/Page/ChoiceBlock.php deleted file mode 100644 index 69f5b38..0000000 --- a/core/Entity/Site/Page/ChoiceBlock.php +++ /dev/null @@ -1,21 +0,0 @@ -getValue() instanceof File && null === $value) { - return $this; - } - - return parent::setValue($value); - } -} diff --git a/core/Entity/Site/Page/Page.php b/core/Entity/Site/Page/Page.php deleted file mode 100644 index 7d74000..0000000 --- a/core/Entity/Site/Page/Page.php +++ /dev/null @@ -1,276 +0,0 @@ -blocks = new ArrayCollection(); - $this->nodes = new ArrayCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getTemplate(): ?string - { - return $this->template; - } - - public function setTemplate(?string $template): self - { - $this->template = $template; - - return $this; - } - - /** - * @return Collection|Block[] - */ - public function getBlocks(): Collection - { - return $this->blocks; - } - - public function addBlock(Block $block): self - { - if (!$this->blocks->contains($block)) { - $this->blocks[] = $block; - $block->setPage($this); - } - - return $this; - } - - public function removeBlock(Block $block): self - { - if ($this->blocks->removeElement($block)) { - // set the owning side to null (unless already changed) - if ($block->getPage() === $this) { - $block->setPage(null); - } - } - - return $this; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - } - - public function getBlock($name, string $className = null) - { - foreach ($this->getBlocks() as $block) { - if ($block->getName() === $name) { - return $block; - } - } - - if ($className) { - $block = new $className(); - } else { - $block = new Block(); - } - - $block->setName($name); - $block->setPage($this); - - return $block; - } - - public function setBlock(Block $block): self - { - foreach ($this->blocks->toArray() as $key => $value) { - if ($value->getName() === $block->getName()) { - $this->blocks->remove($key); - $this->blocks->add($block); - - return $this; - } - } - - $this->blocks->add($block); - - return $this; - } - - public function getMetaTitle(): ?string - { - return $this->metaTitle; - } - - public function setMetaTitle(?string $metaTitle): self - { - $this->metaTitle = $metaTitle; - - return $this; - } - - public function getMetaDescription(): ?string - { - return $this->metaDescription; - } - - public function setMetaDescription(?string $metaDescription): self - { - $this->metaDescription = $metaDescription; - - return $this; - } - - public function getOgTitle(): ?string - { - return $this->ogTitle; - } - - public function setOgTitle(?string $ogTitle): self - { - $this->ogTitle = $ogTitle; - - return $this; - } - - public function getOgDescription(): ?string - { - return $this->ogDescription; - } - - public function setOgDescription(?string $ogDescription): self - { - $this->ogDescription = $ogDescription; - - return $this; - } - - public function getOgImage() - { - return FileAttribute::handleFile($this->ogImage); - } - - public function setOgImage($ogImage): self - { - if (null !== $this->ogImage && null === $ogImage) { - return $this; - } - - $this->ogImage = $ogImage; - - return $this; - } - - /** - * @return Collection|Node[] - */ - public function getNodes(): Collection - { - return $this->nodes; - } - - public function addNode(Node $node): self - { - if (!$this->nodes->contains($node)) { - $this->nodes[] = $node; - $node->setPage($this); - } - - return $this; - } - - public function removeNode(Node $node): self - { - if ($this->nodes->removeElement($node)) { - // set the owning side to null (unless already changed) - if ($node->getPage() === $this) { - $node->setPage(null); - } - } - - return $this; - } -} diff --git a/core/Entity/Site/Page/TextBlock.php b/core/Entity/Site/Page/TextBlock.php deleted file mode 100644 index 54ec679..0000000 --- a/core/Entity/Site/Page/TextBlock.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -class PasswordRequestEvent extends Event -{ - const EVENT = 'account_event.password_request'; - - protected User $user; - - public function __construct(User $user) - { - $this->user = $user; - } - - public function getUser(): USer - { - return $this->user; - } -} diff --git a/core/Event/EntityManager/EntityManagerEvent.php b/core/Event/EntityManager/EntityManagerEvent.php deleted file mode 100644 index 7c5c666..0000000 --- a/core/Event/EntityManager/EntityManagerEvent.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class EntityManagerEvent extends Event -{ - const CREATE_EVENT = 'entity_manager_event.create'; - const UPDATE_EVENT = 'entity_manager_event.update'; - const DELETE_EVENT = 'entity_manager_event.delete'; - const PRE_CREATE_EVENT = 'entity_manager_event.pre_create'; - const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update'; - const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete'; - - protected EntityInterface $entity; - - public function __construct(EntityInterface $entity) - { - $this->entity = $entity; - } - - public function getEntity(): EntityInterface - { - return $this->entity; - } -} diff --git a/core/Event/Page/PageEditEvent.php b/core/Event/Page/PageEditEvent.php deleted file mode 100644 index afa7d3d..0000000 --- a/core/Event/Page/PageEditEvent.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class PageEditEvent extends Event -{ - const FORM_INIT_EVENT = 'page_edit_event.form_init'; - - protected Page $page; - protected array $pageBuilderOptions = []; - - public function __construct(Page $page) - { - $this->page = $page; - } - - public function getPage() - { - return $this->page; - } - - public function getPageBuilderOptions(): array - { - return $this->pageBuilderOptions; - } - - public function addPageBuilderOptions(array $options): self - { - $this->pageBuilderOptions = array_merge( - $this->pageBuilderOptions, - $options - ); - - return $this; - } -} diff --git a/core/Event/Setting/NavigationSettingEvent.php b/core/Event/Setting/NavigationSettingEvent.php deleted file mode 100644 index 60133c7..0000000 --- a/core/Event/Setting/NavigationSettingEvent.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class NavigationSettingEvent extends Event -{ - const INIT_EVENT = 'navigation_setting_event.init'; - const FORM_INIT_EVENT = 'navigation_setting_event.form_init'; - - protected $data; - - public function __construct($data = null) - { - $this->data = $data; - } - - public function getData() - { - return $this->data; - } - - public function setOption(string $key, $value): self - { - $this->data['options'][$key] = $value; - - return $this; - } -} diff --git a/core/Event/Setting/SettingEvent.php b/core/Event/Setting/SettingEvent.php deleted file mode 100644 index f5a8805..0000000 --- a/core/Event/Setting/SettingEvent.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class SettingEvent extends Event -{ - const INIT_EVENT = 'setting_event.init'; - const FORM_INIT_EVENT = 'setting_event.form_init'; - - protected $data; - - public function __construct($data = null) - { - $this->data = $data; - } - - public function getData() - { - return $this->data; - } - - public function setOption(string $key, $value): self - { - $this->data['options'][$key] = $value; - - return $this; - } -} diff --git a/core/Event/Task/TaskInitEvent.php b/core/Event/Task/TaskInitEvent.php deleted file mode 100644 index d436195..0000000 --- a/core/Event/Task/TaskInitEvent.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class TaskInitEvent extends Event -{ - const INIT_EVENT = 'task_event.init'; - - protected array $tasks = []; - - public function getTasks(): array - { - usort($this->tasks, function ($t1, $t2) { - return $t1['section'] != $t2['section']; - }); - - return $this->tasks; - } - - public function addTask(string $task, string $section, string $label): self - { - $this->tasks[$task] = [ - 'label' => $label, - 'section' => $section, - 'task' => $task, - ]; - - return $this; - } -} diff --git a/core/Event/Task/TaskRunRequestedEvent.php b/core/Event/Task/TaskRunRequestedEvent.php deleted file mode 100644 index d25ed89..0000000 --- a/core/Event/Task/TaskRunRequestedEvent.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class TaskRunRequestedEvent extends Event -{ - const RUN_REQUEST_EVENT = 'task_event.run_request'; - - protected string $task; - protected InputBag $parameters; - protected BufferedOutput $output; - - public function __construct(string $task, InputBag $parameters, BufferedOutput $output) - { - $this->task = $task; - $this->parameters = $parameters; - $this->output = $output; - } - - public function getTask(): string - { - return $this->task; - } - - public function getParameters(): ParameterBagInterface - { - return $this->parameters; - } - - public function getOutput(): BufferedOutput - { - return $this->output; - } -} diff --git a/core/EventListener/AnalyticListener.php b/core/EventListener/AnalyticListener.php deleted file mode 100644 index 5fe1069..0000000 --- a/core/EventListener/AnalyticListener.php +++ /dev/null @@ -1,153 +0,0 @@ - - */ -class AnalyticListener -{ - protected NodeRepository $nodeRepository; - protected ViewRepositoryQuery $viewRepositoryQuery; - protected ViewFactory $viewFactory; - protected RefererRepositoryQuery $refererRepositoryQuery; - protected RefererFactory $refererFactory; - protected EntityManager $manager; - protected DeviceDetector $deviceDetector; - protected Request $request; - protected Node $node; - - public function __construct( - NodeRepository $nodeRepository, - ViewRepositoryQuery $viewRepositoryQuery, - ViewFactory $viewFactory, - RefererRepositoryQuery $refererRepositoryQuery, - RefererFactory $refererFactory, - EntityManager $manager - ) { - $this->nodeRepository = $nodeRepository; - $this->viewRepositoryQuery = $viewRepositoryQuery; - $this->viewFactory = $viewFactory; - $this->refererRepositoryQuery = $refererRepositoryQuery; - $this->refererFactory = $refererFactory; - $this->manager = $manager; - $this->createDeviceDetector(); - } - - public function onKernelRequest(RequestEvent $event) - { - $request = $event->getRequest(); - - if (!$request->attributes->has('_node')) { - return; - } - - $this->deviceDetector->setUserAgent($request->headers->get('user-agent')); - $this->deviceDetector->parse(); - - if ($this->deviceDetector->isBot()) { - return; - } - - $node = $this->nodeRepository->findOneBy([ - 'id' => $request->attributes->get('_node'), - 'enableAnalytics' => true, - ]); - - if (!$node) { - return; - } - - $this->node = $node; - $this->request = $request; - - $this->createView(); - $this->createReferer(); - } - - protected function createDeviceDetector() - { - $cache = new ApcuAdapter(); - - $this->deviceDetector = new DeviceDetector(); - $this->deviceDetector->setCache(new PSR6Bridge($cache)); - } - - protected function createView() - { - $entity = $this->viewRepositoryQuery->create() - ->filterByRequest($this->request) - ->andWhere('.date=CURRENT_DATE()') - ->findOne() - ; - - if (!$entity) { - $entity = $this->viewFactory->create($this->node, $this->request->getPathInfo()); - } - - $entity->addView(); - - if ($this->deviceDetector->isDesktop()) { - $entity->addDesktopView(); - } elseif ($this->deviceDetector->isMobile()) { - $entity->addMobileView(); - } - - $this->save($entity); - } - - protected function createReferer() - { - if (!$this->request->headers->has('referer')) { - return; - } - - $referer = $this->request->headers->get('referer'); - - if (!filter_var($referer, FILTER_VALIDATE_URL)) { - return; - } - - if (!in_array(parse_url($referer, PHP_URL_SCHEME), ['http', 'https'])) { - return; - } - - $entity = $this->refererRepositoryQuery->create() - ->filterByRequest($this->request) - ->andWhere('.date=CURRENT_DATE()') - ->findOne() - ; - - if (!$entity) { - $entity = $this->refererFactory->create($this->node, $referer); - } - - $entity->addView(); - $this->save($entity); - } - - protected function save(EntityInterface $entity) - { - if ($entity->getId()) { - $this->manager->update($entity); - } else { - $this->manager->create($entity); - } - } -} diff --git a/core/EventListener/RedirectListener.php b/core/EventListener/RedirectListener.php deleted file mode 100644 index edb7218..0000000 --- a/core/EventListener/RedirectListener.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class RedirectListener -{ - protected RedirectMatcher $matcher; - protected RedirectBuilder $builder; - protected RedirectRepositoryQuery $repository; - - public function __construct(RedirectMatcher $matcher, RedirectBuilder $builder, RedirectRepositoryQuery $repository) - { - $this->matcher = $matcher; - $this->builder = $builder; - $this->repository = $repository; - } - - public function onKernelException(ExceptionEvent $event) - { - $request = $event->getRequest(); - - if (!$event->getThrowable() instanceof NotFoundHttpException) { - return; - } - - $redirects = $this->repository - ->orderBy('.sortOrder') - ->where('.isEnabled=1') - ->find() - ; - - foreach ($redirects as $redirect) { - if ($this->matcher->match($redirect, $event->getRequest()->getUri())) { - $event->setResponse($this->builder->buildResponse($redirect, $event->getRequest())); - } - } - } -} diff --git a/core/EventSubscriber/Account/PasswordRequestEventSubscriber.php b/core/EventSubscriber/Account/PasswordRequestEventSubscriber.php deleted file mode 100644 index 8f2c5d2..0000000 --- a/core/EventSubscriber/Account/PasswordRequestEventSubscriber.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class PasswordRequestEventSubscriber implements EventSubscriberInterface -{ - protected MailNotifier $notifier; - protected UrlGeneratorInterface $urlGenerator; - protected EntityManager $entityManager; - protected TokenGeneratorInterface $tokenGenerator; - protected TranslatorInterface $translator; - - public function __construct( - MailNotifier $notifier, - UrlGeneratorInterface $urlGenerator, - EntityManager $entityManager, - TokenGeneratorInterface $tokenGenerator, - TranslatorInterface $translator - ) { - $this->notifier = $notifier; - $this->urlGenerator = $urlGenerator; - $this->entityManager = $entityManager; - $this->tokenGenerator = $tokenGenerator; - $this->translator = $translator; - } - - public static function getSubscribedEvents() - { - return [ - PasswordRequestEvent::EVENT => 'onRequest', - ]; - } - - public function onRequest(PasswordRequestEvent $event) - { - $user = $event->getUser(); - $user->setConfirmationToken($this->tokenGenerator->generateToken()); - $user->setPasswordRequestedAt(new \DateTime('now')); - - $this->entityManager->update($user); - - $this->notifier - ->setSubject($this->translator->trans('Mot de passe perdu')) - ->addRecipient($user->getEmail()) - ->notify('@Core/mail/account/resetting_request.html.twig', [ - 'reseting_update_link' => $this->urlGenerator->generate( - 'auth_resetting_update', - [ - 'token' => $user->getConfirmationToken(), - ], - UrlGeneratorInterface::ABSOLUTE_URL - ), - ]) - ; - } -} diff --git a/core/EventSubscriber/EntityManagerEventSubscriber.php b/core/EventSubscriber/EntityManagerEventSubscriber.php deleted file mode 100644 index 4a57c1b..0000000 --- a/core/EventSubscriber/EntityManagerEventSubscriber.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -abstract class EntityManagerEventSubscriber implements EventSubscriberInterface -{ - protected static int $priority = 0; - - public static function getSubscribedEvents() - { - return [ - EntityManagerEvent::CREATE_EVENT => ['onCreate', self::$priority], - EntityManagerEvent::UPDATE_EVENT => ['onUpdate', self::$priority], - EntityManagerEvent::DELETE_EVENT => ['onDelete', self::$priority], - EntityManagerEvent::PRE_CREATE_EVENT => ['onPreCreate', self::$priority], - EntityManagerEvent::PRE_UPDATE_EVENT => ['onPreUpdate', self::$priority], - EntityManagerEvent::PRE_DELETE_EVENT => ['onPreDelete', self::$priority], - ]; - } - - public function onCreate(EntityManagerEvent $event) - { - } - - public function onUpdate(EntityManagerEvent $event) - { - } - - public function onDelete(EntityManagerEvent $event) - { - } - - public function onPreCreate(EntityManagerEvent $event) - { - } - - public function onPreUpdate(EntityManagerEvent $event) - { - } - - public function onPreDelete(EntityManagerEvent $event) - { - } -} diff --git a/core/EventSubscriber/NavigationSettingEventSubscriber.php b/core/EventSubscriber/NavigationSettingEventSubscriber.php deleted file mode 100644 index 0283d76..0000000 --- a/core/EventSubscriber/NavigationSettingEventSubscriber.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -abstract class NavigationSettingEventSubscriber implements EventSubscriberInterface -{ - protected static int $priority = 0; - - public static function getSubscribedEvents() - { - return [ - NavigationSettingEvent::INIT_EVENT => ['onInit', self::$priority], - NavigationSettingEvent::FORM_INIT_EVENT => ['onFormInit', self::$priority], - ]; - } - - public function onInit(NavigationSettingEvent $event) - { - } - - public function onFormInit(NavigationSettingEvent $event) - { - } -} diff --git a/core/EventSubscriber/RequestSecurityEventSubscriber.php b/core/EventSubscriber/RequestSecurityEventSubscriber.php deleted file mode 100644 index 00ede77..0000000 --- a/core/EventSubscriber/RequestSecurityEventSubscriber.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class RequestSecurityEventSubscriber implements EventSubscriberInterface -{ - protected NodeRepository $nodeRepository; - protected AuthorizationChecker $authorizationChecker; - - public function __construct(NodeRepository $nodeRepository, ContainerInterface $container) - { - $this->nodeRepository = $nodeRepository; - $this->authorizationChecker = $container->get('security.authorization_checker'); - } - - public function onKernelRequest(RequestEvent $event) - { - $request = $event->getRequest(); - - if (!$request->attributes->has('_node')) { - return; - } - - $node = $this->nodeRepository->findOneBy([ - 'id' => $request->attributes->get('_node'), - ]); - - $roles = $node->getSecurityRoles(); - - if (empty($roles)) { - return; - } - - $operator = $node->getSecurityOperator(); - $exception = new AccessDeniedException('Access denied.'); - - foreach ($roles as $role) { - $isGranted = $this->authorizationChecker->isGranted($role); - - if ('or' === $operator && $isGranted) { - return; - } - if ('and' === $operator && !$isGranted) { - throw $exception; - } - } - - throw $exception; - } - - public static function getSubscribedEvents(): array - { - return [ - RequestEvent::class => ['onKernelRequest', 1], - ]; - } -} diff --git a/core/EventSubscriber/SettingEventSubscriber.php b/core/EventSubscriber/SettingEventSubscriber.php deleted file mode 100644 index c0ff1c4..0000000 --- a/core/EventSubscriber/SettingEventSubscriber.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -abstract class SettingEventSubscriber implements EventSubscriberInterface -{ - protected static int $priority = 0; - - public static function getSubscribedEvents() - { - return [ - SettingEvent::INIT_EVENT => ['onInit', self::$priority], - SettingEvent::FORM_INIT_EVENT => ['onFormInit', self::$priority], - ]; - } - - public function onInit(SettingEvent $event) - { - } - - public function onFormInit(SettingEvent $event) - { - } -} diff --git a/core/EventSubscriber/Site/ForcedDomainEventSubscriber.php b/core/EventSubscriber/Site/ForcedDomainEventSubscriber.php deleted file mode 100644 index 5aa86fe..0000000 --- a/core/EventSubscriber/Site/ForcedDomainEventSubscriber.php +++ /dev/null @@ -1,53 +0,0 @@ -siteRequest = $siteRequest; - } - - public function onKernelResponse(ResponseEvent $event) - { - $navigation = $this->siteRequest->getNavigation(); - - if (!$navigation) { - return; - } - - if (!$navigation->getForceDomain()) { - return; - } - - if ($navigation->getDomain() === $this->siteRequest->getDomain()) { - return; - } - - $uri = u($this->siteRequest->getUri()) - ->replace( - '://'.$this->siteRequest->getDomain(), - '://'.$navigation->getDomain() - ); - - $event->getResponse()->headers->set('Location', $uri); - $event->getResponse()->setStatusCode(Response::HTTP_MOVED_PERMANENTLY); - } - - public static function getSubscribedEvents() - { - return [ - KernelEvents::RESPONSE => [['onKernelResponse', 20]], - ]; - } -} diff --git a/core/EventSubscriber/Site/MenuEventSubscriber.php b/core/EventSubscriber/Site/MenuEventSubscriber.php deleted file mode 100644 index bd2843e..0000000 --- a/core/EventSubscriber/Site/MenuEventSubscriber.php +++ /dev/null @@ -1,107 +0,0 @@ - - */ -class MenuEventSubscriber extends EntityManagerEventSubscriber -{ - protected NodeFactory $nodeFactory; - protected NodeRepository $nodeRepository; - protected EntityManager $entityManager; - protected CodeSlugify $slugify; - protected SymfonyCacheManager $cacheManager; - protected TranslatorInterface $translation; - - public function __construct( - NodeFactory $nodeFactory, - NodeRepository $nodeRepository, - EntityManager $entityManager, - CodeSlugify $slugify, - SymfonyCacheManager $cacheManager, - TranslatorInterface $translator - ) { - $this->nodeFactory = $nodeFactory; - $this->nodeRepository = $nodeRepository; - $this->entityManager = $entityManager; - $this->slugify = $slugify; - $this->cacheManager = $cacheManager; - $this->translator = $translator; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Menu; - } - - public function onPreUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $menu = $event->getEntity(); - $menu->setCode($this->slugify->slugify($menu->getCode())); - } - - public function onCreate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $menu = $event->getEntity(); - - if (count($menu->getNodes()) > 2) { - return; - } - - $rootNode = $menu->getRootNode(); - - if (!$rootNode) { - $rootNode = $this->nodeFactory->create($menu); - } - - $childNode = $this->nodeFactory->create($menu, '/'); - $childNode - ->setParent($rootNode) - ->setLabel($this->translator->trans('First element')) - ; - - $menu->setRootNode($rootNode); - - $this->entityManager->getEntityManager()->persist($rootNode); - $this->entityManager->getEntityManager()->persist($childNode); - - $this->entityManager->getEntityManager()->persist($menu); - $this->entityManager->flush(); - - $this->nodeRepository->persistAsFirstChild($childNode, $rootNode); - - $this->cacheManager->cleanRouting(); - } - - public function onUpdate(EntityManagerEvent $event) - { - return $this->onCreate($event); - } - - public function onPreCreate(EntityManagerEvent $event) - { - return $this->onPreUpdate($event); - } -} diff --git a/core/EventSubscriber/Site/NavigationEventSubscriber.php b/core/EventSubscriber/Site/NavigationEventSubscriber.php deleted file mode 100644 index f342799..0000000 --- a/core/EventSubscriber/Site/NavigationEventSubscriber.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class NavigationEventSubscriber extends EntityManagerEventSubscriber -{ - public function __construct( - EntityManager $entityManager, - CodeSlugify $slugify - ) { - $this->entityManager = $entityManager; - $this->slugify = $slugify; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Navigation; - } - - public function onPreUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $menu = $event->getEntity(); - $menu->setCode($this->slugify->slugify($menu->getCode())); - } - - public function onPreCreate(EntityManagerEvent $event) - { - return $this->onPreUpdate($event); - } -} diff --git a/core/EventSubscriber/Site/NodeEventSubscriber.php b/core/EventSubscriber/Site/NodeEventSubscriber.php deleted file mode 100644 index 75255b7..0000000 --- a/core/EventSubscriber/Site/NodeEventSubscriber.php +++ /dev/null @@ -1,183 +0,0 @@ - - */ -class NodeEventSubscriber extends EntityManagerEventSubscriber -{ - protected NodeFactory $nodeFactory; - protected EntityManager $entityManager; - protected KernelInterface $kernel; - protected Slugify $slugify; - protected CodeSlugify $codeSlugify; - protected RouteParameterSlugify $routeParameterSlugify; - - public function __construct( - NodeFactory $nodeFactory, - NodeRepository $nodeRepository, - EntityManager $entityManager, - Slugify $slugify, - CodeSlugify $codeSlugify, - RouteParameterSlugify $routeParameterSlugify - ) { - $this->nodeFactory = $nodeFactory; - $this->nodeRepository = $nodeRepository; - $this->entityManager = $entityManager; - $this->slugify = $slugify; - $this->codeSlugify = $codeSlugify; - $this->routeParameterSlugify = $routeParameterSlugify; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Node; - } - - public function onPreCreate(EntityManagerEvent $event) - { - return $this->onPreUpdate($event); - } - - public function onPreUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $node = $event->getEntity(); - - $node->setCode($this->codeSlugify->slugify($node->getCode())); - - if ($node->getDisableUrl()) { - $node->setUrl(null); - } else { - if ($node->getUrl()) { - $generatedUrl = $node->getUrl(); - } else { - $path = []; - $parent = $node->getParent(); - - if ($parent && $parent->getUrl()) { - $pPath = trim($parent->getUrl(), '/'); - - if ($pPath) { - $path[] = $pPath; - } - } - - $path[] = $this->slugify->slugify($node->getLabel()); - - $generatedUrl = '/'.implode('/', $path); - } - - if ('/' !== $generatedUrl) { - $generatedUrl = rtrim($generatedUrl, '/'); - } - - $parameters = $node->getParameters(); - $routeParameters = []; - - foreach ($parameters as $key => $parameter) { - $parameter['name'] = $this->routeParameterSlugify->slugify($parameter['name']); - $routeParameter = sprintf('{%s}', $parameter['name']); - $regex = '/'.preg_quote($routeParameter).'/'; - $routeParameters[] = $parameter['name']; - - if (!preg_match($regex, $generatedUrl)) { - $generatedUrl .= '/'.$routeParameter; - } - - $parameters[$key] = $parameter; - } - - preg_match_all('/\{(.*)\}/isU', $generatedUrl, $matches, PREG_SET_ORDER); - - foreach ($matches as $match) { - if (!in_array($match[1], $routeParameters)) { - $parameters[] = [ - 'name' => $this->routeParameterSlugify->slugify($match[1]), - 'defaultValue' => null, - 'requirement' => null, - ]; - } - } - - $node->setParameters($parameters); - - $urlExists = $this->nodeRepository->urlExists($generatedUrl, $node); - - if ($urlExists) { - $number = 1; - - while ($this->nodeRepository->urlExists($generatedUrl.'-'.$number, $node)) { - ++$number; - } - - $generatedUrl = $generatedUrl.'-'.$number; - } - - if ( - !u($generatedUrl)->startsWith('https://') - && !u($generatedUrl)->startsWith('http://') - && !u($generatedUrl)->startsWith('tel:') - && !u($generatedUrl)->startsWith('mailto:') - && !u($generatedUrl)->startsWith('fax:') - ) { - $generatedUrl = '/'.$generatedUrl; - $generatedUrl = preg_replace('#/{2,}#', '/', $generatedUrl); - } - - $node->setUrl($generatedUrl); - } - - $attributes = $node->getAttributes(); - $realAttributes = []; - - foreach ($attributes as $key => $attribute) { - $realAttributes[$this->routeParameterSlugify->slugify($attribute['label'])] = $attribute; - } - - $node->setAttributes($realAttributes); - } - - public function onDelete(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $menu = $event->getEntity()->getMenu(); - $rootNode = $menu->getRootNode(); - - if (0 !== count($rootNode->getChildren())) { - return; - } - - $childNode = $this->nodeFactory->create($menu); - $childNode - ->setParent($rootNode) - ->setLabel('Premier élément') - ; - - $this->entityManager->update($rootNode, false); - $this->entityManager->create($childNode, false); - $this->nodeRepository->persistAsFirstChild($childNode, $rootNode); - } -} diff --git a/core/EventSubscriber/Site/Page/BlockEventSubscriber.php b/core/EventSubscriber/Site/Page/BlockEventSubscriber.php deleted file mode 100644 index 46d597d..0000000 --- a/core/EventSubscriber/Site/Page/BlockEventSubscriber.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -class BlockEventSubscriber extends EntityManagerEventSubscriber -{ - protected FileUploadHandler $fileUpload; - - public function __construct(FileUploadHandler $fileUpload) - { - $this->fileUpload = $fileUpload; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Page; - } - - public function onPreUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - foreach ($event->getEntity()->getBlocks() as $block) { - if ($block instanceof FileBlock) { - if ($block->getValue() instanceof UploadedFile) { - $directory = 'uploads/page/block'; - - $this->fileUpload->handleForm( - $block->getValue(), - $directory, - function ($filename) use ($block, $directory) { - $block->setValue($directory.'/'.$filename); - } - ); - } - } - } - } - - public function onPreCreate(EntityManagerEvent $event) - { - return $this->onPreUpdate($event); - } -} diff --git a/core/EventSubscriber/Site/Page/PageEventSubscriber.php b/core/EventSubscriber/Site/Page/PageEventSubscriber.php deleted file mode 100644 index 453567e..0000000 --- a/core/EventSubscriber/Site/Page/PageEventSubscriber.php +++ /dev/null @@ -1,56 +0,0 @@ - - */ -class PageEventSubscriber extends EntityManagerEventSubscriber -{ - protected FileUploadHandler $fileUpload; - - public function __construct(FileUploadHandler $fileUpload) - { - $this->fileUpload = $fileUpload; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Page; - } - - public function onPreUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $page = $event->getEntity(); - - if ($page->getOgImage() instanceof UploadedFile) { - $directory = 'uploads/page/ogImage'; - - $this->fileUpload->handleForm( - $page->getOgImage(), - $directory, - function ($filename) use ($page, $directory) { - $page->setOgImage($directory.'/'.$filename); - } - ); - } - } - - public function onPreCreate(EntityManagerEvent $event) - { - return $this->onPreUpdate($event); - } -} diff --git a/core/EventSubscriber/Site/SiteEventSubscriber.php b/core/EventSubscriber/Site/SiteEventSubscriber.php deleted file mode 100644 index 86aa758..0000000 --- a/core/EventSubscriber/Site/SiteEventSubscriber.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class SiteEventSubscriber extends EntityManagerEventSubscriber -{ - protected KernelInterface $kernel; - protected SymfonyCacheManager $cacheManager; - - public function __construct(KernelInterface $kernel, SymfonyCacheManager $cacheManager) - { - $this->kernel = $kernel; - $this->cacheManager = $cacheManager; - } - - public function support(EntityInterface $entity) - { - return $entity instanceof Node || $entity instanceof Menu || $entity instanceof Navigation; - } - - public function onUpdate(EntityManagerEvent $event) - { - if (!$this->support($event->getEntity())) { - return; - } - - $this->cacheManager->cleanRouting(); - } - - public function onCreate(EntityManagerEvent $event) - { - return $this->onUpdate($event); - } - - public function onDelete(EntityManagerEvent $event) - { - return $this->onUpdate($event); - } -} diff --git a/core/EventSubscriber/Task/CacheCleanTaskEventSubscriber.php b/core/EventSubscriber/Task/CacheCleanTaskEventSubscriber.php deleted file mode 100644 index f2efbcb..0000000 --- a/core/EventSubscriber/Task/CacheCleanTaskEventSubscriber.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class CacheCleanTaskEventSubscriber extends TaskEventSubscriber -{ - protected SymfonyCacheManager $cacheManager; - - public function __construct(SymfonyCacheManager $cacheManager) - { - $this->cacheManager = $cacheManager; - } - - public function onInit(TaskInitEvent $event) - { - $event->addTask('cache:clear', '♻️ Cache', 'Clean all cache'); - } - - public function onRunRequest(TaskRunRequestedEvent $event) - { - if ('cache:clear' !== $event->getTask()) { - return; - } - - $this->cacheManager->cleanAll($event->getOutput()); - } -} diff --git a/core/EventSubscriber/Task/TaskEventSubscriber.php b/core/EventSubscriber/Task/TaskEventSubscriber.php deleted file mode 100644 index 7ee840d..0000000 --- a/core/EventSubscriber/Task/TaskEventSubscriber.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -abstract class TaskEventSubscriber implements EventSubscriberInterface -{ - protected static int $priority = 0; - - public static function getSubscribedEvents() - { - return [ - TaskInitEvent::INIT_EVENT => ['onInit', self::$priority], - TaskRunRequestedEvent::RUN_REQUEST_EVENT => ['onRunRequest', self::$priority], - ]; - } - - public function onInit(TaskInitEvent $event) - { - } - - public function onRunRequest(TaskRunRequestedEvent $event) - { - } -} diff --git a/core/Factory/Analytic/RefererFactory.php b/core/Factory/Analytic/RefererFactory.php deleted file mode 100644 index 8884338..0000000 --- a/core/Factory/Analytic/RefererFactory.php +++ /dev/null @@ -1,22 +0,0 @@ -setNode($node) - ->setUri($uri) - ->setDate(new \DateTime()) - ; - - return $entity; - } -} diff --git a/core/Factory/Analytic/ViewFactory.php b/core/Factory/Analytic/ViewFactory.php deleted file mode 100644 index 840c7ad..0000000 --- a/core/Factory/Analytic/ViewFactory.php +++ /dev/null @@ -1,22 +0,0 @@ -setNode($node) - ->setPath($path) - ->setDate(new \DateTime()) - ; - - return $entity; - } -} diff --git a/core/Factory/FactoryInterface.php b/core/Factory/FactoryInterface.php deleted file mode 100644 index e31ca9e..0000000 --- a/core/Factory/FactoryInterface.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -interface FactoryInterface -{ -} diff --git a/core/Factory/FileInformationFactory.php b/core/Factory/FileInformationFactory.php deleted file mode 100644 index d8b081a..0000000 --- a/core/Factory/FileInformationFactory.php +++ /dev/null @@ -1,16 +0,0 @@ -setId($id); - - return $entity; - } -} diff --git a/core/Factory/NavigationSettingFactory.php b/core/Factory/NavigationSettingFactory.php deleted file mode 100644 index a0d84f4..0000000 --- a/core/Factory/NavigationSettingFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class NavigationSettingFactory implements FactoryInterface -{ - public function create(Navigation $navigation, string $code): NavigationSetting - { - $entity = new NavigationSetting(); - - $entity - ->setNavigation($navigation) - ->setCode($code) - ; - - return $entity; - } -} diff --git a/core/Factory/RedirectFactory.php b/core/Factory/RedirectFactory.php deleted file mode 100644 index d7a138a..0000000 --- a/core/Factory/RedirectFactory.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -class SettingFactory implements FactoryInterface -{ - public function create(string $code): Setting - { - $entity = new Setting(); - - $entity->setCode($code); - - return $entity; - } -} diff --git a/core/Factory/Site/MenuFactory.php b/core/Factory/Site/MenuFactory.php deleted file mode 100644 index 48e2c44..0000000 --- a/core/Factory/Site/MenuFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class MenuFactory implements FactoryInterface -{ - public function create(?Navigation $navigation = null): Menu - { - $entity = new Menu(); - - if (null !== $navigation) { - $entity->setNavigation($navigation); - } - - return $entity; - } -} diff --git a/core/Factory/Site/NavigationFactory.php b/core/Factory/Site/NavigationFactory.php deleted file mode 100644 index a4196db..0000000 --- a/core/Factory/Site/NavigationFactory.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ -class NavigationFactory implements FactoryInterface -{ - public function create(): Navigation - { - return new Navigation(); - } -} diff --git a/core/Factory/Site/NodeFactory.php b/core/Factory/Site/NodeFactory.php deleted file mode 100644 index 587d38a..0000000 --- a/core/Factory/Site/NodeFactory.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -class NodeFactory implements FactoryInterface -{ - public function create(?Menu $menu = null, string $url = null): Node - { - $entity = new Node(); - - if (null !== $menu) { - $entity->setMenu($menu); - } - - if (null !== $url) { - $entity->setUrl($url); - } - - return $entity; - } -} diff --git a/core/Factory/Site/Page/PageFactory.php b/core/Factory/Site/Page/PageFactory.php deleted file mode 100644 index c408d31..0000000 --- a/core/Factory/Site/Page/PageFactory.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ -class PageFactory implements FactoryInterface -{ - public function create(string $className, string $name): Page - { - $entity = new $className(); - $entity->setName($name); - - return $entity; - } -} diff --git a/core/Factory/UserFactory.php b/core/Factory/UserFactory.php deleted file mode 100644 index da9eae6..0000000 --- a/core/Factory/UserFactory.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -class UserFactory implements FactoryInterface -{ - protected TokenGeneratorInterface $tokenGenerator; - protected UserPasswordEncoderInterface $encoder; - - public function __construct(UserPasswordEncoderInterface $encoder) - { - $this->encoder = $encoder; - } - - public function create(?string $email = null, ?string $password = null): User - { - $entity = new User(); - - if (null !== $email) { - $entity->setEmail($email); - } - - if (null !== $password) { - $entity->setPassword($this->encoder->encodePassword($entity, $password)); - } - - return $entity; - } -} diff --git a/core/File/FileAttribute.php b/core/File/FileAttribute.php deleted file mode 100644 index b643187..0000000 --- a/core/File/FileAttribute.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -class FileAttribute -{ - public static function handleFile($attribute, string $class = null) - { - if (null === $class) { - $class = File::class; - } - - if (is_string($attribute)) { - if (file_exists($attribute)) { - return new $class($attribute); - } - - return null; - } - - return $attribute; - } -} diff --git a/core/FileManager/FsFileManager.php b/core/FileManager/FsFileManager.php deleted file mode 100644 index e4a1751..0000000 --- a/core/FileManager/FsFileManager.php +++ /dev/null @@ -1,321 +0,0 @@ - - */ -class FsFileManager -{ - protected array $mimes; - protected string $path; - protected string $pathUri; - protected array $pathLocked; - protected FileUploadHandler $uploadHandler; - protected FileInformationFactory $fileInformationFactory; - protected FileInformationRepositoryQuery $fileInformationRepositoryQuery; - - public function __construct( - ParameterBagInterface $params, - FileUploadHandler $uploadHandler, - FileInformationFactory $fileInformationFactory, - FileInformationRepositoryQuery $fileInformationRepositoryQuery - ) { - $config = $params->get('core')['file_manager']; - - $this->uploadHandler = $uploadHandler; - $this->fileInformationFactory = $fileInformationFactory; - $this->fileInformationRepositoryQuery = $fileInformationRepositoryQuery; - - $this->mimes = $config['mimes']; - $this->path = $config['path']; - $this->pathUri = $this->normalizePath($config['path_uri']); - - foreach ($config['path_locked'] as $k => $v) { - $config['path_locked'][$k] = sprintf('/%s/', $this->normalizePath($v)); - } - - $this->pathLocked = $config['path_locked']; - } - - public function list(string $directory, array $options = []): array - { - $directory = $this->normalizePath($directory); - - $breadcrumb = ['/']; - - if ($directory) { - $breadcrumb = array_merge( - $breadcrumb, - explode('/', $directory) - ); - } - - $data = [ - 'breadcrumb' => $breadcrumb, - 'parent' => dirname($directory), - 'directories' => [], - 'files' => [], - ]; - - $finder = new Finder(); - $finder->directories()->depth('== 0')->in($this->path.'/'.$directory); - - $this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc'); - - foreach ($finder as $file) { - $data['directories'][] = [ - 'basename' => $file->getBasename(), - 'path' => $directory.'/'.$file->getBasename(), - 'webPath' => $this->pathUri.'/'.$directory.'/'.$file->getBasename(), - 'locked' => $this->isLocked($directory.'/'.$file->getBasename()), - 'mime' => null, - ]; - } - - $finder = new Finder(); - $finder->files()->depth('== 0')->in($this->path.'/'.$directory); - - $this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc'); - - foreach ($finder as $file) { - $data['files'][] = [ - 'basename' => $file->getBasename(), - 'path' => $directory, - 'webPath' => $this->pathUri.'/'.$directory.'/'.$file->getBasename(), - 'locked' => $this->isLocked($directory.'/'.$file->getBasename()), - 'mime' => mime_content_type($file->getRealPath()), - ]; - } - - return $data; - } - - public function getSplInfo(string $path): ?SplFileInfo - { - $path = $this->normalizePath($path); - - if ('' === $path) { - return new SplFileInfo($this->path, '', ''); - } - - $finder = new Finder(); - $finder->in($this->path) - ->depth('== '.substr_count($path, '/')) - ->name(basename($path)) - ; - - $dirname = dirname($path); - - if ('.' === $dirname) { - $dirname = ''; - } - - foreach ($finder as $file) { - if ($file->getRelativePath() === $dirname) { - return $file; - } - } - - return null; - } - - public function getFileInformation(string $path): ?FileInformation - { - $file = $this->getSplInfo($path); - - if (!$file) { - return null; - } - - if ($file->isDir()) { - return null; - } - - $hash = hash_file('sha384', $file->getPathName()); - - $info = $this->fileInformationRepositoryQuery - ->where('.id = :hash') - ->setParameter(':hash', $hash) - ->findOne() - ; - - if (!$info) { - $info = $this->fileInformationFactory->create($hash); - } - - return $info; - } - - public function createDirectory(string $name, string $path): bool - { - $file = $this->getSplInfo($path); - - if (!$file || $this->isLocked($path)) { - return false; - } - - $filesystem = new Filesystem(); - $path = $file->getPathname().'/'.$this->normalizePath($name); - - if ($filesystem->exists($path)) { - return false; - } - - $filesystem->mkdir($path, 0755); - - return true; - } - - public function renameDirectory(string $name, string $path): bool - { - $file = $this->getSplInfo($path); - - if (!$file || $this->isLocked($path)) { - return false; - } - - $filesystem = new Filesystem(); - $newPath = $file->getPath().'/'.$this->normalizePath($name); - - if ($filesystem->exists($newPath)) { - return false; - } - - $filesystem->rename($file->getPathName(), $newPath); - - return true; - } - - public function renameFile(string $name, string $path, bool $keepExtension = true): bool - { - $file = $this->getSplInfo($path); - - if (!$file || $this->isLocked($path)) { - return false; - } - - $filesystem = new Filesystem(); - $newPath = $file->getPath().'/'.$this->normalizePath($name); - - if ($keepExtension && $file->getExtension()) { - $newPath .= sprintf('.%s', $file->getExtension()); - } - - if ($filesystem->exists($newPath)) { - return false; - } - - $filesystem->rename($file->getPathName(), $newPath); - - return true; - } - - public function upload($files, string $path, array $fullPaths = []) - { - if ($files instanceof UploadedFile) { - $files = [$files]; - } - - foreach ($files as $key => $file) { - $directory = $this->path.'/'.$path; - - if (isset($fullPaths[$key])) { - $directory .= '/'.trim(dirname($fullPaths[$key]), '/'); - } - - $this->uploadHandler->handleForm($file, $directory, null, true); - } - } - - public function delete(string $path): bool - { - $file = $this->getSplInfo($path); - - if ($this->isLocked($file)) { - return false; - } - - if ($file) { - $filesystem = new Filesystem(); - $filesystem->remove($file); - - return true; - } - - return false; - } - - public function isLocked($path): bool - { - $file = $this->getSplInfo($path); - - if (!$file) { - return false; - } - - foreach ($this->pathLocked as $lock) { - if (u($file->getPathName().'/')->startsWith($lock)) { - return true; - } - } - - return false; - } - - public function getPath(): string - { - return $this->path; - } - - public function getPathUri(): string - { - return $this->pathUri; - } - - public function getMimes(): array - { - return $this->mimes; - } - - public function getPathLocked(): array - { - return $this->pathLocked; - } - - protected function applySort(Finder $finder, string $sort, string $direction) - { - if ('name' === $sort) { - $finder->sortByName(); - } elseif ('modification_date' === $sort) { - $finder->sortByModifiedTime(); - } - - if ('desc' === $direction) { - $finder->reverseSorting(); - } - } - - protected function normalizePath(string $path): string - { - return (string) u($path) - ->replace('..', '.') - ->replaceMatches('#/{2,}#', '/') - ->replaceMatches('#^.$#', '') - ->trim('/') - ->trim() - ; - } -} diff --git a/core/Form/FileManager/DirectoryCreateType.php b/core/Form/FileManager/DirectoryCreateType.php deleted file mode 100644 index fdc7dba..0000000 --- a/core/Form/FileManager/DirectoryCreateType.php +++ /dev/null @@ -1,40 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new Regex([ - 'pattern' => '#['.preg_quote('\\/?%*:|"<>').'\t\n\r]+#', - 'match' => false, - ]), - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - ]); - } -} diff --git a/core/Form/FileManager/DirectoryRenameType.php b/core/Form/FileManager/DirectoryRenameType.php deleted file mode 100644 index a4eac6d..0000000 --- a/core/Form/FileManager/DirectoryRenameType.php +++ /dev/null @@ -1,40 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new Regex([ - 'pattern' => '#['.preg_quote('\\/?%*:|"<>').'\t\n\r]+#', - 'match' => false, - ]), - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - ]); - } -} diff --git a/core/Form/FileManager/FileInformationAttributeType.php b/core/Form/FileManager/FileInformationAttributeType.php deleted file mode 100644 index 8bca9b0..0000000 --- a/core/Form/FileManager/FileInformationAttributeType.php +++ /dev/null @@ -1,49 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'value', - TextType::class, - [ - 'label' => 'Value', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - ]); - } -} diff --git a/core/Form/FileManager/FileInformationType.php b/core/Form/FileManager/FileInformationType.php deleted file mode 100644 index 839ea0d..0000000 --- a/core/Form/FileManager/FileInformationType.php +++ /dev/null @@ -1,34 +0,0 @@ -add( - 'attributes', - CollectionType::class, - [ - 'entry_type' => FileInformationAttributeType::class, - 'by_reference' => false, - 'allow_add' => true, - 'allow_delete' => true, - 'prototype' => true, - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => FileInformation::class, - ]); - } -} diff --git a/core/Form/FileManager/FilePickerType.php b/core/Form/FileManager/FilePickerType.php deleted file mode 100644 index 666c789..0000000 --- a/core/Form/FileManager/FilePickerType.php +++ /dev/null @@ -1,37 +0,0 @@ -vars['pattern'] = null; - unset($view->vars['attr']['pattern']); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return TextType::class; - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'file_picker'; - } -} diff --git a/core/Form/FileManager/FileRenameType.php b/core/Form/FileManager/FileRenameType.php deleted file mode 100644 index b2a2ea5..0000000 --- a/core/Form/FileManager/FileRenameType.php +++ /dev/null @@ -1,40 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new Regex([ - 'pattern' => '#['.preg_quote('\\/?%*:|"<>').'\t\n\r]+#', - 'match' => false, - ]), - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - ]); - } -} diff --git a/core/Form/FileManager/FileUploadType.php b/core/Form/FileManager/FileUploadType.php deleted file mode 100644 index b24bbcc..0000000 --- a/core/Form/FileManager/FileUploadType.php +++ /dev/null @@ -1,64 +0,0 @@ -add( - 'files', - FileType::class, - [ - 'label' => 'Files', - 'required' => false, - 'multiple' => true, - 'attr' => [ - ], - 'constraints' => [ - new All([ - new File([ - 'mimeTypes' => $options['mimes'], - ]), - ]), - ], - ] - ); - - $builder->add( - 'directory', - FileType::class, - [ - 'label' => 'Directory', - 'required' => false, - 'multiple' => true, - 'attr' => [ - 'webkitdirectory' => '', - 'mozdirectory' => '', - 'directory' => '', - ], - 'constraints' => [ - new All([ - new File([ - 'mimeTypes' => $options['mimes'], - ]), - ]), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'mimes' => [], - ]); - } -} diff --git a/core/Form/FileUploadHandler.php b/core/Form/FileUploadHandler.php deleted file mode 100644 index 68b9b90..0000000 --- a/core/Form/FileUploadHandler.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class FileUploadHandler -{ - public function handleForm(?UploadedFile $uploadedFile, string $path, ?callable $afterUploadCallback = null, bool $keepOriginalFilename = false): void - { - if (null === $uploadedFile) { - return; - } - - $originalFilename = pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME); - - if ($keepOriginalFilename) { - $filename = $originalFilename.'.'.$uploadedFile->guessExtension(); - } else { - $safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename); - $filename = date('Ymd-his').$safeFilename.'.'.$uploadedFile->guessExtension(); - } - - $uploadedFile->move($path, $filename); - - if ($afterUploadCallback) { - $afterUploadCallback($filename); - } - } -} diff --git a/core/Form/Filter/RedirectFilterType.php b/core/Form/Filter/RedirectFilterType.php deleted file mode 100644 index 2cf4cd4..0000000 --- a/core/Form/Filter/RedirectFilterType.php +++ /dev/null @@ -1,146 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'scheme', - ChoiceType::class, - [ - 'label' => 'Scheme', - 'required' => false, - 'choices' => [ - 'http(s)://' => 'all', - 'http://' => 'http', - 'https://' => 'https', - ], - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'domain', - TextType::class, - [ - 'label' => 'Domain', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'domainType', - ChoiceType::class, - [ - 'label' => 'Type', - 'required' => false, - 'choices' => [ - 'Domain' => 'domain', - 'Regular expression' => 'regexp', - ], - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'rule', - TextType::class, - [ - 'label' => '', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'ruleType', - ChoiceType::class, - [ - 'label' => 'Type', - 'required' => false, - 'choices' => [ - 'Path' => 'path', - 'Regular expression' => 'regexp', - ], - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'location', - TextType::class, - [ - 'label' => 'Location', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'redirectCode', - ChoiceType::class, - [ - 'label' => 'Code', - 'required' => false, - 'choices' => [ - '301 - Moved Permanently' => 301, - '307 - Temporary Redirect' => 307, - ], - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'data_class' => null, - 'csrf_protection' => false, - ]); - } -} diff --git a/core/Form/RedirectType.php b/core/Form/RedirectType.php deleted file mode 100644 index 3acce35..0000000 --- a/core/Form/RedirectType.php +++ /dev/null @@ -1,182 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'scheme', - ChoiceType::class, - [ - 'label' => 'Scheme', - 'required' => true, - 'choices' => [ - 'http(s)://' => 'all', - 'http://' => 'http', - 'https://' => 'https', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'domain', - TextType::class, - [ - 'label' => 'Domain', - 'required' => true, - 'attr' => [ - ], - 'help' => 'Regular expression: do not add the delimiter', - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'domainType', - ChoiceType::class, - [ - 'label' => 'Type', - 'required' => true, - 'choices' => [ - 'Domain' => 'domain', - 'Regular expression' => 'regexp', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'rule', - TextType::class, - [ - 'label' => 'Rule', - 'required' => true, - 'attr' => [ - ], - 'help' => 'Regular expression: do not add the delimiter', - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'ruleType', - ChoiceType::class, - [ - 'label' => 'Type', - 'required' => true, - 'choices' => [ - 'Path' => 'path', - 'Regular expression' => 'regexp', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'location', - TextType::class, - [ - 'label' => 'Location', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'redirectCode', - ChoiceType::class, - [ - 'label' => 'Code', - 'required' => true, - 'choices' => [ - '301 - Moved Permanently' => 301, - '307 - Temporary Redirect' => 307, - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'isEnabled', - CheckboxType::class, - [ - 'label' => 'Enabled', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'reuseQueryString', - CheckboxType::class, - [ - 'label' => 'Reuse the query string', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'data_class' => Redirect::class, - ]); - } -} diff --git a/core/Form/Site/MenuType.php b/core/Form/Site/MenuType.php deleted file mode 100644 index 3efefdd..0000000 --- a/core/Form/Site/MenuType.php +++ /dev/null @@ -1,51 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'code', - TextType::class, - [ - 'label' => 'Code', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Menu::class, - ]); - } -} diff --git a/core/Form/Site/NavigationAdditionalDomainType.php b/core/Form/Site/NavigationAdditionalDomainType.php deleted file mode 100644 index cc4ecf4..0000000 --- a/core/Form/Site/NavigationAdditionalDomainType.php +++ /dev/null @@ -1,55 +0,0 @@ -add( - 'domain', - TextType::class, - [ - 'label' => 'Domain', - 'required' => true, - 'help' => 'Regular expression: do not add the delimiter', - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'type', - ChoiceType::class, - [ - 'label' => 'Type', - 'required' => true, - 'choices' => [ - 'Domain' => 'domain', - 'Regular expression' => 'regexp', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - ]); - } -} diff --git a/core/Form/Site/NavigationType.php b/core/Form/Site/NavigationType.php deleted file mode 100644 index 9ccf546..0000000 --- a/core/Form/Site/NavigationType.php +++ /dev/null @@ -1,109 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'code', - TextType::class, - [ - 'label' => 'Code', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'domain', - TextType::class, - [ - 'label' => 'Domain', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'forceDomain', - CheckboxType::class, - [ - 'label' => 'Force this domain', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'additionalDomains', - CollectionType::class, - [ - 'entry_type' => NavigationAdditionalDomainType::class, - 'label' => 'Additional domains', - 'by_reference' => false, - 'allow_add' => true, - 'allow_delete' => true, - 'prototype' => true, - ] - ); - - $builder->add( - 'locale', - TextType::class, - [ - 'label' => 'Locale', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - new Length(['min' => 2, 'max' => 10]), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Navigation::class, - ]); - } -} diff --git a/core/Form/Site/NodeAttributeType.php b/core/Form/Site/NodeAttributeType.php deleted file mode 100644 index 4005dd9..0000000 --- a/core/Form/Site/NodeAttributeType.php +++ /dev/null @@ -1,49 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'value', - TextType::class, - [ - 'label' => 'Value', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - ]); - } -} diff --git a/core/Form/Site/NodeMoveType.php b/core/Form/Site/NodeMoveType.php deleted file mode 100644 index f632151..0000000 --- a/core/Form/Site/NodeMoveType.php +++ /dev/null @@ -1,62 +0,0 @@ -add( - 'position', - ChoiceType::class, - [ - 'label' => 'Position', - 'required' => true, - 'choices' => [ - 'After' => 'after', - 'Before' => 'before', - 'Above' => 'above', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'node', - EntityType::class, - [ - 'label' => 'Element', - 'class' => Node::class, - 'choices' => call_user_func(function () use ($options) { - return $options['menu']->getRootNode()->getAllChildren(); - }), - 'choice_label' => 'treeLabel', - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - 'menu' => null, - ]); - } -} diff --git a/core/Form/Site/NodeParameterType.php b/core/Form/Site/NodeParameterType.php deleted file mode 100644 index b00ecdd..0000000 --- a/core/Form/Site/NodeParameterType.php +++ /dev/null @@ -1,63 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'defaultValue', - TextType::class, - [ - 'label' => 'Default value', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'requirement', - TextType::class, - [ - 'label' => 'Requirement', - 'help' => 'Regular expression', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - ]); - } -} diff --git a/core/Form/Site/NodeSitemapParametersType.php b/core/Form/Site/NodeSitemapParametersType.php deleted file mode 100644 index 36a65cf..0000000 --- a/core/Form/Site/NodeSitemapParametersType.php +++ /dev/null @@ -1,82 +0,0 @@ -add( - 'isVisible', - CheckboxType::class, - [ - 'label' => 'Visible', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'priority', - ChoiceType::class, - [ - 'label' => 'Priority', - 'required' => true, - 'attr' => [ - ], - 'choices' => call_user_func(function () { - $choices = []; - - for ($u = 0; $u <= 10; ++$u) { - $choices[$u] = $u / 10; - } - - return $choices; - }), - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'changeFrequency', - ChoiceType::class, - [ - 'label' => 'Frequency of change', - 'required' => true, - 'attr' => [ - ], - 'choices' => [ - 'Toujours' => 'always', - 'Toutes les heures' => 'hourly', - 'Quotidienne' => 'daily', - 'Hebdomadaire' => 'weekly', - 'Mensuelle' => 'monthly', - 'Annuelle' => 'yearly', - 'Jamais' => 'never', - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - ]); - } -} diff --git a/core/Form/Site/NodeType.php b/core/Form/Site/NodeType.php deleted file mode 100644 index 923e7e1..0000000 --- a/core/Form/Site/NodeType.php +++ /dev/null @@ -1,320 +0,0 @@ -add( - 'label', - TextType::class, - [ - 'label' => 'Label', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'url', - TextType::class, - [ - 'label' => 'URL', - 'required' => false, - 'help' => 'Leave blank for automatic generation', - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'disableUrl', - CheckboxType::class, - [ - 'label' => 'Disable URL', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'enableAnalytics', - CheckboxType::class, - [ - 'label' => 'Enable analytics', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'code', - TextType::class, - [ - 'label' => 'Code', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'contentType', - TextType::class, - [ - 'label' => 'Content type', - 'required' => false, - 'help' => 'Leave blank equals "text/html"', - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'controller', - ChoiceType::class, - [ - 'label' => 'Controller', - 'required' => false, - 'help' => 'Leave blank to use the default one', - 'choices' => call_user_func(function () use ($options) { - $choices = []; - - foreach ($options['controllers'] as $controller) { - $choices[$controller->getName()] = $controller->getAction(); - } - - return $choices; - }), - ] - ); - - if (count($options['roles']) > 0) { - $builder->add( - 'securityRoles', - ChoiceType::class, - [ - 'label' => 'Roles', - 'required' => false, - 'multiple' => true, - 'expanded' => true, - 'choices' => call_user_func(function () use ($options) { - $choices = []; - - foreach ($options['roles'] as $role) { - $choices[$role->getName()] = $role->getRole(); - } - - return $choices; - }), - ] - ); - - $builder->add( - 'securityOperator', - ChoiceType::class, - [ - 'label' => 'Condition', - 'required' => true, - 'choices' => [ - 'At least one role' => 'or', - 'All roles' => 'and', - ], - ] - ); - } - - $actions = [ - 'New page' => 'new', - 'Use an existing page' => 'existing', - 'Alias element' => 'alias', - 'No page' => 'none', - ]; - - if ($builder->getData()->getId()) { - $actions['Keep the current configuration'] = 'keep'; - } - - $builder->add( - 'pageAction', - ChoiceType::class, - [ - 'label' => false, - 'required' => true, - 'expanded' => true, - 'mapped' => false, - 'choices' => $actions, - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'pageType', - ChoiceType::class, - [ - 'label' => false, - 'required' => true, - 'mapped' => false, - 'choices' => call_user_func(function () use ($options) { - $choices = []; - - foreach ($options['pages'] as $page) { - $choices[$page->getName()] = $page->getClassName(); - } - - return $choices; - }), - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'pageEntity', - EntityType::class, - [ - 'label' => false, - 'required' => true, - 'mapped' => false, - 'class' => Page::class, - 'choice_label' => 'name', - 'query_builder' => function (EntityRepository $repo) { - return $repo->createQueryBuilder('p') - ->orderBy('p.name', 'ASC') - ; - }, - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'aliasNode', - EntityType::class, - [ - 'label' => false, - 'required' => false, - 'class' => Node::class, - 'choice_label' => 'label', - 'choices' => call_user_func(function () use ($options, $builder) { - $nodes = []; - - foreach ($options['navigation']->getMenus() as $menu) { - $nodes = array_merge( - $nodes, - $menu->getRootNode()->getAllChildren()->toArray() - ); - } - - foreach ($nodes as $k => $value) { - if ($value->getId() === $builder->getData()->getId()) { - unset($nodes[$k]); - } - } - - return $nodes; - }), - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'parameters', - CollectionType::class, - [ - 'entry_type' => NodeParameterType::class, - 'by_reference' => false, - 'allow_add' => true, - 'allow_delete' => true, - 'prototype' => true, - ] - ); - - $builder->add( - 'attributes', - CollectionType::class, - [ - 'entry_type' => NodeAttributeType::class, - 'by_reference' => false, - 'allow_add' => true, - 'allow_delete' => true, - 'prototype' => true, - ] - ); - - $builder->add( - 'sitemapParameters', - NodeSitemapParametersType::class, - [ - 'label' => false, - ] - ); - - if (null === $builder->getData()->getId()) { - $builder->add( - 'position', - ChoiceType::class, - [ - 'label' => 'Position', - 'required' => true, - 'mapped' => false, - 'choices' => [ - 'After' => 'after', - 'Before' => 'before', - 'Above' => 'above', - ], - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - } - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Node::class, - 'pages' => [], - 'controllers' => [], - 'roles' => [], - 'navigation' => null, - ]); - } -} diff --git a/core/Form/Site/Page/ChoiceBlockType.php b/core/Form/Site/Page/ChoiceBlockType.php deleted file mode 100644 index 536b7b9..0000000 --- a/core/Form/Site/Page/ChoiceBlockType.php +++ /dev/null @@ -1,32 +0,0 @@ -add( - 'value', - ChoiceType::class, - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => ChoiceBlock::class, - 'options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/CollectionBlockType.php b/core/Form/Site/Page/CollectionBlockType.php deleted file mode 100644 index d05fe48..0000000 --- a/core/Form/Site/Page/CollectionBlockType.php +++ /dev/null @@ -1,50 +0,0 @@ -add( - 'value', - $options['collection_type'], - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars = array_replace($view->vars, [ - 'collection_name' => $options['collection_name'], - 'label_add' => $options['label_add'], - 'label_delete' => $options['label_delete'], - ]); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Block::class, - 'collection_type' => CollectionType::class, - 'collection_name' => '', - 'label_add' => 'Add', - 'label_delete' => 'Delete', - 'options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/FileBlockType.php b/core/Form/Site/Page/FileBlockType.php deleted file mode 100644 index 7f9de07..0000000 --- a/core/Form/Site/Page/FileBlockType.php +++ /dev/null @@ -1,32 +0,0 @@ -add( - 'value', - FileType::class, - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => FileBlock::class, - 'block_prefix' => 'file_block', - 'options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/FilePickerBlockType.php b/core/Form/Site/Page/FilePickerBlockType.php deleted file mode 100644 index 85a7ed9..0000000 --- a/core/Form/Site/Page/FilePickerBlockType.php +++ /dev/null @@ -1,33 +0,0 @@ -add( - 'value', - FilePickerType::class, - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Block::class, - 'block_prefix' => 'file_picker_page_block', - 'options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/Filter/PageFilterType.php b/core/Form/Site/Page/Filter/PageFilterType.php deleted file mode 100644 index 0aee47f..0000000 --- a/core/Form/Site/Page/Filter/PageFilterType.php +++ /dev/null @@ -1,73 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'navigation', - EntityType::class, - [ - 'label' => 'Navigation', - 'class' => Navigation::class, - 'choice_label' => 'label', - 'choice_value' => 'id', - 'required' => false, - 'attr' => [ - ], - 'query_builder' => function (EntityRepository $repo) { - return $repo->createQueryBuilder('n') - ->orderBy('n.label, n.domain', 'ASC') - ; - }, - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'isAssociated', - ChoiceType::class, - [ - 'label' => 'Associated', - 'choices' => [ - 'Anyway' => -1, - 'No' => 0, - 'Yes' => 1, - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => null, - 'csrf_protection' => false, - ]); - } -} diff --git a/core/Form/Site/Page/ImageBlockType.php b/core/Form/Site/Page/ImageBlockType.php deleted file mode 100644 index df651b6..0000000 --- a/core/Form/Site/Page/ImageBlockType.php +++ /dev/null @@ -1,25 +0,0 @@ -add( - 'value', - FileType::class, - array_merge([ - 'required' => false, - 'label' => false, - 'constraints' => [ - new Image(), - ], - ], $options['options']), - ); - } -} diff --git a/core/Form/Site/Page/PageType.php b/core/Form/Site/Page/PageType.php deleted file mode 100644 index 352c740..0000000 --- a/core/Form/Site/Page/PageType.php +++ /dev/null @@ -1,133 +0,0 @@ -add( - 'name', - TextType::class, - [ - 'label' => 'Name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->add( - 'metaTitle', - TextType::class, - [ - 'label' => 'Title', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'metaDescription', - TextType::class, - [ - 'label' => 'Description', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'ogTitle', - TextType::class, - [ - 'label' => 'Title', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'ogDescription', - TextType::class, - [ - 'label' => 'Description', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'ogImage', - FileType::class, - [ - 'label' => 'Image', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - new Image(), - ], - ] - ); - - $builder->add( - 'template', - ChoiceType::class, - [ - 'label' => 'Render', - 'required' => true, - 'choices' => call_user_func(function () use ($options) { - $choices = []; - - foreach ($options['page_configuration']->getTemplates() as $template) { - $choices[$template['name']] = $template['file']; - } - - return $choices; - }), - 'attr' => [ - ], - 'constraints' => [ - new NotBlank(), - ], - ] - ); - - $builder->getData()->buildForm($builder, $options['page_builder_options']); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Page::class, - 'page_configuration' => null, - 'page_builder_options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/TextBlockType.php b/core/Form/Site/Page/TextBlockType.php deleted file mode 100644 index a642499..0000000 --- a/core/Form/Site/Page/TextBlockType.php +++ /dev/null @@ -1,32 +0,0 @@ -add( - 'value', - TextType::class, - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => Block::class, - 'options' => [], - ]); - } -} diff --git a/core/Form/Site/Page/TextareaBlockType.php b/core/Form/Site/Page/TextareaBlockType.php deleted file mode 100644 index 87ea68a..0000000 --- a/core/Form/Site/Page/TextareaBlockType.php +++ /dev/null @@ -1,21 +0,0 @@ -add( - 'value', - TextareaType::class, - array_merge([ - 'required' => false, - 'label' => false, - ], $options['options']), - ); - } -} diff --git a/core/Form/Type/CollectionType.php b/core/Form/Type/CollectionType.php deleted file mode 100644 index 166d5d5..0000000 --- a/core/Form/Type/CollectionType.php +++ /dev/null @@ -1,41 +0,0 @@ -vars = array_replace($view->vars, [ - 'collection_name' => $options['collection_name'], - 'label_add' => $options['label_add'], - 'label_delete' => $options['label_delete'], - ]); - } - - public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'collection_name' => '', - 'label_add' => 'Add', - 'label_delete' => 'Delete', - ]); - } - - public function getBlockPrefix() - { - return 'murph_collection'; - } -} diff --git a/core/Form/UserType.php b/core/Form/UserType.php deleted file mode 100644 index 6df1c04..0000000 --- a/core/Form/UserType.php +++ /dev/null @@ -1,78 +0,0 @@ -add( - 'email', - EmailType::class, - [ - 'label' => 'E-mail', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - new Email(), - ], - ] - ); - - $builder->add( - 'displayName', - TextType::class, - [ - 'label' => 'Display name', - 'required' => true, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'isAdmin', - CheckboxType::class, - [ - 'label' => 'Administrator', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - - $builder->add( - 'isWriter', - CheckboxType::class, - [ - 'label' => 'Writer', - 'required' => false, - 'attr' => [ - ], - 'constraints' => [ - ], - ] - ); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'data_class' => User::class, - ]); - } -} diff --git a/core/Maker/MakeCrudController.php b/core/Maker/MakeCrudController.php deleted file mode 100644 index d8e3f71..0000000 --- a/core/Maker/MakeCrudController.php +++ /dev/null @@ -1,119 +0,0 @@ -addArgument( - 'controller-class', - InputArgument::OPTIONAL, - 'Choose a name for your CRUD controller class (e.g. MyEntityAdminController)' - ) - ->addArgument( - 'entity-class', - InputArgument::OPTIONAL, - 'Define the entity (e.g. MyEntity)' - ) - ->addArgument( - 'repository-query-class', - InputArgument::OPTIONAL, - 'Define the repository query (e.g. MyEntityRepositoryQuery)' - ) - ->addArgument( - 'factory-class', - InputArgument::OPTIONAL, - 'Define the factory (e.g. MyEntityFactory)' - ) - ->addArgument( - 'form-class', - InputArgument::OPTIONAL, - 'Define the form (e.g. MyEntityType)' - ) - ->setHelp('') - ; - } - - public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) - { - $controllerClassNameDetails = $generator->createClassNameDetails( - $input->getArgument('controller-class'), - 'Controller\\', - 'Controller' - ); - - $entityDetails = $generator->createClassNameDetails( - $input->getArgument('entity-class'), - 'Entity\\', - '' - ); - - $repoDetails = $generator->createClassNameDetails( - $input->getArgument('repository-query-class'), - 'Repository\\', - '' - ); - - $formDetails = $generator->createClassNameDetails( - $input->getArgument('form-class'), - 'Form\\', - '' - ); - - $factoryDetails = $generator->createClassNameDetails( - $input->getArgument('factory-class'), - 'Factory\\', - '' - ); - - $options = [ - 'entity' => $entityDetails->getFullName(), - 'route' => (string) u($entityDetails->getShortName())->snake(), - 'repository_query' => $repoDetails->getFullName(), - 'form' => $formDetails->getFullName(), - 'factory' => $factoryDetails->getFullName(), - ]; - - $controllerPath = $generator->generateController( - $controllerClassNameDetails->getFullName(), - __DIR__.'/../Resources/maker/controller/CrudController.tpl.php', - $options - ); - - $generator->writeChanges(); - - $this->writeSuccessMessage($io); - $io->text('Next: Open your new controller class and configure it!'); - } - - public function configureDependencies(DependencyBuilder $dependencies) - { - $dependencies->addClassDependency( - Annotation::class, - 'doctrine/annotations' - ); - } -} diff --git a/core/Maker/MakeFactory.php b/core/Maker/MakeFactory.php deleted file mode 100644 index 4ed7369..0000000 --- a/core/Maker/MakeFactory.php +++ /dev/null @@ -1,82 +0,0 @@ -addArgument( - 'factory-class', - InputArgument::OPTIONAL, - 'Choose a name for your factory (e.g. MyEntityFactory)' - ) - ->addArgument( - 'entity-class', - InputArgument::OPTIONAL, - 'Define the entity (e.g. MyEntity)' - ) - ->setHelp('') - ; - } - - public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) - { - $entityDetails = $generator->createClassNameDetails( - $input->getArgument('entity-class'), - 'Entity\\', - '' - ); - - $factoryDetails = $generator->createClassNameDetails( - $input->getArgument('factory-class'), - 'Factory\\', - '' - ); - - $options = [ - 'entity' => $entityDetails->getFullName(), - ]; - - $factoryPath = $generator->generateController( - $factoryDetails->getFullName(), - __DIR__.'/../Resources/maker/factory/Factory.tpl.php', - $options - ); - - $generator->writeChanges(); - - $this->writeSuccessMessage($io); - $io->text('Next: Open your new factory class and configure it!'); - } - - public function configureDependencies(DependencyBuilder $dependencies) - { - $dependencies->addClassDependency( - Annotation::class, - 'doctrine/annotations' - ); - } -} diff --git a/core/Maker/MakeRepositoryQuery.php b/core/Maker/MakeRepositoryQuery.php deleted file mode 100644 index 21b27d5..0000000 --- a/core/Maker/MakeRepositoryQuery.php +++ /dev/null @@ -1,85 +0,0 @@ -addArgument( - 'repository-class', - InputArgument::OPTIONAL, - 'Define the repository (e.g. MyEntityRepository)' - ) - ->setHelp('') - ; - } - - public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) - { - $repositoryClass = $input->getArgument('repository-class'); - - $repositoryDetails = $generator->createClassNameDetails( - $repositoryClass, - 'Repository\\', - '' - ); - - $queryDetails = $generator->createClassNameDetails( - $repositoryClass.'Query', - 'Repository\\', - '' - ); - - $id = u($queryDetails->getShortName()) - ->truncate(1) - ->lower() - ; - - $options = [ - 'repository' => $repositoryDetails->getFullName(), - 'id' => $id, - ]; - - $factoryPath = $generator->generateController( - $queryDetails->getFullName(), - __DIR__.'/../Resources/maker/repository/RepositoryQuery.tpl.php', - $options - ); - - $generator->writeChanges(); - - $this->writeSuccessMessage($io); - $io->text('Next: Open your new repository query class and configure it!'); - } - - public function configureDependencies(DependencyBuilder $dependencies) - { - $dependencies->addClassDependency( - Annotation::class, - 'doctrine/annotations' - ); - } -} diff --git a/core/Manager/EntityManager.php b/core/Manager/EntityManager.php deleted file mode 100644 index c4eb80e..0000000 --- a/core/Manager/EntityManager.php +++ /dev/null @@ -1,98 +0,0 @@ - - */ -class EntityManager -{ - protected EventDispatcherInterface $eventDispatcher; - - protected DoctrineEntityManager $entityManager; - - public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager) - { - $this->eventDispatcher = $eventDispatcher; - $this->entityManager = $entityManager; - } - - public function create(EntityInterface $entity, bool $dispatchEvent = true): self - { - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_CREATE_EVENT); - } - - $this->persist($entity); - - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT); - } - - return $this; - } - - public function update(EntityInterface $entity, bool $dispatchEvent = true): self - { - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_UPDATE_EVENT); - } - - $this->persist($entity); - - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT); - } - - return $this; - } - - public function delete(EntityInterface $entity, bool $dispatchEvent = true): self - { - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_DELETE_EVENT); - } - - $this->entityManager->remove($entity); - $this->flush(); - - if ($dispatchEvent) { - $this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT); - } - - return $this; - } - - public function flush(): self - { - $this->entityManager->flush(); - - return $this; - } - - public function clear(): self - { - $this->entityManager->clear(); - - return $this; - } - - public function getEntityManager(): EntityManagerInterface - { - return $this->entityManager; - } - - protected function persist(EntityInterface $entity) - { - $this->entityManager->persist($entity); - $this->flush(); - } -} diff --git a/core/Manager/TranslatableEntityManager.php b/core/Manager/TranslatableEntityManager.php deleted file mode 100644 index 2cb87a0..0000000 --- a/core/Manager/TranslatableEntityManager.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class TranslatableEntityManager extends EntityManager -{ - protected function persist(EntityInterface $entity) - { - $this->entityManager->persist($entity); - $entity->mergeNewTranslations(); - $this->flush(); - } -} diff --git a/core/Notification/MailNotifier.php b/core/Notification/MailNotifier.php deleted file mode 100644 index c4fc96a..0000000 --- a/core/Notification/MailNotifier.php +++ /dev/null @@ -1,236 +0,0 @@ - - */ -class MailNotifier -{ - protected MailerInterface $mailer; - protected array $attachments = []; - protected array $recipients = []; - protected array $bccRecipients = []; - protected ?string $subject = null; - protected ?string $from = null; - protected ?string $replyTo = null; - - public function __construct(TwigEnvironment $twig, MailerInterface $mailer) - { - $this->mailer = $mailer; - $this->twig = $twig; - } - - public function setMailer(Swift_Mailer $mailer): self - { - $this->mailer = $mailer; - - return $this; - } - - public function getMailer(): Swift_Mailer - { - return $this->mailer; - } - - public function setRecipients(array $recipients): self - { - $this->recipients = $recipients; - - return $this; - } - - public function getRecipients(): array - { - return $this->recipients; - } - - public function setBccRecipients(array $bccRecipients): self - { - $this->bccRecipients = $bccRecipients; - - return $this; - } - - public function getBccRecipients(): array - { - return $this->bccRecipients; - } - - public function setSubject(?string $subject): self - { - $this->subject = $subject; - - return $this; - } - - public function getSubject(): string - { - return $this->subject; - } - - public function setFrom($from): self - { - $this->from = $from; - - return $this; - } - - public function getFrom(): ?string - { - return $this->from; - } - - public function setReplyTo($replyTo): self - { - $this->replyTo = $replyTo; - - return $this; - } - - public function getReplyTo(): ?string - { - return $this->replyTo; - } - - public function setAttachments(array $attachments): self - { - $this->attachments = $attachments; - - return $this; - } - - public function getAttachments(): array - { - return $this->attachments; - } - - public function addRecipient(string $email, bool $isBcc = false): self - { - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { - throw new \InvalidArgumentException(sprintf('Invalid email "%s".', $email)); - } - - if ($isBcc) { - if (!in_array($email, $this->bccRecipients)) { - $this->bccRecipients[] = $email; - } - } else { - if (!in_array($email, $this->recipients)) { - $this->recipients[] = $email; - } - } - - return $this; - } - - public function addRecipients(array $emails, bool $isBcc = false): self - { - foreach ($emails as $email) { - $this->addRecipient($email, $isBcc); - } - - return $this; - } - - public function addRecipientByAccount(Account $account, bool $isBcc = false): self - { - return $this->addRecipient($account->getEmail(), $isBcc); - } - - public function addRecipientsByAccounts($accounts, bool $isBcc = false) - { - if (!is_array($accounts)) { - throw new InvalidArgumentException('The "accounts" parameter must be an array or an instance of ObjectCollection'); - } - - foreach ($accounts as $account) { - $this->addRecipientByAccount($account, $isBcc); - } - - return $this; - } - - public function addAttachment(string $attachment): self - { - if (!in_array($attachment, $this->attachments)) { - $this->attachments[] = $attachment; - } - - return $this; - } - - public function addAttachments(array $attachments): self - { - foreach ($attachments as $attachment) { - $this->addAttachment($attachment); - } - - return $this; - } - - public function init(): self - { - $this - ->setSubject(null) - ->setRecipients([]) - ->setBccRecipients([]) - ->setAttachments([]) - ; - - return $this; - } - - public function notify(string $template, array $data = [], string $type = 'text/html'): self - { - $message = $this->createMessage(); - $message->context($data); - - if (in_array($type, ['text/plain', 'text'])) { - $message->textTemplate($template); - } else { - $message->htmlTemplate($template); - } - - $this->mailer->send($message); - - return $this; - } - - protected function createMessage(): TemplatedEmail - { - $message = new TemplatedEmail(); - - if ($this->getSubject()) { - $message->subject($this->getSubject()); - } - - if ($this->getFrom()) { - $message->from($this->getFrom()); - } - - if ($this->getReplyTo()) { - $message->replyTo($this->getReplyTo()); - } - - if (count($this->getRecipients()) > 0) { - $message->to(...$this->getRecipients()); - } - - if (count($this->getBccRecipients()) > 0) { - $message->bcc(...$this->getBccRecipients()); - } - - foreach ($this->getAttachments() as $attachment) { - $message->attachFromPath($attachment); - } - - return $message; - } -} diff --git a/core/Repository/.gitignore b/core/Repository/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/core/Repository/Analytic/RefererRepository.php b/core/Repository/Analytic/RefererRepository.php deleted file mode 100644 index 2bd6b73..0000000 --- a/core/Repository/Analytic/RefererRepository.php +++ /dev/null @@ -1,21 +0,0 @@ -andWhere('.node = :node') - ->andWhere('.uri = :uri') - ->setParameters([ - ':node' => $request->attributes->get('_node'), - ':uri' => $request->headers->get('referer'), - ]) - ; - } -} diff --git a/core/Repository/Analytic/ViewRepository.php b/core/Repository/Analytic/ViewRepository.php deleted file mode 100644 index 4ddf0a3..0000000 --- a/core/Repository/Analytic/ViewRepository.php +++ /dev/null @@ -1,21 +0,0 @@ -andWhere('.node = :node') - ->andWhere('.path = :path') - ->setParameters([ - ':node' => $request->attributes->get('_node'), - ':path' => $request->getPathInfo(), - ]) - ; - } -} diff --git a/core/Repository/FileInformationRepository.php b/core/Repository/FileInformationRepository.php deleted file mode 100644 index faad05a..0000000 --- a/core/Repository/FileInformationRepository.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -class NavigationSettingRepositoryQuery extends RepositoryQuery -{ - public function __construct(NavigationSettingRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 'ns', $paginator); - } -} diff --git a/core/Repository/RedirectRepository.php b/core/Repository/RedirectRepository.php deleted file mode 100644 index c6d6070..0000000 --- a/core/Repository/RedirectRepository.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -abstract class RepositoryQuery -{ - protected ServiceEntityRepository $repository; - protected QueryBuilder $query; - protected PaginatorInterface $paginator; - protected string $id; - protected array $forcedFilterHandlers; - - public function __construct(ServiceEntityRepository $repository, string $id, PaginatorInterface $paginator = null) - { - $this->repository = $repository; - $this->query = $repository->createQueryBuilder($id); - $this->paginator = $paginator; - $this->id = $id; - $this->forcedFilterHandlers = []; - } - - public function __call(string $name, $params): self - { - foreach ($params as $key => $value) { - $this->populateDqlId($params[$key]); - } - - call_user_func_array([$this->query, $name], $params); - - return $this; - } - - public function create() - { - $class = get_called_class(); - - return new $class($this->repository, $this->paginator); - } - - public function call(callable $fn): self - { - $fn($this->query, $this); - - return $this; - } - - public function findOne() - { - return $this->query->getQuery() - ->setMaxResults(1) - ->getOneOrNullResult() - ; - } - - public function find() - { - return $this->query->getQuery()->getResult(); - } - - public function paginate(int $page = 1, int $limit = 20) - { - return $this->paginator->paginate($this->query->getQuery(), $page, $limit); - } - - public function getRepository(): ServiceEntityRepository - { - return $this->repository; - } - - public function useFilters(array $filters) - { - foreach ($filters as $name => $value) { - if (null === $value) { - continue; - } - - if (in_array($name, $this->forcedFilterHandlers)) { - $this->filterHandler($name, $value); - } elseif (is_int($value) || is_bool($value)) { - $this->andWhere('.'.$name.' = :'.$name); - $this->setParameter(':'.$name, $value); - } elseif (is_string($value)) { - $this->andWhere('.'.$name.' LIKE :'.$name); - $this->setParameter(':'.$name, '%'.$value.'%'); - } else { - $this->filterHandler($name, $value); - } - } - - return $this; - } - - protected function populateDqlId(&$data) - { - if (is_string($data)) { - $words = explode(' ', $data); - - foreach ($words as $k => $v) { - if (isset($v[0]) && '.' === $v[0]) { - $words[$k] = $this->id.$v; - } - } - - $data = implode(' ', $words); - } elseif (is_array($data)) { - foreach ($data as $k => $v) { - $this->populateDqlId($data[$k]); - } - } - - return $data; - } - - protected function filterHandler(string $name, $value) - { - } -} diff --git a/core/Repository/SettingRepository.php b/core/Repository/SettingRepository.php deleted file mode 100644 index 6976ae2..0000000 --- a/core/Repository/SettingRepository.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -class SettingRepositoryQuery extends RepositoryQuery -{ - public function __construct(SettingRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 's', $paginator); - } -} diff --git a/core/Repository/Site/MenuRepository.php b/core/Repository/Site/MenuRepository.php deleted file mode 100644 index 6e7b591..0000000 --- a/core/Repository/Site/MenuRepository.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -class MenuRepositoryQuery extends RepositoryQuery -{ - public function __construct(MenuRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 'm', $paginator); - } -} diff --git a/core/Repository/Site/NavigationRepository.php b/core/Repository/Site/NavigationRepository.php deleted file mode 100644 index 987b35e..0000000 --- a/core/Repository/Site/NavigationRepository.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -class NavigationRepositoryQuery extends RepositoryQuery -{ - public function __construct(NavigationRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 'n', $paginator); - } - - public function filterById($id) - { - $this - ->where('.id = :id') - ->setParameter(':id', $id) - ; - - return $this; - } - - public function whereDomain($domain) - { - return $this - ->andWhere('.domain = :domain') - ->setParameter(':domain', $domain) - ; - } -} diff --git a/core/Repository/Site/NodeRepository.php b/core/Repository/Site/NodeRepository.php deleted file mode 100644 index 13a5c73..0000000 --- a/core/Repository/Site/NodeRepository.php +++ /dev/null @@ -1,40 +0,0 @@ -getClassMetadata(Node::class)); - } - - public function urlExists($url, Node $node): bool - { - $query = $this->createQueryBuilder('n') - ->join('n.menu', 'm') - ->where('n.url = :url') - ->andWhere('n.disableUrl = 0') - ->andWhere('n.aliasNode is null') - ->andWhere('m.navigation = :navigation') - ->setParameter(':url', $url) - ->setParameter(':navigation', $node->getMenu()->getNavigation()) - ; - - if ($node->getId()) { - $query - ->andWhere('n.id != :id') - ->setParameter(':id', $node->getId()) - ; - } - - return $query->getQuery() - ->setMaxResults(1) - ->getOneOrNullResult() !== null - ; - } -} diff --git a/core/Repository/Site/Page/BlockRepository.php b/core/Repository/Site/Page/BlockRepository.php deleted file mode 100644 index 1ccca24..0000000 --- a/core/Repository/Site/Page/BlockRepository.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -class BlockRepositoryQuery extends RepositoryQuery -{ - public function __construct(BlockRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 'b', $paginator); - } -} diff --git a/core/Repository/Site/Page/PageRepository.php b/core/Repository/Site/Page/PageRepository.php deleted file mode 100644 index 9338c67..0000000 --- a/core/Repository/Site/Page/PageRepository.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -class PageRepositoryQuery extends RepositoryQuery -{ - public function __construct(PageRepository $repository, PaginatorInterface $paginator) - { - parent::__construct($repository, 'p', $paginator); - - $this->forcedFilterHandlers[] = 'isAssociated'; - } - - public function filterByNavigation(Navigation $navigation): self - { - return $this - ->leftJoin('.nodes', 'node') - ->leftJoin('node.menu', 'menu') - ->leftJoin('menu.navigation', 'navigation') - ->where('navigation.id = :navigationId') - ->setParameter(':navigationId', $navigation->getId()) - ; - } - - public function filterById($id): self - { - $this - ->where('.id = :id') - ->setParameter(':id', $id) - ; - - return $this; - } - - protected function withAssociation(bool $isAssociated): self - { - $entities = $this->create()->find(); - $ids = []; - - foreach ($entities as $entity) { - if ($isAssociated && !$entity->getNodes()->isEmpty()) { - $ids[] = $entity->getId(); - } elseif (!$isAssociated && $entity->getNodes()->isEmpty()) { - $ids[] = $entity->getId(); - } - } - - $this - ->andWhere('.id IN (:ids)') - ->setParameter(':ids', $ids) - ; - - return $this; - } - - protected function filterHandler(string $name, $value) - { - if ('navigation' === $name) { - return $this->filterByNavigation($value); - } - - if ('isAssociated' === $name && $value > -1) { - $this->withAssociation((bool) $value); - } - - return parent::filterHandler($name, $value); - } -} diff --git a/core/Resources/assets/css/admin.scss b/core/Resources/assets/css/admin.scss deleted file mode 100644 index fcc9cc1..0000000 --- a/core/Resources/assets/css/admin.scss +++ /dev/null @@ -1,557 +0,0 @@ -$theme-colors: ( - "primary": #1ab5dc, - "primary-light": lighten(#3183aa, 40%), - "dark-blue": #1e2430, -) !default; - -$grid-gutter-width: 0px !default; -$pagination-color: #343a40 !default; -$pagination-bg: #ffffff !default; -$pagination-active-color: #ffffff !default; -$pagination-active-bg: #343a40 !default; - -@import "~choices.js/src/styles/choices.scss"; -@import "~bootstrap/scss/bootstrap.scss"; -@import "~@fortawesome/fontawesome-free/css/all.css"; -@import "~flag-icon-css/sass/flag-icon.scss"; - -@for $i from 1 through 100 { - .miw-#{$i*5} { - min-width: $i * 5px; - } -} - -.flag-icon-en { - background-image: url(~flag-icon-css/flags/4x3/gb.svg); -} - -body { - overflow-x: hidden; -} - -#logo { - width: 30px; -} - -.choices__list--dropdown { - display: none; -} - -.choices__list--dropdown.is-active { - display: block; -} - -.dropdown-toggle-hide-after { - &::after { - display: none; - } -} - -.login { - &-container { - margin-top: 5%; - margin-bottom: 5%; - } - - &-form { - padding: 5%; - } - - &-image { - width: 100%; - max-width: 80%; - } -} - -.sidebar { - position: fixed; - top: 0; - bottom: 0; - left: 0; - z-index: 100; - padding: 71px 0 0; - box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); -} - -.sidebar-sticky { - position: relative; - top: 0; - height: calc(100vh - 71px); - padding-top: .5rem; - overflow-x: hidden; - overflow-y: hidden; - - &:hover { - overflow-y: auto; - } -} - -@supports ((position: -webkit-sticky) or (position: sticky)) { - .sidebar-sticky { - position: -webkit-sticky; - position: sticky; - } -} - -.actions-container { - padding-right: 25px; -} - -.table .thead-light { - a, th { - color: map-get($theme-colors, 'dark-blue'); - } -} - -tr.table-primary-light { - background-color: #ecf5fa; -} - -.td-nowrap { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.wrap { - word-wrap: anywhere; -} - -.analytic .analytic-referer::before { - content: '▸'; - padding-right: 10px; -} - -.analytic[open] .analytic-referer::before { - content: '▾'; -} - -.analytic-referer { - max-width: calc(100% - 60px); -} - -.table tr { - td { - transition: border 500ms ease-out; - border-bottom: 1px solid #dee2e6; - } - - &:hover { - td { - border-bottom: 1px solid #a8aaac; - } - } -} - -.bg-dark-blue { - background: map-get($theme-colors, 'dark-blue'); - color: #fff; - - .nav-item-label { - color: #fff; - } -} - -.nav-pills { - .nav-item { - margin-right: 3px; - } - - .nav-link:not(.active) { - color: #333; - background: #eee; - } -} - - -.sidebar { - width: 260px; - display: inline-block; - - .nav-link { - font-weight: 500; - color: #333; - border-left: 4px solid map-get($theme-colors, 'dark-blue'); - padding-top: 14px; - padding-bottom: 14px; - - .fa { - font-size: 1.2rem; - margin-right: 5px; - color: #fff; - width: 35px; - display: inline-block; - } - - .nav-item-label { - display: inline-block; - } - - &.active { - font-weight: bold; - border-left: 4px solid map-get($theme-colors, 'primary'); - background: map-get($theme-colors, 'dark-blue'); - } - } - - &-heading { - font-size: .75rem; - text-transform: uppercase; - display: flex; - } -} - -*[data-selectable-selector] { - -moz-user-select: none; - -webkit-user-select: none; - user-select: none; -} - -*[data-selectable-selector] { - &:hover { - cursor: pointer; - } -} - -*[data-sortable-item] { - &:hover { - cursor: pointer; - } - - &.sortable-chosen { - background: map-get($theme-colors, 'primary-light'); - } -} - -.footer { - position: absolute; - bottom: 0; - left: 0; - width: 100%; - z-index: 1000; - height: 35px; - background: #f8f9fa; -} - -.body { - padding-top: 60px; - width: calc(100% - 260px); - margin-left: 260px; - display: inline-block; - - .nav { - padding-left: 10px; - } -} - -@media screen and (max-width: 1080px) { - .sidebar-sticky { - overflow-y: auto !important; - } -} - -@media screen and (max-width: 770px) { - .body { - margin-left: 50px; - width: calc(100vw - 50px); - } - - .sidebar-sticky { - width: 50px; - max-width: 100% !important; - } - - .sidebar { - width: 50px; - max-width: 100% !important; - - .nav { - padding-left: 0; - } - - .nav-link { - padding-left: 10px; - - .nav-item-label { - display: none; - } - } - - .sidebar-heading { - display: none; - } - } -} - -th { - &.sorted { - &::before { - content: '\f0dc'; - font-family: 'FontAwesome'; - color: #aaa; - margin-right: 3px; - } - } -} - -.table-responsive { - max-width: 100%; - overflow-y: hidden; -} - -.toast-container { - display: flex; - position: relative; - z-index: 4000; - - .toast-wrapper { - position: fixed; - top: 20px; - right: 20px; - z-index: 1060; - width: 300px; - } -} - -.bg-tiles { - background-color: #c1c1c1; - background-image: linear-gradient(45deg, #646464 25%, transparent 25%, transparent 75%, #646464 75%), linear-gradient(45deg, #646464 25%, transparent 25%, transparent 75%, #646464 75%); - background-size: 20px 20px; - background-position: 0 0, 10px 10px; -} - -.tab-form { - padding: 15px; -} - -.icon-margin { - margin-right: 4px; -} - -.file-icon { - font-size: 2em; -} - -.d-ib { - display: inline-block; -} - -.list-checkbox { - vertical-align: middle; - margin-right: 10px; - margin-top: -2px; -} - -.password-strenth { - padding: 0 0 5px 0; - margin-top: -4px; - - .col-sm { - height: 8px; - border: 2px solid #fff; - } - - &-info { - font-size: 13px; - height: 22px; - } -} - -.notification-bell:not([disabled]) { - [data-counter]:after { - display: block; - color: #fff; - background: red; - width: 9px; - height: 9px; - position: absolute; - content: ' '; - top: 4px; - right: 10px; - border-radius: 4px; - } -} - -.form-error-icon { - margin-right: 4px; -} - -.custom-file-label::after { - content: "Parcourir"; -} - -#lease_template_html { - height: calc(100vh - 270px); -} - -.panel { - &-toggler { - &:hover { - cursor: pointer; - } - } - - &-content { - display: block; - - &:not(.active) { - display: none; - } - } -} - -*[data-collection-delete-container] { - cursor: pointer; -} - -*[data-collection-add] { - cursor: pointer; -} - -.login-image { - width: 50%; -} - -.tree { - position: relative; - background: white; - color: #212529; - - span { - font-style: italic; - letter-spacing: .4px; - color: #a8a8a8; - } - - .fa-folder-open, .fa-folder { - color: #007bff; - } - - .fa-html5 { - color: #f21f10; - } - - ul { - padding-left: 5px; - list-style: none; - margin: 0; - padding-bottom: 0; - - li { - position: relative; - padding-top: 5px; - padding-bottom: 5px; - padding-left: 15px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - - &:before { - position: absolute; - top: 15px; - left: 0; - width: 10px; - height: 1px; - margin: auto; - content: ''; - background-color: #666; - } - - &:after { - position: absolute; - top: 0; - bottom: 0; - left: 0; - width: 1px; - height: 100%; - content: ''; - background-color: #666; - } - - &:last-child:after { - height: 15px; - } - } - - a { - cursor: pointer; - - &:hover { - text-decoration: none; - } - } - } -} - -fieldset.form-group { - margin-bottom: 0; -} - -.crud-header { - &-title { - font-size: 2em; - } - - &-actions { - text-align: right; - margin-bottom: 10px; - } - - @media screen and (min-width: 770px) { - &-title { - float: left; - font-size: 2em; - } - - &-actions { - float: right; - } - - } - - &::after { - display: block; - content: ""; - clear: both; - } -} - -.table .crud-batch-column { - width: 1%; -} - -form { - .loader { - display: none; - } - - &.is-loading .loader { - display: inline-block; - } -} - -.modal { - z-index: 3000; -} - -.modal-dialog-large { - max-width: 80%; - margin-left: auto; - margin-right: auto; -} - -.output { - &-console { - background: #073642; - line-height: normal; - } -} - -#murph-version { - display: inline; - font-size: 14px; - - a { - color: #333; - } -} diff --git a/core/Resources/assets/js/admin.js b/core/Resources/assets/js/admin.js deleted file mode 100644 index 8a6501b..0000000 --- a/core/Resources/assets/js/admin.js +++ /dev/null @@ -1,26 +0,0 @@ -import '../../../../assets/css/admin.scss'; - -require('../../../../node_modules/bootstrap/dist/js/bootstrap.min.js') -require('./modules/table-fixed.js')() -require('./modules/form-confirm.js')() -require('./modules/form-file.js')() -require('./modules/form-error.js')() -require('./modules/form-ajax.js')() -require('./modules/dbclick.js')() -require('./modules/toast.js')() -require('./modules/modal.js')() -require('./modules/push-state.js')() -require('./modules/password.js')() -require('./modules/tooltip.js')() -require('./modules/editor.js')() -require('./modules/panel.js')() -require('./modules/choices.js')() -require('./modules/checkbox-checker.js')() -require('./modules/rest-choices.js')() -require('./modules/form-collection.js')() -require('./modules/datepicker.js')() -require('./modules/sortable.js')() -require('./modules/batch.js')() -require('./modules/file-manager.js')() -require('./modules/file-picker.js')() -require('./modules/analytics.js')() diff --git a/core/Resources/assets/js/components/file-manager/FileIcon.vue b/core/Resources/assets/js/components/file-manager/FileIcon.vue deleted file mode 100644 index 4c08cca..0000000 --- a/core/Resources/assets/js/components/file-manager/FileIcon.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - - - diff --git a/core/Resources/assets/js/components/file-manager/FileManager.vue b/core/Resources/assets/js/components/file-manager/FileManager.vue deleted file mode 100644 index eab7f4a..0000000 --- a/core/Resources/assets/js/components/file-manager/FileManager.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/core/Resources/assets/js/components/file-manager/Files.vue b/core/Resources/assets/js/components/file-manager/Files.vue deleted file mode 100644 index 6e6af3d..0000000 --- a/core/Resources/assets/js/components/file-manager/Files.vue +++ /dev/null @@ -1,378 +0,0 @@ - - - - - diff --git a/core/Resources/assets/js/modules/analytics.js b/core/Resources/assets/js/modules/analytics.js deleted file mode 100644 index dcb6d1a..0000000 --- a/core/Resources/assets/js/modules/analytics.js +++ /dev/null @@ -1,53 +0,0 @@ -const $ = require('jquery') -const Chart = require('chart.js/auto').default - -const drawChart = () => { - const ctx = document.getElementById('analytic-chart') - const options = { - type: 'bar', - options: { - responsive: true, - maintainAspectRatio: false, - scales: { - y: { - beginAtZero: true - } - } - }, - data: { - labels: JSON.parse(ctx.getAttribute('data-labels')), - datasets: [{ - label: ctx.getAttribute('data-label'), - data: JSON.parse(ctx.getAttribute('data-values')), - backgroundColor: 'rgba(54, 162, 235, 0.2)', - borderColor: 'rgb(54, 162, 235)', - borderWidth: 1 - }] - } - } - - const chart = new Chart(ctx, options) - - const resize = () => { - const width = ctx.parentNode.parentNode.offsetWidth - const height = 250 - - chart.resize(width, height) - } - - resize() - - window.addEventListener('resize', resize) -} - -module.exports = () => { - const body = $('body') - - body.on('shown.bs.modal', '.modal', (e) => { - window.setTimeout(() => { - if (document.getElementById('analytic-chart')) { - drawChart() - } - }, 500) - }) -} diff --git a/core/Resources/assets/js/modules/batch.js b/core/Resources/assets/js/modules/batch.js deleted file mode 100644 index 2d5c1f2..0000000 --- a/core/Resources/assets/js/modules/batch.js +++ /dev/null @@ -1,23 +0,0 @@ -const $ = require('jquery') - -module.exports = () => { - $('th.crud-batch-column input').change((e) => { - $('td.crud-batch-column input').prop('checked', $(e.target).is(':checked')) - }) - - const form = $('#form-batch') - - form.submit((e) => { - e.preventDefault() - - const route = form.attr('action') - const datas = form.serialize() - - form.addClass('is-loading') - - $.post(route, datas) - .always(() => { - document.location.reload() - }) - }) -} diff --git a/core/Resources/assets/js/modules/checkbox-checker.js b/core/Resources/assets/js/modules/checkbox-checker.js deleted file mode 100644 index c6804a5..0000000 --- a/core/Resources/assets/js/modules/checkbox-checker.js +++ /dev/null @@ -1,31 +0,0 @@ -const $ = require('jquery') - -module.exports = function () { - $('*[data-checkbox-ckecker]').click(function () { - const wrapperName = $(this).attr('data-checkbox-ckecker') - - if (!wrapperName) { - return - } - - const checkboxes = $('*[data-checkbox-wrapper="' + wrapperName + '"] *[data-checkbox] input[type="checkbox"]') - - $(checkboxes).each(function (i, v) { - $(v).prop('checked', true) - }) - }) - - $('*[data-checkbox-unckecker]').click(function () { - const wrapperName = $(this).attr('data-checkbox-unckecker') - - if (!wrapperName) { - return - } - - const checkboxes = $('*[data-checkbox-wrapper="' + wrapperName + '"] *[data-checkbox] input[type="checkbox"]') - - $(checkboxes).each(function (i, v) { - $(v).prop('checked', false) - }) - }) -} diff --git a/core/Resources/assets/js/modules/choices.js b/core/Resources/assets/js/modules/choices.js deleted file mode 100644 index d2da709..0000000 --- a/core/Resources/assets/js/modules/choices.js +++ /dev/null @@ -1,8 +0,0 @@ -const Choices = require('choices.js') -const $ = require('jquery') - -module.exports = function () { - $('*[data-jschoice]').each(function (key, item) { - return new Choices(item) - }) -} diff --git a/core/Resources/assets/js/modules/datepicker.js b/core/Resources/assets/js/modules/datepicker.js deleted file mode 100644 index 673ae32..0000000 --- a/core/Resources/assets/js/modules/datepicker.js +++ /dev/null @@ -1,30 +0,0 @@ -const Datepicker = require('vanillajs-datepicker') - -const isDateSupported = () => { - const input = document.createElement('input') - const value = 'a' - - input.setAttribute('type', 'date') - input.setAttribute('value', value) - - return input.value !== value -} - -const createDatePicker = (input) => { - return new Datepicker.Datepicker(input, { - format: 'yyyy-mm-dd' - }) -} - -module.exports = () => { - if (isDateSupported()) { - return - } - - const inputs = document.querySelectorAll('input[type="date"]') - const size = inputs.length - - for (let i = 0, c = size; i < c; i++) { - createDatePicker(inputs[i]) - } -} diff --git a/core/Resources/assets/js/modules/dbclick.js b/core/Resources/assets/js/modules/dbclick.js deleted file mode 100644 index 57713cf..0000000 --- a/core/Resources/assets/js/modules/dbclick.js +++ /dev/null @@ -1,7 +0,0 @@ -const $ = require('jquery') - -module.exports = function () { - $('*[data-dblclick]').dblclick(function (e) { - document.location.href = $(this).attr('data-dblclick') - }) -} diff --git a/core/Resources/assets/js/modules/document-selector.js b/core/Resources/assets/js/modules/document-selector.js deleted file mode 100644 index 604f77f..0000000 --- a/core/Resources/assets/js/modules/document-selector.js +++ /dev/null @@ -1,42 +0,0 @@ -const $ = require('jquery') - -const DocumentSelector = () => { - const forms = $('.document-selector-form') - - const handler = function () { - forms.each((fi, f) => { - const form = $(f) - const ids = form.find('.document-selector-ids') - const btn = form.find('.document-selector-button') - - ids.html('') - let hasSelection = false - - $('*[data-documents] *[data-selectable-row] input[data-selectable-checkbox]').each((i, c) => { - const checkbox = $(c) - - if (checkbox.is(':checked')) { - ids.append(checkbox[0].outerHTML) - hasSelection = true - } - }) - - if (hasSelection && btn.length) { - btn.removeAttr('disabled') - ids.find('input').prop('checked', true) - } else { - btn.attr('disabled', 'disabled') - } - }) - } - - $('*[data-documents] *[data-selectable-row]').click(function () { - window.setTimeout(handler, 100) - }) - - $('*[data-documents] *[data-selectable-row]').on('clicked', function () { - window.setTimeout(handler, 100) - }) -} - -module.exports = DocumentSelector diff --git a/core/Resources/assets/js/modules/editor.js b/core/Resources/assets/js/modules/editor.js deleted file mode 100644 index 7bfba77..0000000 --- a/core/Resources/assets/js/modules/editor.js +++ /dev/null @@ -1,626 +0,0 @@ -const $ = require('jquery') -const Vue = require('vue').default -const FileManager = require('../components/file-manager/FileManager').default - -const createModal = function () { - let container = $('#fm-modal') - const body = $('body') - - if (!container.length) { - container = $('