Skip to content

Commit

Permalink
Additional check for empty template element "File content"
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Oct 23, 2023
1 parent 5c1eb46 commit 58d23cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/template/models/FileContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,9 @@ public function canEdit($user = null): bool
return PagePermission::canEdit();
}

}
public function isEmpty(): bool
{
return !$this->hasFile();
}

}
3 changes: 2 additions & 1 deletion modules/template/models/OwnerContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public function renderEmpty($options = [])

public function isEmpty()
{
return $this->getInstance() == null;
$instance = $this->getInstance();
return $instance === null || $instance->isEmpty();
}

public function isDefault()
Expand Down
5 changes: 5 additions & 0 deletions modules/template/models/TemplateContentActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,9 @@ public function getOption($options, $key, $default = null)
return isset($options[$key]) ? strval($options[$key]) : $default;
}

public function isEmpty(): bool
{
return false;
}

}

0 comments on commit 58d23cb

Please sign in to comment.