Skip to content

Commit

Permalink
[TASK] Use instanceof where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov committed Apr 15, 2022
1 parent e6446fe commit d561cf2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Classes/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ public function checkFieldKey(ServerRequest $request): Response
// All other fields must be unique per table. Exception: If a field
// with the same field type exists, it may be shared.
$field = $this->tableDefinitionCollection->loadField($table, $fieldKey);
return new JsonResponse(['isAvailable' => ($field === null || $field->type->equals($type))]);

return new JsonResponse(['isAvailable' => (!$field instanceof TcaFieldDefinition || $field->type->equals($type))]);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Classes/Domain/Repository/StorageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,10 @@ public function add(array $element, array $fields, string $table, bool $isNew):
public function remove(string $table, string $elementKey): array
{
$this->currentKey = $elementKey;
// Load
$json = $this->load();

// Remove
$element = $this->tableDefinitionCollection->loadElement($table, $elementKey);

if (!$element) {
if (!$element instanceof ElementTcaDefinition) {
return $json;
}

Expand Down

0 comments on commit d561cf2

Please sign in to comment.