From c9dd23ef123f8f1b0e32205c09eff1e3ea3d7805 Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Tue, 11 Dec 2018 15:11:57 +0100 Subject: [PATCH] COM-20066: Full view of Bundle page https://jira.ez.no/browse/COM-20066 --- .../ezplatform/form/bundle_search.html.twig | 10 -- .../form/bundle_sort_order.html.twig | 5 - .../ezplatform/form/package_search.html.twig | 10 ++ .../form/package_sort_order.html.twig | 5 + .../themes/ezplatform/full/bundle.html.twig | 105 -------------- .../themes/ezplatform/full/package.html.twig | 105 ++++++++++++++ ..._list.html.twig => package_list.html.twig} | 47 ++++--- .../themes/ezplatform/layout/header.html.twig | 2 +- .../ezplatform/line/bundle_card.html.twig | 28 ---- .../ezplatform/line/package_card.html.twig | 26 ++++ .../{bundle_list => package}/list.html.twig | 2 +- .../ezplatform/row/download_section.html.twig | 2 +- app/config/config_ezplatform_page.yml | 21 ++- app/config/routing.yml | 32 ++--- app/config/services/controller.yml | 12 +- app/config/services/packagist.yml | 4 +- app/config/services/pagerfanta.yml | 10 +- app/config/services/query_type.yml | 4 +- app/config/views.yml | 23 +-- ...mmand.php => UpdatePackageListCommand.php} | 16 +-- ...leController.php => PackageController.php} | 133 +++++++++--------- ...ndleOrderType.php => PackageOrderType.php} | 4 +- ...leSearchType.php => PackageSearchType.php} | 8 +- ...lesQueryType.php => PackagesQueryType.php} | 16 +-- ...stTemplate.php => PackageListTemplate.php} | 4 +- web/assets/js/app.js | 10 +- web/assets/scss/bundle_card.scss | 92 ------------ web/assets/scss/{bundle.scss => package.scss} | 2 +- web/assets/scss/package_card.scss | 85 +++++++++++ .../{bundle_list.scss => package_list.scss} | 8 +- web/assets/scss/page.scss | 6 +- 31 files changed, 415 insertions(+), 422 deletions(-) delete mode 100644 app/Resources/views/themes/ezplatform/form/bundle_search.html.twig delete mode 100644 app/Resources/views/themes/ezplatform/form/bundle_sort_order.html.twig create mode 100644 app/Resources/views/themes/ezplatform/form/package_search.html.twig create mode 100644 app/Resources/views/themes/ezplatform/form/package_sort_order.html.twig delete mode 100644 app/Resources/views/themes/ezplatform/full/bundle.html.twig create mode 100644 app/Resources/views/themes/ezplatform/full/package.html.twig rename app/Resources/views/themes/ezplatform/full/{bundle_list.html.twig => package_list.html.twig} (66%) delete mode 100644 app/Resources/views/themes/ezplatform/line/bundle_card.html.twig create mode 100644 app/Resources/views/themes/ezplatform/line/package_card.html.twig rename app/Resources/views/themes/ezplatform/parts/{bundle_list => package}/list.html.twig (84%) rename src/AppBundle/Command/{UpdateBundlesListCommand.php => UpdatePackageListCommand.php} (92%) rename src/AppBundle/Controller/{BundleController.php => PackageController.php} (66%) rename src/AppBundle/Form/{BundleOrderType.php => PackageOrderType.php} (90%) rename src/AppBundle/Form/{BundleSearchType.php => PackageSearchType.php} (77%) rename src/AppBundle/QueryType/{BundlesQueryType.php => PackagesQueryType.php} (88%) rename src/AppBundle/View/Template/{BundlesListTemplate.php => PackageListTemplate.php} (84%) delete mode 100644 web/assets/scss/bundle_card.scss rename web/assets/scss/{bundle.scss => package.scss} (99%) create mode 100644 web/assets/scss/package_card.scss rename web/assets/scss/{bundle_list.scss => package_list.scss} (96%) diff --git a/app/Resources/views/themes/ezplatform/form/bundle_search.html.twig b/app/Resources/views/themes/ezplatform/form/bundle_search.html.twig deleted file mode 100644 index 82b427c7..00000000 --- a/app/Resources/views/themes/ezplatform/form/bundle_search.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{{ form_start(searchBundleForm) }} -
- {{ form_widget(searchBundleForm.search, {'id': 'bundle-list-search-query'} )}} -
- -
-
-{{ form_end(searchBundleForm) }} diff --git a/app/Resources/views/themes/ezplatform/form/bundle_sort_order.html.twig b/app/Resources/views/themes/ezplatform/form/bundle_sort_order.html.twig deleted file mode 100644 index cd2a5cc8..00000000 --- a/app/Resources/views/themes/ezplatform/form/bundle_sort_order.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{{ form_start(sortOrderBundleForm) }} -
- {{ form_row(sortOrderBundleForm.order) }} -
-{{ form_end(sortOrderBundleForm) }} diff --git a/app/Resources/views/themes/ezplatform/form/package_search.html.twig b/app/Resources/views/themes/ezplatform/form/package_search.html.twig new file mode 100644 index 00000000..7a82c6b0 --- /dev/null +++ b/app/Resources/views/themes/ezplatform/form/package_search.html.twig @@ -0,0 +1,10 @@ +{{ form_start(searchPackageForm) }} +
+ {{ form_widget(searchPackageForm.search, {'id': 'package-list-search-query'} )}} +
+ +
+
+{{ form_end(searchPackageForm) }} diff --git a/app/Resources/views/themes/ezplatform/form/package_sort_order.html.twig b/app/Resources/views/themes/ezplatform/form/package_sort_order.html.twig new file mode 100644 index 00000000..abf2f8ca --- /dev/null +++ b/app/Resources/views/themes/ezplatform/form/package_sort_order.html.twig @@ -0,0 +1,5 @@ +{{ form_start(sortOrderPackageForm) }} +
+ {{ form_row(sortOrderPackageForm.order) }} +
+{{ form_end(sortOrderPackageForm) }} diff --git a/app/Resources/views/themes/ezplatform/full/bundle.html.twig b/app/Resources/views/themes/ezplatform/full/bundle.html.twig deleted file mode 100644 index 1ab52fe3..00000000 --- a/app/Resources/views/themes/ezplatform/full/bundle.html.twig +++ /dev/null @@ -1,105 +0,0 @@ -{% extends '@ezdesign/pagelayout.html.twig' %} - -{% block content %} -
-
-
-
-
-

