Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 55efda3

Browse files
Make project as symfony bundle
0 parents  commit 55efda3

31 files changed

+2264
-0
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
###> symfony/framework-bundle ###
2+
/.env
3+
/.env.local
4+
/.env.local.php
5+
/.env.test
6+
/.env.*.local
7+
/config/secrets/prod/prod.decrypt.private.php
8+
/public/bundles/
9+
/var/
10+
/vendor/
11+
###< symfony/framework-bundle ###
12+
###> custom ###
13+
/docker-compose.override.yml
14+
/.idea
15+
/.pdepend
16+
/.composer/cache
17+
###< custom ###
18+
19+
###> symfony/webpack-encore-bundle ###
20+
/node_modules/
21+
/public/build/
22+
npm-debug.log
23+
yarn-error.log
24+
###< symfony/webpack-encore-bundle ###
25+
26+
###> squizlabs/php_codesniffer ###
27+
/.phpcs-cache
28+
/phpcs.xml
29+
/.php-cs-fixer.cache
30+
###< squizlabs/php_codesniffer ###

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## CleverAge/ProcessUIBundle
2+
A simple UX for cleverage/processbundle using EasyAdmin
3+
4+
**Installation**
5+
* Import routes
6+
```yaml
7+
#config/routes.yaml
8+
process-ui:
9+
resource: '@CleverAgeProcessUiBundle/Resources/config/routes.yaml'
10+
```
11+
* Run doctrine migration
12+
* Create an user using cleverage:process-ui:user-create console.
13+
14+
Now you can access Process UI via http://your-domain.com/process
15+
16+
**About performance**
17+
18+
In order to make search into ****Process > History**** UI, ProcessUiBundle "index" process logs line into mysql database.
19+
This indexation is made on process end and use symfony/messenger component.
20+
So you can simply say to ProcessUsBundle to index log async.
21+
22+
```yaml
23+
#config/messenger.yaml
24+
framework:
25+
messenger:
26+
transports:
27+
log_index: 'doctrine://default'
28+
29+
routing:
30+
CleverAge\ProcessUiBundle\Message\LogIndexerMessage: log_index
31+
```
32+
33+
Then you have to consume messages by running (use a supervisor to keep consumer alive)
34+
```
35+
bin/console messenger:consume log_index --memory-limit=64M
36+
```
37+
38+
See official symfony/messenger component documentations for more informations https://symfony.com/doc/current/messenger.html
39+
40+
**Integrate CrudController**
41+
42+
Of course you can integrate ProcessUI CRUD into your own easy admin Dashboard
43+
```php
44+
public function configureMenuItems(): iterable
45+
{
46+
/* ... your configuration */
47+
yield MenuItem::linkToCrud('History', null, ProcessExecution::class);
48+
}
49+
```

