Author: Matt Stauffer (mattstauffer)
Committer: Derick Rethans (derickr)
Date: 2026-11-12T14:28:28Z

Commit: 
https://github.com/php/web-php/commit/f895103040cb32fc8a5208d7c2ce3a29698d423b
Raw diff: 
https://github.com/php/web-php/commit/f895103040cb32fc8a5208d7c2ce3a29698d423b.diff

Update Conference code to use news category enum; update 'want to see' text to 
differentiate conference vs. cfp

Changed paths:
  A  src/News/Category.php
  M  public/conferences/index.php
  M  src/News/ConferenceSchedule.php


Diff:

diff --git a/public/conferences/index.php b/public/conferences/index.php
index e78c3870b2..17ee6b2d18 100644
--- a/public/conferences/index.php
+++ b/public/conferences/index.php
@@ -1,5 +1,6 @@
 <?php
 
+use phpweb\News\Category;
 use phpweb\News\ConferenceSchedule;
 use phpweb\News\NewsHandler;
 
@@ -51,7 +52,7 @@
 
     if (isset($entry["finalTeaserDate"])) {
         $isPast = $entry["finalTeaserDate"] < $today;
-        if (ConferenceSchedule::termFor($entry) === 'cfp') {
+        if (ConferenceSchedule::termFor($entry) === Category::Cfp) {
             $label = $isPast ? 'CFP closed' : 'CFP closes';
         } else {
             $label = $isPast ? 'Started' : 'Starts';
@@ -120,7 +121,10 @@
 echo $content;
 
 // Build sidebar mirroring the active view: conferences grouped into 
upcoming/past, or CFPs into open/closed.
-$panels = '<p class="prepend"><a href="https://wiki.php.net/conferences";>Want 
to see your conference appear here?</a></p>';
+$panels = sprintf(
+    '<p class="prepend"><a href="https://wiki.php.net/conferences";>Want to see 
your %s appear here?</a></p>',
+    $view === 'cfps' ? 'call for papers' : 'conference',
+);
 
 $renderPanels = static function (array $entries): string {
     $html = '';
diff --git a/src/News/Category.php b/src/News/Category.php
new file mode 100644
index 0000000000..95f3b0d2e3
--- /dev/null
+++ b/src/News/Category.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace phpweb\News;
+
+/**
+ * The category terms a news entry can carry.
+ */
+enum Category: string
+{
+    case Frontpage = 'frontpage';
+    case Releases = 'releases';
+    case Conferences = 'conferences';
+    case Cfp = 'cfp';
+}
diff --git a/src/News/ConferenceSchedule.php b/src/News/ConferenceSchedule.php
index f648cf2373..ad8d166e1a 100644
--- a/src/News/ConferenceSchedule.php
+++ b/src/News/ConferenceSchedule.php
@@ -53,20 +53,22 @@ public function __construct(array $entries, string $today)
     /**
      * The entry's primary term. A few posts announce a conference and open 
its CFP at once,
      * carrying both terms; anything that is a conference is treated as a 
conference (and so
-     * placed by its date), leaving 'cfp' for CFP-only posts.
+     * placed by its date), leaving Cfp for CFP-only posts.
      *
      * @param array<array-key, mixed> $entry
      */
-    public static function termFor(array $entry): ?string
+    public static function termFor(array $entry): ?Category
     {
         $found = null;
         foreach ($entry['category'] as $category) {
-            if ($category['term'] === 'conferences') {
-                return 'conferences';
+            $term = Category::tryFrom($category['term']);
+
+            if ($term === Category::Conferences) {
+                return $term;
             }
 
-            if ($category['term'] === 'cfp') {
-                $found = 'cfp';
+            if ($term === Category::Cfp) {
+                $found = $term;
             }
         }
 
@@ -79,7 +81,7 @@ public static function termFor(array $entry): ?string
     private function assignConferenceOrCfp(array $conferenceOrCfp, string 
$today): void
     {
         $isFuture = isset($conferenceOrCfp['finalTeaserDate']) && 
$conferenceOrCfp['finalTeaserDate'] >= $today;
-        $isCfp = self::termFor($conferenceOrCfp) === 'cfp';
+        $isCfp = self::termFor($conferenceOrCfp) === Category::Cfp;
 
         match (true) {
             $isCfp && $isFuture => $this->openCallsForPapers[] = 
$conferenceOrCfp,

Reply via email to