Update to Drupal 8.0.0-rc3. For more information, see https://www.drupal.org/node/2608078
This commit is contained in:
parent
6419a031d7
commit
4afb23bbd3
762 changed files with 20080 additions and 6368 deletions
45
vendor/jcalderonzumba/mink-phantomjs-driver/src/CookieTrait.php
vendored
Normal file
45
vendor/jcalderonzumba/mink-phantomjs-driver/src/CookieTrait.php
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Zumba\Mink\Driver;
|
||||
|
||||
use Zumba\GastonJS\Cookie;
|
||||
|
||||
/**
|
||||
* Trait CookieTrait
|
||||
* @package Zumba\Mink\Driver
|
||||
*/
|
||||
trait CookieTrait {
|
||||
|
||||
/**
|
||||
* Sets a cookie on the browser, if null value then delete it
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function setCookie($name, $value = null) {
|
||||
if ($value === null) {
|
||||
$this->browser->removeCookie($name);
|
||||
}
|
||||
//TODO: set the cookie with domain, not with url, meaning www.aaa.com or .aaa.com
|
||||
if ($value !== null) {
|
||||
$urlData = parse_url($this->getCurrentUrl());
|
||||
$cookie = array("name" => $name, "value" => $value, "domain" => $urlData["host"]);
|
||||
$this->browser->setCookie($cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cookie by its name if exists, else it will return null
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function getCookie($name) {
|
||||
$cookies = $this->browser->cookies();
|
||||
foreach ($cookies as $cookie) {
|
||||
if ($cookie instanceof Cookie && strcmp($cookie->getName(), $name) === 0) {
|
||||
return $cookie->getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue