Commit f2a47e0a authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Issue #3091386 by DieterHolvoet, Guilherme Rabelo, sourabhjain, tmaiochi,...

Issue #3091386 by DieterHolvoet, Guilherme Rabelo, sourabhjain, tmaiochi, bbu23, Yedhukrishnan Pillai: Adhere Drupal Coding Standards
parent 46c246b8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ services:

  content_planner.dashboard_service:
    class: Drupal\content_planner\DashboardService
    arguments: ['@content_planner.dashboard_settings_service']
    arguments: ['@content_planner.dashboard_settings_service', '@module_handler']

  content_planner.dashboard_block_plugin_manager:
    class: Drupal\content_planner\DashboardBlockPluginManager
+13 −11
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@ function content_calendar_theme($existing, $type, $theme, $path) {
      ],
    ],

    'content_calendar' => array(
      'variables' => array(
        'calendar' => array(),
        'node_type_creation_permissions' => array(),
      ),
    ),
    'content_calendar' => [
      'variables' => [
        'calendar' => [],
        'node_type_creation_permissions' => [],
      ],
    ],

    'content_calendar_entry' => [
      'variables' => [
@@ -81,7 +81,9 @@ function content_calendar_form_node_form_alter(&$form,
    $node_type = \Drupal::routeMatch()->getParameter('node_type');

    /**
     * @var $content_type_config_service \Drupal\content_calendar\ContentTypeConfigService
     * Drupal\content_calendar\ContentTypeConfigService definition.
     *
     * @var \Drupal\content_calendar\ContentTypeConfigService $content_type_config_service
     */
    $content_type_config_service = \Drupal::service('content_calendar.content_type_config_service');

@@ -92,9 +94,9 @@ function content_calendar_form_node_form_alter(&$form,
      $date = \Drupal::request()->query->get('publish_on');

      // If the date is a valid MySQL Date.
      if (DateTimeHelper::dateIsMySQLDateOnly($date)) {
      if (DateTimeHelper::dateIsMySqlDateOnly($date)) {

        // Check scheduler for default time
        // Check scheduler for default time.
        $scheduler_config = \Drupal::config('scheduler.settings');
        $default_time = FALSE;
        if ($scheduler_config->get('allow_date_only')) {
@@ -103,7 +105,8 @@ function content_calendar_form_node_form_alter(&$form,
        // Create DrupalDateTime object.
        if ($default_time) {
          $datetime = DrupalDateTime::createFromFormat('Y-m-d H:i:s', $date . ' ' . $default_time);
        } else {
        }
        else {
          $datetime = DrupalDateTime::createFromFormat('Y-m-d', $date);
        }

@@ -111,7 +114,6 @@ function content_calendar_form_node_form_alter(&$form,
        $form['created']['widget'][0]['value']['#default_value'] = $datetime;

        // Assign date to the scheduler date, if it exists.

        if (\Drupal::currentUser()->hasPermission('schedule publishing of nodes')) {
          if (array_key_exists('publish_on', $form)) {
            $form['publish_on']['widget'][0]['value']['#default_value'] = $datetime;
+1 −0
Original line number Diff line number Diff line
@@ -9,5 +9,6 @@ services:

  content_calendar.scheduler_publish_subscriber:
    class: Drupal\content_calendar\EventSubscriber\SchedulerPublishSubScriber
    arguments: ['@module_handler']
    tags:
      - { name: event_subscriber }
+16 −8
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Theme\ThemeManagerInterface;

/**
 *
 * Implements Calendar class.
 */
class Calendar {

@@ -21,18 +21,22 @@ class Calendar {
  protected $themeManager;

  /**
   * Drupal\content_calendar\ContentTypeConfigService definition.
   * The content type config service.
   *
   * @var \Drupal\content_calendar\ContentTypeConfigService
   */
  protected $contentTypeConfigService;

  /**
   * The content calendar service.
   *
   * @var \Drupal\content_calendar\ContentCalendarService
   */
  protected $contentCalendarService;

  /**
   * Defines the Content Type Config entity.
   *
   * @var \Drupal\content_calendar\Entity\ContentTypeConfig[]
   */
  protected $contentTypeConfigEntities;
@@ -61,6 +65,8 @@ class Calendar {
  /**
   * Calendar constructor.
   *
   * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
   *   The theme manager service.
   * @param \Drupal\content_calendar\ContentTypeConfigService $content_type_config_service
   *   The content type config service.
   * @param \Drupal\content_calendar\ContentCalendarService $content_calendar_service
@@ -125,8 +131,8 @@ class Calendar {

    // Place nodes in Calendars.
    $this->placeNodesInCalendars($calendar, $node_basic_data);
    // Get the weekdays based on the Drupal first day of week setting.

    // Get the weekdays based on the Drupal first day of week setting.
    $build = [
      '#theme' => 'content_calendar',
      '#calendar' => $calendar,
@@ -147,6 +153,7 @@ class Calendar {
   * Get all permitted Node Type Creation actions.
   *
   * @return array
   *   Returns an array with permitted node types.
   */
  protected function getPermittedNodeTypeCreationActions() {

@@ -217,8 +224,9 @@ class Calendar {
   * Place Nodes in Calendar.
   *
   * @param array $calendar
   *
   *   Calendar array.
   * @param array $node_basic_data
   *   Array with node basic data.
   */
  protected function placeNodesInCalendars(array &$calendar, array $node_basic_data) {

@@ -236,10 +244,10 @@ class Calendar {
        foreach ($calendar['days'] as &$day) {

          // If date of entry is the current date of the calendar day.
          if ($day['date'] == $calendar_entry->formatSchedulingDateAsMySQLDateOnly()) {
          if ($day['date'] == $calendar_entry->formatSchedulingDateAsMySqlDateOnly()) {

            // Generate a unique key within the day for the entry.
            $key = $calendar_entry->getRelevantDate() . '_' . $calendar_entry->getNodeID();
            $key = $calendar_entry->getRelevantDate() . '_' . $calendar_entry->getNodeId();

            $day['nodes'][$key] = $calendar_entry->build();

@@ -276,9 +284,9 @@ class Calendar {
   * Determines whether the current theme is Gin or a subtheme of Gin.
   *
   * @return bool
   *   TRUE if the current theme is Gin or a subtheme of Gin
   */
  protected function isGinThemeActive()
  {
  protected function isGinThemeActive() {
    $theme = $this->themeManager->getActiveTheme();

    return $theme->getName() === 'gin' || isset($theme->getBaseThemeExtensions()['gin']);
+33 −13
Original line number Diff line number Diff line
@@ -8,33 +8,43 @@ use Drupal\content_calendar\Form\SettingsForm;
use Drupal\content_planner\Component\BaseEntry;

/**
 * Class CalendarEntry.
 * Implements CalendarEntry class.
 *
 * @package Drupal\content_calendar\Component
 */
class CalendarEntry extends BaseEntry {

  /**
   * Desired months to be rendered.
   *
   * @var int
   */
  protected $month;

  /**
   * Desired year to be rendered.
   *
   * @var int
   */
  protected $year;

  /**
   * The content type config.
   *
   * @var \Drupal\content_calendar\Entity\ContentTypeConfig
   */
  protected $contentTypeConfig;

  /**
   * @var \stdClass
   * The node.
   *
   * @var object
   */
  protected $node;

  /**
   * The immutable config to store existing configuration.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $config;
@@ -43,9 +53,13 @@ class CalendarEntry extends BaseEntry {
   * CalendarEntry constructor.
   *
   * @param int $month
   *   The month to display in the calendar.
   * @param int $year
   *   The year to display in the calendar.
   * @param \Drupal\content_calendar\Entity\ContentTypeConfig $content_type_config
   * @param \stdClass $node
   *   Content config type.
   * @param object $node
   *   Node Object.
   */
  public function __construct(
    $month,
@@ -65,8 +79,9 @@ class CalendarEntry extends BaseEntry {
   * Get Node ID.
   *
   * @return mixed
   *   Return id of the node.
   */
  public function getNodeID() {
  public function getNodeId() {
    return $this->node->nid;
  }

@@ -76,6 +91,7 @@ class CalendarEntry extends BaseEntry {
   * When the Scheduler date is empty, then take the creation date.
   *
   * @return int
   *   Return published or created date.
   */
  public function getRelevantDate() {

@@ -90,8 +106,9 @@ class CalendarEntry extends BaseEntry {
   * Format creation date as MySQL Date only.
   *
   * @return string
   *   Return datatime formated.
   */
  public function formatSchedulingDateAsMySQLDateOnly() {
  public function formatSchedulingDateAsMySqlDateOnly() {

    $datetime = DateTimeHelper::convertUnixTimestampToDatetime($this->node->created);

@@ -102,17 +119,18 @@ class CalendarEntry extends BaseEntry {
   * Build.
   *
   * @return array
   *   Returns an builded array.
   */
  public function build() {

    // Get User Picture.
    $user_picture = $this->getUserPictureURL();

    $user_picture = $this->getUserPictureUrl();

    if ($this->node->publish_on) {
      $this->node->scheduled = true;
    } else {
      $this->node->scheduled = false;
      $this->node->scheduled = TRUE;
    }
    else {
      $this->node->scheduled = FALSE;
    }

    // Add time to node object.
@@ -123,12 +141,12 @@ class CalendarEntry extends BaseEntry {
    $options = $this->buildOptions();

    if (\Drupal::currentUser()->hasPermission('manage content calendar')) {
      $this->node->editoptions = true;
      $this->node->editoptions = TRUE;
    }

    if (\Drupal::currentUser()->hasPermission('manage own content calendar')) {
      if ($this->node->uid == \Drupal::currentUser()->id()) {
        $this->node->editoptions = true;
        $this->node->editoptions = TRUE;
      }
    }

@@ -149,6 +167,7 @@ class CalendarEntry extends BaseEntry {
   * Build options before rendering.
   *
   * @return array
   *   Returns an array with the options.
   */
  protected function buildOptions() {

@@ -164,8 +183,9 @@ class CalendarEntry extends BaseEntry {
   * Get the URL of the user picture.
   *
   * @return bool|string
   *   Returns false or string.
   */
  protected function getUserPictureURL() {
  protected function getUserPictureUrl() {

    // If show user thumb is active.
    if ($this->config->get('show_user_thumb')) {
Loading