# studio1gmbh/pimcore-workflow-extend architecture

> Architecture diagram of the GitHub repository studio1gmbh/pimcore-workflow-extend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/studio1gmbh/pimcore-workflow-extend
- Repository: https://github.com/studio1gmbh/pimcore-workflow-extend

## Overview

##### Project Type and Purpose
- This is a Pimcore bundle designed to extend the workflow engine/designer with additional data modification during transitions and to display the state ID in the editing interface.
- The README makes it clear that it works by applying patches (via Composer patches) to the core Pimcore functionality and listens to workflow events to set attributes.

##### File Structure
- Top-level files and directories include configuration files (.editorconfig, .gitignore, composer.json, etc.), documentation (docs folder), and patches (patches folder).
- The src directory is organized into:
- DependencyInjection: Contains configuration classes (Configuration.php, WorkflowExtendExtension.php) that integrate the bundle with Pimcore’s DI container.
- EventSubscriber: Contains the SetAttributeSubscriber.php, which listens to workflow.transition events to modify data.
- Resources: Holds additional configuration (for Pimcore, translations, and service definitions).
- The patches directory contains:
- addDiConfiguration.patch: Applies changes to add DI configuration options to the core workflow bundle.
- placeSettings.js.patch and transitionSettings.js.patch: Alter the frontend aspects of the Pimcore Workflow Designer to add extra UI fields/features.

##### README for Additional Insights
- The README explains the installation process (via composer) and the fact that patches are used to modify core functionalities.
- It explicitly mentions the two main functional enhancements: modifying data during transitions and displaying a state id.
- Dependencies and usage examples outline how the system ties into Pimcore’s existing workflows.

a. Main Components:
- Pimcore Core System – Specifically, the Pimcore Workflow Engine and Workflow Designer components.
- The Studio1® Workflow Extend Bundle – This will be represented as a separate module that integrates with Pimcore.
- Within the bundle, highlight:
▪ DependencyInjection & Configuration Modules (Configuration.php, WorkflowExtendExtension.php)
▪ Event Subscriber (SetAttributeSubscriber.php) which listens to workflow events.
▪ Resources (configuration and translations) that dictate settings and UI customization.
- Patches – Represent the three patches (addDiConfiguration, transitionSettings.js, placeSettings.js) as integration points that modify or extend the Pimcore core behavior.
- Composer Patches Plugin – Represent how the bundle patches are applied to the Pimcore core files during installation.

b. Relationships and Interactions:
- An event flow where a workflow transition in Pimcore emits an event that is captured by the SetAttributeSubscriber in the bundle, which then updates data accordingly.
- An interaction from the Composer Patches mechanism to both the Pimcore core and the bundle to showcase the dependency injection of patches.

c. Architectural Patterns and Design Principles:
- Dependency Injection – The bundle leverages a DI mechanism to extend Pimcore’s workflow configuration.
- Event Subscriber Pattern – The SetAttributeSubscriber listens to workflow transitions and modifies attributes.
- Patch-Based Modification – Instead of subclassing, the bundle uses patches to extend existing functionality, which is key to its integration with the Pimcore Enterprise assets.

d. Relevant Technologies, Frameworks, or Libraries:
- Pimcore Workflow Engine/Designer (core platform).
- Composer and Composer Patches plugin (for dependency and patch management).
- PHP (as the language for bundles, DI configuration, and event subscribers).
- YAML & JavaScript (in configuration and UI patch scripts).

##### Elements
▪ Use another for the custom bundle components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Components
    A("Composer Patches Plugin"):::external
    B("Pimcore Core Workflow Engine"):::external
    C("Pimcore Workflow Designer UI"):::external

    %% Workflow Extend Bundle Subgraph
    subgraph "Workflow Extend Bundle"
        D("DependencyInjection Configuration"):::bundle
        E("EventSubscriber (SetAttributeSubscriber)"):::bundle
        F("Resources (Config & Translations)"):::bundle
        G("Patch: addDiConfiguration"):::patch
        H("Patch: transitionSettings.js"):::patch
        I("Patch: placeSettings.js"):::patch
    end

    %% Relationships
    A -->|"applies"| G
    A -->|"applies"| H
    A -->|"applies"| I

    D -->|"injects"| B
    G -->|"modifiesDI"| B

    H -->|"modifiesUI"| C
    I -->|"modifiesUI"| C
    F -->|"enhancesUI"| C

    B -->|"emitsEvent"| E
    E -->|"updatesData"| B

    %% Click Events
    click D "https://github.com/studio1gmbh/pimcore-workflow-extend/tree/pimcore-11/src/DependencyInjection"
    click E "https://github.com/studio1gmbh/pimcore-workflow-extend/blob/pimcore-11/src/EventSubscriber/SetAttributeSubscriber.php"
    click F "https://github.com/studio1gmbh/pimcore-workflow-extend/tree/pimcore-11/src/Resources"
    click G "https://github.com/studio1gmbh/pimcore-workflow-extend/blob/pimcore-11/patches/addDiConfiguration.patch"
    click H "https://github.com/studio1gmbh/pimcore-workflow-extend/blob/pimcore-11/patches/transitionSettings.js.patch"
    click I "https://github.com/studio1gmbh/pimcore-workflow-extend/blob/pimcore-11/patches/placeSettings.js.patch"

    %% Styles
    classDef external fill:#d3e5ff,stroke:#333,stroke-width:2px;
    classDef bundle fill:#e5ffcc,stroke:#333,stroke-width:2px;
    classDef patch fill:#ffe5d3,stroke:#333,stroke-width:2px;
```