composer.json

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"name": "cleverage/process-ui-bundle",
3+
"type": "symfony-bundle",
4+
"license": "MIT",
5+
"description": "UI for cleverage/process-bundle",
6+
"minimum-stability": "dev",
7+
"prefer-stable": true,
8+
"authors": [
9+
{
10+
"name": "Baudouin Douliery",
11+
"email": "[email protected]",
12+
"role": "Developer"
13+
},
14+
{
15+
"name": "Grégory Tonon",
16+
"email": "[email protected]",
17+
"role": "Developer"
18+
}
19+
],
20+
"require": {
21+
"php": ">=8.0",
22+
"ext-ctype": "*",
23+
"ext-iconv": "*",
24+
"cleverage/process-bundle": "^3.2",
25+
"easycorp/easyadmin-bundle": "^3.5",
26+
"ddtraceweb/monolog-parser": "^1.3",
27+
"composer/package-versions-deprecated": "1.11.99.2",
28+
"doctrine/doctrine-bundle": "^2.4",
29+
"doctrine/doctrine-migrations-bundle": "^3.1",
30+
"doctrine/orm": "^2.9",
31+
"sensio/framework-extra-bundle": "^6.1",
32+
"symfony/console": "*",
33+
"symfony/messenger": "^5.3",
34+
"symfony/doctrine-messenger": "^5.3",
35+
"symfony/dotenv": "5.3.*",
36+
"symfony/filesystem": "5.3.*",
37+
"symfony/flex": "^1.3.1",
38+
"symfony/form": "5.3.*",
39+
"symfony/framework-bundle": "*",
40+
"symfony/mime": "5.3.*",
41+
"symfony/proxy-manager-bridge": "5.3.*",
42+
"symfony/runtime": "5.3",
43+
"symfony/security-bundle": "5.3.*",
44+
"symfony/stopwatch": "^5.3",
45+
"symfony/twig-bundle": "^5.3",
46+
"symfony/validator": "*",
47+
"symfony/webpack-encore-bundle": "^1.11",
48+
"symfony/yaml": "*",
49+
"twig/extra-bundle": "^2.12|^3.0",
50+
"twig/intl-extra": "^3.3"
51+
},
52+
"config": {
53+
"optimize-autoloader": true,
54+
"preferred-install": {
55+
"*": "dist"
56+
},
57+
"sort-packages": true
58+
},
59+
"autoload": {
60+
"psr-4": {
61+
"CleverAge\\ProcessUiBundle\\": "src/"
62+
}
63+
},
64+
"autoload-dev": {
65+
"psr-4": {
66+
"CleverAge\\ProcessUiBundle\\Tests\\": "tests/"
67+
}
68+
},
69+
"replace": {
70+
"symfony/polyfill-ctype": "*",
71+
"symfony/polyfill-iconv": "*",
72+
"symfony/polyfill-php72": "*"
73+
},
74+
"scripts": {
75+
"auto-scripts": {
76+
"cache:clear": "symfony-cmd",
77+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
78+
},
79+
"post-install-cmd": [
80+
"@auto-scripts"
81+
],
82+
"post-update-cmd": [
83+
"@auto-scripts"
84+
]
85+
},
86+
"conflict": {
87+
"symfony/symfony": "*"
88+
},
89+
"extra": {
90+
"symfony": {
91+
"allow-contrib": false,
92+
"require": "5.3.*"
93+
}
94+
},
95+
"require-dev": {
96+
"doctrine/doctrine-fixtures-bundle": "^3.4",
97+
"phpmd/phpmd": "^2.10",
98+
"phpstan/phpstan": "^0.12.89",
99+
"squizlabs/php_codesniffer": "^3.6",
100+
"symfony/maker-bundle": "^1.31",
101+
"symfony/web-profiler-bundle": "^5.3"
102+
}
103+
}

config/routes.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_process-ui:
2+
prefix: '/process'
3+
resource: ../src/Controller/
4+
type: annotation

config/services.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
parameters:
2+
uploads_directory: '%kernel.project_dir%/public/uploads'
3+
cleverage_processes: '%kernel.project_dir%/config/packages'
4+
process_logs_dir: '%kernel.logs_dir%/process'
5+
6+
services:
7+
_defaults:
8+
autowire: true
9+
autoconfigure: true
10+
bind:
11+
$processLogDir: '%process_logs_dir%'
12+
13+
CleverAge\ProcessUiBundle\:
14+
resource: '../src'
15+
exclude:
16+
- '../src/DependencyInjection/'
17+
- '../src/Entity/'
18+
- '../src/Tests/'
19+
- '../src/Migrations'
20+
21+
CleverAge\ProcessUiBundle\Monolog\Handler\ProcessLogHandler:
22+
arguments: ['%process_logs_dir%']

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"devDependencies": {
3+
"@symfony/stimulus-bridge": "^2.0.0",
4+
"@symfony/webpack-encore": "^1.0.0",
5+
"core-js": "^3.0.0",
6+
"regenerator-runtime": "^0.13.2",
7+
"sass": "^1.34.1",
8+
"stimulus": "^2.0.0",
9+
"webpack-notifier": "^1.6.0"
10+
},
11+
"license": "UNLICENSED",
12+
"private": true,
13+
"scripts": {
14+
"dev-server": "encore dev-server",
15+
"dev": "encore dev",
16+
"watch": "encore dev --watch",
17+
"build": "encore production --progress"
18+
},
19+
"dependencies": {
20+
"@popperjs/core": "^2.9.2",
21+
"bootstrap": "^5.0.1",
22+
"font-awesome": "^4.7.0",
23+
"sass-loader": "11"
24+
}
25+
}

