class Announcement

Same name in other branches
  1. 11.x core/modules/announcements_feed/src/Announcement.php \Drupal\announcements_feed\Announcement

Object containing a single announcement from the feed.

@internal

Hierarchy

Expanded class hierarchy of Announcement

File

core/modules/announcements_feed/src/Announcement.php, line 14

Namespace

Drupal\announcements_feed
View source
final class Announcement {
    
    /**
     * Construct an Announcement object.
     *
     * @param string $id
     *   Unique identifier of the announcement.
     * @param string $title
     *   Title of the announcement.
     * @param string $url
     *   URL where the announcement can be seen.
     * @param string $date_modified
     *   When was the announcement last modified.
     * @param string $date_published
     *   When was the announcement published.
     * @param string $content_html
     *   HTML content of the announcement.
     * @param string $version
     *   Target Drupal version of the announcement.
     * @param bool $featured
     *   Whether this announcement is featured or not.
     */
    public function __construct(string $id, string $title, string $url, string $date_modified, string $date_published, string $content_html, string $version, bool $featured) {
    }
    
    /**
     * Returns the content of the announcement with no markup.
     *
     * @return string
     *   Content of the announcement without markup.
     */
    public function getContent() {
        return strip_tags($this->content_html);
    }
    
    /**
     * Gets the published date in timestamp format.
     *
     * @return int
     *   Date published timestamp.
     */
    public function getDatePublishedTimestamp() {
        return DrupalDateTime::createFromFormat(DATE_ATOM, $this->date_published)
            ->getTimestamp();
    }

}

Members

Title Sort descending Modifiers Object type Summary
Announcement::getContent public function Returns the content of the announcement with no markup.
Announcement::getDatePublishedTimestamp public function Gets the published date in timestamp format.
Announcement::__construct public function Construct an Announcement object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.