]> _ Git - cubist_locale.git/commitdiff
#2868
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jul 2019 13:27:56 +0000 (15:27 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jul 2019 13:27:56 +0000 (15:27 +0200)
src/Country.php
src/List.php [deleted file]
src/Locale.php
src/LocalizedList.php [new file with mode: 0644]

index 4ebd3c1e3d4f53ca08b6c75e18a444c481fca0c0..bd245713b8dc4e768960db9610b5bc8b40d51584 100644 (file)
@@ -6,5 +6,5 @@ namespace Cubist\Locale;
 
 class Country extends LocalizedList
 {
-    protected static $_listPath = '/vendor/umpirsky/country-list/data/$locale/country.php';
+    protected static $_listPath = 'vendor/umpirsky/country-list/data/$locale/country.php';
 }
diff --git a/src/List.php b/src/List.php
deleted file mode 100644 (file)
index 4bc03d9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace Cubist\Locale;
-class LocalizedList
-{
-    protected static $_rawList = [];
-    protected static $_listPath='';
-
-    public static function getList($locale)
-    {
-        if (!isset(self::$_rawList[$locale])) {
-            self::$_rawList[$locale] = static::_getList($locale);
-        }
-        return self::$_rawList[$locale];
-    }
-
-    /**
-     * @param string $locale
-     * @return array
-     */
-    protected static function _getList($locale)
-    {
-       include base_path(str_replace('$locale',$locale,self::$_listPath));
-    }
-}
index 2a854fac715d1e8f89a1087071eb45e7dbdd28b7..a0fbee734859040c8177ca4065c36257f946dd6e 100644 (file)
@@ -4,5 +4,5 @@ namespace Cubist\Locale;
 
 class Locale extends LocalizedList
 {
-    protected static $_listPath = '/vendor/umpirsky/locale-list/data/$locale/locales.php';
+    protected static $_listPath = 'vendor/umpirsky/locale-list/data/$locale/locales.php';
 }
diff --git a/src/LocalizedList.php b/src/LocalizedList.php
new file mode 100644 (file)
index 0000000..4c61c92
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace Cubist\Locale;
+class LocalizedList
+{
+    protected static $_rawList = [];
+    protected static $_listPath = '';
+
+    public static function getList($locale)
+    {
+        if (!isset(self::$_rawList[$locale])) {
+            self::$_rawList[$locale] = static::_getList($locale);
+        }
+        return self::$_rawList[$locale];
+    }
+
+    /**
+     * @param string $locale
+     * @return array
+     */
+    protected static function _getList($locale)
+    {
+        $f = base_path(str_replace('$locale', $locale, self::$_listPath));
+        if (!file_exists($f)) {
+            return [];
+        }
+        include $f;
+    }
+}