Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acumatica
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
acumatica
Commits
f905674e
Commit
f905674e
authored
Apr 17, 2023
by
Dimitris Bozelos
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3354752
Added runner for list operations
parent
8ccceeb9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
acumatica.services.yml
+8
-0
8 additions, 0 deletions
acumatica.services.yml
src/EntitySync/Runner/Base.php
+82
-0
82 additions, 0 deletions
src/EntitySync/Runner/Base.php
src/EntitySync/Runner/EntityList.php
+51
-0
51 additions, 0 deletions
src/EntitySync/Runner/EntityList.php
with
141 additions
and
0 deletions
acumatica.services.yml
+
8
−
0
View file @
f905674e
...
...
@@ -15,6 +15,14 @@ services:
-
'
@datetime.time'
-
'
@entity_type.manager'
## Runners.
acumatica.entity_sync_runner.entity_list
:
class
:
Drupal\acumatica\EntitySync\Runner\EntityList
arguments
:
-
'
@entity_type.manager'
-
'
@logger.channel.acumatica'
-
'
@entity_sync.import.manager'
## Subscribers.
acumatica.entity_sync_subscriber.variation_import_remote_entity_mapping
:
class
:
Drupal\acumatica\EventSubscriber\VariationImportRemoteEntityMapping
...
...
This diff is collapsed.
Click to expand it.
src/EntitySync/Runner/Base.php
0 → 100644
+
82
−
0
View file @
f905674e
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\acumatica\EntitySync\Runner
;
use
Drupal\entity_sync
\MachineName\Field\Operation
as
OperationField
;
use
Drupal\entity_sync
\Entity\OperationInterface
;
use
Drupal\entity_sync
\Entity\Runner\RunnerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Psr\Log\LoggerInterface
;
/**
* Base class for runnners.
*
* All operations have the same workflow by default. We provide here code that
* wraps the operation execution and handles state transitions.
*/
abstract
class
Base
implements
RunnerInterface
{
/**
* Runs the operation.
*
* The `run` method handles state transitions. Child classes must define the
* actual execution of the operation by implementing this method.
*
* @param \Drupal\entity_sync\Entity\OperationInterface $operation
* The operation to run.
* @param array $context
* Additional context that the runner may need for running the operation.
*/
abstract
protected
function
doRun
(
OperationInterface
$operation
,
array
$context
):
void
;
/**
* Constructs a new Base object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Psr\Log\LoggerInterface $logger
* The module's logger channel.
*/
public
function
__construct
(
protected
EntityTypeManagerInterface
$entityTypeManager
,
protected
LoggerInterface
$logger
)
{
}
/**
* {@inheritdoc}
*/
public
function
run
(
OperationInterface
$operation
,
array
$context
=
[])
{
$transition_id
=
'complete'
;
try
{
$this
->
doRun
(
$operation
,
$context
);
}
catch
(
\Throwable
$throwable
)
{
$transition_id
=
'fail'
;
$this
->
logger
->
error
(
'Operation with ID "@operation_id" failed to run: @throwable @message'
,
[
'@operation_id'
=>
$operation
->
id
(),
'@throwable'
=>
get_class
(
$throwable
),
'@message'
=>
$throwable
->
getMessage
(),
]
);
}
$operation
->
get
(
OperationField
::
STATE
)
->
first
()
->
applyTransitionById
(
$transition_id
);
$this
->
entityTypeManager
->
getStorage
(
'entity_sync_operation'
)
->
save
(
$operation
);
}
}
This diff is collapsed.
Click to expand it.
src/EntitySync/Runner/EntityList.php
0 → 100644
+
51
−
0
View file @
f905674e
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\acumatica\EntitySync\Runner
;
use
Drupal\entity_sync
\Entity\OperationInterface
;
use
Drupal\entity_sync
\Import\ManagerInterface
as
ImportManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Psr\Log\LoggerInterface
;
/**
* Runner for operation configurator plugins that operate on lists of entities.
*
* Currently only supports importing entities. Support for exporting entities
* will be added here.
*/
class
EntityList
extends
Base
{
/**
* Constructs a new EntityList object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Psr\Log\LoggerInterface $logger
* The module's logger channel.
* @param \Drupal\entity_sync\Import\ManagerInterface $importManager
* The Entity Synchronization entity import manager.
*/
public
function
__construct
(
protected
EntityTypeManagerInterface
$entityTypeManager
,
protected
LoggerInterface
$logger
,
protected
ImportManagerInterface
$importManager
)
{
}
/**
* {@inheritdoc}
*/
protected
function
doRun
(
OperationInterface
$operation
,
array
$context
):
void
{
$this
->
importManager
->
importRemoteList
(
$operation
->
bundle
(),
$context
[
'filters'
],
$context
[
'options'
]
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment