Completed
Push — 8.x-1.x ( e8a96d...427045 )
by Alexandre
01:48
created
crop.module 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
  */
9 9
 use Drupal\Component\Utility\UrlHelper;
10 10
 use \Drupal\Core\Form\FormStateInterface;
11
-use Drupal\Core\StreamWrapper\PublicStream;
12 11
 use Drupal\crop\Entity\Crop;
13 12
 use Drupal\image\Entity\ImageStyle;
14 13
 use \Drupal\media_entity\MediaBundleInterface;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     // Get the file path without query parameter.
122 122
     $parsed_uri = UrlHelper::parse($match[3]);
123 123
     // Get the file URI using parsed schema and file path.
124
-    $file_uri = $match[2] . '://' . $parsed_uri['path'];
124
+    $file_uri = $match[2].'://'.$parsed_uri['path'];
125 125
 
126 126
     // Prevent double hashing, if there is a hash argument already, do not add
127 127
     // it again.
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     if ($crop_type && $crop = Crop::findCrop($file_uri, $crop_type)) {
150 150
       // Found a crop for this image, append a hash of it to the URL,
151 151
       // so that browsers reload the image and CDNs and proxies can be bypassed.
152
-      $shortened_hash = substr(md5(implode($crop->position()) . implode($crop->anchor())), 0, 8);
152
+      $shortened_hash = substr(md5(implode($crop->position()).implode($crop->anchor())), 0, 8);
153 153
 
154 154
       // If the URI has a schema and that is not http, https or data, convert
155 155
       // the URI to the external URL. Otherwise the appended query argument
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 
165 165
       // Append either with a ? or a & if there are existing query arguments.
166 166
       if (strpos($uri, '?') === FALSE) {
167
-        $uri .= '?h=' . $shortened_hash;
167
+        $uri .= '?h='.$shortened_hash;
168 168
       }
169 169
       else {
170
-        $uri .= '&h=' . $shortened_hash;
170
+        $uri .= '&h='.$shortened_hash;
171 171
       }
172 172
     }
173 173
   }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -165,8 +165,7 @@
 block discarded – undo
165 165
       // Append either with a ? or a & if there are existing query arguments.
166 166
       if (strpos($uri, '?') === FALSE) {
167 167
         $uri .= '?h=' . $shortened_hash;
168
-      }
169
-      else {
168
+      } else {
170 169
         $uri .= '&h=' . $shortened_hash;
171 170
       }
172 171
     }
Please login to merge, or discard this patch.
src/Tests/CropFunctionalTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
     $this->assertRaw($edit['description']);
106 106
 
107 107
     // See if crop type appears on image effect configuration form.
108
-    $this->drupalGet('admin/config/media/image-styles/manage/' . $this->testStyle->id() . '/add/crop_crop');
108
+    $this->drupalGet('admin/config/media/image-styles/manage/'.$this->testStyle->id().'/add/crop_crop');
109 109
     $option = $this->xpath("//select[@id='edit-data-crop-type']/option");
110 110
     $this->assert(strpos($option[0]->asXML(), $edit['label']) !== FALSE, 'Crop type label found on image effect page.');
111
-    $this->drupalPostForm('admin/config/media/image-styles/manage/' . $this->testStyle->id() . '/add/crop_crop', ['data[crop_type]' => $edit['id']], t('Add effect'));
111
+    $this->drupalPostForm('admin/config/media/image-styles/manage/'.$this->testStyle->id().'/add/crop_crop', ['data[crop_type]' => $edit['id']], t('Add effect'));
112 112
     $this->assertText(t('The image effect was successfully applied.'));
113 113
     $this->assertText(t('Manual crop uses @name crop type', ['@name' => $edit['label']]));
114 114
     $this->testStyle = $this->container->get('entity.manager')->getStorage('image_style')->loadUnchanged($this->testStyle->id());
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
     // Try to access edit form as anonymous user.
124 124
     $this->drupalLogout();
125
-    $this->drupalGet('admin/config/media/crop/manage/' . $edit['id']);
125
+    $this->drupalGet('admin/config/media/crop/manage/'.$edit['id']);
126 126
     $this->assertResponse(403);
127 127
     $this->drupalLogin($this->adminUser);
128 128
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     $this->assertLink('Test image style');
136 136
     $this->clickLink(t('Delete'));
137 137
     $this->assertText(t('Are you sure you want to delete the crop type @name?', ['@name' => $edit['label']]));
138
-    $this->drupalPostForm('admin/config/media/crop/manage/' . $edit['id'] . '/delete', [], t('Delete'));
138
+    $this->drupalPostForm('admin/config/media/crop/manage/'.$edit['id'].'/delete', [], t('Delete'));
139 139
     $this->assertRaw(t('The crop type %name has been deleted.', ['%name' => $edit['label']]));
140 140
     $this->assertText(t('No crop types available.'));
141 141
   }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
    */
148 148
   protected function doTestFileUriAlter() {
149 149
     // Get the test file.
150
-    file_unmanaged_copy(drupal_get_path('module', 'crop') . '/tests/files/sarajevo.png', PublicStream::basePath());
150
+    file_unmanaged_copy(drupal_get_path('module', 'crop').'/tests/files/sarajevo.png', PublicStream::basePath());
151 151
     $file_uri = 'public://sarajevo.png';
152 152
     $file = File::create(['uri' => $file_uri, 'status' => FILE_STATUS_PERMANENT]);
153 153
     $file->save();
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     // Test that the hash is appended both when a URL is created and passed
170 170
     // through file_create_url() and when a URL is created, without additional
171 171
     // file_create_url() calls.
172
-    $shortened_hash = substr(md5(implode($crop->position()) . implode($crop->anchor())), 0, 8);
172
+    $shortened_hash = substr(md5(implode($crop->position()).implode($crop->anchor())), 0, 8);
173 173
 
174 174
     // Build an image style derivative for the file URI.
175 175
     $image_style_uri = $this->testStyle->buildUri($file_uri);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     // Update the crop to assert the hash has changed.
184 184
     $crop->setPosition('80', '80')->save();
185 185
     $old_hash = $shortened_hash;
186
-    $new_hash = substr(md5(implode($crop->position()) . implode($crop->anchor())), 0, 8);
186
+    $new_hash = substr(md5(implode($crop->position()).implode($crop->anchor())), 0, 8);
187 187
     $image_style_url = $this->testStyle->buildUrl($file_uri);
188 188
     $this->assertFalse(strpos($image_style_url, $old_hash) !== FALSE, 'The image style URL does not contain the old hash.');
189 189
     $this->assertTrue(strpos($image_style_url, $new_hash) !== FALSE, 'The image style URL contains an updated hash.');
Please login to merge, or discard this patch.