phpcs.xml.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<arg name="basepath" value="."/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
11+
<rule ref="PSR12"/>
12+
13+
<file>bin/</file>
14+
<file>config/</file>
15+
<file>public/</file>
16+
<file>src/</file>
17+
<file>tests/</file>
18+
19+
</ruleset>

src/CleverAgeProcessUiBundle.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
namespace CleverAge\ProcessUiBundle;
3+
4+
use CleverAge\ProcessUiBundle\DependencyInjection\Compiler\RegisterLogHandlerCompilerPass;
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\HttpKernel\Bundle\Bundle;
7+
8+
class CleverAgeProcessUiBundle extends Bundle
9+
{
10+
public const ICON_NEW = 'fa fa-plus';
11+
public const ICON_EDIT = 'far fa-edit';
12+
public const ICON_DELETE = 'fa fa-trash-o';
13+
public const LABEL_NEW = false;
14+
public const LABEL_EDIT = false;
15+
public const LABEL_DELETE = false;
16+
public const CLASS_NEW = '';
17+
public const CLASS_EDIT = 'text-warning';
18+
public const CLASS_DELETE = '';
19+
20+
21+
public function build(ContainerBuilder $container): void
22+
{
23+
parent::build($container);
24+
$container->addCompilerPass(new RegisterLogHandlerCompilerPass());
25+
}
26+
27+
public function getPath(): string
28+
{
29+
return \dirname(__DIR__);
30+
}
31+
}

src/Command/PurgeProcessExecution.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
namespace CleverAge\ProcessUiBundle\Command;
3+
4+
use CleverAge\ProcessUiBundle\Entity\ProcessExecution;
5+
use CleverAge\ProcessUiBundle\Repository\ProcessExecutionRepository;
6+
use Doctrine\Persistence\ManagerRegistry;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputDefinition;
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Input\InputOption;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Symfony\Component\Filesystem\Filesystem;
13+
use Symfony\Component\Finder\Finder;
14+
15+
class PurgeProcessExecution extends Command
16+
{
17+
private ManagerRegistry $managerRegistry;
18+
19+
private string $processLogDir;
20+
21+
/**
22+
* @required
23+
*/
24+
public function setManagerRegistry(ManagerRegistry $managerRegistry): void
25+
{
26+
$this->managerRegistry = $managerRegistry;
27+
}
28+
29+
/**
30+
* @required
31+
*/
32+
public function setProcessLogDir(string $processLogDir): void
33+
{
34+
$this->processLogDir = $processLogDir;
35+
}
36+
37+
protected function configure(): void
38+
{
39+
$this->setName('cleverage:process-ui:purge');
40+
$this->setDescription('Purge process_execution table.');
41+
$this->setDefinition(
42+
new InputDefinition([
43+
new InputOption('days', 'd', InputOption::VALUE_OPTIONAL, 'Days to keep. Default 180', 180),
44+
new InputOption('remove-files', 'rf', InputOption::VALUE_NEGATABLE, 'Remove log files ? (default false)', false)
45+
])
46+
);
47+
}
48+
49+
public function execute(InputInterface $input, OutputInterface $output): int
50+
{
51+
$days = $input->getOption('days');
52+
$removeFiles = $input->getOption('remove-files');
53+
$date = new \DateTime();
54+
$date->modify("-$days day");
55+
if ($removeFiles) {
56+
$finder = new Finder();
57+
$fs = new Filesystem();
58+
$finder->in($this->processLogDir)->date("before " . $date->format(\DateTime::ATOM));
59+
$count = $finder->count();
60+
$fs->remove($finder);
61+
$output->writeln("<info>$count log files are deleted on filesystem.</info>");
62+
}
63+
/** @var ProcessExecutionRepository $repository */
64+
$repository = $this->managerRegistry->getRepository(ProcessExecution::class);
65+
$repository->deleteBefore($date);
66+
67+
$output->writeln('<info>Process Execution before '.$date->format(\DateTime::ATOM).' are deleted into database.</info>');
68+
return Command::SUCCESS;
69+
}
70+
}

0 commit comments

Comments
 (0)