Skip to content

Commit

Permalink
Workflow Extend Bundle
Browse files Browse the repository at this point in the history
- Initial commit
  • Loading branch information
Lars77 committed Mar 16, 2023
1 parent 42dcfe8 commit b429bad
Show file tree
Hide file tree
Showing 26 changed files with 887 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ indent_size = 4

[composer.json]
indent_style = space
indent_size = 2
indent_size = 2
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
commit-message:
prefix: "Composer"
include: "scope"
24 changes: 12 additions & 12 deletions .github/workflows/php-cs-fixer.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: PHP Style

on: [ push ]
on: [push, workflow_dispatch]

jobs:
php-cs-fixer:
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
with:
args: --config=.php_cs.dist --allow-risky yes
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
with:
args: --config=.php_cs.dist --allow-risky yes

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
23 changes: 23 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Notify on pullrequest action

on:
pull_request:
types: [opened, reopened, closed]
pull_request_review:
types: [submitted, edited, dismissed]
issue_comment:
types: [created, deleted]

jobs:
success:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: always()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
1 change: 0 additions & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ Thumbs.db
# PHP-CS-Fixer
/.php_cs
/.php_cs.cache

6 changes: 3 additions & 3 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ return PhpCsFixer\Config::create()
'This source file is available under following license:' . PHP_EOL .
'- GNU General Public License v3.0 (GNU GPLv3)' . PHP_EOL .
PHP_EOL .
' @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)' . PHP_EOL .
' @license https://www.gnu.org/licenses/gpl-3.0.txt'
'@copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)' . PHP_EOL .
'@license https://www.gnu.org/licenses/gpl-3.0.txt'
],

// keep aligned = and => operators as they are: do not force aligning, but do not remove it
Expand Down Expand Up @@ -65,4 +65,4 @@ return PhpCsFixer\Config::create()
'ternary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
->setFinder($finder);
11 changes: 3 additions & 8 deletions CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Changelog

All notable changes to this Bundle will be documented in this file.
All notable changes to the Workflow Extend Bundle will be documented in this file.

| **Bundle Version** | **Pimcore Version** |
|--------------------|---------------------|
| 1.x.x | Pimcore 10 |

## [1.0.0] - 2023-02-10

- initial commit
## [1.0.0] - 2023-01-13
- initial release
122 changes: 109 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,114 @@
# Template Pimcore Bundle
# Studio1® Pimcore Workflow Extend Bundle

## Post Fork Instructions
This bundle extends the Pimcore Workflow Feature. It adds the possibility to change data during the workflow transition.

### Search and replace
> **Warning:** This bundle is completely untested with the Pimcore communitiy edition and will probably not work.
> Further work is needed to make it work with the community edition.
- [ ] search and replace `template_pimcore` within your bundle source code
- [ ] search and replace `TemplatePimcore` within your bundle source code
- [ ] search and replace `Template Pimcore` within your bundle source code
- [ ] add correct namespace to the files 'src/TemplatePimcoreBundle.php' and '
src/DependencyInjection/TemplatePimcoreExtension.php'
- [ ] add correct translations to the files in 'src/Resources/translations'
## Dependencies

### Rename files
Will be automatically installed with composer:

