Completed
Pull Request — 8.x-1.x (#33)
by
unknown
02:29
created
src/Form/UrlEmbedDialog.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -109,8 +109,7 @@  discard block
 block discarded – undo
109 109
       if (!empty($url_element['data-embed-url']) && $info = $this->urlEmbed()->getEmbed($url_element['data-embed-url'])) {
110 110
         $url_element['data-url-provider'] = $info->getProviderName();
111 111
       }
112
-    }
113
-    catch (\Exception $e) {
112
+    } catch (\Exception $e) {
114 113
       watchdog_exception('url_embed', $e);
115 114
     }
116 115
 
@@ -160,8 +159,7 @@  discard block
 block discarded – undo
160 159
         '#weight' => -10,
161 160
       );
162 161
       $response->addCommand(new HtmlCommand('#url-embed-dialog-form', $form));
163
-    }
164
-    else {
162
+    } else {
165 163
       $response->addCommand(new EditorDialogSave($values));
166 164
       $response->addCommand(new CloseModalDialogCommand());
167 165
     }
Please login to merge, or discard this patch.
src/Plugin/Filter/UrlEmbedFilter.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -77,8 +77,7 @@  discard block
 block discarded – undo
77 77
             $url_output = $info->getCode();
78 78
             $node->setAttribute('data-url-provider', $info->getProviderName());
79 79
           }
80
-        }
81
-        catch (\Exception $e) {
80
+        } catch (\Exception $e) {
82 81
           watchdog_exception('url_embed', $e);
83 82
         }
84 83
 
@@ -100,8 +99,7 @@  discard block
 block discarded – undo
100 99
         <ul>
101 100
           <li><code>&lt;drupal-url data-embed-url="https://www.youtube.com/watch?v=xxXXxxXxxxX" data-url-provider="YouTube" /&gt;</code></li>
102 101
         </ul>');
103
-    }
104
-    else {
102
+    } else {
105 103
       return $this->t('You can embed URLs.');
106 104
     }
107 105
   }
Please login to merge, or discard this patch.
src/Plugin/Field/FieldFormatter/LinkEmbedFormatter.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@
 block discarded – undo
40 40
               '#template' => $info->getCode(),
41 41
             );
42 42
           }
43
-        }
44
-        catch (\Exception $exception) {
43
+        } catch (\Exception $exception) {
45 44
           watchdog_exception('url_embed', $exception);
46 45
         }
47 46
       }
Please login to merge, or discard this patch.
src/Plugin/CKEditorPlugin/DrupalUrl.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
    * {@inheritdoc}
26 26
    */
27 27
   public function getFile() {
28
-    return drupal_get_path('module', 'url_embed') . '/js/plugins/drupalurl/plugin.js';
28
+    return drupal_get_path('module', 'url_embed').'/js/plugins/drupalurl/plugin.js';
29 29
   }
30 30
 
31 31
   /**
Please login to merge, or discard this patch.
src/Plugin/EmbedType/Url.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,6 +23,6 @@
 block discarded – undo
23 23
    * {@inheritdoc}
24 24
    */
25 25
   public function getDefaultIconUrl() {
26
-    return file_create_url(drupal_get_path('module', 'url_embed') . '/js/plugins/drupalurl/urlembed.png');
26
+    return file_create_url(drupal_get_path('module', 'url_embed').'/js/plugins/drupalurl/urlembed.png');
27 27
   }
28 28
 }
Please login to merge, or discard this patch.
src/Tests/LinkEmbedFormatterTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  *
19 19
  * @group url_embed
20 20
  */
