Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
Pimcore X refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fracsi committed Jul 16, 2021
1 parent d5ea2dc commit 35a9a9d
Show file tree
Hide file tree
Showing 48 changed files with 91 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.github export-ignore
/images export-ignore
/Tests export-ignore
9 changes: 6 additions & 3 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
Finder::create()
->ignoreDotFiles(true)
->ignoreVCS(true)
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->exclude('project')
->in(__DIR__)
->exclude([
'vendor',
'node_modules',
'Tests/project/var',
])
);
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### [2.0] 2021-07-16

* Pimcore X compatible version

### [1.1] 2021-04-08

* Refactored configuration storage to be extendable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Wgg\MailchimpBundle\ApiClient;
use Wgg\MailchimpBundle\Util\ApiClient;

class GetListCommand extends Command
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Wgg\MailchimpBundle\ApiClient;
use Wgg\MailchimpBundle\Util\ApiClient;

class PingCommand extends Command
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wgg\MailchimpBundle\ApiClient;
use Wgg\MailchimpBundle\MailchimpConfiguration;
use Wgg\MailchimpBundle\Util\ApiClient;
use Wgg\MailchimpBundle\Util\MailchimpConfiguration;

use function array_filter;
use function is_array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Wgg\MailchimpBundle\MailchimpConfiguration;
use Wgg\MailchimpBundle\Util\MailchimpConfiguration;

class ConfigurationCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function load(array $configs, ContainerBuilder $container): void
$configs = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('services.yaml');

$container->setParameter('wgg_mailchimp.storage', $configs['storage']);
}
Expand Down
File renamed without changes.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img width="600" alt="pimcore-mailchimp" src="images/logo_fullcolor.svg?raw=true" /></p>
<p align="center"><img width="600" alt="pimcore-mailchimp" src="./images/logo_fullcolor.svg?raw=true" /></p>

Mailchimp integration for Pimcore

Expand All @@ -7,12 +7,12 @@ Mailchimp integration for Pimcore

#### Requirements

* Pimcore >= 6.8.0
* Pimcore X (^10.0.0)

## Installation

```shell
$ composer require wgg/pimcore-mailchimp
$ composer require wgg/pimcore-x-mailchimp
```

### Installation via Extension Manager
Expand Down Expand Up @@ -53,10 +53,9 @@ Does actually the same as the update command and preferred in CI-Workflow:

The bundle currently supports two kind of configuration storage:

