Skip to content

Commit

Permalink
fix: do not copy unique identifier + copy language and other metadata…
Browse files Browse the repository at this point in the history
… from translations resources
  • Loading branch information
gabrielfs7 committed Oct 24, 2024
1 parent f2654cd commit fa56845
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions models/classes/resources/CopierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use oat\generis\model\fileReference\FileReferenceSerializer;
use oat\tao\model\resources\Specification\RootClassSpecification;
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\tao\model\TaoOntology;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
Expand Down Expand Up @@ -73,6 +74,22 @@ public function __invoke(ContainerConfigurator $configurator): void
service(ClassMetadataMapper::class),
service(FileReferenceSerializer::SERVICE_ID),
service(FileSystemService::SERVICE_ID),
[
TaoOntology::PROPERTY_LANGUAGE,
TaoOntology::PROPERTY_TRANSLATION_STATUS,
TaoOntology::PROPERTY_TRANSLATION_TYPE
]
]
);

$services
->get(InstanceMetadataCopier::class)
->call(
'addPropertyUrisToBlacklist',
[
[
TaoOntology::PROPERTY_UNIQUE_IDENTIFIER,
]
]
);

Expand Down
10 changes: 8 additions & 2 deletions models/classes/resources/Service/InstanceMetadataCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ class InstanceMetadataCopier implements InstanceMetadataCopierInterface
/** @var array<string, bool> */
private $fileProperties = [];

private array $allowedNonCustomerProperties;

public function __construct(
ClassMetadataMapperInterface $classMetadataMapper,
FileReferenceSerializer $fileReferenceSerializer,
FileSystemService $fileSystemService
FileSystemService $fileSystemService,
array $allowedNonCustomerProperties = []
) {
$this->classMetadataMapper = $classMetadataMapper;
$this->fileReferenceSerializer = $fileReferenceSerializer;
$this->fileSystemService = $fileSystemService;
$this->allowedNonCustomerProperties = $allowedNonCustomerProperties;
}

public function addPropertyUriToBlacklist(string $propertyUri): void
Expand Down Expand Up @@ -113,7 +117,9 @@ private function getOriginalProperty(core_kernel_classes_Property $property): ?c
$originalPropertyUri = $this->classMetadataMapper->get($property);

if ($originalPropertyUri === null) {
return $property->isCustom() ? $property : null;
return $property->isCustom() || in_array($property->getUri(), $this->allowedNonCustomerProperties) ?
$property :
null;
}

return $property->getProperty($originalPropertyUri);
Expand Down

0 comments on commit fa56845

Please sign in to comment.