Skip to content

Commit

Permalink
LinkActivityDefinition preview doesn't work: Create PreviewGenerator (#…
Browse files Browse the repository at this point in the history
…494)

* LinkActivityDefinition preview doesn't work: Create PreviewGenerator

* Move to PreviewGenerator namespace

* Fix deprecation
  • Loading branch information
blankse authored Aug 21, 2023
1 parent e1caae8 commit de98f9e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
"group": "CustomerManagement",
"showAppLoggerTab": false,
"linkGeneratorReference": "@CustomerManagementFrameworkBundle\\LinkGenerator\\LinkActivityDefinitionLinkGenerator",
"previewGeneratorReference": "@CustomerManagementFrameworkBundle\\PreviewGenerator\\LinkActivityDefinitionPreviewGenerator",
"compositeIndices": [],
"showFieldLookup": false,
"propertyVisibility": {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Preview/ObjectPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
class ObjectPreviewController extends FrontendController
{
/**
* @Route("/link-activity-definition-preview")
* @Route("/link-activity-definition-preview", name="cmf_link_activity_definition_preview")
*/
public function linkActivityDefinitionPreviewAction(Request $request): Response
{
$activityDefinition = LinkActivityDefinition::getById($request->get('pimcore_object_preview'));
$activityDefinition = LinkActivityDefinition::getById($request->query->getInt('pimcore_object_preview'));

return $this->render(
'@PimcoreCustomerManagementFramework/preview/object_preview/link_activity_definition_preview.html.twig',
Expand Down
40 changes: 40 additions & 0 deletions src/PreviewGenerator/LinkActivityDefinitionPreviewGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace CustomerManagementFrameworkBundle\PreviewGenerator;

use Pimcore\Model\DataObject\ClassDefinition\PreviewGeneratorInterface;
use Pimcore\Model\DataObject\Concrete;
use Symfony\Component\Routing\RouterInterface;

class LinkActivityDefinitionPreviewGenerator implements PreviewGeneratorInterface
{
public function __construct(protected RouterInterface $router)
{
}

public function generatePreviewUrl(Concrete $object, array $params): string
{
return $this->router->generate(
'cmf_link_activity_definition_preview',
['pimcore_object_preview' => $object->getId()]
);
}

public function getPreviewConfig(Concrete $object): array
{
return [];
}
}
2 changes: 2 additions & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ services:
arguments:
- '%pimcore_customer_management_framework.url_activity_tracker.linkCmfcPlaceholder%'

CustomerManagementFrameworkBundle\PreviewGenerator\LinkActivityDefinitionPreviewGenerator: ~

cmf.link-activity-definition.linkgenerator:
alias: CustomerManagementFrameworkBundle\LinkGenerator\LinkActivityDefinitionLinkGenerator
deprecated:
Expand Down

0 comments on commit de98f9e

Please sign in to comment.