Files
Phraseanet/lib/Alchemy/Phrasea/Command/Feedback/Report/MetadataAction.php
jygaulier 69f3b30ee5 PHRAS-3768_feedback-report-per-record (#4421)
* add command feedback:report ; bump back to 4.1.8-rc9
WIP OK TO TEST

* aadd dry, log, ... ; move conf ; bump back to 4.1.8-rc8
WIP OK TO TEST

* add command feedback:report ; bump back to 4.1.8-rc9
WIP OK TO TEST

* aadd dry, log, ... ; move conf ; bump back to 4.1.8-rc8
WIP OK TO TEST

* add default (disabled) conf in conf.d

* Update Version.php

bump version made in #4426
2023-11-30 17:26:14 +01:00

43 lines
1.2 KiB
PHP

<?php
namespace Alchemy\Phrasea\Command\Feedback\Report;
use Twig_Environment;
class MetadataAction extends Action implements ActionInterface
{
/** @var string */
private $fieldName;
/** @var string */
private $method;
/** @var string */
private $delimiter;
public function __construct(Twig_Environment $twig, string $fieldName, array $action_conf)
{
parent::__construct($twig, $action_conf);
$this->fieldName = $fieldName;
$this->method = array_key_exists('method', $action_conf) ? $action_conf['method'] : '';
$this->delimiter = array_key_exists('delimiter', $action_conf) ? $action_conf['delimiter'] : '';
}
public function addAction(array &$actions, array $context)
{
if(!array_key_exists('metadatas', $actions)) {
$actions['metadatas'] = [];
}
$action = [
"field_name" => $this->fieldName,
"value" => trim($this->getValue($context))
];
if($this->method !== '') {
$action['method'] = $this->method;
}
if($this->delimiter !== '') {
$action['delimiter'] = $this->delimiter;
}
$actions['metadatas'][] = $action;
}
}