class CartLinksValidator in Ubercart 8.4
Utility functions for dealing with Cart Links.
Hierarchy
- class \Drupal\uc_cart_links\CartLinksValidator implements CartLinksValidatorInterface
Expanded class hierarchy of CartLinksValidator
1 file declares its use of CartLinksValidator
- CartLinksRegexpTest.php in uc_cart_links/
tests/ src/ Unit/ CartLinksRegexpTest.php
1 string reference to 'CartLinksValidator'
- uc_cart_links.services.yml in uc_cart_links/
uc_cart_links.services.yml - uc_cart_links/uc_cart_links.services.yml
1 service uses CartLinksValidator
File
- uc_cart_links/
src/ CartLinksValidator.php, line 10
Namespace
Drupal\uc_cart_linksView source
class CartLinksValidator implements CartLinksValidatorInterface {
/**
* The messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Constructor.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
*/
public function __construct(MessengerInterface $messenger) {
$this->messenger = $messenger;
}
/**
* {@inheritdoc}
*/
public function isValidSyntax($link, $debug = FALSE) {
$result = preg_match('~/cart/add/(e-)?(p[1-9][0-9]*(_q[1-9][0-9]*)*(_a[1-9][0-9]*o[a-zA-Z0-9%]+)*(_s)?)+(-m[0-9]+|-i[a-zA-Z0-9]+)*(\\?destination=/[a-zA-Z0-9/%]+)?~', $link, $matches);
if ($debug) {
$this->messenger
->addMessage('Cart Link = ' . $link);
$this->messenger
->addMessage('Regular expression matches = <pre>' . print_r($matches) . '</pre>');
}
return (bool) $result;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CartLinksValidator:: |
protected | property | The messenger service. | |
CartLinksValidator:: |
public | function |
Tests a string containing a Cart Link to see if it is syntactically valid. Overrides CartLinksValidatorInterface:: |
|
CartLinksValidator:: |
public | function | Constructor. |