MarkdownConfig.php in Markdown 8.2
File
src/Config/MarkdownConfig.php
View source
<?php
namespace Drupal\markdown\Config;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class MarkdownConfig extends Config implements ContainerInjectionInterface {
protected $keyPrefix;
public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, array $data = NULL) {
parent::__construct($name, $storage, $event_dispatcher, $typed_config);
if (isset($data)) {
$this
->initWithData($data);
}
}
public static function create(ContainerInterface $container = NULL, $name = NULL, array $data = NULL) {
if (!$container) {
$container = \Drupal::getContainer();
}
return new static($name, $container
->get('config.storage'), $container
->get('event_dispatcher'), $container
->get('config.typed'), $data);
}
public static function load($name, array $data = NULL, ContainerInterface $container = NULL) {
if (!isset($data)) {
$data = \Drupal::config($name)
->getRawData();
}
return static::create($container, $name, $data);
}
public function getKeyPrefix() {
return $this->keyPrefix;
}
protected function prefixKey($key) {
if ($prefix = $this
->getKeyPrefix()) {
if (($pos = strpos($key, "{$prefix}.")) === 0) {
$key = substr($key, strlen("{$prefix}."));
}
$key = "{$prefix}.{$key}";
}
return $key;
}
protected function prefixKeys(array $data) {
$prefixed = [];
foreach ($data as $key => $value) {
$prefixed[$this
->prefixKey($key)] = $value;
}
return $prefixed;
}
public function setKeyPrefix($keyPrefix) {
$this->keyPrefix = rtrim($keyPrefix, '.');
return $this;
}
}