21
-class LinkEmbedFormatterTest extends LinkFieldTest{
21
+class LinkEmbedFormatterTest extends LinkFieldTest {
22 22
 
23 23
   /**
24 24
    * Modules to enable.
Please login to merge, or discard this patch.
src/Tests/UrlEmbedDialogTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@
 block discarded – undo
66 66
   public function getEmbedDialog($filter_format_id = NULL, $embed_button_id = NULL) {
67 67
     $url = 'url-embed/dialog';
68 68
     if (!empty($filter_format_id)) {
69
-      $url .= '/' . $filter_format_id;
69
+      $url .= '/'.$filter_format_id;
70 70
       if (!empty($embed_button_id)) {
71
-        $url .= '/' . $embed_button_id;
71
+        $url .= '/'.$embed_button_id;
72 72
       }
73 73
     }
74 74
     return $this->drupalGet($url);
Please login to merge, or discard this patch.
src/Plugin/Filter/ConvertUrlToEmbedFilter.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -78,25 +78,25 @@  discard block
 block discarded – undo
78 78
     // optional for all protocols.
79 79
     // @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
80 80
     $protocols = \Drupal::getContainer()->getParameter('filter_protocols');
81
-    $protocols = implode(':(?://)?|', $protocols) . ':(?://)?';
81
+    $protocols = implode(':(?://)?|', $protocols).':(?://)?';
82 82
 
83 83
     $valid_url_path_characters = "[\p{L}\p{M}\p{N}!\*\';:=\+,\.\$\/%#\[\]\-_~@&]";
84 84
 
85 85
     // Allow URL paths to contain balanced parens
86 86
     // 1. Used in Wikipedia URLs like /Primer_(film)
87 87
     // 2. Used in IIS sessions like /S(dfd346)/
88
-    $valid_url_balanced_parens = '\('. $valid_url_path_characters . '+\)';
88
+    $valid_url_balanced_parens = '\('.$valid_url_path_characters.'+\)';
89 89
 
90 90
     // Valid end-of-path characters (so /foo. does not gobble the period).
91 91
     // 1. Allow =&# for empty URL parameters and other URL-join artifacts
92
-    $valid_url_ending_characters = '[\p{L}\p{M}\p{N}:_+~#=/]|(?:' . $valid_url_balanced_parens . ')';
92
+    $valid_url_ending_characters = '[\p{L}\p{M}\p{N}:_+~#=/]|(?:'.$valid_url_balanced_parens.')';
93 93
 
94 94
     $valid_url_query_chars = '[a-zA-Z0-9!?\*\'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]';
95 95
     $valid_url_query_ending_chars = '[a-zA-Z0-9_&=#\/]';
96 96
 
97 97
     //full path
98 98
     //and allow @ in a url, but only in the middle. Catch things like http://example.com/@user/
99
-    $valid_url_path = '(?:(?:'.$valid_url_path_characters . '*(?:'.$valid_url_balanced_parens .$valid_url_path_characters . '*)*'. $valid_url_ending_characters . ')|(?:@' . $valid_url_path_characters . '+\/))';
99
+    $valid_url_path = '(?:(?:'.$valid_url_path_characters.'*(?:'.$valid_url_balanced_parens.$valid_url_path_characters.'*)*'.$valid_url_ending_characters.')|(?:@'.$valid_url_path_characters.'+\/))';
100 100
 
101 101
     // Prepare domain name pattern.
102 102
     // The ICANN seems to be on track towards accepting more diverse top level
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     $domain = '(?:[\p{L}\p{M}\p{N}._+-]+\.)?[\p{L}\p{M}]{2,64}\b';
106 106
     $ip = '(?:[0-9]{1,3}\.){3}[0-9]{1,3}';
107 107
     $auth = '[\p{L}\p{M}\p{N}:%_+*~#?&=.,/;-]+@';
108
-    $trail = '('.$valid_url_path.'*)?(\\?'.$valid_url_query_chars .'*'.$valid_url_query_ending_chars.')?';
108
+    $trail = '('.$valid_url_path.'*)?(\\?'.$valid_url_query_chars.'*'.$valid_url_query_ending_chars.')?';
109 109
 
110 110
     // Match absolute URLs.
111 111
     $url_pattern = "(?:$auth)?(?:$domain|$ip)/?(?:$trail)?";
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
           // function contained in $task.
138 138
           $chunks[$i] = preg_replace_callback(
139 139
             $pattern,
140
-            function ($match) {
140
+            function($match) {
141 141
               if (\Drupal::service('url_embed')->getEmbed(Html::decodeEntities($match[1]))) {
142
-                return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>';
142
+                return '<drupal-url data-embed-url="'.$match[1].'"></drupal-url>';
143 143
               }
144 144
               else {
145 145
                 return $match[1];
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -140,8 +140,7 @@  discard block
 block discarded – undo
140 140
             function ($match) {
141 141
               if (\Drupal::service('url_embed')->getEmbed(Html::decodeEntities($match[1]))) {
142 142
                 return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>';
143
-              }
144
-              else {
143
+              } else {
145 144
                 return $match[1];
146 145
               }
147 146
             },
@@ -150,8 +149,7 @@  discard block
 block discarded – undo
150 149
         }
151 150
         // Text chunk is done, so next chunk must be a tag.
152 151
         $chunk_type = 'tag';
153
-      }
154
-      else {
152
+      } else {
155 153
         // Only process this tag if there are no unclosed $ignore_tags.
156 154
         if ($open_tag == '') {
157 155
           // Check whether this tag is contained in $ignore_tags.
@@ -182,8 +180,7 @@  discard block
 block discarded – undo
182 180
   public function tips($long = FALSE) {
183 181
     if ($long) {
184 182
       return $this->t('<p>You can convert plain URLs to &lt;drupal-url&gt; HTML elements. Those elements are later converted to embeds using "Display embedded URLs" text filter.</p>');
185
-    }
186
-    else {
183
+    } else {
187 184
       return $this->t('You can convert plain URLs to embed elements.');
188 185
     }
189 186
   }
Please login to merge, or discard this patch.
src/Tests/ConvertUrlToEmbedFilterTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     $settings['title'] = 'Test convert url to embed with sample Twitter url';
81 81
     $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
82 82
     $node = $this->drupalCreateNode($settings);
83
-    $this->drupalGet('node/' . $node->id());
83
+    $this->drupalGet('node/'.$node->id());
84 84
     $this->assertRaw('<drupal-url data-embed-url="https://twitter.com/drupal/status/735873777683320832"></drupal-url>');
85 85
     $this->assertNoText(strip_tags($content), 'URL does not appear in the output when embed is successful.');
86 86
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     $settings['title'] = 'Test convert url to embed with non valid URL';
91 91
     $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
92 92
     $node = $this->drupalCreateNode($settings);
93
-    $this->drupalGet('node/' . $node->id());
93
+    $this->drupalGet('node/'.$node->id());
94 94
     $this->assertRaw($content);
95 95
 
96 96
     /** @var \Drupal\filter\FilterFormatInterface $format */
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     $settings['title'] = 'Test convert url to embed with sample Twitter url and no prefix';
107 107
     $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
108 108
     $node = $this->drupalCreateNode($settings);
109
-    $this->drupalGet('node/' . $node->id());
109
+    $this->drupalGet('node/'.$node->id());
110 110
     $this->assertRaw(strip_tags($content));
111 111
     $this->assertNoRaw('<drupal-url data-embed-url="https://twitter.com/drupal/status/735873777683320832"></drupal-url>');
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     $settings['title'] = 'Test convert url to embed with sample Twitter url with the prefix';
117 117
     $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
118 118
     $node = $this->drupalCreateNode($settings);
119
-    $this->drupalGet('node/' . $node->id());
119
+    $this->drupalGet('node/'.$node->id());
120 120
     $this->assertRaw('<drupal-url data-embed-url="https://twitter.com/drupal/status/735873777683320832"></drupal-url>');
121 121
     $this->assertNoText(strip_tags($content), 'URL does not appear in the output when embed is successful.');
122 122
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     $settings['title'] = 'Test convert url to embed with sample Twitter url with wrong prefix';
127 127
     $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
128 128
     $node = $this->drupalCreateNode($settings);
129
-    $this->drupalGet('node/' . $node->id());
129
+    $this->drupalGet('node/'.$node->id());
130 130
     $this->assertRaw(strip_tags($content));
131 131
     $this->assertNoRaw('<drupal-url data-embed-url="https://twitter.com/drupal/status/735873777683320832"></drupal-url>');
132 132
   }
Please login to merge, or discard this patch.