Skip to content

Commit

Permalink
Merge pull request #230 from dof-dss/development
Browse files Browse the repository at this point in the history
Merge dev to main for release
  • Loading branch information
neilblair authored Sep 1, 2022
2 parents 8bfc303 + 85a5da0 commit 7071ecf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 82 deletions.
60 changes: 22 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,57 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
version: 2.1

default_docker_image: &docker_image
docker:
- image: thecodingmachine/php:8.1-v4-apache-node12
environment:
PROJECT_ROOT: "/home/docker/project"
PHP_EXTENSION_GD: 1
PHP_INI_MEMORY_LIMIT: 1g

jobs:
# Test that coding standards fit drupal.org definitions.
coding_standards:
docker:
- image: circleci/php:8.0-apache-browsers
<<: *docker_image
steps:
- checkout
- run:
name: Update public Key for Google repo
command: |
# Fix for the 'No public key availaible' warning.
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- run:
name: Fetch phpcs and dependencies
command: |
composer require drupal/coder --prefer-stable --no-interaction --optimize-autoloader
# Commenting out this dependency due to version constraint issues.
# composer require slevomat/coding-standard --prefer-stable --no-interaction --optimize-autoloader
composer require drupal/coder
# Move vendor directory up a level as we don't want to code-check all of that.
mv vendor ../
- run:
name: Fetch phpcs convenience script
command: |
curl https://raw.githubusercontent.com/dof-dss/nidirect-drupal/development/phpcs.sh -o /home/circleci/project/phpcs.sh
chmod +x /home/circleci/project/phpcs.sh
curl https://raw.githubusercontent.com/dof-dss/nidirect-drupal/development/phpcs.sh -o $PROJECT_ROOT/phpcs.sh
chmod +x $PROJECT_ROOT/phpcs.sh
- run:
name: PHPCS analysis
command: /home/circleci/project/phpcs.sh /home/circleci "/home/circleci/project"
command: $PROJECT_ROOT/phpcs.sh ~/ "${PROJECT_ROOT}"

deprecated_code:
docker:
- image: circleci/php:8.0-apache-browsers
<<: *docker_image
steps:
- checkout:
path: /home/circleci/origins_modules
- run:
name: Update public Key for Google repo
command: |
# Fix for the 'No public key availaible' warning.
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- run:
name: Add OS and PHP extensions/config
command: |
sudo cp /home/circleci/origins_modules/.circleci/docker-php-circleci.ini /usr/local/etc/php/conf.d/
sudo apt-get update
sudo apt-get install -y libpng-dev
sudo docker-php-ext-install gd
path: ~/nicsdru_origins_modules
- run:
name: Fetch latest Drupal version
command: |
cd /home/circleci
composer create-project drupal-composer/drupal-project:9.x-dev /home/circleci/project --no-interaction
cd $PROJECT_ROOT
composer create-project drupal-composer/drupal-project:9.x-dev $PROJECT_ROOT --no-interaction
- run:
name: Download dependent contrib modules.
command: |
cd /home/circleci/project
composer require drupal/entity_embed mglaman/drupal-check:1.3.0 composer/xdebug-handler:2.0.1 --no-interaction
cd $PROJECT_ROOT
composer require drupal/entity_embed mglaman/drupal-check drupal/flag
- run:
name: Move custom code into position
command: mv /home/circleci/origins_modules /home/circleci/project/web/modules/origins
command: mv ~/nicsdru_origins_modules $PROJECT_ROOT/web/modules/origins
- run:
name: Deprecated code check
command: |
cd /home/circleci/project/web
../vendor/bin/drupal-check modules/origins -e "*/tests/*"
cd $PROJECT_ROOT/web
../vendor/bin/drupal-check modules/origins
workflows:
version: 2
Expand Down
29 changes: 0 additions & 29 deletions .circleci/docker-php-circleci.ini

This file was deleted.

6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
"license": "MIT",
"require": {
"composer/installers": "^1.6"
},
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use Drupal\Core\Form\FormStateInterface;
* Implements hook_element_info_alter().
*/
function origins_ckeditor_enhancements_element_info_alter(array &$types) {
$types['text_format']['#process'][] = 'remove_format_help_process_text_format_element';
$types['text_format']['#process'][] = 'origins_ckeditor_enhancements_remove_format_help_process_text_format_element';
}

