Browse Source

Added a new parser service called MarkupGenerator which uses Parser interface and TemplateCreator helper class
depends on Embed library, installed by composer

logicp 7 years ago
parent
commit
8f818d7117
2 changed files with 11 additions and 5 deletions
  1. 8 5
      src/Form/StatusForm.php
  2. 3 0
      statusmessage.services.yml

+ 8 - 5
src/Form/StatusForm.php

@@ -6,6 +6,7 @@ use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\statusmessage\Entity\Status;
 use Drupal\statusmessage\ClientGeneratorService;
+use Drupal\statusmessage\MarkupGenerator;
 use Drupal\statusmessage\StatusService;
 use Drupal\statusmessage\StatusTypeService;
 use Drupal\statusmessage\Ajax\ClientCommand;
@@ -27,7 +28,7 @@ class StatusForm extends FormBase {
 
   protected $statusService;
 
-  protected $previewGenerator;
+  protected $markupgenerator;
 
   private $mediaTabs;
 
@@ -38,18 +39,20 @@ class StatusForm extends FormBase {
     return new static(
       $container->get('status_type_service'),
       $container->get('statusservice'),
-      $container->get('preview_generator'));
+      $container->get('markupgenerator'));
   }
 
+  //TODO remove markup generator from this class
+
   /**
    * StatusForm constructor.
    * @param StatusTypeService $status_type_service
    * @param StatusService $status_service
    */
-  public function __construct(StatusTypeService $status_type_service, StatusService $status_service, ClientGeneratorService $preview_generator) {
+  public function __construct(StatusTypeService $status_type_service, StatusService $status_service, MarkupGenerator $markupgenerator) {
     $this->statusTypeService = $status_type_service;
     $this->statusService = $status_service;
-    $this->previewGenerator = $preview_generator;
+    $this->markupgenerator = $markupgenerator;
     $this->mediaTabs = ['Photo', 'Video'];
   }
 
@@ -166,7 +169,7 @@ $stophere = null;
     preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $message, $match);
 
 
-    if ($this->previewGenerator !== null && !empty($match) && array_values($match)[0] !== null) {
+    if ($this->markupgenerator !== null && !empty($match) && array_values($match)[0] !== null) {
 
       $url = array_values($match)[0];
 

+ 3 - 0
statusmessage.services.yml

@@ -7,6 +7,9 @@ services:
     class: Drupal\statusmessage\StatusTypeService
     arguments: ['@entity.query', '@entity_type.manager']
 
+  preview_generator:
+    class: Drupal\statusmessage\ClientGeneratorService
+    arguments: ['@http_client']
   markupgenerator:
     class: Drupal\statusmessage\MarkupGenerator