Problem/Motivation

A lot of 'get' functions are set in the CloudflareVideoItem.php & CloudflareVideoFormatter.php files.
Let's refactor this & create a general service.

Proposed resolution

Create a Cloudflare Stream service

Comments

pjbaert created an issue. See original summary.

tim-diels’s picture

Sounds good. Let's use that service throughout the whole module and clean up the needed files:

  • CloudflareVideoFormatter
  • CloudflareVideoItem
pjbaert’s picture

Issue summary: View changes

Yes, indeed.
Updated the issue summary as suggested by @tim-diels

pjbaert’s picture

Title: Create a Cloudflare Service » Create a Cloudflare Stream Service
Assigned: pjbaert » Unassigned
Status: Active » Needs review
StatusFileSize
new13.36 KB

This patch creates a Cloudflare Stream service file & interface.
The existing cloudflare_stream.file_extensions is integrated in this new general service.
We now correctly use these new service in our CloudflareVideoItem.php & CloudflareVideoFormatter.php files

Please review the patch.

tim-diels’s picture

Status: Needs review » Needs work

Didn't had the time to fully test this. but here are some remarks already.

  1. +++ b/src/Plugin/Field/FieldFormatter/CloudflareVideoFormatter.php
    @@ -80,14 +80,14 @@ class CloudflareVideoFormatter extends FormatterBase {
    -    $this->config = $configFactory->get('cloudflare_stream.settings');
    

    You should also remove the property definition.

  2. +++ b/src/Plugin/Field/FieldFormatter/CloudflareVideoFormatter.php
    @@ -80,14 +80,14 @@ class CloudflareVideoFormatter extends FormatterBase {
    +    $this->cloudflareStream = $cloudflareStream;
    

    I'm missing the property definition here?

  3. +++ b/src/Plugin/Field/FieldType/CloudflareVideoItem.php
    @@ -89,41 +81,41 @@ class CloudflareVideoItem extends FileItem {
    +    $this->cloudflareStream = $cloudflareStream;
    

    I'm missing the property definition here?

pjbaert’s picture

Status: Needs work » Needs review
StatusFileSize
new15.11 KB

Thanks for the initial feedback. I reworked your suggestions & removed some other nitpicks.
Please review

tim-diels’s picture

StatusFileSize
new15.15 KB
new691 bytes

You forgot the argument for the service. So added this and small nitpick on the service doc.

pjbaert’s picture

Status: Needs review » Fixed

Thanks for your review & feedback.
I consider this done for now. This is pushed to the 8.x-2.x branch

  • pjbaert committed abf2c58 on 8.x-2.x
    Issue #3239401 by pjbaert, tim-diels: Create a Cloudflare Stream Service
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.