mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 10:34:34 +00:00

* 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
43 lines
1.2 KiB
PHP
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;
|
|
}
|
|
}
|