{{ bundle.packageId }}

- Install Package -
-
-
-
-
- -
-
-
-
-
-
- {{ ez_render_field(content, 'description') }} -
-
- {{ ez_comments_render_content(content.contentInfo, { - 'identifier': content.id, - 'url': app.request.uri - }) }} -
-
-
-
-
-
-

Created by:

- -
-
-

Categories:

-
- {% if not ez_is_field_empty(content, 'bundle_category') %} - {% for tags in content.fields.bundle_category %} - {% for tag in tags.tags %} - {% set tagKeyword = netgen_tags_tag_keyword( tag ) %} - {{ tagKeyword }} - {% endfor %} - {% endfor %} - {% endif %} -
-
-
-

Downloads:

-
- - {{ bundle.downloads }} -
-
-
-

Stars:

-
- - {{ bundle.stars }} -
-
-
-

Forks:

-
- - {{ bundle.forks }} -
-
-
-

Created:

- -
-
-

Updated:

- -
-
-
-
-
-
-{% endblock %} diff --git a/app/Resources/views/themes/ezplatform/full/package.html.twig b/app/Resources/views/themes/ezplatform/full/package.html.twig new file mode 100644 index 00000000..8918c71b --- /dev/null +++ b/app/Resources/views/themes/ezplatform/full/package.html.twig @@ -0,0 +1,105 @@ +{% extends '@ezdesign/pagelayout.html.twig' %} + +{% block content %} +
+
+
+
+
+

{{ package.packageId }}

+ Install Package +
+
+
+
+
+ +
+
+
+
+
+
+ {{ ez_render_field(content, 'description') }} +
+
+ {{ ez_comments_render_content(content.contentInfo, { + 'identifier': content.id, + 'url': app.request.uri + }) }} +
+
+
+
+
+
+

Created by:

+ +
+
+

Categories:

+
+ {% if not ez_is_field_empty(content, 'package_category') %} + {% for tags in content.fields.package_category %} + {% for tag in tags.tags %} + {% set tagKeyword = netgen_tags_tag_keyword( tag ) %} + {{ tagKeyword }} + {% endfor %} + {% endfor %} + {% endif %} +
+
+
+

Downloads:

+
+ + {{ package.downloads }} +
+
+
+

Stars:

+
+ + {{ package.stars }} +
+
+
+

Forks:

+
+ + {{ package.forks }} +
+
+
+

Created:

+ +
+
+

Updated:

+ +
+
+
+
+
+
+{% endblock %} diff --git a/app/Resources/views/themes/ezplatform/full/bundle_list.html.twig b/app/Resources/views/themes/ezplatform/full/package_list.html.twig similarity index 66% rename from app/Resources/views/themes/ezplatform/full/bundle_list.html.twig rename to app/Resources/views/themes/ezplatform/full/package_list.html.twig index 968bcd51..5f0e68a2 100644 --- a/app/Resources/views/themes/ezplatform/full/bundle_list.html.twig +++ b/app/Resources/views/themes/ezplatform/full/package_list.html.twig @@ -1,31 +1,32 @@ {% extends '@ezdesign/pagelayout.html.twig' %} {% block content %} -
-
+
+
{{ ez_render_field(content, 'description') }} -
+
-
+
-
+

