Skip to content

Commit b4f5962

Browse files
committed
Pimcore X
1 parent b2a9d08 commit b4f5962

16 files changed

+90
-143
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ are available (custom settings which the user can define for runtime execution)
2121
* [Installation & updates](./doc/installationAndUpdates.md)
2222
* [Configuration](./doc/configuration.md)
2323
* [Getting started (basics)](./doc/gettingStarted.md)
24+
* [Commands validator](./doc/commandsValidator.md)
2425
* [Callbacks (Configuration windows)](./doc/callbacks.md)
2526
* [Actions](./doc/actions.md)
2627
* [Meta data files](./doc/metaDataFile.md)

doc/actions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $downloadAction = new Action\Download();
2020
$downloadAction
2121
->setAccessKey('myIcon')
2222
->setLabel('Download Icon')
23-
->setFilePath('/web/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
23+
->setFilePath('/public/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
2424
->setDeleteWithMonitoringItem(false);
2525

2626
$openItemAction = new Action\OpenItem();
@@ -47,7 +47,7 @@ $downloadAction = new Action\Download();
4747
$downloadAction
4848
->setAccessKey('myIcon')
4949
->setLabel('Download Icon')
50-
->setFilePath('/web/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
50+
->setFilePath('/public/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
5151
->setDeleteWithMonitoringItem(false);
5252
$monitoringItem->setActions([
5353
$downloadAction

doc/callbacks.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ When you execute the "regular job", you can select these settings with the "Pred
2424
![callbackPredefined](img/selectPredefined.png)
2525
# Creating your own callbacks
2626

27-
To create a callback you have to add a definition in the /app/config/pimcore/plugin-process-manager.php (section "executorCallbackClasses")
28-
29-
30-
```php
31-
[
32-
"name" => "exportProducts",
33-
"class" => "\\Elements\\Bundle\\ProcessManagerBundle\\Executor\\Callback\\General",
34-
"extJsClass" => "pimcore.plugin.PLUGINNAME.processmanager.executor.callback.exportProducts",
35-
]
27+
To create a callback you have to add a Service definition like this:
28+
29+
```yaml
30+
services:
31+
example:
32+
class : Elements\Bundle\ProcessManagerBundle\Executor\Callback\General
33+
arguments :
34+
$name: "example"
35+
$extJsClass: "pimcore.plugin.processmanager.executor.callback.example"
36+
$jsFile: "/bundles/elementsprocessmanager/js/executor/callback/example.js"
37+
tags:
38+
- { name: "elements.processManager.executorCallbackClasses" }
3639
```
37-
Most of the time you will add a definition like the one above and just alter the "extJsClass" + "name".
38-
The "name" should be unique and the "extJsClass" have to be loaded by your own extension.
40+
41+
Just replace "example" with a unique identifier of your callback window.
3942
4043
The ExtJs Class should extend the pimcore.plugin.processmanager.executor.callback.abstractCallback and implement a "getFormItems" method which returns the configuration fields.
4144
Please take a look at the [callback/example.js](../src/Resources/public/js/executor/callback/example.js) file which should give you a good starting point.

doc/components.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ The bundle consists of 6 main components.
2626

2727
| Class| Description |
2828
| ----- | ----------- |
29-
| \Elements\Bundle\ProcessManagerBundle\Executor\CliCommand | Executes a custom cli command |
3029
|\Elements\Bundle\ProcessManagerBundle\Executor\PimcoreCommand | Executes a pimcore command |
3130
|\Elements\Bundle\ProcessManagerBundle\Executor\ClassMethod | Initializes a Class and calls a method |
3231

@@ -35,6 +34,8 @@ The bundle consists of 6 main components.
3534
| Class| Description |
3635
| ----- | ----------- |
3736
| \Elements\Bundle\ProcessManagerBundle\Executor\Action\Download| Provide a download after a job has finished |
37+
| \Elements\Bundle\ProcessManagerBundle\Executor\Action\OpenItem| Adds a button to open an item (object/document/asset) after a job has finished |
38+
| \Elements\Bundle\ProcessManagerBundle\Executor\Action\JsEvent| Executes a custom JavaScript event after a job has finished |
3839

3940

4041
### Callback Classes
@@ -50,5 +51,6 @@ The bundle consists of 6 main components.
5051
| \Elements\Bundle\ProcessManagerBundle\Executor\Logger\File | Logs the messages to a file. If no file path is specified, the logs are written to /website/var/log/process-manager/(MonitoringItem-ID).log |
5152
|\Elements\Bundle\ProcessManagerBundle\Executor\Logger\Console | The messages are logged to the php stdout (for cli execution) |
5253
|\Elements\Bundle\ProcessManagerBundle\Executor\Logger\Application | The messages are logged to the Application-Logger. The name of the Configuration is used as component name |
54+
|\Elements\Bundle\ProcessManagerBundle\Executor\Logger\Email | The messages are sent per email to the recipient (one email with all logs)|
5355

5456
If "Simple log format" is checked, the Context-Information is omitted (cleaner log messages -> useful for File and Console Logger)

doc/configuration.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
11
### Configuration
2-
The [default configuration file](../src/Resources/install/plugin-process-manager.php) gets copied to `<Pimcore root folder>/var/config/plugin-process-manager.php`. You can change those settings either directly in the file or by overriding it in a new file called `<Pimcore root folder>/app/config/pimcore/plugin-process-manager.php`.
2+
A sample configuration could look like this.
3+
4+
```yaml
5+
elements_process_manager:
6+
archiveThresholdLogs: 14
7+
processTimeoutMinutes : 60
8+
disableShortcutMenu : false
9+
additionalScriptExecutionUsers : ["www-data","stagingUser"]
10+
reportingEmailAddresses : ["[email protected]"]
11+
restApiUsers:
12+
- {username: "tester" , apiKey: "1234"}
13+
- {username: "tester2" , apiKey: "344"}
14+
15+
services:
16+
example:
17+
class : Elements\Bundle\ProcessManagerBundle\Executor\Callback\General
18+
arguments :
19+
$name: "example"
20+
$extJsClass: "pimcore.plugin.processmanager.executor.callback.example"
21+
$jsFile: "/bundles/elementsprocessmanager/js/executor/callback/example.js"
22+
tags:
23+
- { name: "elements.processManager.executorCallbackClasses" }
24+
```
25+
26+
You can execute
27+
```command
28+
bin/console config:dump-reference ElementsProcessManagerBundle
29+
```
30+
to dump the configuration.

doc/installationAndUpdates.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ Please set up the Cronjob which checks/executes the processes.
4646
To update the bundle please use the following command:
4747

4848
```
49-
composer update elements/process-manager-bundle; bin/console pimcore:bundle:update ElementsProcessManagerBundle
49+
composer update elements/process-manager-bundle
50+
./bin/console doctrine:migrations:migrate --prefix=Elements\\Bundle\\ProcessManagerBundle
5051
```
5152

52-
If you want that the migrations of the ProcessManagerBundle are automatically executed when you do a "composer update elements/process-manager-bundle;", please add
53-
"Elements\\Bundle\\ProcessManagerBundle\\Composer::executeMigrationsUp"
54-
to your **project composer.json**
53+
If you want, that the migrations of the ProcessManagerBundle be executed automatically, please add the following
54+
line to your **project composer.json**
5555
```
5656
"scripts": {
57-
"post-create-project-cmd": "Pimcore\\Composer::postCreateProject",
58-
"post-install-cmd": [
59-
//...,
60-
],
6157
"post-update-cmd": [
6258
//...,
63-
"Elements\\Bundle\\ProcessManagerBundle\\Composer::executeMigrationsUp"
59+
"./bin/console doctrine:migrations:migrate --prefix=Elements\\Bundle\\ProcessManagerBundle --no-interaction"
6460
],
6561
```

doc/metaDataFile.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The MetaDataFile Class is a simple data storage which writes data in a json format to a file.
44
It is useful if you for example have to query APIs in a cronjob and you need to store the last successfully execution time...
55

6-
The [ProcessManagerSampleCommandSimple](sample/src/AppBundle/Command/ProcessManagerSampleCommandSimple.php) shows a basic usage.
6+
The [ProcessManagerSampleCommandSimple](sample/src/App/Command/ProcessManagerSampleCommandSimple.php) shows a basic usage.
77

88
Getting the file and writing data:
99
```php

doc/migration.md

+2-31
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,6 @@ bin/console pimcore:bundle:update ElementsProcessManagerBundle
4646
* CliCommand executor has been removed
4747
* ExecuteShellCmdCommand executor has been removed
4848
* ExportToolkit executor has been removed
49-
* Configuration is now done with .yml files (instead of the plugin-process-manager.php)
50-
Please change the settings manually
49+
* **Configuration is now done with .yml files (instead of the plugin-process-manager.php)
50+
Please change the settings manually**
5151
* Executor classes / actions / loggers are now defined as services
52-
53-
54-
## Migration from Pimcore 4 to Pimcore 5
55-
56-
* Create a backup of the following tables:
57-
- plugin_process_manager_callback_setting
58-
- plugin_process_manager_configuration
59-
- plugin_process_manager_monitoring_item
60-
* Update to Pimcore 5 first
61-
* Install the bundle
62-
* The location of the plugin configuration file has changed.
63-
If you can't find it at var/config/plugin-process-manager.php then copy your existing version to that directory or place the config file in /app/config/pimcore/plugin-process-manager.php
64-
65-
* The location of file log files has changed. If you want to rescue them copy them from
66-
/website/var/log/process-manager to /var/logs/process-manager
67-
68-
* The tmp directory has changed. It is now located at /var/tmp
69-
Please note that you may have to adapt your configurations.
70-
71-
* The last step is to migrate the process mananager tables stored in the database.
72-
Execute the "process-manager:migrate" console command. If you need additional mappings just adapt the Migrator class to your needs.
73-
74-
Watch for messages like this one:
75-
76-
pimcore-5@pimcore:~/www$ php bin/console process-manager:migrate
77-
do not have mapping for \ProcessManager\Executor\Action\Download
78-
79-
If there is a mapping missing, add it to the Migrator class.
80-

doc/restApi.md

+3-18
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,10 @@
22

33
The Process Manager also provides a rest service to start jobs...
44
If you want to use the Rest Service you have to define the Pimcore users which should be allowed to execute/list... jobs in the "plugin-process-manager.php" config file.
5-
Therefore add an array "restApiUsers" to the config as shown in the example below
6-
```php
7-
return [
8-
"general" => [
9-
"archive_treshold_logs" => 7,
10-
"executeWithMaintenance" => false,
11-
"processTimeoutMinutes" => 30
12-
],
13-
"restApiUsers" => [
14-
[
15-
"username" => "ckogler",
16-
'apiKey' => "secret"
17-
]
18-
],
19-
20-
...
21-
]
5+
Therefore add an array "restApiUsers" to the config.
6+
A example is shown [here](./configuration.md)
7+
228

23-
```
249
You have to pass the "username" and "apiKey" parameter on each request.
2510

2611
**URL: http://YOUR-DOMAIN/webservice/elementsprocessmanager/rest/execute?username=ckogler&apiKey=secret**

doc/sample/src/App/Command/MultiprocessingSampleCommand.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function execute(InputInterface $input, OutputInterface $output)
3939
}else{
4040
$this->executeParent($input,$output,$monitoringItem); //main process
4141
}
42+
return 0;
4243
}
4344

4445
/**
@@ -67,15 +68,17 @@ protected function executeChild(InputInterface $input, OutputInterface $output,
6768

6869
$monitoringItem->setCurrentWorkload(0)->setTotalWorkload(count($workload))->setMessage('Processing Data')->save();
6970
foreach($workload as $i => $data){
70-
$object = \AppBundle\Model\DataObject\Product::getById($data['id']);
71+
72+
#$object = \AppBundle\Model\DataObject\Product::getById($data['id']);
73+
$object = new \stdClass();
7174

7275
if($data['id'] == 88){
7376
# throw new \Exception('Oh something happened with 88');
7477
}
7578
if($object){
76-
$monitoringItem->setMessage('Updating object ID:' . $object->getId())->setCurrentWorkload($i+1)->save();
77-
$object->setName($data['name'].' MID: ' . $monitoringItem->getId() ,'en');
78-
$object->save();
79+
$monitoringItem->setMessage('Updating object ID:' . $data['id'])->setCurrentWorkload($i+1)->save();
80+
#$object->setName($data['name'].' MID: ' . $monitoringItem->getId() ,'en');
81+
#$object->save();
7982
sleep(1); //just for demo
8083
}
8184
}

doc/sample/src/App/Command/ProcessManagerSampleCommandSimple.php

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
namespace App\Command;
1717

18-
use AppBundle\Model\Product\Car;
19-
use Carbon\Carbon;
2018
use Elements\Bundle\ProcessManagerBundle\MetaDataFile;
2119
use Pimcore\Console\AbstractCommand;
2220
use Symfony\Component\Console\Input\InputInterface;

doc/usageParallelization.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The Processmanager allows you to execute multiple child processes. Before you use the multiprocessing option please make sure
44
that you have read the [Basic usage guide](/doc/usage.md).
55

6-
To get started please take a look at the [Sample Command](/doc/sample/src/AppBundle/Command/MultiprocessingSampleCommand.php) which shows how to use the feature.
6+
To get started please take a look at the [Sample Command](sample/src/App/Command/MultiprocessingSampleCommand.php) which shows how to use the feature.
77

88
When a child process is executed the parameter "--monitoring-item-parent-id" is passed so you have to support this parameter in your command.
99
Depending on the paremeter you can execute different methods... it's up to you.

src/Composer.php

-56
This file was deleted.

src/DependencyInjection/ElementsProcessManagerExtension.php

+18-5
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,32 @@
1717

1818
use Symfony\Component\Config\FileLocator;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
20-
use Symfony\Component\DependencyInjection\Extension\Extension;
2120
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
2221
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
22+
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
2323

24-
class ElementsProcessManagerExtension extends Extension
24+
class ElementsProcessManagerExtension extends ConfigurableExtension implements PrependExtensionInterface
2525
{
26+
/**
27+
* @param ContainerBuilder $container
28+
*/
29+
public function prepend(ContainerBuilder $container)
30+
{
31+
if ($container->hasExtension('doctrine_migrations')) {
32+
$loader = new YamlFileLoader(
33+
$container,
34+
new FileLocator(__DIR__ . '/../Resources/config')
35+
);
36+
37+
$loader->load('doctrine_migrations.yml');
38+
}
39+
}
40+
2641
/**
2742
* {@inheritdoc}
2843
*/
29-
public function load(array $configs, ContainerBuilder $container)
44+
public function loadInternal(array $config, ContainerBuilder $container)
3045
{
31-
$configuration = new Configuration();
32-
$config = $this->processConfiguration($configuration, $configs);
3346
$container->setParameter('elements_process_manager', $config);
3447

3548
$loader = new YamlFileLoader(

src/ExecutionTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ protected static function childProcessCheck(MonitoringItem $monitoringItem){
297297
$monitoringItem->setModificationDate(time())->save();
298298
if($statuses['summary']['failed'] && static::getChildProcessErrorHandling() == 'strict'){
299299
foreach([MonitoringItem::STATUS_RUNNING,MonitoringItem::STATUS_INITIALIZING,MonitoringItem::STATUS_UNKNOWN] as $status){
300-
$items = $statuses['details'][$status];
300+
$items = $statuses['details'][$status] ?? [];
301301
foreach((array)$items as $entry){
302302
$mItem = MonitoringItem::getById($entry['id']);
303303

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
doctrine_migrations:
2+
migrations_paths:
3+
'Elements\Bundle\ProcessManagerBundle\Migrations': '%kernel.project_dir%/vendor/elements/process-manager-bundle/src/Migrations'

0 commit comments

Comments
 (0)