Skip to content

Commit

Permalink
⬆ pimcore 11 support
Browse files Browse the repository at this point in the history
* Big thank you to @blankse !

* Pimcore 11 Support (#7)

* Requires Pimcore >= 11
  • Loading branch information
blankse committed Aug 21, 2023
1 parent fe74d33 commit 9fe2067
Show file tree
Hide file tree
Showing 21 changed files with 230 additions and 200 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
matrix:
include:
- { php-version: "8.0", dependencies: "lowest" }
- { php-version: "8.1", dependencies: "highest" }
- { php-version: "8.1", dependencies: "lowest" }
- { php-version: "8.2", dependencies: "highest" }
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
/vendor/
/.php-cs-fixer.cache
/composer.lock
59 changes: 59 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
])
;

// do not enable self_accessor as it breaks pimcore models relying on get_called_class()
$config = new PhpCsFixer\Config();
$config->setRules([
'@PSR1' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'list_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => true,
'encoding' => true,
'function_typehint_space' => true,
'single_line_comment_style' => true,
'lowercase_cast' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['on_multiline' => 'ignore'],
'class_attributes_separation' => true,
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_short_bool_cast' => true,
'no_spaces_around_offset' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => true],
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'phpdoc_indent' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'whitespace_after_comma_in_array' => true,
]);

$config->setFinder($finder);
return $config;
55 changes: 0 additions & 55 deletions .php_cs.dist

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2.0.0]

Pimcore 11 Support
Require pimcore >= 11.0

## [1.3.0]

