From d302d25d38fa9506908c8313e7568c7374a1896c Mon Sep 17 00:00:00 2001
From: s j <sj@1729.be>
Date: Sat, 18 Sep 2021 07:56:56 +0200
Subject: [PATCH 1/2] imp: add message dependency, branch alias

---
 .gitlab-ci.yml                                |  2 +-
 .gitlab-ci/build.php                          |  1 +
 .gitlab-ci/phpstan.neon                       | 43 +++++++++++++++++++
 composer.json                                 | 29 ++++++++-----
 druplan.info.yml                              |  1 +
 .../src/Plugin/migrate/process/State.php      | 19 +++++---
 6 files changed, 77 insertions(+), 18 deletions(-)
 create mode 100644 .gitlab-ci/phpstan.neon

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dc742e4..33fc66f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,7 +24,7 @@ include:
   #   file: '/.gitlab-ci/.gitlab-ci-template.yml'
   # If hosted on an other Gitlab instance.
   # - remote: 'https://gitlab.com/mog33/gitlab-ci-drupal/-/raw/3.x-dev/.gitlab-ci/.gitlab-ci-template.yml'
-  - remote: 'https://git.startx.be/forks/gitlab-ci-drupal/-/raw/3.x-dev/.gitlab-ci/.gitlab-ci-template.yml'
+  - remote: 'https://git.startx.be/forks/gitlab-ci-drupal/-/raw/startx/.gitlab-ci/.gitlab-ci-template.yml'
 
 # If needed by your Gitlab-ci instance, you can set global tags for all jobs.
 # default:
diff --git a/.gitlab-ci/build.php b/.gitlab-ci/build.php
index d56a6e6..6135aa2 100644
--- a/.gitlab-ci/build.php
+++ b/.gitlab-ci/build.php
@@ -54,6 +54,7 @@ $this->composerRequire()
   ->dependency('drupal/resource_planning', 'dev-master')
   ->dependency('drupal/address', '^1.8')
   ->dependency('drupal/profile', '^1.2')
+  ->dependency('drupal/message', '^1.2')
   ->dependency('drupal/migrate_plus', '^5.1.0')
   ->dependency('drupal/migrate_tools', '^5.0.0')
   ->dependency('drupal/migrate_source_csv', '^3.4.0')
diff --git a/.gitlab-ci/phpstan.neon b/.gitlab-ci/phpstan.neon
new file mode 100644
index 0000000..70aaad5
--- /dev/null
+++ b/.gitlab-ci/phpstan.neon
@@ -0,0 +1,43 @@
+includes:
+    - /var/www/.composer/vendor/mglaman/phpstan-drupal/extension.neon
+    - /var/www/.composer/vendor/phpstan/phpstan-deprecation-rules/rules.neon
+parameters:
+    # This level is overriden when using phpqa in .phpqa.yml
+    level: 5
+    drupal:
+        drupal_root: /opt/drupal
+    excludePaths:
+        analyseAndScan:
+            - *RoboFile.php
+            - */tests/*
+            - */Tests/*
+    inferPrivatePropertyTypeFromConstructor: true
+    checkMissingIterableValueType: false
+    ## Samples of common false positive for Drupal, adapt to your code.
+    reportUnmatchedIgnoredErrors: false
+    ignoreErrors:
+    #     - '#Function t not found.#'
+    #     - '#Function node_is_page not found.#'
+    #     - '#Function theme_get_setting not found.#'
+    #     - '#Function file_prepare_directory not found.#'
+    #     - '#Function file_unmanaged_save_data not found.#'
+    #     - '#Function batch_set not found.#'
+    #     - '#Function _locale_parse_js_file not found.#'
+    #     - '#Constant FILE_CREATE_DIRECTORY not found.#'
+    #     - '#Constant FILE_EXISTS_RENAME not found.#'
+    #     - '#Constant FILE_STATUS_PERMANENT not found.#'
+    #     - '#Constant SAVED_NEW not found.#'
+    #     - '#Constant SAVED_UPDATED not found.#'
+    #     - '#Cannot call method toLink\(\) on Drupal\\node\\NodeInterface\|null.#'
+        - '#Unsafe usage of new static\(\).#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$entity.#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$value.#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$title.#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$target_id.#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$end_value.#'
+        - '#Access to an undefined property Drupal\\Core\\Field\\FieldItemListInterface\:\:\$duration.#'
+        - '#Call to an undefined method Drupal\\Core\\Field\\FieldItemListInterface\:\:referencedEntities\(\).#'
+        - '#^Offset .* does not exist on array\(.*$#'
+    #     - '#Call to an undefined method Drupal\\Core\\Database\\Query\\AlterableInterface\:\:execute\(\).#'
+    #     - '#Call to an undefined method Drupal\\Core\\Database\\Query\\AlterableInterface\:\:count\(\).#'
+    #     - '#Call to an undefined method Drupal\\Core\\Access\\AccessResultInterface\:\:setCacheMaxAge\(\).#'
diff --git a/composer.json b/composer.json
index 448b15b..ffc9f2e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,13 +1,22 @@
 {
-    "name": "drupal/druplan",
-    "type": "drupal-module",
-    "description": "DruPlan",
-    "keywords": [
-    ],
-    "homepage": "https://www.drupal.org/project/druplan",
-    "minimum-stability": "dev",
-    "support": {
-        "issues": "https://www.drupal.org/project/issues/druplan",
-        "source": "http://cgit.drupalcode.org/druplan"
+  "name": "drupal/druplan",
+  "type": "drupal-module",
+  "description": "DruPlan",
+  "keywords": [
+  ],
+  "homepage": "https://www.drupal.org/project/druplan",
+  "minimum-stability": "dev",
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/druplan",
+    "source": "http://cgit.drupalcode.org/druplan"
+  },
+  "require": {
+    "drupal/message": "^1.2",
+    "drupal/profile": "^1.3"
+  },
+  "extra": {
+    "branch-alias": {
+      "dev-master": "1.0.x-dev"
     }
+  }
 }
diff --git a/druplan.info.yml b/druplan.info.yml
index f99d1b4..1af6527 100644
--- a/druplan.info.yml
+++ b/druplan.info.yml
@@ -8,3 +8,4 @@ dependencies:
   - profile
   - address
   - node
+  - message
diff --git a/modules/druplan_demo/src/Plugin/migrate/process/State.php b/modules/druplan_demo/src/Plugin/migrate/process/State.php
index e0aab09..24bfe2f 100644
--- a/modules/druplan_demo/src/Plugin/migrate/process/State.php
+++ b/modules/druplan_demo/src/Plugin/migrate/process/State.php
@@ -7,13 +7,13 @@ use Drupal\migrate\ProcessPluginBase;
 use Drupal\migrate\Row;
 
 /**
+ * Migrate process plugin for event state from ZAP.
  *
  * @MigrateProcessPlugin(
  *   id = "state_value",
  *   handle_multiples = TRUE
  * )
  *
- *
  * @code
  *   last_author:
  *     plugin: array_pop
@@ -26,17 +26,22 @@ class State extends ProcessPluginBase {
    * {@inheritdoc}
    */
   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
