Commit 7aa2e17a authored by Tamás Nagy's avatar Tamás Nagy
Browse files

Issue #2859461 by fgm: Check brightcove video tags existance in its own vocabulary

parent 9343f954
Loading
Loading
Loading
Loading
+2 −1
Changes for brightcove.module: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 */

use Drupal\brightcove\Entity\BrightcoveSubscription;
use Drupal\brightcove\Entity\BrightcoveVideo;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
@@ -300,7 +301,7 @@ function brightcove_theme($existing, $type, $theme, $path) {
 */
function brightcove_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  // Disable editing/deleting video tags.
  if (($entity instanceof TermInterface && $entity->getVocabularyId() == 'brightcove_video_tags' || $entity instanceof VocabularyInterface && $entity->id() == 'brightcove_video_tags') && ($operation == 'update' || $operation == 'delete')) {
  if (($entity instanceof TermInterface && $entity->getVocabularyId() == BrightcoveVideo::TAGS_VID || $entity instanceof VocabularyInterface && $entity->id() == BrightcoveVideo::TAGS_VID) && ($operation == 'update' || $operation == 'delete')) {
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
+2 −1
Changes for src/BrightcoveUtil.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -336,6 +336,7 @@ class BrightcoveUtil {
      $entity_tags = array_keys($entity_tags);
      foreach ($new_tags as $tag) {
        $existing_tags = \Drupal::entityQuery('taxonomy_term')
          ->condition('vid', BrightcoveVideo::TAGS_VID)
          ->condition('name', $tag)
          ->execute();

@@ -343,7 +344,7 @@ class BrightcoveUtil {
        if (empty($existing_tags)) {
          $values = [
            'name' => $tag,
            'vid' => 'brightcove_video_tags',
            'vid' => BrightcoveVideo::TAGS_VID,
            'brightcove_api_client' => [
              'target_id' => $api_client_id,
            ],
+5
Changes for src/BrightcoveVideoInterface.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ interface BrightcoveVideoInterface {
   */
  const STATE_INACTIVE = 'INACTIVE';

  /**
   * Brightcove video tags vocabulary ID.
   */
  const TAGS_VID = 'brightcove_video_tags';

  /**
   * Helper function to save the image for the entity.
   *
+1 −1
Changes for src/Entity/BrightcovePlaylist.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -568,7 +568,7 @@ class BrightcovePlaylist extends BrightcoveVideoPlaylistCMSEntity implements Bri
      ->setSettings([
        'target_type' => 'taxonomy_term',
        'handler_settings' => [
          'target_bundles' => ['brightcove_video_tags' => 'brightcove_video_tags'],
          'target_bundles' => [BrightcoveVideo::TAGS_VID => BrightcoveVideo::TAGS_VID],
          'auto_create' => TRUE,
        ],
      ])
+1 −1
Changes for src/Entity/BrightcoveVideo.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -1148,7 +1148,7 @@ class BrightcoveVideo extends BrightcoveVideoPlaylistCMSEntity implements Bright
      ->setSettings([
        'target_type' => 'taxonomy_term',
        'handler_settings' => [
          'target_bundles' => ['brightcove_video_tags' => 'brightcove_video_tags'],
          'target_bundles' => [self::TAGS_VID => self::TAGS_VID],
          'auto_create' => TRUE,
        ],
      ])