Resolve pimcore plugin broker deprecation, see [original PR](https://github.com/pimcore/pimcore/pull/12637)
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Adds a backend configuration view for QR-Codes.

## Requirements

Pimcore >= 10.5
Pimcore >= 11.0

## Installation

Expand All @@ -14,8 +14,15 @@ Require the bundle
composer require gal-digital-gmbh/pimcore-qrcode-bundle
```

Enable the bundle
Add the bundle to the `config/bundles.php` file to enable it. The following lines should be added:

```bash
php bin/console pimcore:bundle:enable PimcoreQrcodeBundle
```php
use GalDigitalGmbh\PimcoreQrcodeBundle\PimcoreQrcodeBundle;
// ...

return [
// ...
PimcoreQrcodeBundle::class => ['all' => true],
// ...
];
```
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gal-digital-gmbh/pimcore-qrcode-bundle",
"version": "1.3.0",
"version": "2.0.0",
"type": "pimcore-bundle",
"description": "Pimcore QR-Code bundle",
"keywords": [
Expand All @@ -18,12 +18,14 @@
}
],
"require": {
"pimcore/pimcore": "^10.5",
"endroid/qr-code": "^4"
"php": "^8.1",
"endroid/qr-code": "^4.8",
"pimcore/admin-ui-classic-bundle": "^1.0",
"pimcore/pimcore": "^11.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"phpstan/phpstan": "^1.3"
"friendsofphp/php-cs-fixer": "^3.23",
"phpstan/phpstan": "^1.10.29"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.2-dev"
"dev-main": "2.0-dev"
},
"pimcore": {
"bundles": [
Expand Down
25 changes: 11 additions & 14 deletions src/Controller/Admin/QrCodeController.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<?php
<?php declare(strict_types = 1);

namespace GalDigitalGmbh\PimcoreQrcodeBundle\Controller\Admin;

use Endroid\QrCode\Builder\Builder;
use GalDigitalGmbh\PimcoreQrcodeBundle\Model\QrCode;
use Pimcore\Bundle\AdminBundle\Controller\AdminController;
use Pimcore\Controller\Traits\JsonHelperTrait;
use Pimcore\Controller\UserAwareController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class QrCodeController extends AdminController
final class QrCodeController extends UserAwareController
{
/**
* @var UrlGeneratorInterface
*/
private $urlGenerator;
use JsonHelperTrait;

public function __construct(UrlGeneratorInterface $urlGenerator)
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}

public function getItem(Request $request): JsonResponse
Expand All @@ -30,7 +27,7 @@ public function getItem(Request $request): JsonResponse
$code = QrCode::getByName($request->get('name'));
$success = (bool) $code;

return $this->adminJson([
return $this->jsonResponse([
'success' => $success,
'code' => $code,
]);
Expand All @@ -52,7 +49,7 @@ public function addItem(Request $request): JsonResponse
$success = true;
}

return $this->adminJson([
return $this->jsonResponse([
'success' => $success,
'id' => $code->getName(),
]);
Expand Down Expand Up @@ -80,7 +77,7 @@ public function updateItem(Request $request): JsonResponse
$success = true;
}

return $this->adminJson([
return $this->jsonResponse([
'success' => $success,
]);
}
Expand All @@ -97,7 +94,7 @@ public function deleteItem(Request $request): JsonResponse
$success = true;
}

return $this->adminJson([
return $this->jsonResponse([
'success' => $success,
]);
}
Expand All @@ -116,7 +113,7 @@ public function listItems(): JsonResponse
];
}, $list->getCodes());

return $this->adminJson([
return $this->jsonResponse([
'codes' => $codes,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/QrCodeController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace GalDigitalGmbh\PimcoreQrcodeBundle\Controller;

Expand All @@ -8,7 +8,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class QrCodeController extends FrontendController
final class QrCodeController extends FrontendController
{
public function code(Request $request): Response
{
Expand Down
11 changes: 8 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php
<?php declare(strict_types = 1);

namespace GalDigitalGmbh\PimcoreQrcodeBundle\DependencyInjection;

use Pimcore\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('pimcore_qrcode');
$rootNode = $treeBuilder->getRootNode();
Expand All @@ -28,6 +30,9 @@ public function getConfigTreeBuilder()
->end()
->end();

/** @var ArrayNodeDefinition $rootNode */
ConfigurationHelper::addConfigLocationWithWriteTargetNodes($rootNode, ['qrcode' => '/var/config/qrcode']);

return $treeBuilder;
}
}
35 changes: 13 additions & 22 deletions src/DependencyInjection/PimcoreQrcodeExtension.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<?php
<?php declare(strict_types = 1);

namespace GalDigitalGmbh\PimcoreQrcodeBundle\DependencyInjection;

use GalDigitalGmbh\PimcoreQrcodeBundle\Model\QrCode\Dao;
use Pimcore\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;

class PimcoreQrcodeExtension extends ConfigurableExtension implements PrependExtensionInterface
final class PimcoreQrcodeExtension extends ConfigurableExtension implements PrependExtensionInterface
{
/**
* @param array<mixed> $mergedConfig
* @param ContainerBuilder $container
*
* @return void
*/
public function loadInternal(array $mergedConfig, ContainerBuilder $container)
public function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
$container->setParameter('pimcore_qrcode', $mergedConfig);

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

/**
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container): void
{
if ($container->hasExtension('doctrine_migrations')) {
Expand All @@ -40,17 +33,15 @@ public function prepend(ContainerBuilder $container): void
$loader->load('doctrine_migrations.yaml');
}

$configDir = Dao::CONFIG_PATH;
if (is_dir($configDir)) {
$configLoader = new YamlFileLoader(
$container,
new FileLocator($configDir)
);
$finder = new Finder();
$finder->files()->in($configDir)->name(['*.yml', '*.yaml']);
foreach ($finder as $config) {
$configLoader->load($config);
}
$containerConfig = ConfigurationHelper::getConfigNodeFromSymfonyTree($container, 'pimcore_qrcode');
$configDir = $containerConfig['config_location']['qrcode']['write_target']['options']['directory'];
$configLoader = new YamlFileLoader(
$container,
new FileLocator($configDir)
);
$configs = ConfigurationHelper::getSymfonyConfigFiles($configDir);
foreach ($configs as $config) {
$configLoader->load($config);
}
}
}
Loading

0 comments on commit 9fe2067

Please sign in to comment.