/**
* Text input element process handler.
*
* Removes the filter-help 'About text formats' text.
*/
function remove_format_help_process_text_format_element(&$element, FormStateInterface $form_state, &$complete_form) {
function origins_ckeditor_enhancements_remove_format_help_process_text_format_element(&$element, FormStateInterface $form_state, &$complete_form) {
// Only remove the filter help if the user doesn't have permission
// to use the 'Full HTML' text format.
if (!\Drupal::currentUser()->hasPermission('use text format full_html')) {
Expand Down
26 changes: 13 additions & 13 deletions origins_workflow/origins_workflow.module
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ function origins_workflow_form_alter(&$form, FormStateInterface $form_state, $fo
*/
function origins_workflow_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add an extra validator to the node edit form.
array_unshift($form['#validate'], '_origins_workflow_validate_path_alias');
array_unshift($form['#validate'], 'origins_workflow_validate_path_alias');
}

/**
* Provide extra validation for node edit form.
*/
function _origins_workflow_validate_path_alias(&$form, FormStateInterface $form_state) {
function origins_workflow_validate_path_alias(&$form, FormStateInterface $form_state) {
// If this node has its moderation state set to 'archived' then make sure
// that 'generate automatic alias' is un-checked and that the 'URL alias'
// field is empty. This will make sure that there is no alias and hence
Expand All @@ -125,13 +125,13 @@ function _origins_workflow_validate_path_alias(&$form, FormStateInterface $form_
*/
function origins_workflow_form_taxonomy_term_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add an extra validator to the term edit form.
array_unshift($form['#validate'], '_origins_workflow_validate_term_path_alias');
array_unshift($form['#validate'], 'origins_workflow_validate_term_path_alias');
}

/**
* Provide extra validation for taxonomy term edit form.
*/
function _origins_workflow_validate_term_path_alias(&$form, FormStateInterface $form_state) {
function origins_workflow_validate_term_path_alias(&$form, FormStateInterface $form_state) {
// If this term is unpublished then make sure
// that 'generate automatic alias' is un-checked and that the 'URL alias'
// field is empty. This will make sure that there is no alias and hence
Expand Down Expand Up @@ -184,13 +184,13 @@ function origins_workflow_entity_update(EntityInterface $entity) {
}
}
// Now add processing for moderation sidebar.
_origins_workflow_menu_creation_check($entity);
origins_workflow_menu_creation_check($entity);
}

/**
* Check for menu creation.
*/
function _origins_workflow_menu_creation_check(EntityInterface $entity) {
function origins_workflow_menu_creation_check(EntityInterface $entity) {
// If a node is published using the moderation sidebar it is possible
// that menu creation might be overlooked. Code added here to rectify
// this bug.
Expand Down Expand Up @@ -364,7 +364,7 @@ function origins_workflow_preprocess_field(&$variables) {
$audit_types = $config->get('audit_content_types');
$msg = NULL;
if (in_array($content_type, $audit_types)) {
$msg = _build_audit_link($variables);
$msg = origins_workflow_build_audit_link($variables);
}
if ($msg) {
// Send out 'needs audit' link as a Drupal warning message.
Expand All @@ -384,7 +384,7 @@ function origins_workflow_preprocess_field(&$variables) {
/**
* Top level function to build audit links.
*/
function _build_audit_link(&$variables) {
function origins_workflow_build_audit_link(&$variables) {
// Get the current node.
$node = Drupal::routeMatch()->getParameter('node');
if (!empty($node)) {
Expand All @@ -398,10 +398,10 @@ function _build_audit_link(&$variables) {
}
if (!empty($nid)) {
if ($node->hasField('field_next_audit_due')) {
return _audit_link('field_next_audit_due', $node->get('field_next_audit_due')->value, $nid);
return origins_workflow_audit_link('field_next_audit_due', $node->get('field_next_audit_due')->value, $nid);
}
elseif ($node->hasField('field_next_review_date')) {
return _audit_link('field_next_review_date', $node->get('field_next_review_date')->value, $nid);
return origins_workflow_audit_link('field_next_review_date', $node->get('field_next_review_date')->value, $nid);
}
}
}
Expand All @@ -410,7 +410,7 @@ function _build_audit_link(&$variables) {
/**
* Utility function to build the audit link html.
*/
function _audit_link($field, $dt, $nid) {
function origins_workflow_audit_link($field, $dt, $nid) {
if (!empty($dt) && (strtotime($dt) < Drupal::time()->getCurrentTime())) {
// Next review date is in the past,
// so this node is due for audit - display node edit link
Expand Down Expand Up @@ -575,7 +575,7 @@ function origins_workflow_preprocess_table(&$variables) {
$row['attributes']->addClass('revision-' . $node->get('moderation_state')->getValue()[0]['value']);

// Create a "Create Draft of Published" link.
_create_draft_link_for_revision($variables, $node, $idx, $row);
origins_workflow_create_draft_link_for_revision($variables, $node, $idx, $row);
}

// Insert revision number column at the beginning.
Expand All @@ -588,7 +588,7 @@ function origins_workflow_preprocess_table(&$variables) {
/**
* Add a 'Create Draft of Published' link.
*/
function _create_draft_link_for_revision(&$variables, $node, $idx, $row) {
function origins_workflow_create_draft_link_for_revision(&$variables, $node, $idx, $row) {
// Does this user have permission to create drafts of published ?
if (\Drupal::currentUser()->hasPermission('use nics_editorial_workflow transition draft_of_published')) {
// Now change the 'Current Revision' markup to a
Expand Down

0 comments on commit 7071ecf

Please sign in to comment.