Files
Phraseanet/lib/Alchemy/Phrasea/Controller/Api/InstanceIdAware.php
jygaulier 179431d1b5 PHRAS-3931_phraseanet_local_id_in_api (#4400)
* add "resource_id" to record / story ; formula defined into InstanceIdAware.php

* fix tests

* fix tests

* switch to main/instance_id
2023-10-30 17:15:04 +01:00

32 lines
696 B
PHP

<?php
namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
trait InstanceIdAware
{
private $instanceId;
/**
* @param PropertyAccess $conf
* @return InstanceIdAware
*/
public function setInstanceId(PropertyAccess $conf)
{
$this->instanceId = $conf->get(
['main', 'instance_id'],
md5($conf->get(['main', 'key'], ''))
);
return $this;
}
public function getResourceIdResolver()
{
return function(\record_adapter $record): string {
return $this->instanceId . '_' . $record->getDataboxId() . '_' . $record->getRecordId();
};
}
}