Skip to content

Commit

Permalink
fix ide inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Sep 20, 2023
1 parent 503263f commit 178519c
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}
Expand Down
12 changes: 12 additions & 0 deletions databox/api/src/Elasticsearch/AbstractSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion databox/api/src/Elasticsearch/AssetDataTemplateSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
25 changes: 0 additions & 25 deletions databox/api/src/Elasticsearch/CollectionSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
5 changes: 1 addition & 4 deletions databox/api/src/Entity/Core/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion databox/api/src/Entity/Template/AssetDataTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion databox/api/src/Form/Type/AceEditorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion databox/api/src/Integration/IntegrationDataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 178519c

Please sign in to comment.