From 90ffa019fea6913814a5935f2229801c564d3757 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Fri, 4 Oct 2024 07:21:49 -0400 Subject: [PATCH] Add lint action --- .github/workflows/lint.yml | 36 ++++++++++++++++++++++++++++++++++++ islandora_vtt.module | 16 +++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..74bf9eb --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,36 @@ +name: lint + +on: + push: + branches: + +jobs: + phpcs: + name: Run PHPCS with Drupal Standards + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up PHP and Composer + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: phpcs + coverage: none + + - name: Install Drupal Coder Standards + run: | + composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer global require --no-interaction drupal/coder slevomat/coding-standard + COMPOSER_HOME=$(composer config --global home) + phpcs --config-set installed_paths \ + "$COMPOSER_HOME/vendor/drupal/coder/coder_sniffer,$COMPOSER_HOME/vendor/slevomat/coding-standard" + phpcs -i + + - name: Run PHPCS + run: phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme --ignore=vendor/ ./ + + - name: Run DrupalPractice + run: phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme --ignore=vendor/ ./ diff --git a/islandora_vtt.module b/islandora_vtt.module index 3450e3e..ebbe72b 100644 --- a/islandora_vtt.module +++ b/islandora_vtt.module @@ -1,5 +1,10 @@ bundle(); } +/** + * Helper function to get a media's sibling VTT URL. + */ function islandora_vtt_get_vtt($media) { $mid = \Drupal::database()->query("SELECT mid FROM {media__field_media_of} mo @@ -48,7 +59,7 @@ function islandora_vtt_get_vtt($media) { AND field_media_of_target_id = :mid", [ ':mid' => $media->field_media_of->target_id, ':tid' => islandora_vtt_extracted_text_tid(), - ])->fetchField(); + ])->fetchField(); $vtt = $mid ? Media::load($mid) : FALSE; return $vtt && $vtt->access('view') @@ -57,6 +68,9 @@ function islandora_vtt_get_vtt($media) { && !is_null($vtt->field_media_file->entity) ? $vtt : FALSE; } +/** + * Helper function to get the extracted text term ID. + */ function islandora_vtt_extracted_text_tid() { static $tid = ''; if ($tid != '') {