Skip to content

Commit b5f6712

Browse files
committed
feat: import export bundle
1 parent e478fe0 commit b5f6712

19 files changed

+439
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Novactive, https://github.com/Novactive/AlmaviaCXIbexaImportExportBundle <dirtech.web@almaviacx.com>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# AlmaviaCX Ibexa Import/Export Bundle
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
install: true
2+
test: false
3+
repo: Novactive/AlmaviaCXIbexaImportExportBundle
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "almaviacx/ibexaimportexportbundle",
3+
"description": "Bundle that add a way to connect to Ibexa using the SAML protocol",
4+
"keywords": [
5+
"ibexa",
6+
"bundle"
7+
],
8+
"homepage": "https://github.com/Novactive/AlmaviaCXIbexaSamlBundle",
9+
"type": "ibexa-bundle",
10+
"authors": [
11+
{
12+
"name": "AlmaviaCX",
13+
"homepage": "https://almaviacx.com/expertises/web-mobile/",
14+
"email": "dirtech.web@almaviacx.com"
15+
}
16+
],
17+
"license": [
18+
"MIT"
19+
],
20+
"require": {
21+
"php": "^7.3 || ^8.0",
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"AlmaviaCX\\Bundle\\IbexaImportExportBundle\\": "src/bundle",
26+
"AlmaviaCX\\Bundle\\IbexaImportExport\\": "src/lib"
27+
}
28+
},
29+
"extra": {
30+
"thanks": {
31+
"name": "hslavich/oneloginsaml-bundle",
32+
"url": "https://github.com/hslavich/OneloginSamlBundle"
33+
}
34+
}
35+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AlmaviaCX\Bundle\IbexaImportExportBundle;
6+
7+
use Symfony\Component\HttpKernel\Bundle\Bundle;
8+
9+
class AlmaviaCXIbexaImportExportBundle extends Bundle
10+
{
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace AlmaviaCX\Bundle\IbexaImportExportBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\FileLocator;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Extension\Extension;
8+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
9+
10+
class AlmaviaCXIbexaImportExportExtension extends Extension
11+
{
12+
public function load( array $configs, ContainerBuilder $container )
13+
{
14+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
15+
$loader->load('default_settings.yml');
16+
$loader->load('services.yml');
17+
}
18+
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parameters:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
services:
2+
AlmaviaCX\Bundle\IbexaImportExport\Workflow\WorkflowExecutor:
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
declare( strict_types=1 );
3+
4+
namespace AlmaviaCX\Bundle\IbexaImportExport\Job;
5+
6+
class Job
7+
{
8+
public const STATUS_PENDING = 0;
9+
public const STATUS_RUNNING = 1;
10+
public const STATUS_COMPLETED = 2;
11+
public const STATUS_QUEUED = 3;
12+
13+
protected string $workflowIdentifier;
14+
15+
protected int $status = self::STATUS_PENDING;
16+
17+
protected ?\DateTimeInterface $startTime = null;
18+
19+
protected ?\DateTimeInterface $endTime = null;
20+
21+
protected array $options = [];
22+
23+
/**
24+
* @return string
25+
*/
26+
public function getWorkflowIdentifier(): string
27+
{
28+
return $this->workflowIdentifier;
29+
}
30+
31+
public function getStatus(): int
32+
{
33+
return $this->status;
34+
}
35+
36+
public function setStatus( int $status ): void
37+
{
38+
$this->status = $status;
39+
}
40+
41+
public function getStartTime(): ?\DateTimeInterface
42+
{
43+
return $this->startTime;
44+
}
45+
46+
public function setStartTime( ?\DateTimeInterface $startTime ): void
47+
{
48+
$this->startTime = $startTime;
49+
}
50+
51+
public function getEndTime(): ?\DateTimeInterface
52+
{
53+
return $this->endTime;
54+
}
55+
56+
public function setEndTime( ?\DateTimeInterface $endTime ): void
57+
{
58+
$this->endTime = $endTime;
59+
}
60+
61+
/**
62+
* @return array
63+
*/
64+
public function getOptions(): array
65+
{
66+
return $this->options;
67+
}
68+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
declare( strict_types=1 );
3+
4+
namespace AlmaviaCX\Bundle\IbexaImportExport\Job;
5+
6+
use AlmaviaCX\Bundle\IbexaImportExport\Workflow\WorkflowExecutor;
7+
use AlmaviaCX\Bundle\IbexaImportExport\Workflow\WorkflowFactoryRegistry;
8+
9+
class JobProcessor
10+
{
11+
protected WorkflowExecutor $workflowExecutor;
12+
protected WorkflowFactoryRegistry $workflowFactoryRegistry;
13+
protected JobRepository $repository;
14+
15+
public function __construct(
16+
WorkflowExecutor $workflowExecutor,
17+
WorkflowFactoryRegistry $workflowFactoryRegistry,
18+
JobRepository $repository
19+
)
20+
{
21+
$this->repository = $repository;
22+
$this->workflowFactoryRegistry = $workflowFactoryRegistry;
23+
$this->workflowExecutor = $workflowExecutor;
24+
}
25+
26+
public function __invoke(Job $job)
27+
{
28+
$workflowFactory = $this->workflowFactoryRegistry->getFactory( $job->getWorkflowIdentifier());
29+
30+
$job->setStatus(Job::STATUS_RUNNING);
31+
$job->setStartTime(new \DateTime());
32+
$this->repository->save($job);
33+
34+
$workflowResults = ($this->workflowExecutor)($workflowFactory, $job->getOptions());
35+
36+
$job->setStatus(Job::STATUS_COMPLETED);
37+
$job->setEndTime($workflowResults->getEndTime());
38+
$this->repository->save($job);
39+
40+
41+
}
42+
}

0 commit comments

Comments
 (0)