Skip to content

Commit

Permalink
Merge branch 'next-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed Apr 22, 2020
2 parents f56f166 + c46540f commit 41fbb11
Show file tree
Hide file tree
Showing 48 changed files with 691 additions and 546 deletions.
12 changes: 12 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
| Q | A
| ------------- | ---
| Branch? | master / x.y.z
| Bug fix? | yes/no
| New feature? | yes/no <!-- don't forget updating docs/CHANGELOG.md files -->
| BC breaks? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->

<!--
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->
13 changes: 13 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
| Q | A
| ---------------- | -----
| Bug report? | yes/no
| Feature request? | yes/no
| BC Break report? | yes/no
| RFC? | yes/no
| Version | x.y.z


<!--
- Please fill in this template according to your issue.
- And replace this comment by the description of your issue.
-->
116 changes: 116 additions & 0 deletions .github/workflows/main-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: CI

on: [push, pull_request]

jobs:
lint:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.3
id: php

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction

- name: Check Sources
run: php vendor/bin/phpcs --standard=.cs/cs_ruleset.xml --extensions=php bundle/ tests/

- name: Check Mess Sources
run: php vendor/bin/phpmd bundle,tests text .cs/md_ruleset.xml
tests:
name: Tests
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.3
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: ezplatform
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:latest
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
php: [7.3]
env:
CACHE_POOL: cache.redis
DATABASE_URL: mysql://root@127.0.0.1:3306/ezplatform
CACHE_DSN: 127.0.0.1:6379
APP_ENV: dev
APP_DEBUG: 1
COMPOSER_MEMORY_LIMIT: 4G
PANTHER_EXTERNAL_BASE_URI: http://127.0.0.1:8000
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl
id: php

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction

- name: Install Symfony Server
run: |
wget https://get.symfony.com/cli/installer -O - | bash
/home/runner/.symfony/bin/symfony local:php:list
- name: Install eZ Platform
run: |
composer create-project ezsystems/ezplatform --prefer-dist --no-progress --no-interaction --no-scripts ezplatform
cd ezplatform
rm -rf var/cache
composer ezplatform-install
- name: Install Bundle on Top of a fresh eZ Installation
run: |
curl -o tests/provisioning/wrap.php https://raw.githubusercontent.com/Plopix/symfony-bundle-app-wrapper/master/wrap-bundle.php
WRAP_APP_DIR=./ezplatform WRAP_BUNDLE_DIR=./ php tests/provisioning/wrap.php
rm tests/provisioning/wrap.php
mysql -u root -h 127.0.0.1 ezplatform < bundle/Resources/sql/schema.sql
cd ezplatform
COMPOSER_MEMORY_LIMIT=-1 composer update --lock
bin/console cache:clear
- name: Run Webserver
run: |
cd ezplatform
/home/runner/.symfony/bin/symfony local:server:start --no-tls -d
/home/runner/.symfony/bin/symfony local:server:list
- name: Install Field everywhere
run: cd ezplatform && bin/console nova_ezseo:addnovaseometasfieldtype --group_identifier=Content --no-interaction

- name: Test Web Server
run: curl -I http://127.0.0.1:8000 | grep "HTTP/1.1 200 OK"

- name: Finally Run the tests
run: php vendor/bin/phpunit ./tests --exclude-group behat
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PHP_BIN := php
COMPOSER := composer
CURRENT_DIR := $(shell pwd)
.DEFAULT_GOAL := list
SYMFONY := symfony
EZ_DIR := $(CURRENT_DIR)/ezplatform

