Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / Tests / Classic / ParagraphsCoreVersionUiTestTrait.php
1 <?php
2
3 namespace Drupal\paragraphs\Tests\Classic;
4
5 /**
6  * Provides helper methods for Drupal 8.3.x and 8.4.x versions.
7  */
8 trait ParagraphsCoreVersionUiTestTrait {
9
10   /**
11    * An adapter for 8.3 > 8.4 Save (and (un)publish) node button change.
12    *
13    * Arguments are the same as WebTestBase::drupalPostForm.
14    *
15    * @see \Drupal\simpletest\WebTestBase::drupalPostForm
16    * @see https://www.drupal.org/node/2847274
17    *
18    * @param \Drupal\Core\Url|string $path
19    *   Location of the post form.
20    * @param array $edit
21    *   Field data in an associative array.
22    * @param mixed $submit
23    *   Value of the submit button whose click is to be emulated. For example,
24    * @param array $options
25    *   (optional) Options to be forwarded to the url generator.
26    * @param array $headers
27    *   (optional) An array containing additional HTTP request headers.
28    * @param string $form_html_id
29    *   (optional) HTML ID of the form to be submitted.
30    * @param string $extra_post
31    *   (optional) A string of additional data to append to the POST submission.
32    */
33   protected function paragraphsPostNodeForm($path, $edit, $submit, array $options = [], array $headers = [], $form_html_id = NULL, $extra_post = NULL) {
34     $drupal_version = (float) substr(\Drupal::VERSION, 0, 3);
35     if ($drupal_version > 8.3) {
36       switch ($submit) {
37         case  t('Save and unpublish'):
38           $submit = t('Save');
39           $edit['status[value]'] = FALSE;
40           break;
41
42         case t('Save and publish'):
43           $submit = t('Save');
44           $edit['status[value]'] = TRUE;
45           break;
46
47         case t('Save and keep published (this translation)'):
48           $submit = t('Save (this translation)');
49           break;
50
51         default:
52           $submit = t('Save');
53       }
54     }
55     parent::drupalPostForm($path, $edit, $submit, $options, $headers, $form_html_id, $extra_post);
56   }
57
58 }