Categories

    {% set selectedCategory = 'All' %} -
  • - {{ selectedCategory }} Bundles +
  • + {{ selectedCategory }} Packages
  • - {% if bundlesCategories is defined and bundlesCategories|length > 0 %} - {% for bundleCategory in bundlesCategories %} -
  • - {{ bundleCategory.keyword }} + {% if packageCategories is defined and packageCategories|length > 0 %} + {% for packageCategory in packageCategories %} + {% set keyword = packageCategory.keyword|lower %} +
  • + {{ packageCategory.keyword }}
  • {% endfor %} {% endif %} @@ -34,31 +35,31 @@
    -
    -
    +
    {% if items is defined and items|length > 0 %}
    -
    +
    {% if search is defined and search is not empty %}

    Search / Keyword: {{ search }}

    {% else %} -

    {{ selectedCategory }} Bundles

    +

    {{ selectedCategory }} Packages

    {% endif %}
    -
    +
    {% set sortingOrder = order is defined ? order : 'default' %} - {{ render_esi(controller('app.controller.bundle:renderSortOrderBundleForm', {"order": sortingOrder})) }} + {{ render_esi(controller('app.controller.package:renderSortOrderPackageForm', {"order": sortingOrder})) }}
    - {% include '@ezdesign/parts/bundle_list/list.html.twig' with { + {% include '@ezdesign/parts/package/list.html.twig' with { 'items': items, 'viewType': 'line', 'extraParams': { @@ -67,13 +68,13 @@ } only %}
    - {{ pagerfanta(pager, 'bundles_list') }} + {{ pagerfanta(pager, 'package_list') }}
    {% else %}
    -

    Bundles not found

    +

    Packages not found

    {% endif %} diff --git a/app/Resources/views/themes/ezplatform/layout/header.html.twig b/app/Resources/views/themes/ezplatform/layout/header.html.twig index 2352e52b..6ac09cf4 100644 --- a/app/Resources/views/themes/ezplatform/layout/header.html.twig +++ b/app/Resources/views/themes/ezplatform/layout/header.html.twig @@ -16,7 +16,7 @@ - +
diff --git a/app/Resources/views/themes/ezplatform/line/bundle_card.html.twig b/app/Resources/views/themes/ezplatform/line/bundle_card.html.twig deleted file mode 100644 index f71cb8aa..00000000 --- a/app/Resources/views/themes/ezplatform/line/bundle_card.html.twig +++ /dev/null @@ -1,28 +0,0 @@ - - diff --git a/app/Resources/views/themes/ezplatform/line/package_card.html.twig b/app/Resources/views/themes/ezplatform/line/package_card.html.twig new file mode 100644 index 00000000..54e1e6d5 --- /dev/null +++ b/app/Resources/views/themes/ezplatform/line/package_card.html.twig @@ -0,0 +1,26 @@ + + diff --git a/app/Resources/views/themes/ezplatform/parts/bundle_list/list.html.twig b/app/Resources/views/themes/ezplatform/parts/package/list.html.twig similarity index 84% rename from app/Resources/views/themes/ezplatform/parts/bundle_list/list.html.twig rename to app/Resources/views/themes/ezplatform/parts/package/list.html.twig index bebb84a6..e4c30761 100644 --- a/app/Resources/views/themes/ezplatform/parts/bundle_list/list.html.twig +++ b/app/Resources/views/themes/ezplatform/parts/package/list.html.twig @@ -4,7 +4,7 @@ {% for card in items %}
{{ render(controller('ez_content:viewAction', { - 'locationId': card.bundle.valueObject.versionInfo.contentInfo.mainLocationId, + 'locationId': card.package.valueObject.versionInfo.contentInfo.mainLocationId, 'viewType': viewType, 'params': { 'extra': extraParams, diff --git a/app/Resources/views/themes/ezplatform/row/download_section.html.twig b/app/Resources/views/themes/ezplatform/row/download_section.html.twig index d62d7e24..0ca119a0 100644 --- a/app/Resources/views/themes/ezplatform/row/download_section.html.twig +++ b/app/Resources/views/themes/ezplatform/row/download_section.html.twig @@ -142,7 +142,7 @@

eZ Launchpad requires you to have PHP (5.6+ or 7+) and Docker installed.

You can find a full documentation here: - https://ezsystems.github.io/launchpad/ + https://ezsystems.github.io/launchpad/

{% endif %} diff --git a/app/config/config_ezplatform_page.yml b/app/config/config_ezplatform_page.yml index f2a67aef..31d4b456 100755 --- a/app/config/config_ezplatform_page.yml +++ b/app/config/config_ezplatform_page.yml @@ -17,16 +17,16 @@ parameters: blog.posts_limit: 10 # `authors` folder locationId blog.authors_container_location_id: 72 - # `bundles_list` locationId - bundles.location_id: 168 - # 'bundles_list` elements limit on `bundles_list` page - bundles.cards_limit: 12 - # 'bundle_categories parent tag id' - bundles.categories_parent_tag_id: 32 - # 'bundles' cache expiration time in seconds - bundles.cache_expiration_time: 604800 - # names of excluded bundle maintainers - bundles.excluded_maintainers: ['ezrobot'] + # `package_list` locationId + packages.location_id: 168 + # 'package_list` elements limit on `packages_list` page + packages.cards_limit: 12 + # 'package_categories parent tag id' + packages.categories_parent_tag_id: 32 + # 'package' cache expiration time in seconds + packages.cache_expiration_time: 604800 + # names of excluded package maintainers + packages.excluded_maintainers: ['ezrobot'] # overwrites default tag view page template netgen_tags.default.tag_view.pagelayout: 'pagelayout.html.twig' # overwrites default tag related content limit @@ -63,6 +63,5 @@ ez_comments: twig: globals: blogLocationId: '%blog.location_id%' - bundlesListLocationId: '%bundles.location_id%' communityMetricsIframeUrl: '%community_metrics.iframe_url%' productFeedbackIframeUrl: '%product_feedback.iframe_url%' diff --git a/app/config/routing.yml b/app/config/routing.yml index fe70f201..fafb5a21 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -65,33 +65,31 @@ _ezplatform_blog_ajax: requirements: "page": '\d+' - -# BUNDLES LIST -_ezplatform_bundles_list: - path: /Bundles/{category}/{page}/{order}/{searchText} - defaults: { _controller: app.controller.bundle:showBundlesListAction, page: 1, order: 'default', searchText: '', category: 'all' } +# PACKAGE LIST +_ezplatform_package_list: + path: /packages/{page} + defaults: { _controller: app.controller.package:showPackageListAction, page: 1 } methods: [GET] requirements: - "order": 'default|latestUpdate|stars|downloads' + "page": '\d+' -#I will change this when we provide new name for bundles -_ezplatform_bundle_details: - path: bundle/{locationId} - defaults: { _controller: app.controller.bundle:getBundleDetailsAction } +_ezplatform_package_list_category: + path: /packages/category/{category}/{page}/{order}/{searchText} + defaults: { _controller: app.controller.package:showPackageListAction, page: 1, order: 'default', searchText: '', category: 'all' } methods: [GET] requirements: - "locationId": '\d+' + "order": 'default|latestUpdate|stars|downloads' -_ezplatform_bundles_search_init: - path: /Bundles/search/ - defaults: { _controller: app.controller.bundle:searchBundlesAction, page: 1, order: 'default' } +_ezplatform_package_list_search_init: + path: /packages/search/ + defaults: { _controller: app.controller.package:searchPackagesAction, page: 1, order: 'default' } methods: [POST] requirements: "order": 'default|latestUpdate|stars|downloads' -_ezplatform_bundles_search: - path: /Bundles/search/{category}/{searchText}/{page}/{order} - defaults: { _controller: app.controller.bundle:showBundlesListAction, page: 1, order: 'default', searchText: '', category: 'all' } +_ezplatform_package_list_search: + path: /packages/search/{category}/{searchText}/{page}/{order} + defaults: { _controller: app.controller.package:showPackageListAction, page: 1, order: 'default', searchText: '', category: 'all' } methods: [GET, POST] # TAGS diff --git a/app/config/services/controller.yml b/app/config/services/controller.yml index 250f2a76..da71d3d3 100644 --- a/app/config/services/controller.yml +++ b/app/config/services/controller.yml @@ -14,21 +14,21 @@ services: - '@app.query_type.children' - '%blog.location_id%' - '%blog.posts_limit%' - app.controller.bundle: - class: AppBundle\Controller\BundleController + app.controller.package: + class: AppBundle\Controller\PackageController arguments: - '@templating' - '@ezpublish.api.service.search' - '@ezpublish.urlalias_router' - - '@app.query_type.bundles' + - '@app.query_type.packages' - '@app.packagist_service_provider' - '@form.factory' - '@router.default' - '@eztags.api.service.tags' - '@ezpublish.api.service.location' - - '%bundles.location_id%' - - '%bundles.cards_limit%' - - '%bundles.categories_parent_tag_id%' + - '%packages.location_id%' + - '%packages.cards_limit%' + - '%packages.categories_parent_tag_id%' app.controller.tag: class: AppBundle\Controller\TagController arguments: diff --git a/app/config/services/packagist.yml b/app/config/services/packagist.yml index 11b5da54..4304bdea 100644 --- a/app/config/services/packagist.yml +++ b/app/config/services/packagist.yml @@ -3,11 +3,11 @@ services: class: Packagist\Api\Client app.packagist_api_mapper: class: AppBundle\Service\Packagist\Mapper - arguments: ['%bundles.excluded_maintainers%'] + arguments: ['%packages.excluded_maintainers%'] app.packagist_service_provider: class: AppBundle\Service\Packagist\PackagistServiceProvider arguments: - '@ezpublish.cache_pool' - '@app.packagist_api_client' - '@app.packagist_api_mapper' - - '%bundles.cache_expiration_time' + - '%packages.cache_expiration_time' diff --git a/app/config/services/pagerfanta.yml b/app/config/services/pagerfanta.yml index ea8e07e4..0846548d 100644 --- a/app/config/services/pagerfanta.yml +++ b/app/config/services/pagerfanta.yml @@ -1,11 +1,11 @@ services: - app.pagerfanta.template.bundles_list: - class: AppBundle\View\Template\BundlesListTemplate + app.pagerfanta.template.package_list: + class: AppBundle\View\Template\PackageListTemplate - pagerfanta.view.bundles_list: + pagerfanta.view.package_list: class: Pagerfanta\View\DefaultView public: false arguments: - - "@app.pagerfanta.template.bundles_list" + - "@app.pagerfanta.template.package_list" tags: - - { name: pagerfanta.view, alias: bundles_list } + - { name: pagerfanta.view, alias: package_list } diff --git a/app/config/services/query_type.yml b/app/config/services/query_type.yml index c3744d74..82dd4da1 100644 --- a/app/config/services/query_type.yml +++ b/app/config/services/query_type.yml @@ -9,7 +9,7 @@ services: tags: - name: ezpublish.query_type - app.query_type.bundles: - class: AppBundle\QueryType\BundlesQueryType + app.query_type.packages: + class: AppBundle\QueryType\PackagesQueryType tags: - name: ezpublish.query_type diff --git a/app/config/views.yml b/app/config/views.yml index 0cbae85a..f52dede5 100755 --- a/app/config/views.yml +++ b/app/config/views.yml @@ -13,7 +13,7 @@ ezpublish: omitted_location_ids: - '%blog.location_id%' - '%blog.authors_container_location_id%' - - '%bundles.location_id%' + - '%packages.location_id%' query: query_type: AppBundle:Children parameters: @@ -21,7 +21,7 @@ ezpublish: excluded_content_types: - layout - article - - bundle_list + - package_list assign_results_to: items template: "@ezdesign/full/home.html.twig" match: @@ -57,21 +57,26 @@ ezpublish: template: "@ezdesign/full/article.html.twig" match: Identifier\ContentType: article - bundle_list: - controller: app.controller.bundle:showBundlesListAction - template: "@ezdesign/full/bundle_list.html.twig" + package_list: + controller: app.controller.package:showPackageListAction + template: "@ezdesign/full/package_list.html.twig" match: - Identifier\ContentType: bundle_list + Identifier\ContentType: package_list + package: + controller: app.controller.package:getPackageDetailsAction + template: "@ezdesign/full/package.html.twig" + match: + Identifier\ContentType: package line: blog_post: template: "@ezdesign/line/blog_post.html.twig" match: Identifier\ContentType: blog_post - bundle: - template: "@ezdesign/line/bundle_card.html.twig" + package: + template: "@ezdesign/line/package_card.html.twig" match: - Identifier\ContentType: bundle + Identifier\ContentType: package row: banner_slider: diff --git a/src/AppBundle/Command/UpdateBundlesListCommand.php b/src/AppBundle/Command/UpdatePackageListCommand.php similarity index 92% rename from src/AppBundle/Command/UpdateBundlesListCommand.php rename to src/AppBundle/Command/UpdatePackageListCommand.php index 2c494749..43625859 100755 --- a/src/AppBundle/Command/UpdateBundlesListCommand.php +++ b/src/AppBundle/Command/UpdatePackageListCommand.php @@ -1,7 +1,7 @@ setName('app:update_bundles_list') - ->setDescription('This command updates Bundle List with data gathered from Packagist.org') + ->setName('app:update_package_list') + ->setDescription('This command updates Package List with data gathered from Packagist.org') ->addOption('force', 'f', InputOption::VALUE_NONE, false) ->addOption('details', 'd', InputOption::VALUE_NONE, false); } @@ -58,8 +58,8 @@ function (Repository $repository) use ($query) { foreach ($results->searchHits as $searchHit) { $currentPackage = $searchHit->valueObject; - $package = $packagistServiceProvider->getPackageDetails($currentPackage->getFieldValue('bundle_id'), $input->getOption('force')); - $output->write(''.$currentPackage->getFieldValue('bundle_id').''); + $package = $packagistServiceProvider->getPackageDetails($currentPackage->getFieldValue('package_id'), $input->getOption('force')); + $output->write(''.$currentPackage->getFieldValue('package_id').''); if (($package->checksum !== $currentPackage->getFieldValue('checksum')->__toString()) || $input->getOption('force')) { if ( !empty($this->getDiff($currentPackage, $package)) && $input->getOption('details')) { @@ -87,7 +87,7 @@ function () use ($contentService, $contentId, $contentUpdateStruct) { $output->writeln(': Already up-to-date'); } } - $output->writeln('The bundles have been successfully updated.'); + $output->writeln('The packages have been successfully updated.'); } /** @@ -96,7 +96,7 @@ function () use ($contentService, $contentId, $contentUpdateStruct) { private function getQuery() { $query = new Query(); - $criterion = new Query\Criterion\ParentLocationId($this->getContainer()->getParameter('bundles.location_id')); + $criterion = new Query\Criterion\ParentLocationId($this->getContainer()->getParameter('packages.location_id')); $query->filter = $criterion; $query->limit = 1000; diff --git a/src/AppBundle/Controller/BundleController.php b/src/AppBundle/Controller/PackageController.php similarity index 66% rename from src/AppBundle/Controller/BundleController.php rename to src/AppBundle/Controller/PackageController.php index 253b60ed..7ed2d18d 100644 --- a/src/AppBundle/Controller/BundleController.php +++ b/src/AppBundle/Controller/PackageController.php @@ -2,9 +2,9 @@ namespace AppBundle\Controller; -use AppBundle\Form\BundleOrderType; -use AppBundle\Form\BundleSearchType; -use AppBundle\QueryType\BundlesQueryType; +use AppBundle\Form\PackageOrderType; +use AppBundle\Form\PackageSearchType; +use AppBundle\QueryType\PackagesQueryType; use AppBundle\Service\Packagist\PackagistServiceProviderInterface; use eZ\Bundle\EzPublishCoreBundle\Routing\DefaultRouter; use eZ\Bundle\EzPublishCoreBundle\Routing\UrlAliasRouter; @@ -20,11 +20,11 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Templating\EngineInterface; -class BundleController +class PackageController { private const DEFAULT_ORDER_CLAUSE = 'default'; - private const DEFAULT_BUNDLES_CATEGORY = 'all'; + private const DEFAULT_PACKAGE_CATEGORY = 'all'; /** * @var \Symfony\Bundle\TwigBundle\TwigEngine @@ -42,9 +42,9 @@ class BundleController private $aliasRouter; /** - * @var \AppBundle\QueryType\BundlesQueryType + * @var \AppBundle\QueryType\PackagesQueryType */ - private $bundlesQueryType; + private $packagesQueryType; /** * @var \AppBundle\Service\Packagist\PackagistServiceProviderInterface; @@ -74,65 +74,65 @@ class BundleController /** * @var int */ - private $bundlesListLocationId; + private $packageListLocationId; /** * @var int */ - private $bundlesListCardsLimit; + private $packageListCardsLimit; /** * @var int */ - private $bundleCategoriesParentTagId; + private $packageCategoriesParentTagId; /** - * BundleController constructor. + * PackageBundleController constructor. * @param EngineInterface $templating * @param SearchService $searchService * @param UrlAliasRouter $aliasRouter - * @param BundlesQueryType $bundlesQueryType + * @param PackagesQueryType $packagesQueryType * @param PackagistServiceProviderInterface $packagistServiceProvider * @param FormFactory $formFactory * @param DefaultRouter $router * @param TagsService $tagsService * @param LocationService $locationService - * @param int $bundlesListLocationId - * @param int $bundlesListCardsLimit - * @param int $bundleCategoriesParentTagId + * @param int $packageListLocationId + * @param int $packageListCardsLimit + * @param int $packageCategoriesParentTagId */ public function __construct( EngineInterface $templating, SearchService $searchService, UrlAliasRouter $aliasRouter, - BundlesQueryType $bundlesQueryType, + PackagesQueryType $packagesQueryType, PackagistServiceProviderInterface $packagistServiceProvider, FormFactory $formFactory, DefaultRouter $router, TagsService $tagsService, LocationService $locationService, - int $bundlesListLocationId, - int $bundlesListCardsLimit, - int $bundleCategoriesParentTagId + int $packageListLocationId, + int $packageListCardsLimit, + int $packageCategoriesParentTagId ) { $this->templating = $templating; $this->searchService = $searchService; $this->aliasRouter = $aliasRouter; - $this->bundlesQueryType = $bundlesQueryType; + $this->packagesQueryType = $packagesQueryType; $this->packagistServiceProvider = $packagistServiceProvider; $this->formFactory = $formFactory; $this->router = $router; $this->tagsService = $tagsService; $this->locationService = $locationService; - $this->bundlesListLocationId = $bundlesListLocationId; - $this->bundlesListCardsLimit = $bundlesListCardsLimit; - $this->bundleCategoriesParentTagId = $bundleCategoriesParentTagId; + $this->packageListLocationId = $packageListLocationId; + $this->packageListCardsLimit = $packageListCardsLimit; + $this->packageCategoriesParentTagId = $packageCategoriesParentTagId; } /** - * Renders full view `bundle_list`. + * Renders full view `package_list`. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param Request $request * @param string $category * @param int $page * @param string $order @@ -141,19 +141,18 @@ public function __construct( * @return \Symfony\Component\HttpFoundation\Response * * @throws \Twig\Error\Error - * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException */ - public function showBundlesListAction(Request $request, string $category = self::DEFAULT_BUNDLES_CATEGORY, $page = 1, $order = self::DEFAULT_ORDER_CLAUSE, $searchText = '') + public function showPackageListAction(Request $request, string $category = self::DEFAULT_PACKAGE_CATEGORY, $page = 1, $order = self::DEFAULT_ORDER_CLAUSE, $searchText = '') { - $orderForm = $this->formFactory->create(BundleOrderType::class); + $orderForm = $this->formFactory->create(PackageOrderType::class); $orderForm->handleRequest($request); if ($orderForm->isSubmitted() && $orderForm->isValid()) { $order = $orderForm->get('order')->getData(); } - $searchForm = $this->formFactory->create(BundleSearchType::class); + $searchForm = $this->formFactory->create(PackageSearchType::class); $searchForm->handleRequest($request); if ($searchForm->isSubmitted() || $searchForm->isValid()) { $searchText = $searchForm->get('search')->getData(); @@ -161,30 +160,30 @@ public function showBundlesListAction(Request $request, string $category = self: $tagId = null; - if ($category && $category !== self::DEFAULT_BUNDLES_CATEGORY) { + if ($category && $category !== self::DEFAULT_PACKAGE_CATEGORY) { $tagId = $this->getCategoryTagId($category); } - $content = $this->locationService->loadLocation($this->bundlesListLocationId)->getContent(); + $content = $this->locationService->loadLocation($this->packageListLocationId)->getContent(); // Create pager - $adapter = new ContentSearchHitAdapter($this->getBundlesQuery(0, $order, $searchText, $tagId), $this->searchService); + $adapter = new ContentSearchHitAdapter($this->getPackagesQuery(0, $order, $searchText, $tagId), $this->searchService); $pagerfanta = new Pagerfanta($adapter); - $pagerfanta->setMaxPerPage($this->bundlesListCardsLimit); + $pagerfanta->setMaxPerPage($this->packageListCardsLimit); $pagerfanta->setCurrentPage($page); - // Get list of bundles using already fetched data from pager - $bundles = $this->getList($adapter->getSlice(($page - 1) * $this->bundlesListCardsLimit, $this->bundlesListCardsLimit)); + // Get list of packages using already fetched data from pager + $packages = $this->getList($adapter->getSlice(($page - 1) * $this->packageListCardsLimit, $this->packageListCardsLimit)); - return $this->templating->renderResponse('@ezdesign/full/bundle_list.html.twig', [ - 'items' => $bundles, + return $this->templating->renderResponse('@ezdesign/full/package_list.html.twig', [ + 'items' => $packages, 'content' => $content, 'order' => $order, 'pager' => $pagerfanta, 'searchText' => $searchText, - 'bundlesCategories' => $this->getBundlesCategoriesList($this->bundleCategoriesParentTagId), - 'selectedBundleCategory' => $category !== self::DEFAULT_BUNDLES_CATEGORY ? $category : '' + 'packageCategories' => $this->getPackageCategoriesList($this->packageCategoriesParentTagId), + 'selectedPackageCategory' => $category !== self::DEFAULT_PACKAGE_CATEGORY ? mb_strtolower($category) : '' ]); } @@ -197,13 +196,13 @@ public function showBundlesListAction(Request $request, string $category = self: * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException */ - public function getBundleDetailsAction(Request $request) + public function getPackageDetailsAction(Request $request) { $content = $this->locationService->loadLocation($request->get('locationId'))->getContent(); - return $this->templating->renderResponse('@ezdesign/full/bundle.html.twig', [ + return $this->templating->renderResponse('@ezdesign/full/package.html.twig', [ 'content' => $content, - 'bundle' => $this->packagistServiceProvider->getPackageDetails($content->getName()) + 'package' => $this->packagistServiceProvider->getPackageDetails($content->getName()) ]); } @@ -214,22 +213,22 @@ public function getBundleDetailsAction(Request $request) * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function searchBundlesAction(Request $request) + public function searchPackagesAction(Request $request) { - $searchForm = $this->formFactory->create(BundleSearchType::class); + $searchForm = $this->formFactory->create(PackageSearchType::class); $searchForm->handleRequest($request); if (!$searchForm->isSubmitted() || !$searchForm->isValid()) { return new RedirectResponse($this->aliasRouter->generate('ez_urlalias', - ['locationId' => $this->bundlesListLocationId], UrlGeneratorInterface::ABSOLUTE_PATH)); + ['locationId' => $this->packageListLocationId], UrlGeneratorInterface::ABSOLUTE_PATH)); } $searchText = $searchForm->get('search')->getData(); - return new RedirectResponse($this->router->generate('_ezplatform_bundles_search', [ + return new RedirectResponse($this->router->generate('_ezplatform_package_list_search', [ 'page' => 1, 'order' => self::DEFAULT_ORDER_CLAUSE, 'searchText' => $searchText, - 'category' => self::DEFAULT_BUNDLES_CATEGORY + 'category' => self::DEFAULT_PACKAGE_CATEGORY ])); } @@ -240,16 +239,16 @@ public function searchBundlesAction(Request $request) * * @throws \Twig\Error\Error */ - public function renderSortOrderBundleForm($order) + public function renderSortOrderPackageForm($order) { - $sortOrderBundleForm = $this->formFactory->create(BundleOrderType::class, [ + $sortOrderPackageForm = $this->formFactory->create(PackageOrderType::class, [ 'order' => $order, ]); return $this->templating->renderResponse( - '@ezdesign/form/bundle_sort_order.html.twig', + '@ezdesign/form/package_sort_order.html.twig', [ - 'sortOrderBundleForm' => $sortOrderBundleForm->createView(), + 'sortOrderPackageForm' => $sortOrderPackageForm->createView(), ] )->setPrivate(); } @@ -261,22 +260,22 @@ public function renderSortOrderBundleForm($order) * * @throws \Twig\Error\Error */ - public function renderSearchBundleForm($searchText) + public function renderSearchPackageForm($searchText) { - $searchBundleForm = $this->formFactory->create(BundleSearchType::class, [ + $searchPackageForm = $this->formFactory->create(PackageSearchType::class, [ 'search' => $searchText, ]); return $this->templating->renderResponse( - '@ezdesign/form/bundle_search.html.twig', + '@ezdesign/form/package_search.html.twig', [ - 'searchBundleForm' => $searchBundleForm->createView(), + 'searchPackageForm' => $searchPackageForm->createView(), ] )->setPrivate(); } /** - * Returns list with bundles categories + * Returns list with package categories * * @var int $categoryId * @@ -285,7 +284,7 @@ public function renderSearchBundleForm($searchText) * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException */ - private function getBundlesCategoriesList(int $categoryId): array + private function getPackageCategoriesList(int $categoryId): array { $tag = $this->tagsService->loadTag($categoryId); @@ -305,7 +304,7 @@ private function getCategoryTagId(string $category, string $language = ''): int $tags = $this->tagsService->loadTagsByKeyword($category, $language); $tags = array_filter($tags, function(Tag $tag) { - return $tag->parentTagId === $this->bundleCategoriesParentTagId; + return mb_strtolower($tag->parentTagId) === mb_strtolower($this->packageCategoriesParentTagId); }); $tag = reset($tags); @@ -321,11 +320,11 @@ private function getCategoryTagId(string $category, string $language = ''): int * * @return \eZ\Publish\API\Repository\Values\Content\LocationQuery */ - private function getBundlesQuery($offset = 0, $order = null, $searchText = '', $tagId = null) + private function getPackagesQuery($offset = 0, $order = null, $searchText = '', $tagId = null) { - return $this->bundlesQueryType->getQuery([ - 'parent_location_id' => $this->bundlesListLocationId, - 'limit' => $this->bundlesListCardsLimit, + return $this->packagesQueryType->getQuery([ + 'parent_location_id' => $this->packageListLocationId, + 'limit' => $this->packageListCardsLimit, 'offset' => $offset, 'order' => $order, 'search' => $searchText, @@ -334,7 +333,7 @@ private function getBundlesQuery($offset = 0, $order = null, $searchText = '', $ } /** - * Returns list of bundles with package details for given $searchResult set. + * Returns list of packages with package details for given $searchResult set. * * @param array $searchHits * @@ -342,14 +341,14 @@ private function getBundlesQuery($offset = 0, $order = null, $searchText = '', $ */ private function getList(array $searchHits) { - $bundles = []; + $packages = []; foreach ($searchHits as $searchHit) { - $bundles[] = [ - 'bundle' => $searchHit, + $packages[] = [ + 'package' => $searchHit, 'packageDetails' => $this->packagistServiceProvider->getPackageDetails($searchHit->valueObject->contentInfo->name), ]; } - return $bundles; + return $packages; } } diff --git a/src/AppBundle/Form/BundleOrderType.php b/src/AppBundle/Form/PackageOrderType.php similarity index 90% rename from src/AppBundle/Form/BundleOrderType.php rename to src/AppBundle/Form/PackageOrderType.php index 91f2abf9..94dcecac 100644 --- a/src/AppBundle/Form/BundleOrderType.php +++ b/src/AppBundle/Form/PackageOrderType.php @@ -1,7 +1,7 @@ setAction('/Bundles/search/') + ->setAction('/packages/search/') ->setMethod('POST') ->add('search', TextType::class, [ 'attr' => [ 'class' => 'form-control', - 'placeholder' => 'Search Bundle...', + 'placeholder' => 'Search Package...', ], ]); } diff --git a/src/AppBundle/QueryType/BundlesQueryType.php b/src/AppBundle/QueryType/PackagesQueryType.php similarity index 88% rename from src/AppBundle/QueryType/BundlesQueryType.php rename to src/AppBundle/QueryType/PackagesQueryType.php index ea48c1b0..ac4d9f96 100644 --- a/src/AppBundle/QueryType/BundlesQueryType.php +++ b/src/AppBundle/QueryType/PackagesQueryType.php @@ -1,7 +1,7 @@ [ - 'bundle_id', + 'package_id', 'name', 'description', 'packagist_url' @@ -52,11 +52,11 @@ public function getQuery(array $parameters = []) if (isset($parameters['order'])) { if ($parameters['order'] === 'latestUpdate') { - $options['sortClauses'] = [new Query\SortClause\Field('bundle', 'updated', Query::SORT_DESC)]; + $options['sortClauses'] = [new Query\SortClause\Field('package', 'updated', Query::SORT_DESC)]; } elseif ($parameters['order'] === 'stars') { - $options['sortClauses'] = [new Query\SortClause\Field('bundle', 'stars', Query::SORT_DESC)]; + $options['sortClauses'] = [new Query\SortClause\Field('package', 'stars', Query::SORT_DESC)]; } elseif ($parameters['order'] === 'downloads') { - $options['sortClauses'] = [new Query\SortClause\Field('bundle', 'downloads', Query::SORT_DESC)]; + $options['sortClauses'] = [new Query\SortClause\Field('package', 'downloads', Query::SORT_DESC)]; } else { $options['sortClauses'] = [new Query\SortClause\DateModified(Query::SORT_DESC)]; } @@ -95,7 +95,7 @@ public function getSupportedParameters() */ public static function getName() { - return 'AppBundle:Bundles'; + return 'AppBundle:Packages'; } } diff --git a/src/AppBundle/View/Template/BundlesListTemplate.php b/src/AppBundle/View/Template/PackageListTemplate.php similarity index 84% rename from src/AppBundle/View/Template/BundlesListTemplate.php rename to src/AppBundle/View/Template/PackageListTemplate.php index b6df27dc..6af0c2b4 100644 --- a/src/AppBundle/View/Template/BundlesListTemplate.php +++ b/src/AppBundle/View/Template/PackageListTemplate.php @@ -1,7 +1,7 @@