mirror of
https://github.com/code-rhapsodie/ezdataflow-bundle.git
synced 2026-03-24 06:32:06 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ca493e3e8 | ||
|
|
473968791b | ||
|
|
dd655543ce | ||
|
|
d49d23b4fe | ||
|
|
7ab5b5cbd1 | ||
|
|
df1fcd5132 | ||
|
|
35d3788a59 | ||
|
|
c36fef9220 | ||
|
|
b4186ed3ce | ||
|
|
657c269eb3 | ||
|
|
6f1a719314 | ||
|
|
52f607616d |
55
.github/workflows/php.yml
vendored
Normal file
55
.github/workflows/php.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: PHP Composer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-version: [7.3, 7.4, 8.0, 8.1]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP ${{ matrix.php-version }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
extensions: xdebug
|
||||
- name: PHP Version
|
||||
run: php -v
|
||||
|
||||
- name: PHP Lint
|
||||
run: find . -type f -name '*.php' -exec php -l {} \; | (! grep -v "No syntax errors detected" )
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate --strict
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php${{ matrix.php-version }}-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer update --prefer-dist --no-progress --no-scripts
|
||||
|
||||
- name: PHPUnit
|
||||
run: php -d xdebug.mode=coverage vendor/bin/phpunit --log-junit junit.xml
|
||||
|
||||
- name: Publish Unit Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
if: always()
|
||||
with:
|
||||
files: junit.xml
|
||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,8 +1,30 @@
|
||||
# Version 3.1.0
|
||||
|
||||
* Allow `LocationCreateStruct` objects inside the `$locations` argument of `ContentCreateStructure` to have more control over the created locations.
|
||||
|
||||
# Version 3.0.1
|
||||
|
||||
* Bump minimum PHP version to PHP 7.3 like code-rhapsodie/dataflow-bundle dependency.
|
||||
* Allow PHP 8.x.
|
||||
* Add GitHub Action to run tests.
|
||||
|
||||
# Version 3.0.0
|
||||
|
||||
* Add compatibility with Ibexa Content 3.3
|
||||
* Add compatibility with Symfony 5.x
|
||||
|
||||
# Version 2.3.0
|
||||
|
||||
* Added a button to display exceptions / log in a modal
|
||||
* Add log in `CodeRhapsodie\EzDataflowBundle\Filter\NotModifiedContentFilter` and `CodeRhapsodie\EzDataflowBundle\Writer\ContentWriter`
|
||||
|
||||
# Version 2.2.0
|
||||
* added `NotModifiedContentFilter` and a bunch of `FieldComparator` classes
|
||||
|
||||
* Added `NotModifiedContentFilter` and a bunch of `FieldComparator` classes
|
||||
|
||||
# version 2.1.0
|
||||
* contentWriter return created content
|
||||
|
||||
* ContentWriter return created content
|
||||
|
||||
# version 2.0.1
|
||||
|
||||
|
||||
@@ -206,6 +206,8 @@ class MyDataflowType extends AbstractDataflowType
|
||||
ContentStructureFactoryInterface::MODE_INSERT_OR_UPDATE //Optional value. Other choice : ContentStructureFactoryInterface::MODE_INSERT_ONLY or ContentStructureFactoryInterface::MODE_UPDATE_ONLY
|
||||
);
|
||||
});
|
||||
// If you want the writer log
|
||||
$this->contentWriter->setLogger($this->logger);
|
||||
$builder->addWriter($this->contentWriter);
|
||||
}
|
||||
}
|
||||
@@ -228,6 +230,8 @@ public function __construct(NotModifiedContentFilter $notModifiedContentFilter)
|
||||
protected function buildDataflow(DataflowBuilder $builder, array $options): void
|
||||
{
|
||||
//[...]
|
||||
// If you want the filter log
|
||||
$this->notModifiedContentFilter->setLogger($this->logger);
|
||||
$builder->addStep($this->notModifiedContentFilter);
|
||||
//[...]
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1",
|
||||
"code-rhapsodie/dataflow-bundle": "^2.1 || dev-master",
|
||||
"ezsystems/ezplatform-admin-ui": "^1.0",
|
||||
"ezsystems/ezpublish-kernel": "^7.0"
|
||||
"php": "^7.3||^8.0",
|
||||
"code-rhapsodie/dataflow-bundle": "^3.0",
|
||||
"ezsystems/ezplatform-admin-ui": "^2.3",
|
||||
"ezsystems/ezplatform-kernel": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7||^8",
|
||||
"phpunit/phpunit": "^7||^8||^9",
|
||||
"doctrine/dbal": "^2.0"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
|
||||
49
phpunit.xml
49
phpunit.xml
@@ -1,32 +1,21 @@
|
||||
<?xml version = '1.0' encoding = 'UTF-8'?>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
|
||||
<phpunit
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
colors="false"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
<testsuites>
|
||||
<testsuite name="EzDataflow tests suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/</directory>
|
||||
<exclude>
|
||||
<directory>tests/</directory>
|
||||
<directory>vendor/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="tests/bootstrap.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" colors="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory>./src/</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<directory>tests/</directory>
|
||||
<directory>vendor/</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1"/>
|
||||
</php>
|
||||
<testsuites>
|
||||
<testsuite name="EzDataflow tests suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
||||
@@ -4,12 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeRhapsodie\EzDataflowBundle\Controller;
|
||||
|
||||
use CodeRhapsodie\DataflowBundle\Entity\Job;
|
||||
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
|
||||
use CodeRhapsodie\EzDataflowBundle\Form\CreateOneshotType;
|
||||
use CodeRhapsodie\EzDataflowBundle\Form\CreateScheduledType;
|
||||
use CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway;
|
||||
use CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway;
|
||||
use CodeRhapsodie\DataflowBundle\Entity\Job;
|
||||
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute;
|
||||
use EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface;
|
||||
@@ -41,8 +41,6 @@ class DashboardController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/", name="coderhapsodie.ezdataflow.main")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function main(): Response
|
||||
{
|
||||
@@ -69,10 +67,6 @@ class DashboardController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/repeating", name="coderhapsodie.ezdataflow.repeating")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getRepeatingPage(Request $request): Response
|
||||
{
|
||||
@@ -101,10 +95,6 @@ class DashboardController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/oneshot", name="coderhapsodie.ezdataflow.oneshot")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getOneshotPage(Request $request): Response
|
||||
{
|
||||
@@ -126,10 +116,6 @@ class DashboardController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/history", name="coderhapsodie.ezdataflow.history")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getHistoryPage(Request $request): Response
|
||||
{
|
||||
@@ -142,11 +128,6 @@ class DashboardController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/history/schedule/{id}", name="coderhapsodie.ezdataflow.history.workflow")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getHistoryForScheduled(Request $request, int $id): Response
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @Route("/ezdataflow/job")
|
||||
@@ -26,7 +26,7 @@ class JobController extends Controller
|
||||
private $jobGateway;
|
||||
/** @var NotificationHandlerInterface */
|
||||
private $notificationHandler;
|
||||
/** @var TranslatorInterface */
|
||||
/** @var Symfony\Component\Translation\TranslatorInterface|Symfony\Contracts\Translation\TranslatorInterface */
|
||||
private $translator;
|
||||
|
||||
public function __construct(
|
||||
@@ -41,10 +41,6 @@ class JobController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/details/{id}", name="coderhapsodie.ezdataflow.job.details")
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function displayDetails(int $id): Response
|
||||
{
|
||||
@@ -56,12 +52,28 @@ class JobController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/create", name="coderhapsodie.ezdataflow.job.create", methods={"POST"})
|
||||
* @Route("/details/log/{id}", name="coderhapsodie.ezdataflow.job.log")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function displayLog(int $id): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'view'));
|
||||
$item = $this->jobGateway->find($id);
|
||||
$log = array_map(function ($line) {
|
||||
return preg_replace('~#\d+~', "\n$0", $line);
|
||||
}, $item->getExceptions());
|
||||
|
||||
return $this->render('@ezdesign/ezdataflow/Item/log.html.twig', [
|
||||
'log' => $log,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/create", name="coderhapsodie.ezdataflow.job.create", methods={"POST"})
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'edit'));
|
||||
|
||||
@@ -4,11 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeRhapsodie\EzDataflowBundle\Controller;
|
||||
|
||||
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
|
||||
use CodeRhapsodie\EzDataflowBundle\Form\CreateScheduledType;
|
||||
use CodeRhapsodie\EzDataflowBundle\Form\UpdateScheduledType;
|
||||
use CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway;
|
||||
use CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway;
|
||||
use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow;
|
||||
use CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway;
|
||||
use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute;
|
||||
use EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface;
|
||||
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller;
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @Route("/ezdataflow/scheduled_workflow")
|
||||
@@ -32,8 +32,12 @@ class ScheduledDataflowController extends Controller
|
||||
/** @var TranslatorInterface */
|
||||
private $translator;
|
||||
|
||||
public function __construct(JobGateway $jobGateway, NotificationHandlerInterface $notificationHandler, ScheduledDataflowGateway $scheduledDataflowGateway, TranslatorInterface $translator)
|
||||
{
|
||||
public function __construct(
|
||||
JobGateway $jobGateway,
|
||||
NotificationHandlerInterface $notificationHandler,
|
||||
ScheduledDataflowGateway $scheduledDataflowGateway,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->jobGateway = $jobGateway;
|
||||
$this->notificationHandler = $notificationHandler;
|
||||
$this->scheduledDataflowGateway = $scheduledDataflowGateway;
|
||||
@@ -42,10 +46,6 @@ class ScheduledDataflowController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/create", name="coderhapsodie.ezdataflow.workflow.create", methods={"POST"})
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
@@ -63,7 +63,8 @@ class ScheduledDataflowController extends Controller
|
||||
$this->scheduledDataflowGateway->save($newWorkflow);
|
||||
$this->notificationHandler->success($this->translator->trans('coderhapsodie.ezdataflow.workflow.create.success'));
|
||||
} catch (\Exception $e) {
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.create.error', ['message' => $e->getMessage()]));
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.create.error',
|
||||
['message' => $e->getMessage()]));
|
||||
}
|
||||
|
||||
return new JsonResponse(['redirect' => $this->generateUrl('coderhapsodie.ezdataflow.main')]);
|
||||
@@ -79,10 +80,6 @@ class ScheduledDataflowController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/{id}/delete", name="coderhapsodie.ezdataflow.workflow.delete", methods={"post"})
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function delete(int $id): Response
|
||||
{
|
||||
@@ -94,7 +91,8 @@ class ScheduledDataflowController extends Controller
|
||||
|
||||
return new JsonResponse(['code' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.delete.error', ['message' => $e->getMessage()]));
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.delete.error',
|
||||
['message' => $e->getMessage()]));
|
||||
|
||||
return new JsonResponse(['code' => $e->getCode()]);
|
||||
}
|
||||
@@ -102,11 +100,6 @@ class ScheduledDataflowController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", name="coderhapsodie.ezdataflow.workflow.edit")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Request $request, int $id): Response
|
||||
{
|
||||
@@ -123,7 +116,8 @@ class ScheduledDataflowController extends Controller
|
||||
$this->scheduledDataflowGateway->save($editDataflow);
|
||||
$this->notificationHandler->success($this->translator->trans('coderhapsodie.ezdataflow.workflow.edit.success'));
|
||||
} catch (\Exception $e) {
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.edit.error', ['message' => $e->getMessage()]));
|
||||
$this->notificationHandler->error($this->translator->trans('coderhapsodie.ezdataflow.workflow.edit.error',
|
||||
['message' => $e->getMessage()]));
|
||||
}
|
||||
|
||||
return new JsonResponse(['redirect' => $this->generateUrl('coderhapsodie.ezdataflow.main')]);
|
||||
@@ -139,10 +133,6 @@ class ScheduledDataflowController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/{id}/enable", name="coderhapsodie.ezdataflow.workflow.enable")
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function enableDataflow(int $id): Response
|
||||
{
|
||||
@@ -153,22 +143,6 @@ class ScheduledDataflowController extends Controller
|
||||
return $this->redirectToRoute('coderhapsodie.ezdataflow.main');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/disable", name="coderhapsodie.ezdataflow.workflow.disable")
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function disableDataflow(int $id): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'edit'));
|
||||
|
||||
$this->changeDataflowStatus($id, false);
|
||||
|
||||
return $this->redirectToRoute('coderhapsodie.ezdataflow.main');
|
||||
}
|
||||
|
||||
private function changeDataflowStatus(int $id, bool $status)
|
||||
{
|
||||
try {
|
||||
@@ -182,4 +156,16 @@ class ScheduledDataflowController extends Controller
|
||||
$this->notificationHandler->error(sprintf('An error occured : "%s".', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/disable", name="coderhapsodie.ezdataflow.workflow.disable")
|
||||
*/
|
||||
public function disableDataflow(int $id): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'edit'));
|
||||
|
||||
$this->changeDataflowStatus($id, false);
|
||||
|
||||
return $this->redirectToRoute('coderhapsodie.ezdataflow.main');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,6 @@ class ContentCreator implements ContentCreatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContentCreateStructure $structure
|
||||
*
|
||||
* @return Content
|
||||
*
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException
|
||||
@@ -58,17 +54,21 @@ class ContentCreator implements ContentCreatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $locations
|
||||
*
|
||||
* @return LocationCreateStruct[]
|
||||
*/
|
||||
private function getLocationCreateStructs(array $locations): array
|
||||
{
|
||||
$locationCreateStructs = [];
|
||||
|
||||
foreach ($locations as $locationOrIdOrRemoteId) {
|
||||
foreach ($locations as $locationOrIdOrRemoteIdOrStruct) {
|
||||
if ($locationOrIdOrRemoteIdOrStruct instanceof LocationCreateStruct) {
|
||||
$locationCreateStructs[] = $locationOrIdOrRemoteIdOrStruct;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$locationCreateStructs[] = new LocationCreateStruct([
|
||||
'parentLocationId' => $this->matcher->matchLocation($locationOrIdOrRemoteId)->id,
|
||||
'parentLocationId' => $this->matcher->matchLocation($locationOrIdOrRemoteIdOrStruct)->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@ class ContentUpdater implements ContentUpdaterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContentUpdateStructure $structure
|
||||
*
|
||||
* @return Content
|
||||
*
|
||||
* @throws NoMatchFoundException
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException
|
||||
|
||||
@@ -17,8 +17,6 @@ class ContentStructFieldFiller implements ContentStructFieldFillerInterface
|
||||
|
||||
/**
|
||||
* ContentStructFieldFiller constructor.
|
||||
*
|
||||
* @param iterable $fieldValueCreators
|
||||
*/
|
||||
public function __construct(iterable $fieldValueCreators)
|
||||
{
|
||||
@@ -47,10 +45,7 @@ class ContentStructFieldFiller implements ContentStructFieldFillerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fieldTypeIdentifier
|
||||
* @param mixed $hash
|
||||
*
|
||||
* @return Value
|
||||
* @param mixed $hash
|
||||
*
|
||||
* @throws UnsupportedFieldTypeException
|
||||
*/
|
||||
|
||||
@@ -9,10 +9,5 @@ use eZ\Publish\API\Repository\Values\ContentType\ContentType;
|
||||
|
||||
interface ContentStructFieldFillerInterface
|
||||
{
|
||||
/**
|
||||
* @param ContentType $contentType
|
||||
* @param ContentStruct $contentStruct
|
||||
* @param array $fieldHashes
|
||||
*/
|
||||
public function fillFields(ContentType $contentType, ContentStruct $contentStruct, array $fieldHashes): void;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeRhapsodie\EzDataflowBundle\Core\Field;
|
||||
|
||||
use eZ\Publish\API\Repository\FieldType;
|
||||
use eZ\Publish\API\Repository\FieldTypeService;
|
||||
use eZ\Publish\Core\FieldType\Value;
|
||||
|
||||
|
||||
@@ -8,18 +8,10 @@ use eZ\Publish\Core\FieldType\Value;
|
||||
|
||||
interface FieldValueCreatorInterface
|
||||
{
|
||||
/**
|
||||
* @param string $fieldTypeIdentifier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supports(string $fieldTypeIdentifier): bool;
|
||||
|
||||
/**
|
||||
* @param string $fieldTypeIdentifier
|
||||
* @param mixed $hash
|
||||
*
|
||||
* @return Value
|
||||
* @param mixed $hash
|
||||
*/
|
||||
public function createValue(string $fieldTypeIdentifier, $hash): Value;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace CodeRhapsodie\EzDataflowBundle\Exception;
|
||||
class UnknownFieldException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @param string $fieldIdentifier
|
||||
* @param string $contentTypeIdentifier
|
||||
*
|
||||
* @return UnknownFieldException
|
||||
*/
|
||||
public static function create(string $fieldIdentifier, string $contentTypeIdentifier): self
|
||||
|
||||
@@ -19,8 +19,6 @@ final class ContentStructureFactory implements ContentStructureFactoryInterface
|
||||
|
||||
/**
|
||||
* ContentStructureFactory constructor.
|
||||
*
|
||||
* @param ContentService $contentService
|
||||
*/
|
||||
public function __construct(ContentService $contentService)
|
||||
{
|
||||
@@ -28,12 +26,8 @@ final class ContentStructureFactory implements ContentStructureFactoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string $remoteId
|
||||
* @param string $language
|
||||
* @param string $contentType
|
||||
* @param mixed $parentLocations
|
||||
* @param int $mode One of the constant ContentStructureFactoryInterface::MODE_*
|
||||
* @param mixed $parentLocations
|
||||
* @param int $mode One of the constant ContentStructureFactoryInterface::MODE_*
|
||||
*
|
||||
* @return false|ContentStructure
|
||||
*
|
||||
|
||||
@@ -11,10 +11,6 @@ interface ContentStructureFactoryInterface
|
||||
public const MODE_UPDATE_ONLY = 3;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param string $remoteId
|
||||
* @param string $language
|
||||
* @param string $contentType
|
||||
* @param int|string $parentLocations Int for location id or string for remote location id
|
||||
* @param int $mode ContentStructureFactoryInterface
|
||||
*
|
||||
|
||||
@@ -7,18 +7,22 @@ namespace CodeRhapsodie\EzDataflowBundle\Filter;
|
||||
use CodeRhapsodie\EzDataflowBundle\Core\FieldComparator\FieldComparatorInterface;
|
||||
use CodeRhapsodie\EzDataflowBundle\Model\ContentUpdateStructure;
|
||||
use eZ\Publish\API\Repository\ContentService;
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Filters ContentUpdateStructure that would not result in any actual changes in the content.
|
||||
*/
|
||||
class NotModifiedContentFilter
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/** @var ContentService */
|
||||
private $contentService;
|
||||
|
||||
/** @var FieldComparatorInterface */
|
||||
private $comparator;
|
||||
|
||||
|
||||
public function __construct(ContentService $contentService, FieldComparatorInterface $comparator)
|
||||
{
|
||||
$this->contentService = $contentService;
|
||||
@@ -46,6 +50,15 @@ class NotModifiedContentFilter
|
||||
}
|
||||
|
||||
// All fields are identical, filter this item out.
|
||||
$this->log('info', 'Not modified content skipped', ['id' => $data->getId(), 'remote_id' => $data->getRemoteId()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
private function log(string $level, string $message, array $context = [])
|
||||
{
|
||||
if ($this->logger === null) {
|
||||
return;
|
||||
}
|
||||
$this->logger->log($level, $message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,6 @@ final class JobGateway
|
||||
->addOrderBy('w.requested_date', 'DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Job $job
|
||||
*/
|
||||
public function save(Job $job)
|
||||
{
|
||||
$this->jobRepository->save($job);
|
||||
|
||||
@@ -29,17 +29,12 @@ final class ScheduledDataflowGateway
|
||||
->addOrderBy('s.label', 'ASC');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ScheduledDataflow $scheduledDataflow
|
||||
*/
|
||||
public function save(ScheduledDataflow $scheduledDataflow)
|
||||
{
|
||||
$this->scheduledDataflowRepository->save($scheduledDataflow);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function delete(int $id): void
|
||||
|
||||
@@ -22,8 +22,6 @@ class LocationMatcher implements LocationMatcherInterface
|
||||
/**
|
||||
* @param mixed $valueToMatch
|
||||
*
|
||||
* @return Location
|
||||
*
|
||||
* @throws NoMatchFoundException
|
||||
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
|
||||
*/
|
||||
|
||||
@@ -10,8 +10,6 @@ interface LocationMatcherInterface
|
||||
{
|
||||
/**
|
||||
* @param mixed $valueToMatch
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public function matchLocation($valueToMatch): Location;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CodeRhapsodie\EzDataflowBundle\Model;
|
||||
|
||||
use CodeRhapsodie\EzDataflowBundle\Exception\InvalidArgumentTypeException;
|
||||
use eZ\Publish\API\Repository\Values\Content\Location;
|
||||
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
|
||||
|
||||
class ContentCreateStructure extends ContentStructure
|
||||
{
|
||||
@@ -18,17 +19,14 @@ class ContentCreateStructure extends ContentStructure
|
||||
/**
|
||||
* ContentCreateStructure constructor.
|
||||
*
|
||||
* @param string $contentTypeIdentifier
|
||||
* @param string $languageCode
|
||||
* @param array $locations
|
||||
* A location can be any of the following:
|
||||
* <ul>
|
||||
* <li>an integer, the id of the Location object</li>
|
||||
* <li>a string, the remote id of the Location object</li>
|
||||
* <li>a Location object</li>
|
||||
* </ul>
|
||||
* @param array $fields
|
||||
* @param string|null $remoteId
|
||||
* @param array $locations
|
||||
* A location can be any of the following:
|
||||
* <ul>
|
||||
* <li>an integer, the id of the Location object</li>
|
||||
* <li>a string, the remote id of the Location object</li>
|
||||
* <li>a Location object</li>
|
||||
* <li>a LocationCreateStruct object</li>
|
||||
* </ul>
|
||||
*
|
||||
* @throws InvalidArgumentTypeException
|
||||
*/
|
||||
@@ -41,35 +39,28 @@ class ContentCreateStructure extends ContentStructure
|
||||
$this->remoteId = $remoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentTypeIdentifier(): string
|
||||
{
|
||||
return $this->contentTypeIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLocations(): array
|
||||
{
|
||||
return $this->locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $locations
|
||||
*
|
||||
* @throws InvalidArgumentTypeException
|
||||
*/
|
||||
private function setLocations(array $locations)
|
||||
{
|
||||
foreach ($locations as $locationOrIdOrRemoteId) {
|
||||
if (!is_int($locationOrIdOrRemoteId)
|
||||
&& !is_string($locationOrIdOrRemoteId)
|
||||
&& !$locationOrIdOrRemoteId instanceof Location
|
||||
foreach ($locations as $locationOrIdOrRemoteIdOrStruct) {
|
||||
if (!is_int($locationOrIdOrRemoteIdOrStruct)
|
||||
&& !is_string($locationOrIdOrRemoteIdOrStruct)
|
||||
&& !$locationOrIdOrRemoteIdOrStruct instanceof Location
|
||||
&& !$locationOrIdOrRemoteIdOrStruct instanceof LocationCreateStruct
|
||||
) {
|
||||
throw InvalidArgumentTypeException::create(['int', 'string', Location::class], $locationOrIdOrRemoteId);
|
||||
throw InvalidArgumentTypeException::create(['int', 'string', Location::class, LocationCreateStruct::class], $locationOrIdOrRemoteIdOrStruct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,25 +15,16 @@ abstract class ContentStructure
|
||||
/** @var array */
|
||||
protected $fields;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRemoteId(): ?string
|
||||
{
|
||||
return $this->remoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLanguageCode(): string
|
||||
{
|
||||
return $this->languageCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
return $this->fields;
|
||||
|
||||
@@ -16,10 +16,6 @@ class ContentUpdateStructure extends ContentStructure
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $languageCode
|
||||
* @param array $fields
|
||||
*
|
||||
* @return ContentUpdateStructure
|
||||
*/
|
||||
public static function createForContentId(int $id, string $languageCode, array $fields): self
|
||||
@@ -31,10 +27,6 @@ class ContentUpdateStructure extends ContentStructure
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $remoteId
|
||||
* @param string $languageCode
|
||||
* @param array $fields
|
||||
*
|
||||
* @return ContentUpdateStructure
|
||||
*/
|
||||
public static function createForContentRemoteId(string $remoteId, string $languageCode, array $fields): self
|
||||
@@ -45,9 +37,6 @@ class ContentUpdateStructure extends ContentStructure
|
||||
return $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
||||
@@ -9,25 +9,40 @@ services:
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Controller\DashboardController:
|
||||
public: true
|
||||
tags:
|
||||
- { name: controller.service_arguments }
|
||||
arguments:
|
||||
$jobGateway: '@CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway'
|
||||
$notificationHandler: '@EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface'
|
||||
$scheduledDataflowGateway: '@CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway'
|
||||
calls:
|
||||
- ['setContainer', ['@service_container']]
|
||||
- ['performAccessCheck', []]
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Controller\ScheduledDataflowController:
|
||||
public: true
|
||||
tags:
|
||||
- { name: controller.service_arguments }
|
||||
arguments:
|
||||
$jobGateway: '@CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway'
|
||||
$notificationHandler: '@EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface'
|
||||
$scheduledDataflowGateway: '@CodeRhapsodie\EzDataflowBundle\Gateway\ScheduledDataflowGateway'
|
||||
$translator: '@translator'
|
||||
calls:
|
||||
- [ 'setContainer', [ '@service_container' ] ]
|
||||
- [ 'performAccessCheck', [ ] ]
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Controller\JobController:
|
||||
public: true
|
||||
tags:
|
||||
- { name: controller.service_arguments }
|
||||
arguments:
|
||||
$jobGateway: '@CodeRhapsodie\EzDataflowBundle\Gateway\JobGateway'
|
||||
$notificationHandler: '@EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface'
|
||||
$translator: '@translator'
|
||||
calls:
|
||||
- [ 'setContainer', [ '@service_container' ] ]
|
||||
- [ 'performAccessCheck', [ ] ]
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Writer\RepositoryWriter:
|
||||
abstract: true
|
||||
@@ -113,21 +128,28 @@ services:
|
||||
CodeRhapsodie\EzDataflowBundle\Tab\RepeatingTab:
|
||||
parent: EzSystems\EzPlatformAdminUi\Tab\AbstractTab
|
||||
public: false
|
||||
arguments:
|
||||
$httpKernelRuntime: '@twig.runtime.httpkernel'
|
||||
tags:
|
||||
- {name: ezplatform.tab, group: coderhapsodie-ezdataflow}
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Tab\OneshotTab:
|
||||
parent: EzSystems\EzPlatformAdminUi\Tab\AbstractTab
|
||||
public: false
|
||||
arguments:
|
||||
$httpKernelRuntime: '@twig.runtime.httpkernel'
|
||||
tags:
|
||||
- {name: ezplatform.tab, group: coderhapsodie-ezdataflow}
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Tab\HistoryTab:
|
||||
parent: EzSystems\EzPlatformAdminUi\Tab\AbstractTab
|
||||
public: false
|
||||
arguments:
|
||||
$httpKernelRuntime: '@twig.runtime.httpkernel'
|
||||
tags:
|
||||
- {name: ezplatform.tab, group: coderhapsodie-ezdataflow}
|
||||
|
||||
|
||||
CodeRhapsodie\EzDataflowBundle\Filter\NotModifiedContentFilter:
|
||||
arguments:
|
||||
$contentService: '@eZ\Publish\API\Repository\ContentService'
|
||||
@@ -140,3 +162,14 @@ services:
|
||||
arguments:
|
||||
$fieldTypeService: '@eZ\Publish\API\Repository\FieldTypeService'
|
||||
abstract: true
|
||||
|
||||
_cr.admin_tabs.ezdataflow_group:
|
||||
parent: EzSystems\EzPlatformAdminUi\Component\TabsComponent
|
||||
autowire: true
|
||||
autoconfigure: false
|
||||
public: false
|
||||
arguments:
|
||||
$template: '@@ezdesign/ezdataflow/parts/tab/ezdataflow.html.twig'
|
||||
$groupIdentifier: 'coderhapsodie-ezdataflow'
|
||||
tags:
|
||||
- { name: ezplatform.admin_ui.component, group: 'coderhapsodie-ezdataflow' }
|
||||
|
||||
@@ -36,16 +36,18 @@ coderhapsodie.ezdataflow.history.details.request: 'Requested on'
|
||||
coderhapsodie.ezdataflow.history.details.status: Status
|
||||
coderhapsodie.ezdataflow.history.details.start: 'Started on'
|
||||
coderhapsodie.ezdataflow.history.details.end: 'Finished on'
|
||||
coderhapsodie.ezdataflow.history.details.count: 'Items count'
|
||||
coderhapsodie.ezdataflow.history.details.count: 'Items successfully processed'
|
||||
coderhapsodie.ezdataflow.history.details.options: 'Run options'
|
||||
coderhapsodie.ezdataflow.history.details.errors: Errors
|
||||
coderhapsodie.ezdataflow.history.details.type: 'Name of the dataflow executed'
|
||||
coderhapsodie.ezdataflow.history.details.log: 'View log'
|
||||
coderhapsodie.ezdataflow.workflow.repeating.new.title: 'Add a new repeating dataflow'
|
||||
coderhapsodie.ezdataflow.workflow.new.cancel: Cancel
|
||||
coderhapsodie.ezdataflow.workflow.new.submit: Create
|
||||
coderhapsodie.ezdataflow.history.list.empty: 'No execution yet.'
|
||||
coderhapsodie.ezdataflow.workflow.list.empty: 'No repeating workflow configured yet'
|
||||
coderhapsodie.ezdataflow.workflow.history.title: 'Execution history'
|
||||
coderhapsodie.ezdataflow.workflow.log.title: 'Execution log'
|
||||
coderhapsodie.ezdataflow.workflow.list.delete: Delete
|
||||
coderhapsodie.ezdataflow.workflow.delete: 'Are you sure you want to delete this dataflow schedule?'
|
||||
coderhapsodie.ezdataflow.workflow.create.success: 'Dataflow schedule successfully added.'
|
||||
|
||||
@@ -40,12 +40,14 @@ coderhapsodie.ezdataflow.history.details.count: 'Nombre d''objets mis à jour'
|
||||
coderhapsodie.ezdataflow.history.details.options: 'Options de lancement'
|
||||
coderhapsodie.ezdataflow.history.details.errors: Erreurs
|
||||
coderhapsodie.ezdataflow.history.details.type: 'Nom du dataflow exécuté'
|
||||
coderhapsodie.ezdataflow.history.details.log: 'Voir le log'
|
||||
coderhapsodie.ezdataflow.workflow.repeating.new.title: 'Nouvel programmation d''un dataflow récurrent'
|
||||
coderhapsodie.ezdataflow.workflow.new.cancel: Annuler
|
||||
coderhapsodie.ezdataflow.workflow.new.submit: Créer
|
||||
coderhapsodie.ezdataflow.history.list.empty: 'Aucune exécution pour le moment.'
|
||||
coderhapsodie.ezdataflow.workflow.list.empty: 'Aucun dataflow n''a été programmé.'
|
||||
coderhapsodie.ezdataflow.workflow.history.title: 'Historique des exécutions'
|
||||
coderhapsodie.ezdataflow.workflow.log.title: 'Log de l''exécution'
|
||||
coderhapsodie.ezdataflow.workflow.list.delete: Supprimer
|
||||
coderhapsodie.ezdataflow.workflow.delete: 'Êtes-vous sûr de vouloir supprimer ce dataflow ?'
|
||||
coderhapsodie.ezdataflow.workflow.create.success: 'La programmation du dataflow a bien été ajoutée.'
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
{% extends "@ezdesign/layout.html.twig" %}
|
||||
{% extends ["@ezdesign/layout.html.twig", "@ezdesign/ui/layout.html.twig"] %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{% include '@ezdesign/parts/breadcrumbs.html.twig' with { items: [
|
||||
{% include ['@ezdesign/parts/breadcrumbs.html.twig', '@ezdesign/ui/breadcrumbs.html.twig'] with { items: [
|
||||
{ value: 'breadcrumb.admin'|trans(domain='messages')|desc('Admin') },
|
||||
{ value: 'coderhapsodie.ezdataflow'|trans|desc('EzDataflow') }
|
||||
]} %}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_title %}
|
||||
{% include '@ezdesign/parts/page_title.html.twig' with {
|
||||
{% include ['@ezdesign/parts/page_title.html.twig', '@ezdesign/ui/page_title.html.twig'] with {
|
||||
title: 'coderhapsodie.ezdataflow'|trans|desc('EzDataflow'),
|
||||
iconName: 'workflow'
|
||||
} %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ ez_platform_tabs('coderhapsodie-ezdataflow', {}, '@ezdesign/ezdataflow/parts/tab/ezdataflow.html.twig') }}
|
||||
{{ ez_render_component_group('coderhapsodie-ezdataflow', {}, '@ezdesign/ezdataflow/parts/tab/ezdataflow.html.twig') }}
|
||||
|
||||
<div class="modal fade ez-modal show" id="ez-modal--history-details" tabindex="-1" role="dialog" aria-modal="true">
|
||||
<div class="modal-dialog" role="document" style="max-width: 90%">
|
||||
@@ -42,6 +42,10 @@
|
||||
$('.history-details-aware').delegate('.modal-history-details', 'click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#modal_content-details').html('');
|
||||
$('#ez-modal--history-details h3').html("{{ 'coderhapsodie.ezdataflow.workflow.history.title'|trans }}");
|
||||
if ($(this).hasClass('modal-history-log')) {
|
||||
$('#ez-modal--history-details h3').html("{{ 'coderhapsodie.ezdataflow.workflow.log.title'|trans }}");
|
||||
}
|
||||
$('#ez-modal--history-details').modal('show');
|
||||
$.ajax(this.href, {
|
||||
success: function (result) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{% import '@ezdesign/ezdataflow/macros.twig' as macros %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container ez-main-container">
|
||||
<div class="container ez-main-container history-details-aware">
|
||||
{% if item is not null %}
|
||||
<h2>{{ 'coderhapsodie.ezdataflow.history.job.title'|trans }} n°{{ item.id }}</h2>
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{% for line in log %}
|
||||
<p>{{ line|nl2br }}</p>
|
||||
{% endfor %}
|
||||
@@ -41,6 +41,14 @@
|
||||
xlink:href="/bundles/ezplatformadminui/img/ez-icons.svg#about-info"></use>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="{{ path('coderhapsodie.ezdataflow.job.log', {id: job.id}) }}"
|
||||
class="btn btn-icon mx-2 modal-history-details modal-history-log"
|
||||
title="{{ 'coderhapsodie.ezdataflow.history.details.log'|trans }}">
|
||||
<svg class="ez-icon ez-icon--small-medium">
|
||||
<use xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xlink:href="/bundles/ezplatformadminui/img/ez-icons.svg#article"></use>
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -9,9 +9,6 @@ trait UserSwitcherAwareTrait
|
||||
/** @var UserSwitcherInterface */
|
||||
protected $userSwitcher;
|
||||
|
||||
/**
|
||||
* @param UserSwitcherInterface $userSwitcher
|
||||
*/
|
||||
public function setUserSwitcher(UserSwitcherInterface $userSwitcher): void
|
||||
{
|
||||
$this->userSwitcher = $userSwitcher;
|
||||
|
||||
@@ -11,8 +11,12 @@ use CodeRhapsodie\EzDataflowBundle\Model\ContentCreateStructure;
|
||||
use CodeRhapsodie\EzDataflowBundle\Model\ContentStructure;
|
||||
use CodeRhapsodie\EzDataflowBundle\Model\ContentUpdateStructure;
|
||||
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
|
||||
class ContentWriter extends RepositoryWriter implements DelegateWriterInterface
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/** @var ContentCreatorInterface */
|
||||
private $creator;
|
||||
|
||||
@@ -31,14 +35,20 @@ class ContentWriter extends RepositoryWriter implements DelegateWriterInterface
|
||||
public function write($item)
|
||||
{
|
||||
if (!$item instanceof ContentStructure) {
|
||||
$this->log('warning', "Data is not a ContentStucture");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item instanceof ContentCreateStructure) {
|
||||
$this->log('info', 'Save content', [
|
||||
'content_type' => $item->getContentTypeIdentifier(),
|
||||
'content_location' => $item->getLocations()
|
||||
]);
|
||||
return $this->creator->createFromStructure($item);
|
||||
}
|
||||
|
||||
if ($item instanceof ContentUpdateStructure) {
|
||||
$this->log('info', 'Update content', ['id' => $item->getId(), 'remote_id' => $item->getRemoteId()]);
|
||||
return $this->updater->updateFromStructure($item);
|
||||
}
|
||||
}
|
||||
@@ -50,4 +60,12 @@ class ContentWriter extends RepositoryWriter implements DelegateWriterInterface
|
||||
{
|
||||
return $item instanceof ContentStructure;
|
||||
}
|
||||
|
||||
private function log(string $level, string $message, array $context = [])
|
||||
{
|
||||
if ($this->logger === null) {
|
||||
return;
|
||||
}
|
||||
$this->logger->log($level, $message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace CodeRhapsodie\EzDataflowBundle\Writer;
|
||||
|
||||
use CodeRhapsodie\DataflowBundle\DataflowType\Writer\WriterInterface;
|
||||
use CodeRhapsodie\EzDataflowBundle\UserSwitcher\UserSwitcherAwareInterface;
|
||||
use CodeRhapsodie\EzDataflowBundle\UserSwitcher\UserSwitcherAwareTrait;
|
||||
use CodeRhapsodie\DataflowBundle\DataflowType\Writer\WriterInterface;
|
||||
|
||||
abstract class RepositoryWriter implements WriterInterface, UserSwitcherAwareInterface
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user