Skip to content

Commit

Permalink
Temp: Rename interfaces and other related items
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Sep 27, 2021
1 parent a541031 commit 323a46f
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 119 deletions.
16 changes: 8 additions & 8 deletions UPGRADE-5.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ GeneratorBundle
NodeBundle
----------

* `Kunstmaan\NodeBundle\Controller\SlugActionInterface` is deprecated and will be removed in 6.0. Implement the `Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface`
interface on your page entity and provide page render service id. That service should implement `Kunstmaan\NodeBundle\Entity\PageRenderInterface` and will allow you to customize the twig view and variables.
* `Kunstmaan\NodeBundle\Controller\SlugActionInterface` is deprecated and will be removed in 6.0. Implement the `Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface`
interface on your page entity and provide page render service id. That service should implement `Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface` and will allow you to customize the twig view and variables.

Before:

Expand Down Expand Up @@ -129,25 +129,25 @@ After:
use App\PageRenderer\BlogOverviewPageRenderer;
use Kunstmaan\NodeBundle\Entity\AbstractPage
use Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface
use Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface
class BlogOverviewPage extends AbstractPage implements CustomPageRenderInterface
class BlogOverviewPage extends AbstractPage implements CustomViewDataProviderInterface
{
// ...
public function customPageRenderServiceId(): string
public function getViewDataProviderServiceId(): string
{
return BlogOverviewPageRenderer::class;
}
}
use Kunstmaan\NodeBundle\Entity\PageRenderInterface;
use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Symfony\Component\HttpFoundation\RedirectResponse;
class BlogOverviewPageRenderer implements PageRenderInterface
class BlogOverviewPageViewDataProvider implements PageViewDataProviderInterface
{
public function render(RenderContext $renderContext): void
public function provideViewData(RenderContext $renderContext): void
{
// Set a variable to be used in the twig template
$renderContext['custom_var'] = 'text';
Expand Down
22 changes: 11 additions & 11 deletions docs/content-management/creating-a-pagetype.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,32 +137,32 @@ render it below the page parts.
{% endblock %}
```

Next we'll have to pass the employees to the Twig function. To do that we have to implement the `Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface` interface.
Next we'll have to pass the employees to the Twig function. To do that we have to implement the `Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface` interface.

So add the following in `EmployeesPage.php` :

```php
use App\PageRenderer\EmployeesPageRenderer;
use Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface;
use Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface;

class EmployeesPage /* ... */ implements CustomPageRenderInterface
class EmployeesPage /* ... */ implements CustomViewDataProviderInterface
{
public function getPageRendererServiceId(): string
public function getViewDataProviderServiceId(): string
{
return EmployeesPageRenderer::class;
return EmployeesPageViewDataProviderr::class;
}
}
```

And create a page renderer `EmployeesPageRenderer.php` to handle the logic :
And create a page viewdata provider `EmployeesPageViewDataProviderr.php` to handle the logic :

```php
namespace App\PageRenderer;
namespace App\ViewDataProvider;

use Doctrine\ORM\EntityManagerInterface;use Kunstmaan\NodeBundle\Entity\PageRenderInterface;
use Doctrine\ORM\EntityManagerInterface;use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;

class EmployeesPageRenderer implements PageRenderInterface
class EmployeesPageRenderer implements PageViewDataProviderInterface
{
/** @var EntityManagerInterface */
private $em;
Expand All @@ -172,7 +172,7 @@ And create a page renderer `EmployeesPageRenderer.php` to handle the logic :
$this->em = $em;
}

public function render(RenderContext $renderContext): void
public function provideViewData(RenderContext $renderContext): void
{
$employees = $this->em->getRepository('MyProjectWebsiteBundle:Employee')->findAll();

Expand All @@ -181,7 +181,7 @@ And create a page renderer `EmployeesPageRenderer.php` to handle the logic :
}
```

This class must be a service and tagged with `kunstmaan.node.page_renderer`. If you use service autowiring/autoconfigure then this
This class must be a service and tagged with `kunstmaan.node.page_view_data_provider`. If you use service autowiring/autoconfigure then this
is done automatically.
As you can see we just fetch all employees (using Doctrine), and pass them into the RenderContext (which is passed into Twig, so you'll get the list in your Twig template as the `employees` variable).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Kunstmaan\ArticleBundle\Entity;

use Kunstmaan\ArticleBundle\PagePartAdmin\AbstractArticleOverviewPagePagePartAdminConfigurator;
use Kunstmaan\ArticleBundle\PageRenderer\ArticlePageRenderer;
use Kunstmaan\ArticleBundle\ViewDataProvider\ArticlePageViewDataProvider;
use Kunstmaan\NodeBundle\Controller\SlugActionInterface;
use Kunstmaan\NodeBundle\Entity\AbstractPage;
use Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface;
use Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface;
use Kunstmaan\PagePartBundle\Helper\HasPagePartsInterface;
use Kunstmaan\PagePartBundle\PagePartAdmin\AbstractPagePartAdminConfigurator;

/**
* The article overview page which shows its articles
*/
abstract class AbstractArticleOverviewPage extends AbstractPage implements HasPagePartsInterface, SlugActionInterface, CustomPageRenderInterface
abstract class AbstractArticleOverviewPage extends AbstractPage implements HasPagePartsInterface, SlugActionInterface, CustomViewDataProviderInterface
{
/**
* @return array
Expand Down Expand Up @@ -47,15 +47,15 @@ public function getDefaultView()
}

/**
* @deprecated since KunstmaanArticleBundle 5.9 and will be removed in KunstmaanArticleBundle 6.0. Use the `Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface` and a custom page render service instead.
* @deprecated since KunstmaanArticleBundle 5.9 and will be removed in KunstmaanArticleBundle 6.0. Use the `Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface` and a custom page render service instead.
*/
public function getControllerAction()
{
return 'KunstmaanArticleBundle:AbstractArticleOverviewPage:service';
}

public function getPageRendererServiceId(): string
public function getViewDataProviderServiceId(): string
{
return ArticlePageRenderer::class;
return ArticlePageViewDataProvider::class;
}
}
4 changes: 2 additions & 2 deletions src/Kunstmaan/ArticleBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
tags:
- { name: twig.extension }

Kunstmaan\ArticleBundle\PageRenderer\BaseArticlePageRenderer:
Kunstmaan\ArticleBundle\ViewDataProvider\ArticlePageViewDataProvider:
arguments: [ '@doctrine.orm.entity_manager', '@request_stack' ]
tags:
- { name: 'kunstmaan.node.page_renderer' }
- { name: 'kunstmaan.node.page_view_data_provider' }
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

declare(strict_types=1);

namespace Kunstmaan\ArticleBundle\PageRenderer;
namespace Kunstmaan\ArticleBundle\ViewDataProvider;

use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\NodeBundle\Entity\PageRenderInterface;
use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
use Symfony\Component\HttpFoundation\RequestStack;

final class ArticlePageRenderer implements PageRenderInterface
final class ArticlePageViewDataProvider implements PageViewDataProviderInterface
{
/** @var EntityManagerInterface */
private $em;
Expand All @@ -24,7 +24,7 @@ public function __construct(EntityManagerInterface $em, RequestStack $requestSta
$this->requestStack = $requestStack;
}

public function render(RenderContext $renderContext): void
public function provideViewData(RenderContext $renderContext): void
{
$request = $this->requestStack->getMasterRequest();
if (null === $request) {
Expand Down
12 changes: 6 additions & 6 deletions src/Kunstmaan/FormBundle/Entity/AbstractFormPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use Doctrine\ORM\Mapping as ORM;
use Kunstmaan\FormBundle\Form\AbstractFormPageAdminType;
use Kunstmaan\FormBundle\Helper\FormPageInterface;
use Kunstmaan\FormBundle\ViewDataProvider\FormPageViewDataProvider;
use Kunstmaan\NodeBundle\Controller\SlugActionInterface;
use Kunstmaan\NodeBundle\Entity\AbstractPage;
use Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface;
use Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface;
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Kunstmaan\NodeSearchBundle\PageRenderer\SearchPageRenderer;
use Kunstmaan\PagePartBundle\Helper\HasPagePartsInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -21,7 +21,7 @@
* Furthermore it's possible to configure an administrative email to be send when a form is submitted with in it an
* overview of all the submitted fields.
*/
abstract class AbstractFormPage extends AbstractPage implements FormPageInterface, HasPagePartsInterface, SlugActionInterface, CustomPageRenderInterface
abstract class AbstractFormPage extends AbstractPage implements FormPageInterface, HasPagePartsInterface, SlugActionInterface, CustomViewDataProviderInterface
{
/**
* The thank you text to be shown when the form was successfully submitted
Expand Down Expand Up @@ -188,7 +188,7 @@ public function getFormElementsContext()
}

/**
* @deprecated since KunstmaanFormBundle 5.9 and will be removed in KunstmaanFormBundle 6.0. Use the `Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface` and a custom page render service instead.
* @deprecated since KunstmaanFormBundle 5.9 and will be removed in KunstmaanFormBundle 6.0. Use the `Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface` and a custom page render service instead.
*
* @return string
*/
Expand All @@ -197,8 +197,8 @@ public function getControllerAction()
return 'KunstmaanFormBundle:AbstractFormPage:service';
}

public function getPageRendererServiceId(): string
public function getViewDataProviderServiceId(): string
{
return SearchPageRenderer::class;
return FormPageViewDataProvider::class;
}
}
4 changes: 2 additions & 2 deletions src/Kunstmaan/FormBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
tags:
- { name: 'kernel.event_listener', event: 'kunstmaan_form.add_submission', method: 'onSubmission' }

Kunstmaan\FormBundle\PageRenderer\BaseFormPageRenderer:
Kunstmaan\FormBundle\ViewDataProvider\FormPageViewDataProvider:
arguments: ['@request_stack', '@kunstmaan_form.form_handler']
tags:
- { name: 'kunstmaan.node.page_renderer' }
- { name: 'kunstmaan.node.page_view_data_provider' }
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Kunstmaan\FormBundle\PageRenderer;
namespace Kunstmaan\FormBundle\ViewDataProvider;

use Kunstmaan\FormBundle\Helper\FormHandlerInterface;
use Kunstmaan\NodeBundle\Entity\PageRenderInterface;
use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

final class FormPageRenderer implements PageRenderInterface
final class FormPageViewDataProvider implements PageViewDataProviderInterface
{
/** @var RequestStack */
private $requestStack;
Expand All @@ -23,7 +23,7 @@ public function __construct(RequestStack $requestStack, FormHandlerInterface $fo
$this->formHandler = $formHandler;
}

public function render(RenderContext $renderContext): void
public function provideViewData(RenderContext $renderContext): void
{
$request = $this->requestStack->getMasterRequest();
if (null === $request) {
Expand Down
10 changes: 5 additions & 5 deletions src/Kunstmaan/GeneratorBundle/Generator/ArticleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function generate(BundleInterface $bundle, $entity, $prefix, $multilangua
$this->generateRouting($parameters, $multilanguage);
$this->generateMenu($parameters);
$this->generateServices($parameters);
$this->generatePageRenderer($parameters);
$this->generateViewDataProvider($parameters);
$this->updateParentPages();
if ($dummydata) {
$this->generateFixtures($parameters);
Expand Down Expand Up @@ -500,15 +500,15 @@ public function updateParentPages()
}
}

private function generatePageRenderer(array $parameters): void
private function generateViewDataProvider(array $parameters): void
{
$relPath = '/PageRenderer/';
$relPath = '/ViewDataProvider/';
$sourceDir = $this->skeletonDir . $relPath;
$targetDir = $this->bundle->getPath() . $relPath;

$filename = 'PageRenderer.php';
$filename = 'PageViewDataProvider.php';
$this->renderSingleFile($sourceDir, $targetDir, $filename, $parameters, false, $this->entity . $filename);

$this->assistant->writeLine('Generating page renderer : <info>OK</info>');
$this->assistant->writeLine('Generating page view data provider : <info>OK</info>');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace {{ namespace }}\Entity\Pages;

use {{ namespace }}\Form\Pages\{{ entity_class }}OverviewPageAdminType;
use {{ namespace }}\PageRenderer\{{ entity_class }}PageRenderer;
use {{ namespace }}\ViewDataProvider\{{ entity_class }}PageViewDataProvider;
use Doctrine\ORM\Mapping as ORM;
use Kunstmaan\ArticleBundle\Entity\AbstractArticleOverviewPage;
use Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface;
use Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface;
use Kunstmaan\NodeSearchBundle\Helper\SearchTypeInterface;
use Kunstmaan\PagePartBundle\Helper\HasPageTemplateInterface;
use Kunstmaan\PagePartBundle\PagePartAdmin\AbstractPagePartAdminConfigurator;
Expand All @@ -15,7 +15,7 @@
* @ORM\Entity(repositoryClass="{{ namespace }}\Repository\{{ entity_class }}OverviewPageRepository")
* @ORM\Table(name="{{ prefix }}{{ entity_class|lower }}_overview_pages")
*/
class {{ entity_class }}OverviewPage extends AbstractArticleOverviewPage implements HasPageTemplateInterface, SearchTypeInterface, CustomPageRenderInterface
class {{ entity_class }}OverviewPage extends AbstractArticleOverviewPage implements HasPageTemplateInterface, SearchTypeInterface, CustomViewDataProviderInterface
{
public function getPagePartAdminConfigurations(): array
{
Expand Down Expand Up @@ -52,8 +52,8 @@ public function getDefaultAdminType(): string
return {{ entity_class }}OverviewPageAdminType::class;
}

public function getPageRendererServiceId(): string
public function getViewDataProviderServiceId(): string
{
return {{ entity_class }}PageRenderer::class;
return {{ entity_class }}PageViewDataProvider::class;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace {{ namespace }}\PageRenderer;
namespace {{ namespace }}\ViewDataProvider;

{%if isV4%}use App\Entity\Pages\{{ entity_class }}Page;
{%endif%}
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Kunstmaan\NodeBundle\Entity\PageRenderInterface;
use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
Expand All @@ -15,7 +15,7 @@
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class {{ entity_class }}PageRenderer implements PageRenderInterface
class {{ entity_class }}PageViewDataProvider implements PageViewDataProviderInterface
{
/** @var RequestStack */
private $requestStack;
Expand All @@ -31,7 +31,7 @@ public function __construct(RequestStack $requestStack, EntityManagerInterface $
$this->urlGenerator = $urlGenerator;
}

public function render(RenderContext $renderContext): void
public function provideViewData(RenderContext $renderContext): void
{
$request = $this->requestStack->getMasterRequest();

Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/NodeBundle/Controller/SlugActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Kunstmaan\NodeBundle\Controller;

/**
* @deprecated Using the "Kunstmaan\NodeBundle\Controller\SlugActionInterface" to customize the page render is deprecated since KunstmaanNodeBundle 5.9 and will be removed in KunstmaanNodeBundle 6.0. Implement the "Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface" interface and provide a render service instead.
* @deprecated Using the "Kunstmaan\NodeBundle\Controller\SlugActionInterface" to customize the page render is deprecated since KunstmaanNodeBundle 5.9 and will be removed in KunstmaanNodeBundle 6.0. Implement the "Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface" interface and provide a render service instead.
*/
interface SlugActionInterface
{
/**
* @deprecated Using the "Kunstmaan\NodeBundle\Controller\SlugActionInterface::getControllerAction" to customize the page render is deprecated since KunstmaanNodeBundle 5.9 and will be removed in KunstmaanNodeBundle 6.0. Implement the "Kunstmaan\NodeBundle\Entity\CustomPageRenderInterface" interface and provide a render service instead.
* @deprecated Using the "Kunstmaan\NodeBundle\Controller\SlugActionInterface::getControllerAction" to customize the page render is deprecated since KunstmaanNodeBundle 5.9 and will be removed in KunstmaanNodeBundle 6.0. Implement the "Kunstmaan\NodeBundle\Entity\CustomViewDataProviderInterface" interface and provide a render service instead.
*
* @return mixed
*/
Expand Down
Loading

0 comments on commit 323a46f

Please sign in to comment.