diff --git a/src/Capacity/Loader/Create.php b/src/Capacity/Loader/Create.php new file mode 100644 index 0000000..a6ff2e0 --- /dev/null +++ b/src/Capacity/Loader/Create.php @@ -0,0 +1,47 @@ +withEndpoint(endpoint: new Node\Identifier(sprintf('get%sApi', ucfirst((string) $config['type'])))) + ->withCode(code: compileValueWhenExpression($this->interpreter, $config['code'], 'line')) + ->withData(line: new Node\Expr\Variable('line')) + ; + + if (\array_key_exists('reference_entity', $config)) { + $builder->withReferenceEntity(referenceEntity: new Node\Scalar\String_($config['reference_entity'])); + } + + if (\array_key_exists('reference_entity_attribute', $config)) { + $builder->withReferenceEntityAttribute(referenceEntityAttribute: compileValueWhenExpression($this->interpreter, $config['reference_entity_attribute'], 'line')); + } + + return $builder; + } +} diff --git a/src/Factory/Loader.php b/src/Factory/Loader.php index 28c4a6c..a6ee94c 100644 --- a/src/Factory/Loader.php +++ b/src/Factory/Loader.php @@ -25,6 +25,7 @@ public function __construct( $this->configuration = new Akeneo\Configuration\Loader(); $this->capacities = [ new Akeneo\Capacity\Loader\Upsert($this->interpreter), + new Akeneo\Capacity\Loader\Create($this->interpreter), new Akeneo\Capacity\Loader\UpsertList(), ]; }