class Helpers in Flickr 8
Class Helpers.
@package Drupal\flickr\Service
Hierarchy
- class \Drupal\flickr\Service\Helpers
Expanded class hierarchy of Helpers
1 file declares its use of Helpers
- FlickrFilter.php in modules/
flickr_filter/ src/ Plugin/ Filter/ FlickrFilter.php
1 string reference to 'Helpers'
1 service uses Helpers
File
- src/
Service/ Helpers.php, line 12
Namespace
Drupal\flickr\ServiceView source
class Helpers {
/**
* Helpers constructor.
*
* @param \Drupal\flickr_api\Service\Helpers $flickrApiHelpers
* Helpers.
*/
public function __construct(FlickrApiHelpers $flickrApiHelpers) {
// Flickr API Helpers.
$this->flickrApiHelpers = $flickrApiHelpers;
}
/**
* Split the config.
*
* Parse parameters to the fiter from a format like:
* id=26159919@N00, size=m,num=9
* into an associative array with two sub-arrays. The first sub-array are
* parameters for the request,
* the second are HTML attributes (class and style).
*
* @param string $string
* Param String.
*
* @return array
* Return array.
*/
public function splitConfig($string) {
$config = [];
$attribs = [];
// Put each setting on its own line.
$string = str_replace(',', "\n", $string);
// Break them up around the equal sign (=).
preg_match_all('/([a-zA-Z_.]+)=([-@\\/0-9a-zA-Z :;_.\\|\\%"\'&°]+)/', $string, $parts, PREG_SET_ORDER);
foreach ($parts as $part) {
// Normalize to lowercase and remove extra spaces.
$name = strtolower(trim($part[1]));
$value = htmlspecialchars_decode(trim($part[2]));
// Remove undesired but tolerated characters from the value.
$value = str_replace(str_split('"\''), '', $value);
if ($name == 'style' || $name == 'class') {
$attribs[$name] = $value;
}
else {
$config[$name] = $value;
}
}
return [
$config,
$attribs,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Helpers:: |
public | function | Split the config. | |
Helpers:: |
public | function | Helpers constructor. |