Announcements
in package
uses
Log
The Announcements Class loads announcement configuration files and returns the ones to display
The configration files are simple php files returning an array of this form:
return [
// mandatory! used to set the cookie
'name' => basename(__FILE__, '.php'),
// optional, if not present shown as of now
'from' => DateTimeImmutable(),
// optional, if not present shown forever for a period of 'for'
'to' => DateTimeImmutable(),
// if 'to' is not given the range from 'from' or 'now' to 'to' is calculated
'for' => string, # e.g. 'P1D' period one day. ¹
// The title string used in the template. html tags allowed
'title' => [
'DE' => string,
'FR' => string,
],
// The text string used in the template. html tags allowed
'text' => [
'DE' => string,
'FR' => string,
]
];
¹ see: PHP DateInterval duration documentation
An example file could look like this:
return [
'name' => basename(__FILE__, '.php'),
'from' => new DateTimeImmutable('13.11.2023 13:20:20'),
'to' => new DateTimeImmutable('15.11.2023 20:00'),
'title' => [
'DE' => 'Eine Migration steht an',
'FR' => 'same in french'
],
'text' => [
'DE' => <<<DE_TXT
Ihre Instanz wird auf einen neuen Server migriert.<br> Es wird einen c.a. 20 minütigen Unterbruch
am <b>13.11.2023</b> um <b>20:00</b> geben. Bitte melden sie sich vorher ab und stellen Sie sicher,
dass sie alle Dateneingaben rechtzeitig abschliessen!
DE_TXT,
'FR' => <<<FR_TXT
same in french
FR_TXT
]
];
Tags
Table of Contents
Methods
- __construct() : mixed
- Creates a new Announcemens object
- all() : array<string|int, mixed>
- Returns an array with all Announcement Objects
- toDisplay() : mixed
- Returns all Announcement Objects that have to be displayed
Methods
__construct()
Creates a new Announcemens object
public
__construct(array<string|int, mixed> $directories, Business $business, Owner $user) : mixed
it loops ofer all passed directories and tries to include all php files.
Parameters
all()
Returns an array with all Announcement Objects
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed>toDisplay()
Returns all Announcement Objects that have to be displayed
public
toDisplay([bool $readCookie = true ]) : mixed
Parameters
- $readCookie : bool = true
-
Defaults to true, if set to false cookies are not checked