@@ -176,24 +176,39 @@ function drawBranchInfo(array $release): void
176176}
177177
178178$ eventCards = [];
179+ $ MAX_CONFERENCE_CARDS = 9 ;
180+ $ now = new DateTimeImmutable ();
179181
180- /* todo: Update this with proper date limits when new data is available */
181- foreach ((new NewsHandler ())->getConferences () as $ event ) {
182- $ id = parse_url ($ event ["id " ], PHP_URL_FRAGMENT );
183- $ image = $ event ["newsImage " ]['content ' ] ?? null ;
182+ foreach ((new NewsHandler ())->getConferences () as $ conf ) {
183+ $ finalTeaserDate = $ conf ['finalTeaserDate ' ] ?? null ;
184+ if (!$ finalTeaserDate ) {
185+ continue ;
186+ }
187+
188+ if (DateTimeImmutable::createFromFormat ('Y-m-d ' , $ finalTeaserDate ) < $ now ) {
189+ continue ;
190+ }
191+
192+ $ link = array_find ($ conf ['link ' ], fn (array $ conf ) => ($ conf ['rel ' ] ?? 'alternate ' ) === 'alternate ' );
193+ if ($ link ) {
194+ $ link = str_replace ('https://www.php.net ' , '' , $ link ['href ' ]);
195+ }
196+
197+ $ id = parse_url ($ conf ["id " ], PHP_URL_FRAGMENT );
198+ $ image = $ conf ["newsImage " ]['content ' ] ?? null ;
184199 if ($ image ) {
185200 $ image = '/images/news/ ' . $ image ;
186201 }
187202
188203 $ eventCards [] = new NavCardItem (
189- title: $ event ['title ' ],
190- about: $ event ['summary ' ] ?? '' ,
204+ title: $ conf ['title ' ],
205+ about: $ conf ['summary ' ] ?? '' ,
191206 image: $ image ,
192- href: ' /events ' ,
207+ href: $ link ?? ' /conferences/ ' ,
193208 href_label: 'Explore Event ' ,
194209 );
195210
196- if (count ($ eventCards ) > 12 ) {
211+ if (count ($ eventCards ) > $ MAX_CONFERENCE_CARDS ) {
197212 break ;
198213 }
199214}
0 commit comments