You are here

public function CalendarEntry::build in Content Planner 8

Build.

Return value

array

File

modules/content_calendar/src/Component/CalendarEntry.php, line 106

Class

CalendarEntry
Class CalendarEntry.

Namespace

Drupal\content_calendar\Component

Code

public function build() {

  // Get User Picture.
  $user_picture = $this
    ->getUserPictureURL();
  if ($this->node->publish_on) {
    $this->node->scheduled = true;
  }
  else {
    $this->node->scheduled = false;
  }

  // Add time to node object.
  $this->node->publish_on_time = DateTimeHelper::convertUnixTimestampToDatetime($this->node->publish_on)
    ->format('H:i');
  $this->node->created_on_time = DateTimeHelper::convertUnixTimestampToDatetime($this->node->created)
    ->format('H:i');

  // Build options.
  $options = $this
    ->buildOptions();
  if (\Drupal::currentUser()
    ->hasPermission('manage content calendar')) {
    $this->node->editoptions = true;
  }
  if (\Drupal::currentUser()
    ->hasPermission('manage own content calendar')) {
    if ($this->node->uid == \Drupal::currentUser()
      ->id()) {
      $this->node->editoptions = true;
    }
  }
  $build = [
    '#theme' => 'content_calendar_entry',
    '#node' => $this->node,
    '#node_type_config' => $this->contentTypeConfig,
    '#month' => $this->month,
    '#year' => $this->year,
    '#user_picture' => $user_picture,
    '#options' => $options,
  ];
  return $build;
}