diff --git a/cms/contents/page/translations/sfs_cms_contents.en.yaml b/cms/contents/page/translations/sfs_cms_contents.en.yaml index 2de01197..5aa69287 100644 --- a/cms/contents/page/translations/sfs_cms_contents.en.yaml +++ b/cms/contents/page/translations/sfs_cms_contents.en.yaml @@ -52,29 +52,6 @@ admin_page: confirm_message_title: "Unpublish page" confirm_message_raw: "
Are you sure to unpublish this page?
It will show a 404 error to the users
" - import: - meta.title: "Import page" - title: "Import page" - breadcrumb: "Import page" - actions: - import.button: "Import page" - cancel.button: "Cancel" - form: - file.label: "Import content file" - failed_flash: "An error has been produced during the page importDo not lose links and index!
' actions: - export.button: Export delete.button: "Delete definitely" cancel.button: "Cancel" form: @@ -251,7 +223,6 @@ admin_page: breadcrumb: "Pages" actions: create.link: "New page" - import.link: "Import page" details.link: "View" content.link: "Content" preview.link: "Preview" @@ -267,7 +238,7 @@ admin_page: status.label: "Status" publishedVersionContent.label: "Published version content (case sensitive)" empty: - create_first_content_raw: 'Create or import your first page!' + create_first_content_raw: 'Create your first page!' can_not_create_content: "You can not create a new page" go_to_doc_raw: 'If you need help go to documentation' clean_filters: 'Your query has no results, try to clean filters' @@ -323,13 +294,6 @@ admin_page: success_unlocked_flash: "Version has been unlocked" failed_flash: "An error has been produced during the version lock/unlock¿Estás seguro de despublicar esta página?
Mostrará un error 404 a los usuarios
" - import: - meta.title: "Importar página" - title: "Importar página" - breadcrumb: "Importar página" - actions: - import.button: "Importar página" - cancel.button: "Cancelar" - form: - file.label: "Fichero a importar" - failed_flash: "Se ha producido un error al importar la página¡No pierdas los enlaces e indexación!
' actions: - export.button: "Exportar" delete.button: "Eliminar definitivamente" cancel.button: "Cancelar" form: @@ -251,7 +223,6 @@ admin_page: breadcrumb: "Páginas" actions: create.link: "Nueva página" - import.link: "Importar página" details.link: "Ver" content.link: "Contenido" preview.link: "Previsualizar" @@ -267,7 +238,7 @@ admin_page: status.label: "Estado" publishedVersionContent.label: "Contenido publicado (distingue mayúsculas y minúsculas)" empty: - create_first_content_raw: 'Crea o importa tu primera página!' + create_first_content_raw: 'Crea tu primera página!' can_not_create_content: "No puedes crear páginas" go_to_doc_raw: 'Si necesitas ayuda visita la documentación' clean_filters: 'No se han encontrado páginas con tu búsqueda, limpia los filtros para ver todas las páginas' @@ -323,13 +294,6 @@ admin_page: success_unlocked_flash: "La versión se ha desbloqueado" failed_flash: "Se ha producido un error al bloquear/desbloquear la versión¿Estás seguro de eliminar esta versión v%versionNumber%?
Esta acción no se podrá deshacer.
' offer_backup: 'Si quieres puedes hacer un backup de la versión antes de eliminarla' actions: - export.button: "Exportar" delete.button: "Eliminar definitivamente" cancel.button: "Cancelar" success_flash: "La versión se ha eliminado" diff --git a/composer.json b/composer.json index 76adc108..3faebf73 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,7 @@ }, "suggest": { "softspring/cms-blog-plugin": "Provides a blog for the CMS", + "softspring/cms-data-plugin": "Import/export and fixtures features are now in this plugin. Provides features for the CMS", "softspring/cms-module-coolection": "Provides a module collection for the CMS", "softspring/cms-sections-plugin": "Provides editable sections for the CMS", "softspring/cms-sylius-bundle": "Provides a Sylius integration for the CMS", diff --git a/config/routing/admin_content_type.yaml b/config/routing/admin_content_type.yaml index a322ffe1..a18758e5 100644 --- a/config/routing/admin_content_type.yaml +++ b/config/routing/admin_content_type.yaml @@ -6,15 +6,9 @@ create: controller: sfs_cms.admin.content.controller::create path: /create -import: - controller: sfs_cms.admin.content.controller::create - path: /import - defaults: - configKey: 'import' - details: controller: sfs_cms.admin.content.controller::read - path: /{content} + path: /{content}/details update: controller: sfs_cms.admin.content.controller::update @@ -110,24 +104,12 @@ publish_version: defaults: configKey: 'version_publish' -export_version: - controller: sfs_cms.admin.content_version.controller::apply - path: /{content}/{version}/export - defaults: - configKey: 'version_export' - version_info: controller: sfs_cms.admin.content_version.controller::update path: /{content}/{version}/info defaults: configKey: 'version_info' -import_version: - controller: sfs_cms.admin.content_version.controller::create - path: /{content}/import - defaults: - configKey: 'version_import' - cleanup_versions: controller: sfs_cms.admin.content_version.controller::apply path: /{content}/versions-cleanup diff --git a/config/services/controller/admin_content.yaml b/config/services/controller/admin_content.yaml index d67eb4bb..2c47d62c 100644 --- a/config/services/controller/admin_content.yaml +++ b/config/services/controller/admin_content.yaml @@ -32,18 +32,6 @@ services: form_invalid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_CREATE_FORM_INVALID view_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_CREATE_VIEW exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_CREATE_EXCEPTION - import: - initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_INITIALIZE - create_entity_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_ENTITY - form_prepare_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_PREPARE - form_init_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_INIT - form_valid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_VALID - apply_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_APPLY - success_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_SUCCESS - failure_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FAILURE - form_invalid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_INVALID - view_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_VIEW - exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_IMPORT_EXCEPTION read: param_converter_key: 'id' initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_READ_INITIALIZE @@ -143,4 +131,4 @@ services: not_found_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_DIFF_NOT_FOUND found_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_DIFF_FOUND view_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_DIFF_VIEW - exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_DIFF_EXCEPTION \ No newline at end of file + exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENTS_DIFF_EXCEPTION diff --git a/config/services/controller/admin_content_version.yaml b/config/services/controller/admin_content_version.yaml index 830693d7..3a47e008 100644 --- a/config/services/controller/admin_content_version.yaml +++ b/config/services/controller/admin_content_version.yaml @@ -34,18 +34,6 @@ services: form_invalid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_CREATE_FORM_INVALID view_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_CREATE_VIEW exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_CREATE_EXCEPTION - version_import: - initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_INITIALIZE - create_entity_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_ENTITY - form_prepare_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_FORM_PREPARE - form_init_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_FORM_INIT - form_valid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_FORM_VALID - apply_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_APPLY - success_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_SUCCESS - failure_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_FAILURE - form_invalid_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_FORM_INVALID - view_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_VIEW - exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_IMPORT_EXCEPTION version_preview: param_converter_key: 'id' initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_PREVIEW_INITIALIZE @@ -83,16 +71,6 @@ services: success_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_PUBLISH_SUCCESS failure_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_PUBLISH_FAILURE exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_PUBLISH_EXCEPTION - version_export: - param_converter_key: 'id' - initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_INITIALIZE - load_entity_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_LOAD_ENTITY - not_found_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_NOT_FOUND - found_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_FOUND - apply_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_APPLY - success_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_SUCCESS - failure_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_FAILURE - exception_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_EXPORT_EXCEPTION version_list: initialize_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_LIST_INITIALIZE filter_form_prepare_event_name: !php/const Softspring\CmsBundle\SfsCmsEvents::ADMIN_CONTENT_VERSIONS_LIST_FILTER_FORM_PREPARE diff --git a/config/services/services.yaml b/config/services/services.yaml index 1cd3ef02..1306935a 100644 --- a/config/services/services.yaml +++ b/config/services/services.yaml @@ -15,8 +15,6 @@ services: $esi: '@?esi' $siteConfig: '%sfs_cms.site_config%' $profiler: '@?profiler' - $entityTransformers: !tagged_iterator { tag: sfs_cms.data.entity_transformer, default_priority_method: getPriority } - $fieldTransformers: !tagged_iterator { tag: sfs_cms.data.field_transformer, default_priority_method: getPriority } $cmsLogger: '@?monolog.logger.cms' $debug: '%kernel.debug%' $defaultRestrictPatterns: '%sfs_cms.form_type.symfony_route.default_restrict_patterns%' @@ -27,7 +25,6 @@ services: $contentCacheType: '%sfs_cms.content.cache.type%' $menuCacheType: '%sfs_cms.menu.cache.type%' $blockCacheType: '%sfs_cms.block.cache.type%' - $mediaStoragePath: '%sfs_media.storage.filesystem.path%' $compiledDataExpirationTtl: '%sfs_cms.compiled.expiration_ttl%' $contentRecompileEnabled: '%sfs_cms.content.recompile_enabled%' $registeredPlugins: '%sfs_cms.registered_plugins%' @@ -49,14 +46,6 @@ services: resource: '../../src/Controller/*' tags: [ 'controller.service_arguments' ] - Softspring\CmsBundle\DataFixtures\: - resource: '../../src/DataFixtures/*' - tags: [ 'doctrine.fixtures.loader' ] - - Softspring\CmsBundle\DataFixtures\Purger\CmsPurgerFactory: - tags: - - { name: 'doctrine.fixtures.purger_factory', alias: 'cms_purge' } - Softspring\CmsBundle\Form\Admin\: resource: '../../src/Form/Admin/*' tags: [ 'form.type' ] @@ -77,9 +66,6 @@ services: Softspring\CmsBundle\EventListener\ErrorPageListener: ~ - Softspring\CmsBundle\Data\: - resource: '../../src/Data/*' - Softspring\CmsBundle\Helper\: resource: '../../src/Helper/*' diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 522ae19b..ff3e3277 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,9 +15,6 @@ parameters: message: "#Class Softspring\\\\CmsBundle\\\\DataCollector\\\\TwigDataCollector extends @final class Symfony\\\\Bridge\\\\Twig\\\\DataCollector\\\\TwigDataCollector.#" count: 1 path: src/DataCollector/TwigDataCollector.php - - - message: "##" - path: src/DataFixtures/Purger/CmsPurger.php - message: "#Function twig_template_from_string not found.#" reportUnmatched: false diff --git a/src/Admin/ActionListener/Content/ImportListener.php b/src/Admin/ActionListener/Content/ImportListener.php deleted file mode 100644 index 2f577f9d..00000000 --- a/src/Admin/ActionListener/Content/ImportListener.php +++ /dev/null @@ -1,175 +0,0 @@ - [ - ['onInitializeGetConfig', 20], - ['onEventDispatchContentTypeEvent', 10], - ['onInitializeUpdateHelperConfig', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_ENTITY => [ - ['onEventDispatchContentTypeEvent', 10], - ['onCreateEntity', 1], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_PREPARE => [ - ['onEventDispatchContentTypeEvent', 10], - ['onFormPrepareResolve', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_INIT => [ - ['onEventDispatchContentTypeEvent', 10], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_VALID => [ - ['onEventDispatchContentTypeEvent', 10], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_APPLY => [ - ['onEventDispatchContentTypeEvent', 10], - ['onApply', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_SUCCESS => [ - ['onEventDispatchContentTypeEvent', 10], - ['onSuccess', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FAILURE => [ - ['onEventDispatchContentTypeEvent', 10], - ['onFailure', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_FORM_INVALID => [ - ['onEventDispatchContentTypeEvent', 10], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_VIEW => [ - ['onEventDispatchContentTypeEvent', 10], - ['onViewAddConfig', 0], - ['onViewSetTemplate', 0], - ['onViewAddEntities', 0], - ], - SfsCmsEvents::ADMIN_CONTENTS_IMPORT_EXCEPTION => [ - ['onEventDispatchContentTypeEvent', 10], - ], - ]; - } - - public function onCreateEntity(CreateEntityEvent $event): void - { - // set dummy version - $version = new stdClass(); - $version->file = null; - $event->setEntity($version); - } - - public function onFormPrepareResolve(FormPrepareEvent $event): void - { - $event->setType($this->getOption($event->getRequest(), 'type')); - $event->setFormOptions([ - 'method' => 'POST', - 'content_config' => $event->getRequest()->attributes->get('_content_config'), - ]); - } - - public function onApply(ApplyEvent $event): void - { - /** @var UploadedFile $zipFile */ - $zipFile = $event->getForm()->get('file')->getData(); - - $this->dataImporter->import(ZipContent::read($zipFile->getPath(), $zipFile->getBasename()), ['version_origin' => ContentVersionInterface::ORIGIN_IMPORT]); - - // $this->serializer->load('zip', [ - // 'zip_filename' => $zipFile->getPathname(), - // 'version_origin' => ContentVersionInterface::ORIGIN_IMPORT, - // 'persist_and_flush' => true, - // ]); - - $event->setApplied(true); - } - - /** - * @noinspection PhpRouteMissingInspection - */ - public function onSuccess(SuccessEvent $event): void - { - $contentConfig = $event->getRequest()->attributes->get('_content_config'); - - $this->flashNotifier->addTrans('success', "admin_{$contentConfig['_id']}.import.success_flash", [], 'sfs_cms_contents'); - - $url = $this->router->generate("sfs_cms_admin_content_{$contentConfig['_id']}_list"); - - $event->setResponse(new RedirectResponse($url)); - } - - public function onFailure(FailureEvent $event): void - { - $contentConfig = $event->getRequest()->attributes->get('_content_config'); - - if ($event->getException() instanceof UniqueConstraintViolationException) { - $this->flashNotifier->addTrans('error', "admin_{$contentConfig['_id']}.import.duplicated_flash", ['%exception%' => ''], 'sfs_cms_contents'); - } else { - $exception = $event->getException()->getMessage(); - if ('1' === $event->getRequest()->server->get('APP_DEBUG')) { - $exception .= '{{ ('admin_'~content_type~'.delete.offer_backup')|trans }}
- + {% if route_defined('sfs_cms_admin_content_'~content_type~'_export_version') %} + {# TODO make this configurable and extensible for plugins #} + + {% endif %} {% endif %} {{ ('admin_'~content_type~'.delete.index_warnings_raw')|trans|raw }} diff --git a/templates/admin/content/import.html.twig b/templates/admin/content/import.html.twig deleted file mode 100644 index 5b121d27..00000000 --- a/templates/admin/content/import.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{% trans_default_domain 'sfs_cms_contents' %} - -{% extends '@SfsCms/admin_layout.html.twig' %} - -{% form_theme form - '@SfsCms/forms/cms_theme.html.twig' - '@SfsCms/forms/routes_theme.html.twig' - '@SfsCms/forms/types_theme.html.twig' -%} - -{% block title %}{{ ('admin_'~content_type~'.import.meta.title')|trans }}{% endblock %} - -{% block breadcrums_content %} - {{ parent() }} -{{ ('admin_'~content_type~'.version_delete.offer_backup')|trans }}
+ {% if route_defined('sfs_cms_admin_content_'~content_type~'_export_version') %} + {# TODO make this configurable and extensible for plugins #} + {% endif %} {{ form_rest(form) }} diff --git a/templates/admin/content/version_import.html.twig b/templates/admin/content/version_import.html.twig deleted file mode 100644 index 95797629..00000000 --- a/templates/admin/content/version_import.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{% trans_default_domain 'sfs_cms_contents' %} - -{% extends '@SfsCms/admin_layout.html.twig' %} - -{% form_theme form - '@SfsCms/forms/cms_theme.html.twig' - '@SfsCms/forms/routes_theme.html.twig' - '@SfsCms/forms/types_theme.html.twig' -%} - -{% block title %}{{ ('admin_'~content_type~'.import_version.meta.title')|trans({'%name%':entity.name}) }}{% endblock %} - -{% block breadcrums_content %} - {{ parent() }} -