-    if(stristr($value, 'bevestigd')){
+    if (stristr($value, 'bevestigd')) {
       $value = 'confirmed';
-    }elseif(stristr($value, 'afgelast')){
+    }
+    elseif (stristr($value, 'afgelast')) {
       $value = 'canceled';
-    }elseif(stristr($value, 'besloten')){
+    }
+    elseif (stristr($value, 'besloten')) {
       $value = 'private';
-    }elseif(stristr($value, 'uitgesteld')){
+    }
+    elseif (stristr($value, 'uitgesteld')) {
       $value = 'postponed';
-    }elseif(stristr($value, 'optie')){
+    }
+    elseif (stristr($value, 'optie')) {
       $value = 'option';
-    }elseif(stristr($value, 'uitverkocht')){
+    }
+    elseif (stristr($value, 'uitverkocht')) {
       $value = 'sold_out';
     }
     return $value;
-- 
GitLab


From 8580a1df95a012cf5f6e69f06f7b767cee5a4eca Mon Sep 17 00:00:00 2001
From: s j <sj@1729.be>
Date: Sun, 19 Sep 2021 06:35:11 +0200
Subject: [PATCH 2/2] phpqa

---
 .../src/Plugin/migrate/process/Log.php        |  2 +-
 .../views/style/FullCalendarDisplay.php       | 12 +++--
 .../style/FullCalendarResourceDisplay.php     |  2 +-
 .../Field/FieldFormatter/EventsFormatter.php  |  1 +
 .../Field/FieldType/ProjectEventsItemList.php |  6 +--
 .../FullcalendarViewProcessorDruPlan.php      | 45 -------------------
 6 files changed, 14 insertions(+), 54 deletions(-)
 delete mode 100644 src/Plugin/FullcalendarViewProcessor/FullcalendarViewProcessorDruPlan.php

diff --git a/modules/druplan_demo/src/Plugin/migrate/process/Log.php b/modules/druplan_demo/src/Plugin/migrate/process/Log.php
index 2099c3e..01b71b1 100644
--- a/modules/druplan_demo/src/Plugin/migrate/process/Log.php
+++ b/modules/druplan_demo/src/Plugin/migrate/process/Log.php
@@ -34,7 +34,7 @@ class Log extends ProcessPluginBase {
    * {@inheritdoc}
    */
   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
-    error_log("log_value: " . print_r($value, 1));
+    error_log("log_value: " . print_r($value, TRUE));
     return $value;
   }
 
diff --git a/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php b/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php
index 87771f7..b206fae 100644
--- a/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php
+++ b/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php
@@ -3,7 +3,7 @@
 namespace Drupal\druplan_fc\Plugin\views\style;
 
 use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\core\form\FormStateInterface;
+use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\style\StylePluginBase;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Link;
@@ -481,14 +481,19 @@ class FullCalendarDisplay extends StylePluginBase {
     "If taxonomy color is specified, this settings would be ignored.'),
     '#fieldset' => 'colors',
     ];
+     */
+
     // All bundle types.
     $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo(
     $entity_type);
     // Options list.
     $bundlesList = [];
     foreach ($bundles as $id => $bundle) {
-    $label = $bundle['label'];
-    $bundlesList[$id] = $label;
+      $label = $bundle['label'];
+      $bundlesList[$id] = $label;
+    }
+
+    /*
     // Content type colors.
     $form['color_bundle'][$id] = [
     '#title' => $label,
@@ -527,7 +532,6 @@ class FullCalendarDisplay extends StylePluginBase {
       '#type' => 'select',
       '#empty_value' => '',
       '#options' => $field_names,
-      '#empty_value' => '',
       '#default_value' => (!empty($this->options['duration'])) ? $this->options['duration'] : '',
       '#states' => [
         // Only show this field when the 'rrule' is specified.
diff --git a/modules/druplan_fc/src/Plugin/views/style/FullCalendarResourceDisplay.php b/modules/druplan_fc/src/Plugin/views/style/FullCalendarResourceDisplay.php
index cc71ead..ebfc3ca 100644
--- a/modules/druplan_fc/src/Plugin/views/style/FullCalendarResourceDisplay.php
+++ b/modules/druplan_fc/src/Plugin/views/style/FullCalendarResourceDisplay.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\druplan_fc\Plugin\views\style;
 
-use Drupal\core\form\FormStateInterface;
+use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Link;
 use Drupal\Core\Url;
 
diff --git a/src/Plugin/Field/FieldFormatter/EventsFormatter.php b/src/Plugin/Field/FieldFormatter/EventsFormatter.php
index 176f682..3c9e41b 100644
--- a/src/Plugin/Field/FieldFormatter/EventsFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/EventsFormatter.php
@@ -89,6 +89,7 @@ class EventsFormatter extends FormatterBase {
    * {@inheritdoc}
    */
   public function viewElements(FieldItemListInterface $items, $langcode) {
+    $elements = [];
     $elements[0] = [
       '#type' => 'table',
       '#cache' => [
diff --git a/src/Plugin/Field/FieldType/ProjectEventsItemList.php b/src/Plugin/Field/FieldType/ProjectEventsItemList.php
index 7efc3ce..792990a 100644
--- a/src/Plugin/Field/FieldType/ProjectEventsItemList.php
+++ b/src/Plugin/Field/FieldType/ProjectEventsItemList.php
@@ -27,10 +27,10 @@ class ProjectEventsItemList extends EntityReferenceFieldItemList {
     );
 
     if ($values) {
-      $n = 0;
+      $count = 0;
       foreach ($values as $delta => $value) {
-        $this->list[$n] = $this->createItem($delta, $value);
-        $n++;
+        $this->list[$count] = $this->createItem($delta, $value);
+        $count++;
       }
     }
   }
diff --git a/src/Plugin/FullcalendarViewProcessor/FullcalendarViewProcessorDruPlan.php b/src/Plugin/FullcalendarViewProcessor/FullcalendarViewProcessorDruPlan.php
deleted file mode 100644
index b742ce0..0000000
--- a/src/Plugin/FullcalendarViewProcessor/FullcalendarViewProcessorDruPlan.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace Drupal\druplan\Plugin\FullcalendarViewProcessor;
-
-use Drupal\fullcalendar_view\Plugin\FullcalendarViewProcessorBase;
-
-use Drupal\resource_planning\Entity\Event;
-
-/**
- * DruPlan class for Fullcalendar view processor.
- *
- * @FullcalendarViewProcessor(
- *   id = "druplan",
- *   label = @Translation("DS Plan"),
- *   field_types = {},
- *  )
- */
-class FullcalendarViewProcessorDruPlan extends FullcalendarViewProcessorBase {
-
-  /**
-   * Process the view variable array.
-   *
-   * @param array $variables
-   *   Template variables.
-   */
-  public function process(array &$variables) {
-    $settings = $variables['#attached']['drupalSettings']['fullCalendarView'][$variables['view_index']];
-    $calendar_options = json_decode($settings['calendar_options'], TRUE);
-
-    $events_service = \Drupal::service('druplan.events');
-
-    foreach ($calendar_options['events'] as &$event) {
-      $e = Event::load($event['eid']);
-      /*
-      if ($p = $e->get('project_id')->entity) {
-      error_log("project {$p->id()}");
-      }
-       */
-      $event['classNames'] = $events_service->getClassesForEvent($e);
-    }
-
-    $variables['#attached']['drupalSettings']['fullCalendarView'][$variables['view_index']]['calendar_options'] = json_encode($calendar_options);
-  }
-
-}
-- 
GitLab