-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCommentForm.php
More file actions
62 lines (50 loc) · 1.45 KB
/
CommentForm.php
File metadata and controls
62 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Created by JetBrains PhpStorm.
* User: alex
* Date: 01/09/2013
* Time: 15:23
* To change this template use File | Settings | File Templates.
*/
namespace DrupalPatchUtils;
class CommentForm extends DoFormBase
{
/**
* The browser.
*
* @var \DrupalPatchUtils\DoBrowser
*/
protected $browser;
public function __construct(DoBrowser $browser)
{
$this->browser = $browser;
$this->form = $this->getCrawler()->selectButton('Save')->form();
}
public function setCommentText($text)
{
$comment = $this->form->get('nodechanges_comment_body[value]');
$comment->setValue($text);
$this->form->set($comment);
return $this;
}
public function uploadFiles(array $files = [])
{
$file_nr = 0;
foreach ($files as $key => $file) {
$this->form = $this->getCrawler()->selectButton('Upload')->form();
while (!($this->form->has("files[field_issue_files_und_$file_nr]"))) {
$file_nr++;
}
$this->form["files[field_issue_files_und_$file_nr]"]->setFilePath($file);
$this->browser->getClient()->submit($this->form);
}
$this->form = $this->getCrawler()->selectButton('Save')->form();
}
/**
* @return null|\Symfony\Component\DomCrawler\Crawler
*/
protected function getCrawler()
{
return $this->browser->getClient()->getCrawler();
}
}