diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc742e448194c09414632d1fbc1ded830c7283f6..33fc66f2683080e05ad579f516dbc9e01845e19f 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 d56a6e64bfd33219445fdbf135745e9e608b9ebf..6135aa2b6a2b15495b9c636cd7ec0015b88f75c0 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 0000000000000000000000000000000000000000..70aaad5e00fa887cfa8b925fb6b3ca7f6c1bb326 --- /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 448b15b85da7e8d3fc091501bd931628b6a5a12e..ffc9f2eb192c14c9e9e12941322ac1731ad1bdac 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 f99d1b492b15f533d5b3819f287eac4d877fc85c..1af6527834b29840757be85a986db2470fadce82 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/Log.php b/modules/druplan_demo/src/Plugin/migrate/process/Log.php index 2099c3e6277b84a6c8a7fde8f2b34371b57c301f..01b71b1cacf784ae9095a620c6a42dcd3187a872 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_demo/src/Plugin/migrate/process/State.php b/modules/druplan_demo/src/Plugin/migrate/process/State.php index e0aab0981b5058aa4da373be4e929ee3adbcc5cc..24bfe2f4b493289cfec429a17aa27a6e2f17c9fd 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; diff --git a/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php b/modules/druplan_fc/src/Plugin/views/style/FullCalendarDisplay.php index 87771f7278b02d5a0168b53dfde9786033f7ee82..b206faec3ba6aea075867f03c8a23165004038e8 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 cc71eade21fc6db023a8ebf3394492c64c0a9bf1..ebfc3ca52b35baacdcca0073f03641f91580baf9 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 176f6820eff6c0da4ef276b150f6559fa5247abe..3c9e41b6b9e0483a5c0c2c2234ee8bbf5cf0b99d 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 7efc3cec884de05bc240ed81d8a009c039ada609..792990adaed09c2c48e7812c9ec891533a99ae42 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 b742ce0b70dd30b89929642b06aa985ae8132a87..0000000000000000000000000000000000000000 --- 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); - } - -}