Skip to content

Commit

Permalink
Update to pimcore X
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruiser13 committed Feb 28, 2022
1 parent 2df56ac commit 0655b84
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 46 deletions.
58 changes: 40 additions & 18 deletions README.md
@@ -1,6 +1,8 @@
# Dataprivacy Bundle for Pimcore
Add dataprivacy features (GDPR / DSGVO) to Pimcore

Version 1.x can be used for Pimcore X, use Version 0.X ([branch pimcore-6](https://github.com/pringuin/dataprivacybundle/tree/pimcore-6)) for Pimcore 5/6

## Features
* Does support multiple domains (using Pimcore sites)
* Easy installation in pimcore projects (drop-in-solution)
Expand All @@ -10,7 +12,7 @@ Add dataprivacy features (GDPR / DSGVO) to Pimcore
![Backend Interface](docs/img/localized_admin_interface.png)

## Dependencies
This bundle does include the great script [tarteaucitron.js](https://github.com/AmauriC/tarteaucitron.js) in the `pringuin/DataprivacyBundle/Resources/public/js/tarteaucitron` folder.
This bundle does include the great script [tarteaucitron.js](https://github.com/AmauriC/tarteaucitron.js) in the `pringuin/DataprivacyBundle/Resources/public/js/tarteaucitron` folder.

## Installation

Expand All @@ -19,7 +21,7 @@ This bundle does include the great script [tarteaucitron.js](https://github.com/

```json
"require": {
"pringuin/dataprivacybundle" : "dev-master"
"pringuin/dataprivacybundle" : "^1.0"
}
```

Expand All @@ -44,7 +46,7 @@ You can also change these files directly using your favorite IDE. They can be ar
### Installation into your template
To include the cookie consent into your frontend layout, you can use the following twig code. Simply insert it into your template (e.g. layout.html.twig) before the closing body Tag:
```twig
{{ pimcore_action('default', 'default', 'pringuinDataprivacyBundle', {}) }}
{{ render(controller('pringuin\\DataprivacyBundle\\Controller\\DefaultController::defaultAction', [])) }}
```
Hint: You can always override this template by implementing your own template in the folder `PIMCOREINSTALLATION/app/Resources/pringuinDataprivacyBundle/views/default/default.html.twig`

Expand Down Expand Up @@ -79,7 +81,7 @@ This package does currently ship with the following trackers/tools integrations:
- Vimeo
- Dailymotion

Note that you'll take care of the implementation of your video brick to make YouTube, Vimeo and Daily Motion work.
Note that you'll take care of the implementation of your video brick to make YouTube, Vimeo and Daily Motion work.

Sample code by [breakone](https://github.com/breakone):
```twig
Expand Down Expand Up @@ -115,20 +117,20 @@ If the tracker or tool **is not** included into the tarteaucitron.js package, pl
Alternatively you can directly include your custom service using this example code from tarteaucitron.js:
```js
tarteaucitron.services.mycustomservice = {
"key": "mycustomservice",
"type": "social|analytic|ads|video|support",
"name": "MyCustomService",
"needConsent": true,
"cookies": ['cookie', 'cookie2'],
"readmoreLink": "/custom_read_more", // If you want to change readmore link
"js": function () {
"use strict";
// When user allow cookie
},
"fallback": function () {
"use strict";
// when use deny cookie
}
"key": "mycustomservice",
"type": "social|analytic|ads|video|support",
"name": "MyCustomService",
"needConsent": true,
"cookies": ['cookie', 'cookie2'],
"readmoreLink": "/custom_read_more", // If you want to change readmore link
"js": function () {
"use strict";
// When user allow cookie
},
"fallback": function () {
"use strict";
// when use deny cookie
}
};
(tarteaucitron.job = tarteaucitron.job || []).push('mycustomservice');
```
Expand Down Expand Up @@ -161,6 +163,26 @@ Thanks!

## Updating

### Updating from 0.5 to 1.0

1.0 is the first release for Pimcore X. Simply adapt your composer.json and run composer update as usually.

Since pimcore removed the pimcore_action from the twig template, you'll have to adjust your template installation.

Before:

```twig
{{ pimcore_action('default', 'default', 'pringuinDataprivacyBundle', {}) }}
```

Now:

```twig
{{ render(controller('pringuin\\DataprivacyBundle\\Controller\\DefaultController::defaultAction', [])) }}
```

You might also need to save your configuration again.

### Updating from 0.4 to 0.5

To update to 0.5 simply adapt your composer.json and run composer update as usually.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -26,7 +26,7 @@
}
},
"require": {
"pimcore/pimcore": "^5.8 | ^6.0",
"php":"^7.0"
"pimcore/pimcore": "^10.2",
"php":"^8.0"
}
}
21 changes: 6 additions & 15 deletions src/pringuin/DataprivacyBundle/Controller/AdminController.php
Expand Up @@ -4,25 +4,19 @@

use Pimcore\Controller\FrontendController;
use Pimcore\Tool\Authentication;
use Pimcore\Translation\Translator;
use pringuin\DataprivacyBundle\Helper\Configurationhelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;

class AdminController extends FrontendController
{

public function onKernelController(FilterControllerEvent $event)
{
// set auto-rendering to twig
$this->setViewAutoRender($event->getRequest(), true, 'twig');
}

/**
* @Route("/pringuin_dataprivacy")
*/
public function indexAction(Request $request)
public function indexAction(Request $request, Translator $translator)
{
$user = Authentication::authenticateSession($request);
if(!$user){
Expand Down Expand Up @@ -55,17 +49,15 @@ public function indexAction(Request $request)
if(is_iterable($configurationdata)){
$result = Configurationhelper::setConfigurationForSite($siteid,$configurationdata);
if($result){
$responsemessage .= '<div>'.$this
->get('translator')
$responsemessage .= '<div>'.$translator
->trans(
'configuration_save_success',
['%site%' => $siteid],
'admin'
).'</div>';
}
else{
$responsemessage .= '<div>'.$this
->get('translator')
$responsemessage .= '<div>'.$translator
->trans(
'configuration_save_fail',
['%site%' => $siteid],
Expand Down Expand Up @@ -93,10 +85,9 @@ public function indexAction(Request $request)
}
}

$this->view->message = $responsemessage;
$this->view->configurations = $configurations;
return $this->render('@pringuinDataprivacy/admin/index.html.twig', ['message' => $responsemessage, 'configurations' => $configurations]);


//return new Response('Hello world from pringuin_dataprivacy');
}


Expand Down
Expand Up @@ -9,19 +9,12 @@
use pringuin\DataprivacyBundle\Helper\Configurationhelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends FrontendController
{

public function onKernelController(FilterControllerEvent $event)
{
// set auto-rendering to twig
$this->setViewAutoRender($event->getRequest(), true, 'twig');
}

public function defaultAction(Request $request)
{
if(\Pimcore\Model\Site::isSiteRequest()) {
Expand Down Expand Up @@ -50,7 +43,7 @@ public function defaultAction(Request $request)
}
}

$this->view->configuration = $configuration;
return $this->render('@pringuinDataprivacy/default/default.html.twig', ['configuration' => $configuration]);

}
}
Expand Up @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('pringuin_dataprivacy');
$treeBuilder = new TreeBuilder('pringuin');
$rootNode = $treeBuilder->getRootNode('pringuin_dataprivacy');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
Expand Down
Expand Up @@ -10,7 +10,7 @@ abstract class Configurationhelper {
/**
* @var string
*/
private static $configurationPath = PIMCORE_APP_ROOT . '/config/pringuin_dataprivacy';
private static $configurationPath = PIMCORE_PROJECT_ROOT . '/config/pringuin_dataprivacy';

/**
* @param String $site
Expand Down

0 comments on commit 0655b84

Please sign in to comment.