.PHONY: list
Expand All @@ -22,7 +23,7 @@ list:
.PHONY: installez
installez: ## Install eZ as the local project
@docker run -d -p 3364:3306 --name ezdbnovaezseocontainer -e MYSQL_ROOT_PASSWORD=ezplatform mariadb:10.3
@composer create-project ezsystems/ezplatform:dev-master --prefer-dist --no-progress --no-interaction --no-scripts $(EZ_DIR)
@composer create-project ezsystems/ezplatform --prefer-dist --no-progress --no-interaction --no-scripts $(EZ_DIR)
@curl -o tests/provisioning/wrap.php https://raw.githubusercontent.com/Plopix/symfony-bundle-app-wrapper/master/wrap-bundle.php
@WRAP_APP_DIR=./ezplatform WRAP_BUNDLE_DIR=./ php tests/provisioning/wrap.php
@rm tests/provisioning/wrap.php
Expand All @@ -39,14 +40,11 @@ serveez: stopez ## Clear the cache and start the web server
@cd $(EZ_DIR) && rm -rf var/cache/*
@docker start ezdbnovaezseocontainer
@cd $(EZ_DIR) && bin/console cache:clear
@cd $(EZ_DIR) && bin/console server:start
@cd $(EZ_DIR) && $(SYMFONY) local:server:start -d

.PHONY: stopez
stopez: ## Stop the web server if it is running
@if [ -a $(EZ_DIR)/.web-server-pid ] ; \
then \
cd $(EZ_DIR) && php bin/console server:stop; \
fi;
@cd $(EZ_DIR) && $(SYMFONY) local:server:stop
@docker stop ezdbnovaezseocontainer


Expand Down
80 changes: 36 additions & 44 deletions bundle/Command/AddNovaSEOMetasFieldTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ class AddNovaSEOMetasFieldTypeCommand extends Command
*/
private $adminUserId;

/**
* List of the ContentType we'll manage.
*
* @var ContentType[]
*/
protected $contentTypes;

public function __construct(
ConfigResolverInterface $configResolver,
Repository $repository,
Expand Down Expand Up @@ -109,42 +102,8 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$contentTypes = $this->contentTypes;
if (0 == count($contentTypes)) {
$io->success('Nothing to do.');

return 0;
}

$fieldName = $this->configResolver->getParameter('fieldtype_metas_identifier', 'nova_ezseo');

foreach ($contentTypes as $contentType) {
$io->section("Doing {$contentType->getName()}");
if ($this->fieldInstaller->fieldExists($fieldName, $contentType)) {
$io->block('Field exists');
continue;
}
if (!$this->fieldInstaller->addToContentType($fieldName, $contentType)) {
$io->error(
sprintf(
'There were errors when adding new field to <info>%s</info> ContentType: <error>%s</error>',
$contentType->getName($contentType->mainLanguageCode),
$this->fieldInstaller->getErrorMessage()
)
);
continue;
}
$io->block('FieldType added.');
}

$io->success('Done.');

return 0;
}
$io = new SymfonyStyle($input, $output);

protected function interact(InputInterface $input, OutputInterface $output): void
{
$contentTypes = [];

$groupIdentifier = $input->getOption('group_identifier');
Expand Down Expand Up @@ -172,10 +131,43 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
"\n<question>Are you sure you want to add novaseometas all these Content Type?</question>[yes]",
true
);

if (!$helper->ask($input, $output, $question)) {
return;
$io->success('Nothing to do.');

return 0;
}

if (0 === \count($contentTypes)) {
$io->success('Nothing to do.');

return 0;
}

$fieldName = $this->configResolver->getParameter('fieldtype_metas_identifier', 'nova_ezseo');

foreach ($contentTypes as $contentType) {
$io->section("Doing {$contentType->getName()}");
if ($this->fieldInstaller->fieldExists($fieldName, $contentType)) {
$io->block('Field exists');
continue;
}
if (!$this->fieldInstaller->addToContentType($fieldName, $contentType)) {
$io->error(
sprintf(
'There were errors when adding new field to <info>%s</info> ContentType: <error>%s</error>',
$contentType->getName($contentType->mainLanguageCode),
$this->fieldInstaller->getErrorMessage()
)
);
continue;
}
$io->block('FieldType added.');
}
$this->contentTypes = $contentTypes;

