/** * Constructor */ public function __construct() { // Connection creation $this->memcacheObj = new \Memcached(); $config = \Erdiko::getConfig("local/cache"); $host = $config["memcached"]["host"]; $port = $config["memcached"]["port"]; $cacheAvailable = $this->memcacheObj->addServer($host, $port); }
/** * @expectedException PHPUnit_Framework_Error */ public function testConfigException() { /** * Second Test * * Passing a non-exist config file */ $fileName = "application/non-exist"; $this->assertTrue(Erdiko::getConfig($fileName) != false); }
/** * Get the cache instance * * @param string $cacheConfig * @return object */ public static function getCacheObject($cacheConfig = 'default') { //Check if the caller requests an new object if (empty(self::$instance[$cacheConfig])) { $config = \Erdiko::getConfig('application/default'); //Check if the object already be created if (isset($config["cache"][$cacheConfig])) { self::$instance[$cacheConfig] = new $config["cache"][$cacheConfig]['class'](); } else { throw new \Exception("There is no cache config defined ({$cacheConfig})"); } } return self::$instance[$cacheConfig]; }
<?php /** * Bootstrap Eloquent * * @category erdiko * @package eloquent * @copyright Copyright (c) 2016, Arroyo Labs, http://www.arroyolabs.com * @author John Arroyo, john@arroyolabs.com */ use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule(); // Get db credentials from the database.json config $dbConfig = \Erdiko::getConfig('local/database'); $creds = $dbConfig['connections'][$dbConfig['default']]; $capsule->addConnection(array('driver' => $creds['driver'], 'host' => $creds['host'], 'database' => $creds['database'], 'username' => $creds['username'], 'password' => $creds['password'], 'charset' => $creds['charset'], 'collation' => $creds['collation'], 'prefix' => $creds['prefix'])); $capsule->bootEloquent();
public static function getCache($cacheType = null) { $config = Erdiko::getConfig("contexts/default"); if (!isset($cacheType)) { $cacheType = "default"; } if (isset($config["cache"][$cacheType])) { $cacheConfig = $config["cache"][$cacheType]; $class = "erdiko\\core\\cache\\" . $cacheConfig["type"]; return new $class(); } else { return false; } }
/** * Get the API Scope * * @return string **/ private function returnScope() { $config = \Erdiko::getConfig('local/shopify'); return $config['appInfo']['SHOPIFY_SCOPE']; }
/** * Get About */ public function getAbout() { $this->setTitle("About"); $data = \Erdiko::getConfig("application/default"); $this->setContent("<h2>{$data['site']['full_name']}</h2> <h3>{$data['site']['tagline']}</h3> <p>{$data['site']['description']}</p>"); }
<?php /** important: download zend and place in /www/libraries/Zend **/ // Register Zend autoloader require_once "Zend/Loader.php"; spl_autoload_register(array("Zend_Loader", "loadClass")); /** GET CONFIGS FROM json FILE ***/ $config = Erdiko::getConfig('local/database'); // Use the master settings for now $config = $config['master']; /* CREATE THE DB ADABPTER OUT OF CONFIGURATIONS */ $db = Zend_Db::factory($config['adapter'], $config['params']); /* @TODO: ATTACH THE PROFILER TO THE DB ADAPTER */ /* RUN BASIC QUERIES TO HAVE THE DATA ENTIRELY IN UNICODE */ //$db->query('SET NAMES utf8'); //$db->query('SET CHARACTER SET utf8'); /* SETUP A FIXED DATABASE ADAPTER FOR ALL MODELS THROUGHOUT THE ENTIRE APPLICATION */ Abstract_Table::setDefaultAdapter($db);
/** * Get About */ public function getAbout() { $this->setTitle("About"); $data = \Erdiko::getConfig("application", getenv('ERDIKO_CONTEXT')); $this->addView('examples/about', $data); }