Skip to content

Commit

Permalink
Merge pull request #5 from wieni/feature/drupal-10
Browse files Browse the repository at this point in the history
Add drupal 10 compatibility
  • Loading branch information
akasake authored Sep 12, 2023
2 parents 068fac3 + eb378a4 commit 295460a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=7.1",
"drupal/core": "^8 || ^9"
"drupal/core": "^9.3 || ^10"
},
"require-dev": {
"composer-runtime-api": "^2.0",
Expand Down
19 changes: 18 additions & 1 deletion src/Plugin/Filter/EmbedVimeoFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Drupal\wmvideo\Plugin\Filter;

use Drupal\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

Expand All @@ -15,6 +17,21 @@
*/
class EmbedVimeoFilter extends FilterBase
{
/** @var RendererInterface */
protected $renderer;

public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
$instance = new static($configuration, $plugin_id, $plugin_definition);
$instance->renderer = $container->get('renderer');

return $instance;
}

public function process($text, $langcode): FilterProcessResult
{
$new_text = preg_replace_callback("|\[vimeo:([^]]*)\]|i", 'self::replace', $text);
Expand All @@ -38,6 +55,6 @@ public function replace($results)
'#height' => $height,
];

return render($build);
return $this->renderer->render($build);
}
}
18 changes: 17 additions & 1 deletion src/Plugin/Filter/EmbedYouTubeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Drupal\wmvideo\Plugin\Filter;

use Drupal\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

Expand All @@ -16,6 +18,20 @@
*/
class EmbedYouTubeFilter extends FilterBase
{
protected $renderer;

public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition
) {
$instance = new static($configuration, $plugin_id, $plugin_definition);
$instance->renderer = $container->get('renderer');

return $instance;
}

public function process($text, $langcode): FilterProcessResult
{
$new_text = preg_replace_callback("|\[youtube:([^]]*)\]|i", 'self::replace', $text);
Expand Down Expand Up @@ -54,6 +70,6 @@ public function replace($results)
'#domain' => $domain,
];

return render($build);
return $this->renderer->render($build);
}
}
3 changes: 1 addition & 2 deletions wmvideo.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Wieni Video
type: module
description: Converting a YouTube or Vimeo URL to an embedded player
package: Wieni
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.3 || ^10
dependencies:
- link
- filter

0 comments on commit 295460a

Please sign in to comment.