Skip to content

Commit

Permalink
Add lint action
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Oct 4, 2024
1 parent a75618f commit 90ffa01
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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/ ./
16 changes: 15 additions & 1 deletion islandora_vtt.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* @file
* Contains islandora_vtt.module.
*/

use Drupal\media\Entity\Media;

/**
Expand All @@ -15,6 +20,9 @@ function islandora_vtt_theme($existing, $type, $theme, $path) {
];
}

/**
* Implements hook_preprocess_media().
*/
function islandora_vtt_preprocess_media(&$vars) {
if (!in_array($vars['view_mode'], ['full', 'default_islandora_display'])) {
return;
Expand All @@ -38,6 +46,9 @@ function islandora_vtt_preprocess_media(&$vars) {
$vars['#attached']['drupalSettings']['vttPlayerType'] = $media->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
Expand All @@ -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')
Expand All @@ -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 != '') {
Expand Down

0 comments on commit 90ffa01

Please sign in to comment.