- [`Wgg\MailchimpBundle\Storage\FileStorage`](src/MailchimpBundle/Storage/FileStorage.php) - stores config as YAML file
- [`Wgg\MailchimpBundle\Storage\FileStorage`](Storage/FileStorage.php) - stores config as YAML file
under `PIMCORE_CONFIGURATION_DIRECTORY`
- [`Wgg\MailchimpBundle\Storage\SettingsStoreStorage`](src/MailchimpBundle/Storage/SettingsStoreStorage.php) - stores
config
- [`Wgg\MailchimpBundle\Storage\SettingsStoreStorage`](Storage/SettingsStoreStorage.php) - stores config
through [`SettingsStore`](https://pimcore.com/docs/pimcore/master/Development_Documentation/Development_Tools_and_Details/Settings_Store.html)

You can configure it:
Expand Down Expand Up @@ -110,11 +109,11 @@ wgg_mailchimp:

Configuration is accessible from the `Settings / Mailchimp Settings` on the administration panel.

Through [`Wgg\MailchimpBundle\ApiClient`](src/MailchimpBundle/ApiClient.php) service you can access all Mailchimp API
Through [`Wgg\MailchimpBundle\Util\ApiClient`](Util/ApiClient.php) service you can access all Mailchimp API
functionality.

You can use [`Wgg\MailchimpBundle\ListOptionsProvider`](src/MailchimpBundle/ListOptionsProvider.php) service in
a `Select Type` for audience/list ids.
You can use [`Wgg\MailchimpBundle\Util\ListOptionsProvider`](Util/ListOptionsProvider.php) service in a `Select Type`
for audience/list ids.

From twig you can use `mailchimp_list_store` function to get access to list/audience ids and names.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ services:
public: true
tags: [ 'controller.service_arguments' ]

Wgg\MailchimpBundle\MailchimpConfiguration: ~
Wgg\MailchimpBundle\Util\MailchimpConfiguration: ~

Wgg\MailchimpBundle\ApiClient: ~
Wgg\MailchimpBundle\Util\ApiClient: ~

Wgg\MailchimpBundle\ListOptionsProvider:
Wgg\MailchimpBundle\Util\ListOptionsProvider:
public: true

Wgg\MailchimpBundle\Command\:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Wgg\MailchimpBundle\Storage;

use function file_exists;
use Pimcore\Config;
use Pimcore\File;
use Symfony\Component\Yaml\Yaml;

use function file_exists;

class FileStorage implements StorageInterface
{
public function read(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Wgg\MailchimpBundle\Storage;

use Pimcore\Model\Tool\SettingsStore;

use function explode;
use function implode;
use Pimcore\Model\Tool\SettingsStore;

class SettingsStoreStorage implements StorageInterface
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Pimcore\Test\KernelTestCase;
use stdClass;
use Symfony\Component\Filesystem\Filesystem;
use Wgg\MailchimpBundle\ApiClient;
use Wgg\MailchimpBundle\ListOptionsProvider;
use Wgg\MailchimpBundle\Util\ApiClient;
use Wgg\MailchimpBundle\Util\ListOptionsProvider;

use function ucfirst;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Pimcore\Test\KernelTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Wgg\MailchimpBundle\MailchimpConfiguration;
use Wgg\MailchimpBundle\Util\MailchimpConfiguration;

class MailchimpConfigurationFileStorageTest extends KernelTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Pimcore\Model\Tool\SettingsStore;
use Pimcore\Test\KernelTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Wgg\MailchimpBundle\MailchimpConfiguration;
use Wgg\MailchimpBundle\Util\MailchimpConfiguration;

use function implode;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ doctrine:
dbal:
connections:
default:
wrapper_class: 'DbConnection'
wrapper_class: 'App\DbConnection'
schema_filter: '~^(?!messenger_messages)~'
url: 'sqlite3:///%kernel.project_dir%/var/database.sqlite3'
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
parameters:
secret: '%env(APP_SECRET)%'
secret: fakesecret

services:
file.Wgg\MailchimpBundle\MailchimpConfiguration:
file.Wgg\MailchimpBundle\Util\MailchimpConfiguration:
public: true
class: Wgg\MailchimpBundle\MailchimpConfiguration
class: Wgg\MailchimpBundle\Util\MailchimpConfiguration
arguments:
- '@Wgg\MailchimpBundle\Storage\FileStorage'

settingsStore.Wgg\MailchimpBundle\MailchimpConfiguration:
settingsStore.Wgg\MailchimpBundle\Util\MailchimpConfiguration:
public: true
class: Wgg\MailchimpBundle\MailchimpConfiguration
class: Wgg\MailchimpBundle\Util\MailchimpConfiguration
arguments:
- '@Wgg\MailchimpBundle\Storage\SettingsStoreStorage'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace App;

use Doctrine\DBAL\Connection;
use Exception;
use Pimcore\Db\ConnectionInterface;
use Pimcore\Db\PimcoreExtensionsTrait;

Expand All @@ -25,8 +28,8 @@ public function connect()
* @param string $table
*
* @return int
* @throws Exception
*
* @throws \Exception
*/
public function insertOrUpdate($table, array $data)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

namespace App;

use Pimcore\HttpKernel\BundleCollection\BundleCollection;
use Pimcore\Kernel;
use Pimcore\Kernel as BaseKernel;
use Wgg\MailchimpBundle\WggMailchimpBundle;

class AppTestKernel extends Kernel
class Kernel extends BaseKernel
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use Wgg\MailchimpBundle\ListOptionsProvider;
use Wgg\MailchimpBundle\Util\ListOptionsProvider;

class MailchimpExtension extends AbstractExtension
{
Expand Down
3 changes: 2 additions & 1 deletion src/MailchimpBundle/ApiClient.php → Util/ApiClient.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Wgg\MailchimpBundle;
namespace Wgg\MailchimpBundle\Util;

use MailchimpMarketing\Api\ListsApi;
use MailchimpMarketing\Api\PingApi;
use MailchimpMarketing\ApiClient as BaseApiClient;

use function mb_strtolower;
use function md5;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

namespace Wgg\MailchimpBundle;
namespace Wgg\MailchimpBundle\Util;

use function implode;
use function md5;
use Pimcore\Cache;
use Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\MultiSelectOptionsProviderInterface;
use Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface;
use Wgg\MailchimpBundle\WggMailchimpBundle;

use function implode;
use function md5;

class ListOptionsProvider implements MultiSelectOptionsProviderInterface, SelectOptionsProviderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Wgg\MailchimpBundle;
namespace Wgg\MailchimpBundle\Util;

use Pimcore\Cache;
use Wgg\MailchimpBundle\Storage\StorageInterface;
use Wgg\MailchimpBundle\WggMailchimpBundle;

class MailchimpConfiguration
{
Expand Down
File renamed without changes.
21 changes: 13 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
],
"autoload": {
"psr-4": {
"Wgg\\MailchimpBundle\\": "src/MailchimpBundle/"
}
"Wgg\\MailchimpBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"autoload-dev": {
"psr-4": {
"Wgg\\MailchimpBundle\\Tests\\": "tests/"
"Wgg\\MailchimpBundle\\Tests\\": "/Tests/"
},
"classmap": [
"tests/project/AppTestKernel.php",
"tests/project/DbConnection.php"
"files": [
"./Tests/project/src/Kernel.php",
"./Tests/project/src/DbConnection.php"
]
},
"extra": {
Expand All @@ -40,7 +43,7 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"pimcore/pimcore": ">=10.0.0",
"pimcore/pimcore": "^10.0.0",
"mailchimp/marketing": "^3.0.0"
},
"require-dev": {
Expand Down Expand Up @@ -70,7 +73,9 @@
},
"archive": {
"exclude": [
"docs"
"/.github",
"/images",
"/Tests"
]
}
}
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"name": "@wgg/mailchimp-bundle",
"version": "1.0.0",
"description": "Mailchimp integration for Pimcore",
"private": "true",
"scripts": {
"lint": "eslint -c .eslintrc.js src/MailchimpBundle/Resources/public/js"
"lint": "eslint -c .eslintrc.js Resources/public/js"
},
"author": "WebGarden",
"license": "ISC",
"bugs": {
"url": "https://github.com/WebGardenGroup/mailchimp-bundle/issues"
},
"homepage": "https://github.com/WebGardenGroup/mailchimp-bundle#readme",
"devDependencies": {
"eslint": "^7.22.0",
"eslint-config-standard": "^16.0.2"
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ includes:
parameters:
level: 8
paths:
- src
- .
checkMissingIterableValueType: false
excludePaths:
- Tests
- vendor
- node_modules
6 changes: 4 additions & 2 deletions phpstan.tests.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ includes:
parameters:
level: 8
paths:
- tests
- Tests
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
- vendor/pimcore/pimcore/stubs/dynamic-constants.php
checkMissingIterableValueType: false
excludePaths:
- tests/project/*
- Tests/project/*
- vendor
- node_modules

0 comments on commit 35a9a9d

Please sign in to comment.