Skip to content

Commit

Permalink
Fix sulu 2.0.1 compatibility (#27)
Browse files Browse the repository at this point in the history
* Update dependencies

* Update composer.json

* Update composer.json

* Update readme

* sulu 2.0 compatibility

* add new viewbuilder for automation

* Add php-cs-fixer

* add editorconfig

* resolve dispatch deprecation

* refactor controllers

* phpstan installation and some phpstan fixes

* phpstan fixes

* styleci fixes

* travis and phpunit settings

* increase test memory limit

* fix php unit tests

* upgrade to sulu 2.0.1 branch

* fix remaining phpstan errors

* use class instead of interface

* adjust installation documentation

* Set min requirement to sulu/sulu 2.0.1

* Set min requirement to php-task/php-task dev-master

* pr changes

* remove unnecessary phpdocs

* fix translation file

* Adjust php-task version
  • Loading branch information
Prokyonn authored and wachterjohannes committed Nov 8, 2019
1 parent a090110 commit 395d782
Show file tree
Hide file tree
Showing 96 changed files with 1,180 additions and 1,788 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

# markdown uses two trailing spaces for explicit line breaks
[*.md]
trim_trailing_whitespace = false
29 changes: 22 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
/Tests/app/cache/*
/Tests/app/logs/*
/Tests/app/data/*
/Tests/Application/cache/*
/Tests/Application/logs/*
/Tests/Application/data/*
/node_modules/
/vendor/
/composer.phar
/composer.lock
/.sass-cache/

# PHPUnit
/app/phpunit.xml
/phpunit.xml
*~
.phpunit.result.cache

# composer
/composer.phar
/composer.lock
/auth.json
/vendor

# IDEs
.idea/*
*.iml
*~

# tests
Tests/Application/var
Tests/Application/.env.test.local

# php-cs-fixer
.php_cs.cache
php-cs-fixer
28 changes: 28 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$header = <<<EOF
This file is part of Sulu.
(c) Sulu GmbH
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude(['var/cache'])
->in(__DIR__);

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'class_definition' => false,
'concat_space' => ['spacing' => 'one'],
'function_declaration' => ['closure_function_spacing' => 'none'],
'header_comment' => ['header' => $header],
'ordered_imports' => true,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_types_order' => false,
])
->setFinder($finder);
29 changes: 21 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,39 @@ sudo: false

language: php

services:
- mysql

cache:
directories:
- $HOME/.composer/cache

matrix:
include:
- php: 7.1
- php: 7.2
env:
- COMPOSER_FLAGS="--prefer-lowest --prefer-stable --prefer-dist --no-interaction"
- php: 7.2
- php: 7.3
env:
- COMPOSER_FLAGS="--prefer-dist --no-interaction"
- CODE_COVERAGE="--coverage-clover=coverage.clover"
- PHPSTAN=true

before_script:
- phpenv config-rm xdebug.ini
before_install:
- phpenv config-add Tests/travis.php.ini
- composer self-update
- composer update $COMPOSER_FLAGS
- ./Tests/app/console doctrine:database:create
- ./Tests/app/console doctrine:schema:create

install:
- if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi
- travis_retry composer update $COMPOSER_FLAGS
- composer info -i
- ./Tests/Application/bin/console doctrine:database:create
- ./Tests/Application/bin/console doctrine:schema:update --force

script:
- vendor/bin/phpunit
- if [[ $PHPSTAN = true ]]; then composer phpstan; fi
- composer phpunit -- $CODE_COVERAGE

after_script:
- if [[ -n $CODE_COVERAGE ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
- if [[ -n $CODE_COVERAGE ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi
53 changes: 40 additions & 13 deletions Admin/AutomationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Sulu.
*
* (c) MASSIVE ART WebServices GmbH
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
Expand All @@ -12,31 +12,58 @@
namespace Sulu\Bundle\AutomationBundle\Admin;

use Sulu\Bundle\AdminBundle\Admin\Admin;
use Sulu\Bundle\AdminBundle\Navigation\Navigation;
use Sulu\Bundle\AdminBundle\Navigation\NavigationItem;
use Sulu\Bundle\AdminBundle\Admin\View\ViewBuilderFactoryInterface;
use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection;
use Sulu\Bundle\AutomationBundle\Admin\View\AutomationViewBuilder;
use Sulu\Bundle\PageBundle\Admin\PageAdmin;
use Sulu\Bundle\PageBundle\Document\BasePageDocument;
use Sulu\Component\Security\Authorization\PermissionTypes;
use Sulu\Component\Webspace\Manager\WebspaceManagerInterface;

/**
* Admin integration of the bundle.
*/
class AutomationAdmin extends Admin
{
const TASK_SECURITY_CONTEXT = 'sulu.automation.tasks';
const SECURITY_CONTEXT = 'sulu_automation.automation.tasks';

const LIST_VIEW = 'sulu_automation.list';

const EDIT_FORM_VIEW = 'sulu_automation.edit_form';

/**
* @param string $title
* @var ViewBuilderFactoryInterface
*/
public function __construct($title)
{
$this->setNavigation(new Navigation(new NavigationItem($title)));
}
protected $viewBuilderFactory;

/**
* {@inheritdoc}
* @var string
*/
protected $title;

/**
* @var WebspaceManagerInterface
*/
public function getJsBundleName()
protected $webspaceManager;

public function __construct(
ViewBuilderFactoryInterface $viewBuilderFactory,
WebspaceManagerInterface $webspaceManager,
string $title
) {
$this->title = $title;
$this->viewBuilderFactory = $viewBuilderFactory;
$this->webspaceManager = $webspaceManager;
}

public function configureViews(ViewCollection $viewCollection): void
{
return 'suluautomation';
$automationViewBuilder = new AutomationViewBuilder(static::LIST_VIEW, '/automation');
$automationViewBuilder
->setEntityClass(BasePageDocument::class)
->setParent(PageAdmin::EDIT_FORM_VIEW);

$viewCollection->add($automationViewBuilder);
}

/**
Expand All @@ -47,7 +74,7 @@ public function getSecurityContexts()
return [
'Sulu' => [
'Automation' => [
self::TASK_SECURITY_CONTEXT => [
self::SECURITY_CONTEXT => [
PermissionTypes::VIEW,
PermissionTypes::ADD,
PermissionTypes::EDIT,
Expand Down
111 changes: 0 additions & 111 deletions Admin/AutomationContentNavigationProvider.php

This file was deleted.

57 changes: 57 additions & 0 deletions Admin/View/AutomationViewBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\AutomationBundle\Admin\View;

use Sulu\Bundle\AdminBundle\Admin\View\FormOverlayListViewBuilder;
use Sulu\Bundle\AdminBundle\Admin\View\ToolbarAction;
use Sulu\Bundle\AutomationBundle\Entity\Task;

class AutomationViewBuilder extends FormOverlayListViewBuilder implements AutomationViewBuilderInterface
{
public function __construct(string $name, string $path)
{
parent::__construct($name, $path);

$listToolbarActions = [
new ToolbarAction('sulu_admin.add'),
new ToolbarAction('sulu_admin.delete'),
];

$this->setResourceKey(Task::RESOURCE_KEY)
->setListKey(Task::RESOURCE_KEY)
->setFormKey('task_details')
->setTabTitle('sulu_automation.automation')
->addToolbarActions($listToolbarActions)
->addListAdapters(['table'])
->setTabOrder(4096)
->addRouterAttributesToFormRequest(['id' => 'entityId'])
->addRouterAttributesToListRequest(['id' => 'entityId']);
}

public function setEntityClass(string $entityClass): AutomationViewBuilderInterface
{
$this->addRequestParameter('entityClass', $entityClass);
$this->addMetadataRequestParameters(['entityClass' => $entityClass]);

return $this;
}

private function addRequestParameter(string $key, string $value): void
{
$oldRequestParameters = $this->getView()->getOption('requestParameters');
$newRequestParameters = $oldRequestParameters
? array_merge($oldRequestParameters, [$key => $value])
: [$key => $value];

$this->setRequestParameters($newRequestParameters);
}
}
Loading

0 comments on commit 395d782

Please sign in to comment.