Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkActivityDefinition preview doesn't work: Create PreviewGenerator #494

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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