- [ ] rename the file 'src/TemplatePimcoreBundle.php' to 'src/YourBundleName.php'
- [ ] rename the file 'src/DependencyInjection/TemplatePimcoreExtension.php' to '
src/DependencyInjection/YourBundleNameExtension.php'
- [Pimcore Enterprise Asset Metadata Bundle](https://pimcore.com/docs/asset-metadata/current/)
- [Pimcore Workflow Designer](https://pimcore.com/docs/workflow-designer/current/)
- [Composer Patches](https://github.com/cweagans/composer-patches)

## Installation

### Preparation

Before you require the bundle via composer, you need to add the following to your composer.json:

```json
"extra": {
"enable-patching": true
}
```

This will enable the composer patches plugin, for external dependencies.

### Composer

```bash
composer require studio1/workflow-extend:[version]
```

During the installation process, the composer patches plugin will automatically apply the
needed patches to the pimcore core files.

Please check if the patches were applied correctly. If not, you need to remove the vendor folder and run `composer install` again.

### Enable Bundle

Enable the bundle as with any other Pimcore bundle.

```bash
bin/console pimcore:bundle:enable WorkflowExtendBundle
```

### Uninstall

```bash
composer remove studio1/workflow-extend
```
> Please note that the composer patches plugin will not remove the patches automatically. You need to remove them manually.
## Usage / Configuration

> **Warning:** The bundle currently supports data objects and assets only (no documents etc.).
| Configuration | Explanation |
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| class | MAM- or PIM Class |
| attribute | Attribute that will be changed during the transition |
| value | Value that will be set on the given object/attribute |
| languages | Languages for which the value should be set. Comma separated e.g. (de,de_DE,en,en_US). Not needed, if localized fields are not available or `languagesSetAll` is set. |
| languagesSetAll | The value will be applied for all available languages |

For Pimcore Enterprise Projects, you can configure the workflow transitions in the backend:

![Backend Configuration](docs/backend_configuration.png)

In Pimcore Community Edition, you need to populate the `data` option (implemnted by this bundle) in your workflow
configuration:

```yaml
transitions:
example-transition:
options:
label: 'Example transition'
# ...
# data that will be changed during the transition
data:
class: Basic
attribute: Title
value: test
languages: 'de,de_DE'
languagesSetAll: true
```

## Logs

Can be found in `var/log/workflow-extend-bundle.log`.

## Main components

- [transitionSettings.js](src/Resources/public/js/pimcore/configuration/item/transitionSettings.js)
- Extends the Pimcore Workflow Designer by additional fields for the transition settings popup
- [SetAttributeSubscriber.php](src/EventSubscriber/SetAttributeSubscriber.php)
- Listens to the `workflow.transition` event and changes the data
- [addDiConfiguration.patch](patches/addDiConfiguration.patch)
- Adds the `data` option to the workflow configuration
- A patch file is needed, since there is no other way to extend the dependency injection configuration of the
workflow bundle

## Todos

- Adapt the bundle to work with the Pimcore community edition
- Remove dependency to enterprise bundles
- Check existence of enterprise bundles at runtime
- Support for documents

---

Last Modified: 2023-01-13
24 changes: 18 additions & 6 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "studio1/template-pimcore",
"name": "studio1/workflow-extend",
"type": "pimcore-bundle",
"license": "GPL-3.0-or-later",
"description": "TemplateBundle for Pimcore",
"description": "This bundles extends pimcores workflow engine and workflow designer with additional features.",
"config": {
"allow-plugins": {
"cweagans/composer-patches": true
}
},
"authors": [
{
"name": "Studio1 Kommunikation GmbH",
Expand All @@ -13,18 +17,26 @@
],
"autoload": {
"psr-4": {
"Studio1\\MiddlewareBundle\\": "src/"
"Studio1\\WorkflowExtendBundle\\": "src/"
}
},
"extra": {
"pimcore": {
"bundles": [
"Studio1\\TemplatePimcoreBundle\\TemplatePimcoreBundle"
"Studio1\\WorkflowExtendBundle\\WorkflowExtendBundle"
]
},
"patches": {
"pimcore/pimcore": {
"WorkFlowExtendBundle extend dependency injection patch": "vendor/studio1/workflow-extend/patches/addDiConfiguration.patch"
}
}
},
"require": {
"pimcore/pimcore": "^10.0",
"cweagans/composer-patches": "~1.0",
"pimcore/asset-metadata-class-definitions": "~1.2",
"pimcore/workflow-designer": "~1.0",
"php": "^8.0"
}
}
}
Binary file added docs/backend_configuration.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed install/class_source/.gitkeep
Empty file.
27 changes: 27 additions & 0 deletions patches/addDiConfiguration.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Index: bundles/CoreBundle/DependencyInjection/Configuration.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bundles/CoreBundle/DependencyInjection/Configuration.php b/bundles/CoreBundle/DependencyInjection/Configuration.php
--- a/bundles/CoreBundle/DependencyInjection/Configuration.php
+++ b/bundles/CoreBundle/DependencyInjection/Configuration.php (date 1673604646885)
@@ -1835,6 +1835,18 @@
->arrayNode('options')
->children()
->scalarNode('label')->info('Nice name for the Pimcore backend.')->end()
+ // Studio1 start
+ ->arrayNode('data')
+ ->children()
+ ->scalarNode('type')->info('')->defaultValue('')->end()
+ ->scalarNode('class')->info('')->defaultValue('')->end()
+ ->scalarNode('attribute')->info('')->defaultValue('')->end()
+ ->scalarNode('languages')->info('')->defaultValue('')->end()
+ ->scalarNode('languagesSetAll')->info('')->defaultValue(false)->end()
+ ->scalarNode('value')->info('')->defaultValue('')->end()
+ ->end()
+ ->end()
+ // Studio1 end
->arrayNode('notes')
->children()
->booleanNode('commentEnabled')->defaultFalse()->info('If enabled a detail window will open when the user executes the transition. In this detail view the user be asked to enter a "comment". This comment then will be used as comment for the notes/events feature.')->end()
Empty file removed src/Controller/.gitkeep
Empty file.
14 changes: 2 additions & 12 deletions src/DependencyInjection/Configuration.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<?php

/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\TemplatePimcoreBundle\DependencyInjection;
namespace Studio1\WorkflowExtendBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand All @@ -27,7 +17,7 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('template_pimcore');
$treeBuilder = new TreeBuilder('w_workflow_extend');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
Expand Down
20 changes: 5 additions & 15 deletions ...ncyInjection/TemplatePimcoreExtension.php → ...encyInjection/WorkflowExtendExtension.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
<?php

/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/

namespace Studio1\TemplatePimcoreBundle\DependencyInjection;
namespace Studio1\WorkflowExtendBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration.
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class TemplatePimcoreExtension extends Extension
class WorkflowExtendExtension extends Extension
{
/**
* {@inheritdoc}
Expand All @@ -32,7 +22,7 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

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

0 comments on commit b429bad

Please sign in to comment.