From 939168f879be475c7ba893c8b3647472f8b864c3 Mon Sep 17 00:00:00 2001
From: andileco <daniel@andile.co>
Date: Fri, 7 Apr 2017 09:14:47 -0400
Subject: [PATCH] add ChartsSettingsService and interface to make it easier to
 use Charts without Views

---
 charts.services.yml                           |  4 ++++
 src/Services/ChartsSettingsService.php        | 21 +++++++++++++++++++
 .../ChartsSettingsServiceInterface.php        | 10 +++++++++
 3 files changed, 35 insertions(+)
 create mode 100644 src/Services/ChartsSettingsService.php
 create mode 100644 src/Services/ChartsSettingsServiceInterface.php

diff --git a/charts.services.yml b/charts.services.yml
index 6295540..ae62187 100644
--- a/charts.services.yml
+++ b/charts.services.yml
@@ -7,3 +7,7 @@ services:
 
   charts.views_variable:
     class: Drupal\charts\Services\ViewsDataService
+
+  charts.settings:
+    class: Drupal\charts\Services\ChartsSettingsService
+    arguments: ['@config.factory']
\ No newline at end of file
diff --git a/src/Services/ChartsSettingsService.php b/src/Services/ChartsSettingsService.php
new file mode 100644
index 0000000..2864c19
--- /dev/null
+++ b/src/Services/ChartsSettingsService.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Drupal\charts\Services;
+
+use Drupal\Core\Config\ConfigFactory;
+
+class ChartsSettingsService implements ChartsSettingsServiceInterface{
+
+  //private $editableConfigName = 'charts.settings';
+  private $configFactory;
+
+  public function __construct(ConfigFactory $config_factory){
+    $this->configFactory = $config_factory;
+  }
+
+  public function getChartsSettings(){
+    $config = $this->configFactory->getEditable('charts.settings');
+
+    return $config->get('charts_default_settings');
+  }
+}
\ No newline at end of file
diff --git a/src/Services/ChartsSettingsServiceInterface.php b/src/Services/ChartsSettingsServiceInterface.php
new file mode 100644
index 0000000..07ab16f
--- /dev/null
+++ b/src/Services/ChartsSettingsServiceInterface.php
@@ -0,0 +1,10 @@
+<?php
+
+
+namespace Drupal\charts\Services;
+
+
+interface ChartsSettingsServiceInterface {
+
+  public function getChartsSettings();
+}
\ No newline at end of file
-- 
GitLab