diff --git a/databox/api/src/Api/InputTransformer/TemplateAttributeInputTransformer.php b/databox/api/src/Api/InputTransformer/TemplateAttributeInputTransformer.php index 8e5ed6b7b..4a55b2eee 100644 --- a/databox/api/src/Api/InputTransformer/TemplateAttributeInputTransformer.php +++ b/databox/api/src/Api/InputTransformer/TemplateAttributeInputTransformer.php @@ -35,7 +35,7 @@ public function transform(object $data, string $resourceClass, array $context = $object->setTemplate($data->template); $object->setDefinition($this->getAttributeDefinitionFromInput( $data, - $object->getTemplate() ? $object->getTemplate()->getWorkspace() : null, + $object->getTemplate()?->getWorkspace(), $context )); } diff --git a/databox/api/src/Elasticsearch/AbstractSearch.php b/databox/api/src/Elasticsearch/AbstractSearch.php index a10e22b5a..e1c186550 100644 --- a/databox/api/src/Elasticsearch/AbstractSearch.php +++ b/databox/api/src/Elasticsearch/AbstractSearch.php @@ -86,6 +86,18 @@ private function getPublicWorkspaceIds(): array return $this->em->getRepository(Workspace::class)->getPublicWorkspaceIds(); } + protected function findEntityByIds(string $entityName, array $ids): array + { + return $this->em + ->createQueryBuilder() + ->select('t') + ->from($entityName, 't') + ->where('t.id IN (:ids)') + ->setParameter('ids', $ids) + ->getQuery() + ->getResult(); + } + #[Required] public function setEm(EntityManagerInterface $em): void { diff --git a/databox/api/src/Elasticsearch/AssetDataTemplateSearch.php b/databox/api/src/Elasticsearch/AssetDataTemplateSearch.php index a70cb3514..f262d1e48 100644 --- a/databox/api/src/Elasticsearch/AssetDataTemplateSearch.php +++ b/databox/api/src/Elasticsearch/AssetDataTemplateSearch.php @@ -103,7 +103,7 @@ public function search( protected function createACLBoolQuery(array $filters, ?string $userId, array $groupIds, ?Collection $collection): ?Query\BoolQuery { - $workspaceId = $filters['workspace'] ?? ($collection ? $collection->getWorkspaceId() : null) ?? null; + $workspaceId = $filters['workspace'] ?? ($collection?->getWorkspaceId()) ?? null; if (empty($workspaceId)) { throw new BadRequestHttpException('"workspace" filter is mandatory'); diff --git a/databox/api/src/Elasticsearch/CollectionSearch.php b/databox/api/src/Elasticsearch/CollectionSearch.php index bce3e3137..485795eff 100644 --- a/databox/api/src/Elasticsearch/CollectionSearch.php +++ b/databox/api/src/Elasticsearch/CollectionSearch.php @@ -140,29 +140,4 @@ private function findCollections(array $ids): array { return $this->findEntityByIds(Collection::class, $ids); } - - private function findCollection(string $id): Collection - { - return $this->em->find(Collection::class, $id); - } - - /** - * @return Workspace[] - */ - private function findWorkspaces(array $ids): array - { - return $this->findEntityByIds(Workspace::class, $ids); - } - - private function findEntityByIds(string $entityName, array $ids): array - { - return $this->em - ->createQueryBuilder() - ->select('t') - ->from($entityName, 't') - ->where('t.id IN (:ids)') - ->setParameter('ids', $ids) - ->getQuery() - ->getResult(); - } } diff --git a/databox/api/src/Entity/Core/Asset.php b/databox/api/src/Entity/Core/Asset.php index 9c4662859..c135eec11 100644 --- a/databox/api/src/Entity/Core/Asset.php +++ b/databox/api/src/Entity/Core/Asset.php @@ -339,11 +339,8 @@ public function getTagIds(): array public function getReferenceCollectionId(): ?string { - if (!$this->referenceCollection) { - return null; - } + return $this->referenceCollection?->getId(); - return $this->referenceCollection->getId(); } public function getReferenceCollection(): ?Collection diff --git a/databox/api/src/Entity/Core/WorkspaceItemPrivacyInterface.php b/databox/api/src/Entity/Core/WorkspaceItemPrivacyInterface.php index 02485c20b..eac25be5a 100644 --- a/databox/api/src/Entity/Core/WorkspaceItemPrivacyInterface.php +++ b/databox/api/src/Entity/Core/WorkspaceItemPrivacyInterface.php @@ -15,7 +15,7 @@ interface WorkspaceItemPrivacyInterface // Open to users allowed in the workspace public const PUBLIC_IN_WORKSPACE = 2; - // Item is listed to every users, but content is not accessible + // Item is listed to every user, but content is not accessible public const PRIVATE = 3; // Public to every authenticated users diff --git a/databox/api/src/Entity/Template/AssetDataTemplate.php b/databox/api/src/Entity/Template/AssetDataTemplate.php index c91d8a492..627e1371a 100644 --- a/databox/api/src/Entity/Template/AssetDataTemplate.php +++ b/databox/api/src/Entity/Template/AssetDataTemplate.php @@ -244,7 +244,7 @@ public function getCollectionDepth(): int public function getCollectionId(): ?string { - return $this->collection ? $this->collection->getId() : null; + return $this->collection?->getId(); } public function setIncludeCollectionChildren(bool $includeCollectionChildren): void diff --git a/databox/api/src/Form/Type/AceEditorType.php b/databox/api/src/Form/Type/AceEditorType.php index 5286962fd..204da0e14 100644 --- a/databox/api/src/Form/Type/AceEditorType.php +++ b/databox/api/src/Form/Type/AceEditorType.php @@ -19,7 +19,7 @@ class AceEditorType extends AbstractType public function configureOptions(OptionsResolver $resolver): void { - // Remove id from ace editor wrapper attributes. Id must be generated. + // Remove id from ace editor wrapper attributes. ID must be generated. $wrapperAttrNormalizer = function (Options $options, $aceAttr) { if (is_array($aceAttr)) { if (array_key_exists('id', $aceAttr)) { diff --git a/databox/api/src/Integration/IntegrationDataManager.php b/databox/api/src/Integration/IntegrationDataManager.php index 7c809ed6c..c2111687e 100644 --- a/databox/api/src/Integration/IntegrationDataManager.php +++ b/databox/api/src/Integration/IntegrationDataManager.php @@ -73,7 +73,7 @@ public function getData(WorkspaceIntegration $workspaceIntegration, ?File $file, $criteria = [ 'integration' => $workspaceIntegration->getId(), - 'file' => $file ? $file->getId() : null, + 'file' => $file?->getId(), 'name' => $name, ]; diff --git a/databox/api/src/Validator/SameWorkspaceConstraintValidator.php b/databox/api/src/Validator/SameWorkspaceConstraintValidator.php index d2bef1880..c1c4b20c7 100644 --- a/databox/api/src/Validator/SameWorkspaceConstraintValidator.php +++ b/databox/api/src/Validator/SameWorkspaceConstraintValidator.php @@ -29,7 +29,7 @@ public function validate($value, Constraint $constraint): void foreach ($workspaces as $workspace) { /* @var Workspace $workspace */ - $wId = $workspace ? $workspace->getId() : null; + $wId = $workspace?->getId(); if (null === $wId) { return;