<?php
require_once 'php/model/Article.php';
require_once 'php/model/ArticleManager.php';
require_once 'php/validator/article-validator.php';

if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){
    $category = $_GET["category"];
    try {
        $articleManager = ArticleManager::getInstance();
        $articles = $articleManager->getArticlesByCategory($category);
    } catch (Exception $e) {
        $_SESSION["message"] = "internal_error";
        include_once "content/404.php";
        exit();
    }
}else{
    $_SESSION["message"] = "invalid_category";
    include_once "content/404.php";
    exit();
}
?>