Skip to content

Commit

Permalink
Merge branch '5.2'
Browse files Browse the repository at this point in the history
* 5.2:
  update changelog
  [MediaBundle][SearchBundle] Provide default config for bundles to work on sf4 (#2365)
  [GeneratorBundle] Use new multi language parameter as the check is broken on empty install (#2359)
  [PagePartBundle] Make sure column names are independent of the doctrine naming strategy (#2358)
  [AdminBundle] added SimpleMenuAdaptorTest (#2361)
  [GeneratorBundle] Fixed not supported template naming for SF34 (#2363)
  • Loading branch information
Devolicious committed Feb 12, 2019
2 parents bcd2552 + f49346d commit 1f63036
Show file tree
Hide file tree
Showing 57 changed files with 178 additions and 64 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG-5.X.md
@@ -1,5 +1,14 @@
# Changelog

## 5.2.2 / 2019-02-12

* [MediaBundle][SearchBundle] Provide default config for bundles to work on sf4 [#2365](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2365) ([@acrobat](https://github.com/acrobat))
* [GeneratorBundle] Fixed not supported template naming for SF34 [#2363](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2363) ([@Devolicious](https://github.com/Devolicious))
* [AdminBundle] added SimpleMenuAdaptorTest [#2361](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2361) ([@deZinc](https://github.com/deZinc))
* [GeneratorBundle] Use new multi language parameter as the check is broken on empty install [#2359](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2359) ([@acrobat](https://github.com/acrobat))
* [PagePartBundle] Make sure column names are independent of the doctrine naming strategy [#2358](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2358) ([@acrobat](https://github.com/acrobat))


## 5.2.1 / 2019-02-12

* [AllBundles] Added missing items in upgrade doc for 5.2 [#2356](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2356) ([@acrobat](https://github.com/acrobat))
Expand Down
Expand Up @@ -54,7 +54,7 @@ public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $par
->setUniqueId($item['route'])
->setParent($parent);

if ($request && stripos($request->attributes->get('_route'), $menuItem->getRoute()) === 0) {
if ($request && null !== $parent && stripos($request->attributes->get('_route'), $menuItem->getRoute()) === 0) {
$menuItem->setActive(true);
$parent->setActive(true);
}
Expand Down
@@ -0,0 +1,105 @@
<?php

namespace Kunstmaan\AdminBundle\Tests\Helper\Menu;

use Kunstmaan\AdminBundle\Helper\Menu\MenuAdaptorInterface;
use Kunstmaan\AdminBundle\Helper\Menu\MenuBuilder;
use Kunstmaan\AdminBundle\Helper\Menu\SimpleMenuAdaptor;
use Kunstmaan\AdminBundle\Helper\Menu\TopMenuItem;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

class SimpleMenuAdaptorTest extends TestCase
{
/** @var AuthorizationCheckerInterface (mock) */
private $authorizationCheckerInterface;

/** @var array */
private $menuItems;

public function setUp()
{
$this->authorizationCheckerInterface = $this->createMock(AuthorizationCheckerInterface::class);
$this->menuItems = [];
}

/**
* @return \PHPUnit\Framework\MockObject\MockObject|SimpleMenuAdaptor
*/
public function setUpSimpleMenuAdaptorMock()
{
$simpleMenuAdaptorMock = $this->getMockBuilder(SimpleMenuAdaptor::class)
->setConstructorArgs([$this->authorizationCheckerInterface, $this->menuItems])
->setMethods(null)
->getMock()
;

return $simpleMenuAdaptorMock;
}

/**
* @dataProvider provider
*
* @param TopMenuItem|null $parent
*/
public function testAdaptChildren(?TopMenuItem $parent, ?string $itemParent)
{
$this->menuItems[] = ['parent' => 'not_test_route'];

$this->menuItems[] = [
'role' => 'some_role',
'parent' => $itemParent,
];

$this->menuItems[] = [
'role' => 'some_role',
'parent' => $itemParent,
'route' => 'KunstmaanAdminBundle_menu_item',
'params' => [],
'label' => 'menu_item',
];

$children = [];

/** @var MenuBuilder $menuBuilderMock */
$menuBuilderMock = $this->createMock(MenuBuilder::class);

/** @var Request $request */
$request = new Request([], [], ['_route' => 'KunstmaanAdminBundle_menu_item']);

$this->authorizationCheckerInterface
->expects($this->exactly(2))
->method('isGranted')
->will($this->onConsecutiveCalls(false, true))
;
$simpleMenuAdaptorMock = $this->setUpSimpleMenuAdaptorMock();
$simpleMenuAdaptorMock->adaptChildren($menuBuilderMock, $children, $parent, $request);

$this->assertCount(1, $children);
$this->assertContainsOnlyInstancesOf(TopMenuItem::class, $children);
$this->assertEquals('menu_item', $children[0]->getLabel());
}

public function testHasInterface()
{
$simpleMenuAdaptorMock = $this->setUpSimpleMenuAdaptorMock();
$this->assertInstanceOf(MenuAdaptorInterface::class, $simpleMenuAdaptorMock);
}

public function provider()
{
/** @var TopMenuItem $parent */
$parent = $this->createMock(TopMenuItem::class);
$parent
->expects($this->any())
->method('getRoute')
->willReturn('test_route')
;

return [
'with no parent' => [null, null],
'with parent' => [$parent, 'test_route'],
];
}
}
Expand Up @@ -442,8 +442,8 @@ public function generateTwigExtensions($parameters)
private function isMultiLangEnvironment()
{
// use the multilanguage parameter, if it exists
if ($this->container->hasParameter('multilanguage')) {
return $this->container->getParameter('multilanguage');
if ($this->container->hasParameter('kunstmaan_admin.multi_language')) {
return $this->container->getParameter('kunstmaan_admin.multi_language');
}

// This is a pretty silly implementation.
Expand Down
Expand Up @@ -53,6 +53,6 @@ public function getOverviewPageRepository()
*/
public function getListTemplate()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}AdminList/{{ entity_class }}PageAdminList/list.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}AdminList/{{ entity_class }}PageAdminList{% if not isV4 %}:{% else %}/{% endif %}list.html.twig';
}
}
Expand Up @@ -53,7 +53,7 @@ public function getArticleRepository($em)
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/{{ entity_class }}OverviewPage/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/{{ entity_class }}OverviewPage{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -63,7 +63,7 @@ public function getPageTemplates()

public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/{{ entity_class }}Page/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/{{ entity_class }}Page{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -12,13 +12,13 @@
<div class="blog-filter__top__section blog-filter__top__section--filters">
<h4>{{ 'article_overview_page.filter'|trans }}</h4>
</div>
<% if uses_tag %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage/_filter-tag.html.twig' with {'tags': tagContext.tags} %}<% endif %>
<% if uses_category %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage/_filter-category.html.twig' with {'categories': categoryContext.categories} %}<% endif %>
<% if uses_tag %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage<% if not isV4 %>:<% else %>/<% endif %>_filter-tag.html.twig' with {'tags': tagContext.tags} %}<% endif %>
<% if uses_category %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage<% if not isV4 %>:<% else %>/<% endif %>_filter-category.html.twig' with {'categories': categoryContext.categories} %}<% endif %>
</div>

<% if uses_tag or uses_category %><div class="blog-filter__filters"><% endif %>
<% if uses_tag %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage/_list-tag.html.twig' with {'tagContext': tagContext} %}<% endif %>
<% if uses_category %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage/_list-category.html.twig' with {'categoryContext': categoryContext} %}<% endif %>
<% if uses_tag %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage<% if not isV4 %>:<% else %>/<% endif %>_list-tag.html.twig' with {'tagContext': tagContext} %}<% endif %>
<% if uses_category %>{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Pages/<%= entity_class %>OverviewPage<% if not isV4 %>:<% else %>/<% endif %>_list-category.html.twig' with {'categoryContext': categoryContext} %}<% endif %>
<% if uses_tag or uses_category %></div><% endif %>
</div>
</div>
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundleWithHomePage.name %>:<% endif %>Layout/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundleWithHomePage.name %>:<% endif %>Layout<% if not isV4 %><% if not isV4 %>:<% else %>/<% endif %><% else %>/<% endif %>layout.html.twig' %}

{% block content %}
{{ render_pagetemplate(page) }}
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundleWithHomePage.name %>:<% endif %>Layout/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundleWithHomePage.name %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{% block content %}
{{ render_pagetemplate(page) }}
Expand Down
Expand Up @@ -19,7 +19,7 @@ class BikesListPagePart extends AbstractPagePart
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/BikesListPagePart/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/BikesListPagePart{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -205,7 +205,7 @@ public function getBackgroundImage()
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/PageBannerPagePart/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/PageBannerPagePart{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -244,7 +244,7 @@ public function setImagePosition($imagePosition)
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/ServicePagePart/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/ServicePagePart{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -74,7 +74,7 @@ public function removeItem(UspItem $item)
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/UspPagePart/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}PageParts/UspPagePart{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -125,6 +125,6 @@ public function getPageTemplates()
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/ContentPage/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/ContentPage{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}
}
Expand Up @@ -62,6 +62,6 @@ public function getPageTemplates()
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/FormPage/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/FormPage{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}
}
Expand Up @@ -81,7 +81,7 @@ public function getPageTemplates()
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/HomePage/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/HomePage{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -20,7 +20,7 @@ class SearchPage extends AbstractSearchPage implements HasPageTemplateInterface
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/SearchPage/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/SearchPage{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}

/**
Expand Down
Expand Up @@ -7,5 +7,5 @@ kunstmaan_page_part:
{% if isV4 %} {%endif%}rows:
{% if isV4 %} {%endif%} - regions:
{% if isV4 %} {%endif%} - { name: "main", span: 12 }
{% if isV4 %} {%endif%} - { name: "submenu", span: 12, template: "{% if not isV4 %}{{ bundle.name }}:{% endif %}Layout/submenu.html.twig" }
{% if isV4 %} {%endif%} - { name: "submenu", span: 12, template: "{% if not isV4 %}{{ bundle.name }}:{% endif %}Layout{% if not isV4 %}:{% else %}/{% endif %}submenu.html.twig" }
{% if isV4 %} {%endif%}template: "{% if not isV4 %}{{ bundle.name }}::{% endif %}Pages\\ContentPage\\pagetemplate.html.twig"
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{% block title %} - {{ status_code }} - {{ status_text }} - {{ websitetitle }}{% endblock %}

Expand Down
Expand Up @@ -4,7 +4,7 @@

<% if demosite %>
<div class="submenu">
{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Layout/submenu.html.twig' with {'page': page} %}
{% include '<% if not isV4 %><%= bundle.name %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>submenu.html.twig' with {'page': page} %}
</div>
<% endif %>
</div>
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{% block content %}
{{ render_pagetemplate(page) }}
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% if thanks is defined and thanks %}
{{ page.thanks|raw }}
{% else %}
{% form_theme frontendform '<% if not isV4 %><%= bundle.name %>:<% endif %>Form/fields.html.twig' %}
{% form_theme frontendform '<% if not isV4 %><%= bundle.name %>:<% endif %>Form<% if not isV4 %>:<% else %>/<% endif %>fields.html.twig' %}

{{ form_start(frontendform, {'method': 'POST', 'action': path('_slug', { 'url' : nodemenu.current.slug }), 'attr': {'novalidate': 'novalidate', 'class': 'form--default', 'role': 'form'}}) }}
{{ render_pageparts(page, 'main') }}
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{% block content %}
{{ render_pagetemplate(page) }}
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{# Extra body classes #}
{% block extra_body_classes %} homepage{% endblock %}
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{# Content #}
{% block content %}
Expand Down
@@ -1,4 +1,4 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page/layout.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Page<% if not isV4 %>:<% else %>/<% endif %>layout.html.twig' %}

{% block content %}
<div class="container">
Expand Down
@@ -1,3 +1,3 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error/error.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error<% if not isV4 %>:<% else %>/<% endif %>error.html.twig' %}

{% set status_code = 'other' %}
@@ -1 +1 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error/error.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error<% if not isV4 %>:<% else %>/<% endif %>error.html.twig' %}
@@ -1 +1 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error/error.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error<% if not isV4 %>:<% else %>/<% endif %>error.html.twig' %}
@@ -1 +1 @@
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error/error.html.twig' %}
{% extends '<% if not isV4 %><%= bundle.name %>:<% endif %>Error<% if not isV4 %>:<% else %>/<% endif %>error.html.twig' %}
Expand Up @@ -12,22 +12,22 @@
</title>

{# Favicons #}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout/_favicons.html.twig' %}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>_favicons.html.twig' %}

{# Webfonts #}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout/_webfonts.html.twig' %}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>_webfonts.html.twig' %}

{# CSS #}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout/_css.html.twig' %}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>_css.html.twig' %}
</head>

<body class="{% block extra_body_classes %}<% if demosite %>emulate-pulldown<% endif %>{% endblock %}" {% block extra_body_attributes %}{% endblock %}>

{# Google Tagmanager #}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout/_googletagmanager.html.twig' %}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>_googletagmanager.html.twig' %}

{# Outdated browser message #}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout/_outdatedbrowser.html.twig' %}
{% include '<% if not isV4 %><%= bundle.getName() %>:<% endif %>Layout<% if not isV4 %>:<% else %>/<% endif %>_outdatedbrowser.html.twig' %}

{# Content #}
<main>
Expand Down
Expand Up @@ -43,5 +43,5 @@ public function getPageTemplates()
*/
public function getDefaultView()
{
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/Common/view.html.twig';
return '{% if not isV4 %}{{ bundle.getName() }}:{%endif%}Pages/Common{% if not isV4 %}:{% else %}/{% endif %}view.html.twig';
}
Expand Up @@ -62,6 +62,6 @@ public function getLabel()
*/
public function getAdminView()
{
return '{% if not isV4 %}{{ bundle }}:{%endif%}PageParts/{{ pagepart }}/admin-view.html.twig';
return '{% if not isV4 %}{{ bundle }}:{%endif%}PageParts/{{ pagepart }}{% if not isV4 %}:{% else %}/{% endif %}admin-view.html.twig';
}
}
Expand Up @@ -48,7 +48,7 @@ public function setMedia($media)
*/
public function getDefaultView()
{
return "{% if not isV4 %}{{ bundle }}:{%endif%}PageParts/{{ pagepart }}/view.html.twig";
return "{% if not isV4 %}{{ bundle }}:{%endif%}PageParts/{{ pagepart }}{% if not isV4 %}:{% else %}/{% endif %}view.html.twig";
}

/**
Expand Down

0 comments on commit 1f63036

Please sign in to comment.