$io->success('Done.');

return 0;
}

protected function initialize(InputInterface $input, OutputInterface $output): void
Expand Down
21 changes: 11 additions & 10 deletions bundle/Controller/Admin/RedirectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use eZ\Publish\API\Repository\PermissionResolver;
use eZ\Publish\Core\SignalSlot\URLWildcardService;
use eZ\Publish\Core\Event\URLWildcardService;
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller;
use Novactive\Bundle\eZSEOBundle\Core\Helper\ImportUrlsHelper;
use Novactive\Bundle\eZSEOBundle\Entity\RedirectImportHistory;
Expand All @@ -32,7 +32,7 @@
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @Route("/novaseo/redirect")
Expand Down Expand Up @@ -65,7 +65,7 @@ public function listAction(
$formDelete = $this->createForm(DeleteUrlType::class);
$formDelete->handleRequest($request);

if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$source = trim($form->getData()['source']);
$destination = trim($form->getData()['destination']);
$type = trim($form->getData()['type']);
Expand Down Expand Up @@ -98,8 +98,9 @@ public function listAction(
}
}

if ($formDelete->isValid()) {
$response = $this->forward('NovaeZSEOBundle:Admin/Redirect:delete', ['request' => $request]);
if ($formDelete->isSubmitted() && $formDelete->isValid()) {
$deleteAction = self::class.'::deleteAction';
$response = $this->forward($deleteAction, ['request' => $request]);
if (Response::HTTP_CREATED == $response->getStatusCode()) {
$messages[] = $translator->trans('nova.redirect.delete.info', [], 'redirect');
}
Expand All @@ -112,7 +113,7 @@ public function listAction(
$pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages()));

return $this->render(
'NovaeZSEOBundle::platform_admin/list_url_wildcard.html.twig',
'@NovaeZSEO/platform_admin/list_url_wildcard.html.twig',
[
'pager' => $pagerfanta,
'form' => $form->createView(),
Expand Down Expand Up @@ -152,7 +153,7 @@ public function deleteAction(

/**
* @Route("/url-redirect-import", name="novactive_platform_admin_ui.import-redirect-url")
* @Template("NovaeZSEOBundle::platform_admin/import_urls.html.twig")
* @Template("@NovaeZSEO/platform_admin/import_urls.html.twig")
*/
public function importAction(
Request $request,
Expand All @@ -171,7 +172,7 @@ public function importAction(
$form = $this->createForm(ImportUrlsType::class);
$form->handleRequest($request);

if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$file = $request->files->get('novaseo_import_urls')['file'];
if ($file instanceof UploadedFile) {
$filePath = $file->getRealPath();
Expand Down Expand Up @@ -222,9 +223,9 @@ public function importAction(

/**
* @Route("/history-import-redirect-url", name="novactive_platform_admin_ui.history-import-redirect-url")
* @Template("NovaeZSEOBundle::platform_admin/history_urls_imported.html.twig")
* @Template("@NovaeZSEO/platform_admin/history_urls_imported.html.twig")
*/
public function hisroryUrlsImported(
public function historyUrlsImported(
Request $request,
ImportUrlsHelper $importUrlsHelper,
PermissionResolver $permissionResolver
Expand Down
2 changes: 1 addition & 1 deletion bundle/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function getQuery(): Query
$limitToRootLocation = $this->getConfigResolver()->getParameter('limit_to_rootlocation', 'nova_ezseo');
$excludes = $this->getConfigResolver()->getParameter('sitemap_excludes', 'nova_ezseo');
$query = new Query();
$criterion[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE);
$criterion = [new Criterion\Visibility(Criterion\Visibility::VISIBLE)];
if (true === $limitToRootLocation) {
$criterion[] = new Criterion\Subtree($this->getRootLocation()->pathString);
}
Expand Down
Loading

0 comments on commit 41fbb11

Please sign in to comment.