Skip to content

Commit

Permalink
Pimcore X Compatibility (#48)
Browse files Browse the repository at this point in the history
* px support
  • Loading branch information
solverat committed Feb 18, 2022
1 parent 67e9c2a commit fe1db95
Show file tree
Hide file tree
Showing 48 changed files with 604 additions and 1,611 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
@@ -1,5 +1,5 @@
# License
Copyright (C) 2017 DACHCOM.DIGITAL
Copyright (C) 2022 DACHCOM.DIGITAL

This software is available under the GNU General Public License version 3 (GPLv3).

Expand Down
16 changes: 6 additions & 10 deletions README.md
@@ -1,24 +1,20 @@
# Pimcore News
Pimcore News Bundle. It's also possible to generate [custom entry types](docs/20_EntryTypes.md) like Press or Event.
Pimcore News Bundle. Generate simple [custom entry types](docs/20_EntryTypes.md) like Events, Press or Event.

## Requirements
* Pimcore 5.

#### Pimcore 4
Get the Pimcore4 Version [here](https://github.com/dachcom-digital/pimcore-news/tree/pimcore4).
⚠️⚠️ This extension has reached its end of life and only receives compatibility update. It will not be developed further.

## Installation

**Composer Installation**
1. Add code below to your `composer.json`
2. Activate & install it through backend

```json
"require" : {
"dachcom-digital/news" : "~2.2.0"
"dachcom-digital/news" : "~3.0.0",
}
```

- Execute: `$ bin/console pimcore:bundle:enable NewsBundle`
- Execute: `$ bin/console pimcore:bundle:install NewsBundle`

## Important to know
- The detail url is based on the title for each language. If the detail url field is empty, the title will be transformed to a valid url slug.
- The News Bundle will install two classes (`NewsEntry` and `NewsCategory`). If you're going to modify them, please make sure that you're follow our [upgrade notes](UPGRADE.md) in case we're changing the class structure.
Expand Down
39 changes: 7 additions & 32 deletions UPGRADE.md
@@ -1,36 +1,11 @@
# Upgrade Notes

#### Update from Version 2.2.5 to Version 2.2.6
- fix forced unpublishing if no copy process is active [#44](https://github.com/dachcom-digital/pimcore-news/issues/44)
## Migrating from Version 2.x to Version 3.0.0

#### Update from Version 2.2.4 to Version 2.2.5
- fix detail url slugify listener (remove detail url on copy, improved duplication check)
### Global Changes
- PHP8 return type declarations added: you may have to adjust your extensions accordingly
- View `Areas/news/edit_custom.html.twig` has been removed. Use Event `\NewsBundle\NewsEvents::NEWS_EDITABLE_DIALOG` instead
- It is no longer possible to toggle editable configuration based on given values.
***

#### Update from Version 2.2.3 to Version 2.2.4
- use not found http exception in detail action

#### Update from Version 2.2.2 to Version 2.2.3
- add possibility to add additional view params (@Sarah-Hasler)

#### Update from Version 2.2.1 to Version 2.2.2
- remove jquery dependency

#### Update from Version 2.2.0 to Version 2.2.1
- made extensible with custom configuration fields

#### Update from Version 2.1.2 to Version 2.2.0
- bundle is now compatible with pimcore 6

#### Update from Version 2.1.0 to Version 2.1.1
- implemented [PackageVersionTrait](https://github.com/pimcore/pimcore/blob/master/lib/Extension/Bundle/Traits/PackageVersionTrait.php)
- PHP 7.2 ready
- Fix Link Generator on Multisites

#### Update from Version 2.0.x to Version 2.1.0
- **[NEW FEATURE]**: Single Objects added: Add single entries to your area
- **[NEW FEATURE]**: Offset Configuration: Add a Offset to your Entry List
- **[NEW FEATURE]**: [Link Generator Support](https://pimcore.com/docs/5.x/Development_Documentation/Objects/Object_Classes/Class_Settings/Link_Generator.html)
- **[NEW FEATURE]**: [Presets](./docs/30_Presets.md)

#### Update from Version 1.x to Version 2.0.0
TBD
News 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-news/blob/2.x/UPGRADE.md
7 changes: 3 additions & 4 deletions composer.json
@@ -1,8 +1,8 @@
{
"name": "dachcom-digital/news",
"type": "pimcore-bundle",
"license": "GPL-3.0+",
"description": "Pimcore 5.x News",
"license": "GPL-3.0-or-later",
"description": "Pimcore News",
"keywords": ["pimcore", "news"],
"homepage": "https://github.com/dachcom-digital/pimcore-news",
"authors": [
Expand All @@ -13,13 +13,11 @@
"role": "Developer"
}
],

"autoload": {
"psr-4": {
"NewsBundle\\": "src/NewsBundle"
}
},

"extra": {
"pimcore": {
"bundles": [
Expand All @@ -28,5 +26,6 @@
}
},
"require": {
"pimcore/pimcore": "^10.2"
}
}
37 changes: 7 additions & 30 deletions src/NewsBundle/Configuration/Configuration.php
Expand Up @@ -4,50 +4,27 @@

class Configuration
{
const SYSTEM_CONFIG_DIR_PATH = PIMCORE_PRIVATE_VAR . '/bundles/NewsBundle';
public const SYSTEM_CONFIG_DIR_PATH = PIMCORE_PRIVATE_VAR . '/bundles/NewsBundle';
public const SYSTEM_CONFIG_FILE_PATH = PIMCORE_PRIVATE_VAR . '/bundles/NewsBundle/config.yml';

const SYSTEM_CONFIG_FILE_PATH = PIMCORE_PRIVATE_VAR . '/bundles/NewsBundle/config.yml';
protected array $config;

/**
* @var array
*/
protected $config;

/**
* @var array
*/
protected $systemConfig;

/**
* @param array $config
*/
public function setConfig($config = [])
public function setConfig(array $config = []): void
{
$this->config = $config;
}

/**
* @return array
*/
public function getConfigNode()
public function getConfigNode(): array
{
return $this->config;
}

/**
* @return mixed
*/
public function getConfigArray()
public function getConfigArray(): array
{
return $this->config;
}

/**
* @param $slot
*
* @return mixed
*/
public function getConfig($slot)
public function getConfig(string $slot): mixed
{
return $this->config[$slot];
}
Expand Down
40 changes: 16 additions & 24 deletions src/NewsBundle/Controller/Admin/SettingsController.php
Expand Up @@ -7,32 +7,31 @@
use Pimcore\Model\DataObject;
use Pimcore\Model\Version;
use Pimcore\Translation\Translator;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class SettingsController extends AdminController
{
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function getEntryTypesAction(Request $request)
{
/** @var EntryTypeManager $configuration */
$entryTypeManager = $this->get(EntryTypeManager::class);
protected Translator $translator;
protected EntryTypeManager $entryTypeManager;

/** @var Translator $translator */
$translator = $this->get('pimcore.translator');
public function __construct(Translator $translator, EntryTypeManager $entryTypeManager)
{
$this->translator = $translator;
$this->entryTypeManager = $entryTypeManager;
}

$newsObject = DataObject::getById(intval($request->get('objectId')));
public function getEntryTypesAction(Request $request): JsonResponse
{
$newsObject = DataObject::getById((int) $request->get('objectId'));

$valueArray = [];
foreach ($entryTypeManager->getTypes($newsObject) as $typeName => $type) {
foreach ($this->entryTypeManager->getTypes($newsObject) as $typeName => $type) {
$valueArray[] = [
'custom_layout_id' => $type['custom_layout_id'],
'value' => $typeName,
'key' => $translator->trans($type['name'], [], 'admin'),
'default' => $entryTypeManager->getDefaultType()
'key' => $this->translator->trans($type['name'], [], 'admin'),
'default' => $this->entryTypeManager->getDefaultType()
];
}

Expand All @@ -43,16 +42,10 @@ public function getEntryTypesAction(Request $request)
]);
}

/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Exception
*/
public function changeEntryTypeAction(Request $request)
public function changeEntryTypeAction(Request $request): JsonResponse
{
$entryTypeId = $request->get('entryTypeId');
$object = DataObject::getById(intval($request->get('objectId')));
$object = DataObject::getById((int) $request->get('objectId'));

if ($object instanceof DataObject\NewsEntry) {
$object->setEntryType($entryTypeId);
Expand All @@ -68,5 +61,4 @@ public function changeEntryTypeAction(Request $request)
'message' => ''
]);
}

}
7 changes: 1 addition & 6 deletions src/NewsBundle/Controller/EntryController.php
Expand Up @@ -10,12 +10,7 @@

class EntryController extends FrontendController
{
/**
* @param Request $request
*
* @return Response
*/
public function detailAction(Request $request)
public function detailAction(Request $request): Response
{
$newsFragment = $request->attributes->get('entry');
$locale = $request->attributes->get('_locale');
Expand Down
6 changes: 0 additions & 6 deletions src/NewsBundle/CoreExtension/EntryTypeSelect.php
Expand Up @@ -6,11 +6,5 @@

class EntryTypeSelect extends Select
{
/**
* Static type of this element
*
* @var string
*/
public $fieldtype = 'entryTypeSelect';

}
Expand Up @@ -9,10 +9,7 @@

final class PresetPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition(PresetRegistry::class);
foreach ($container->findTaggedServiceIds('news.preset') as $id => $tags) {
Expand Down
4 changes: 2 additions & 2 deletions src/NewsBundle/DependencyInjection/Configuration.php
Expand Up @@ -12,8 +12,8 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('news');
$treeBuilder = new TreeBuilder('news');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->arrayNode('relations')
Expand Down
6 changes: 1 addition & 5 deletions src/NewsBundle/DependencyInjection/NewsExtension.php
Expand Up @@ -10,11 +10,7 @@

class NewsExtension extends Extension
{
/**
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down

0 comments on commit fe1db95

Please sign in to comment.