getUser($request); if (!EntryScopeGuard::isOwnerUser($this->grav, $user)) { throw new ForbiddenException('Only the site owner can delete journal entries.'); } $slug = $this->getRouteParam($request, 'slug'); if (!is_string($slug) || !EntryScopeGuard::isSafeSegment($slug)) { throw new ApiException(400, 'Bad Request', 'Invalid entry slug.'); } // Resolve via $pages->find() + parent-route assertion (never raw path // concatenation) — same shared check the save path uses. $page = EntryScopeGuard::resolveActiveDailyChild($this->grav, $slug); if ($page === null) { throw new NotFoundException('Entry not found in the active trip.'); } $path = $page->path(); if (!is_string($path) || $path === '' || !is_dir($path)) { throw new NotFoundException('Entry folder not found.'); } Folder::delete($path); $this->grav['cache']->deleteAll(); return ApiResponse::noContent(); } }