@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'A' => 'X', |
|
| 5 | - 'B' => 'B' |
|
| 4 | + 'A' => 'X', |
|
| 5 | + 'B' => 'B' |
|
| 6 | 6 | ]; |
@@ -19,17 +19,17 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Plugin extends AbstractPlugin { |
| 21 | 21 | |
| 22 | - protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 22 | + protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * onPluginsLoaded method |
|
| 26 | - * |
|
| 27 | - * @param null $data |
|
| 28 | - * |
|
| 29 | - * @return mixed|void |
|
| 30 | - */ |
|
| 31 | - public function onPluginsLoaded($data = null) { |
|
| 32 | - ServiceLocator::registerService('Phile_Template', |
|
| 33 | - new Twig($this->settings)); |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * onPluginsLoaded method |
|
| 26 | + * |
|
| 27 | + * @param null $data |
|
| 28 | + * |
|
| 29 | + * @return mixed|void |
|
| 30 | + */ |
|
| 31 | + public function onPluginsLoaded($data = null) { |
|
| 32 | + ServiceLocator::registerService('Phile_Template', |
|
| 33 | + new Twig($this->settings)); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** config file */ |
| 3 | 3 | return array( |
| 4 | - 'template-extension' => 'html', // template file extension |
|
| 5 | - 'cache' => false, // To enable Twig caching change this to CACHE_DIR |
|
| 6 | - 'autoescape' => false, // Autoescape Twig vars |
|
| 7 | - 'debug' => false // Enable Twig debug |
|
| 4 | + 'template-extension' => 'html', // template file extension |
|
| 5 | + 'cache' => false, // To enable Twig caching change this to CACHE_DIR |
|
| 6 | + 'autoescape' => false, // Autoescape Twig vars |
|
| 7 | + 'debug' => false // Enable Twig debug |
|
| 8 | 8 | ); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * persistence implementation class |
|
| 4 | - */ |
|
| 3 | + * persistence implementation class |
|
| 4 | + */ |
|
| 5 | 5 | namespace Phile\Plugin\Phile\SimpleFileDataPersistence\Persistence; |
| 6 | 6 | |
| 7 | 7 | use Phile\ServiceLocator\PersistenceInterface; |
@@ -15,90 +15,90 @@ discard block |
||
| 15 | 15 | * @package Phile\Plugin\Phile\SimpleFileDataPersistence\Persistence |
| 16 | 16 | */ |
| 17 | 17 | class SimpleFileDataPersistence implements PersistenceInterface { |
| 18 | - /** @var string $dataDirectory the data storage directory */ |
|
| 19 | - protected $dataDirectory; |
|
| 18 | + /** @var string $dataDirectory the data storage directory */ |
|
| 19 | + protected $dataDirectory; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * the constructor |
|
| 23 | - */ |
|
| 24 | - public function __construct() { |
|
| 25 | - $this->dataDirectory = STORAGE_DIR; |
|
| 26 | - } |
|
| 21 | + /** |
|
| 22 | + * the constructor |
|
| 23 | + */ |
|
| 24 | + public function __construct() { |
|
| 25 | + $this->dataDirectory = STORAGE_DIR; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * check if key exists |
|
| 30 | - * |
|
| 31 | - * @param $key |
|
| 32 | - * |
|
| 33 | - * @return bool|mixed |
|
| 34 | - */ |
|
| 35 | - public function has($key) { |
|
| 36 | - return (file_exists($this->getStorageFile($key))); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * check if key exists |
|
| 30 | + * |
|
| 31 | + * @param $key |
|
| 32 | + * |
|
| 33 | + * @return bool|mixed |
|
| 34 | + */ |
|
| 35 | + public function has($key) { |
|
| 36 | + return (file_exists($this->getStorageFile($key))); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * get value for given key |
|
| 41 | - * |
|
| 42 | - * @param $key |
|
| 43 | - * |
|
| 44 | - * @return mixed |
|
| 45 | - * @throws \Phile\Exception\AbstractException |
|
| 46 | - */ |
|
| 47 | - public function get($key) { |
|
| 48 | - if (!$this->has($key)) { |
|
| 49 | - throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!"); |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * get value for given key |
|
| 41 | + * |
|
| 42 | + * @param $key |
|
| 43 | + * |
|
| 44 | + * @return mixed |
|
| 45 | + * @throws \Phile\Exception\AbstractException |
|
| 46 | + */ |
|
| 47 | + public function get($key) { |
|
| 48 | + if (!$this->has($key)) { |
|
| 49 | + throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!"); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return unserialize(file_get_contents($this->getStorageFile($key))); |
|
| 53 | - } |
|
| 52 | + return unserialize(file_get_contents($this->getStorageFile($key))); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * set value for given key |
|
| 57 | - * |
|
| 58 | - * @param $key |
|
| 59 | - * @param $value |
|
| 60 | - * |
|
| 61 | - * @return mixed|void |
|
| 62 | - */ |
|
| 63 | - public function set($key, $value) { |
|
| 64 | - file_put_contents($this->getStorageFile($key), serialize($value)); |
|
| 65 | - } |
|
| 55 | + /** |
|
| 56 | + * set value for given key |
|
| 57 | + * |
|
| 58 | + * @param $key |
|
| 59 | + * @param $value |
|
| 60 | + * |
|
| 61 | + * @return mixed|void |
|
| 62 | + */ |
|
| 63 | + public function set($key, $value) { |
|
| 64 | + file_put_contents($this->getStorageFile($key), serialize($value)); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * delte given key/index |
|
| 69 | - * |
|
| 70 | - * @param string $key |
|
| 71 | - * @param array $options |
|
| 72 | - * |
|
| 73 | - * @return mixed|void |
|
| 74 | - * @throws \Phile\Exception\AbstractException |
|
| 75 | - */ |
|
| 76 | - public function delete($key, array $options = array()) { |
|
| 77 | - if (!$this->has($key)) { |
|
| 78 | - throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!"); |
|
| 79 | - } |
|
| 80 | - unlink($this->getStorageFile($key)); |
|
| 81 | - } |
|
| 67 | + /** |
|
| 68 | + * delte given key/index |
|
| 69 | + * |
|
| 70 | + * @param string $key |
|
| 71 | + * @param array $options |
|
| 72 | + * |
|
| 73 | + * @return mixed|void |
|
| 74 | + * @throws \Phile\Exception\AbstractException |
|
| 75 | + */ |
|
| 76 | + public function delete($key, array $options = array()) { |
|
| 77 | + if (!$this->has($key)) { |
|
| 78 | + throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!"); |
|
| 79 | + } |
|
| 80 | + unlink($this->getStorageFile($key)); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * generate internal key |
|
| 85 | - * |
|
| 86 | - * @param $key |
|
| 87 | - * |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - protected function getInternalKey($key) { |
|
| 91 | - return md5($key); |
|
| 92 | - } |
|
| 83 | + /** |
|
| 84 | + * generate internal key |
|
| 85 | + * |
|
| 86 | + * @param $key |
|
| 87 | + * |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + protected function getInternalKey($key) { |
|
| 91 | + return md5($key); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * get storage filename |
|
| 96 | - * |
|
| 97 | - * @param $key |
|
| 98 | - * |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - protected function getStorageFile($key) { |
|
| 102 | - return $this->dataDirectory . $this->getInternalKey($key) . '.ds'; |
|
| 103 | - } |
|
| 94 | + /** |
|
| 95 | + * get storage filename |
|
| 96 | + * |
|
| 97 | + * @param $key |
|
| 98 | + * |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + protected function getStorageFile($key) { |
|
| 102 | + return $this->dataDirectory . $this->getInternalKey($key) . '.ds'; |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin class |
|
| 4 | - */ |
|
| 3 | + * Plugin class |
|
| 4 | + */ |
|
| 5 | 5 | namespace Phile\Plugin\Phile\SimpleFileDataPersistence; |
| 6 | 6 | |
| 7 | 7 | use Phile\Core\ServiceLocator; |
@@ -19,17 +19,17 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class Plugin extends AbstractPlugin { |
| 21 | 21 | |
| 22 | - protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 22 | + protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * onPluginsLoaded method |
|
| 26 | - * |
|
| 27 | - * @param null $data |
|
| 28 | - * |
|
| 29 | - * @return mixed|void |
|
| 30 | - */ |
|
| 31 | - public function onPluginsLoaded($data = null) { |
|
| 32 | - ServiceLocator::registerService('Phile_Data_Persistence', |
|
| 33 | - new SimpleFileDataPersistence()); |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * onPluginsLoaded method |
|
| 26 | + * |
|
| 27 | + * @param null $data |
|
| 28 | + * |
|
| 29 | + * @return mixed|void |
|
| 30 | + */ |
|
| 31 | + public function onPluginsLoaded($data = null) { |
|
| 32 | + ServiceLocator::registerService('Phile_Data_Persistence', |
|
| 33 | + new SimpleFileDataPersistence()); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * config file |
|
| 4 | - */ |
|
| 3 | + * config file |
|
| 4 | + */ |
|
| 5 | 5 | $config = array(); |
| 6 | 6 | |
| 7 | 7 | return $config; |
| 8 | 8 | \ No newline at end of file |
@@ -13,73 +13,73 @@ |
||
| 13 | 13 | * @package Phile\Plugin\Phile\PhpFastCache |
| 14 | 14 | */ |
| 15 | 15 | class PhpFastCache implements \Phile\ServiceLocator\CacheInterface { |
| 16 | - /** |
|
| 17 | - * @var \BasePhpFastCache the cache engine |
|
| 18 | - */ |
|
| 19 | - protected $cacheEngine; |
|
| 16 | + /** |
|
| 17 | + * @var \BasePhpFastCache the cache engine |
|
| 18 | + */ |
|
| 19 | + protected $cacheEngine; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * the constructor |
|
| 23 | - * |
|
| 24 | - * @param \BasePhpFastCache $cacheEngine |
|
| 25 | - */ |
|
| 26 | - public function __construct(\BasePhpFastCache $cacheEngine) { |
|
| 27 | - $this->cacheEngine = $cacheEngine; |
|
| 28 | - } |
|
| 21 | + /** |
|
| 22 | + * the constructor |
|
| 23 | + * |
|
| 24 | + * @param \BasePhpFastCache $cacheEngine |
|
| 25 | + */ |
|
| 26 | + public function __construct(\BasePhpFastCache $cacheEngine) { |
|
| 27 | + $this->cacheEngine = $cacheEngine; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * method to check if cache has entry for given key |
|
| 32 | - * |
|
| 33 | - * @param $key |
|
| 34 | - * |
|
| 35 | - * @return bool|mixed |
|
| 36 | - */ |
|
| 37 | - public function has($key) { |
|
| 38 | - return ($this->cacheEngine->get($key) !== null); |
|
| 39 | - } |
|
| 30 | + /** |
|
| 31 | + * method to check if cache has entry for given key |
|
| 32 | + * |
|
| 33 | + * @param $key |
|
| 34 | + * |
|
| 35 | + * @return bool|mixed |
|
| 36 | + */ |
|
| 37 | + public function has($key) { |
|
| 38 | + return ($this->cacheEngine->get($key) !== null); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * method to get cache entry |
|
| 43 | - * |
|
| 44 | - * @param $key |
|
| 45 | - * |
|
| 46 | - * @return mixed|null |
|
| 47 | - */ |
|
| 48 | - public function get($key) { |
|
| 49 | - return $this->cacheEngine->get($key); |
|
| 50 | - } |
|
| 41 | + /** |
|
| 42 | + * method to get cache entry |
|
| 43 | + * |
|
| 44 | + * @param $key |
|
| 45 | + * |
|
| 46 | + * @return mixed|null |
|
| 47 | + */ |
|
| 48 | + public function get($key) { |
|
| 49 | + return $this->cacheEngine->get($key); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * method to set cache entry |
|
| 54 | - * |
|
| 55 | - * @param string $key |
|
| 56 | - * @param string $value |
|
| 57 | - * @param int $time |
|
| 58 | - * @param array $options |
|
| 59 | - * |
|
| 60 | - * @return mixed|void |
|
| 61 | - */ |
|
| 62 | - public function set($key, $value, $time = 300, array $options = array()) { |
|
| 63 | - $this->cacheEngine->set($key, $value, $time, $options); |
|
| 64 | - } |
|
| 52 | + /** |
|
| 53 | + * method to set cache entry |
|
| 54 | + * |
|
| 55 | + * @param string $key |
|
| 56 | + * @param string $value |
|
| 57 | + * @param int $time |
|
| 58 | + * @param array $options |
|
| 59 | + * |
|
| 60 | + * @return mixed|void |
|
| 61 | + */ |
|
| 62 | + public function set($key, $value, $time = 300, array $options = array()) { |
|
| 63 | + $this->cacheEngine->set($key, $value, $time, $options); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * method to delete cache entry |
|
| 68 | - * |
|
| 69 | - * @param string $key |
|
| 70 | - * @param array $options |
|
| 71 | - * |
|
| 72 | - * @return mixed|void |
|
| 73 | - */ |
|
| 74 | - public function delete($key, array $options = array()) { |
|
| 75 | - $this->cacheEngine->delete($key, $options); |
|
| 76 | - } |
|
| 66 | + /** |
|
| 67 | + * method to delete cache entry |
|
| 68 | + * |
|
| 69 | + * @param string $key |
|
| 70 | + * @param array $options |
|
| 71 | + * |
|
| 72 | + * @return mixed|void |
|
| 73 | + */ |
|
| 74 | + public function delete($key, array $options = array()) { |
|
| 75 | + $this->cacheEngine->delete($key, $options); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * clean complete cache and delete all cached entries |
|
| 80 | - */ |
|
| 81 | - public function clean() { |
|
| 82 | - $this->cacheEngine->clean(); |
|
| 83 | - } |
|
| 78 | + /** |
|
| 79 | + * clean complete cache and delete all cached entries |
|
| 80 | + */ |
|
| 81 | + public function clean() { |
|
| 82 | + $this->cacheEngine->clean(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
@@ -18,20 +18,20 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Plugin extends AbstractPlugin { |
| 20 | 20 | |
| 21 | - protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 21 | + protected $events = ['plugins_loaded' => 'onPluginsLoaded']; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * onPluginsLoaded method |
|
| 25 | - */ |
|
| 26 | - public function onPluginsLoaded() { |
|
| 27 | - // phpFastCache not working in CLI mode... |
|
| 28 | - if (PHILE_CLI_MODE) { |
|
| 29 | - return; |
|
| 30 | - } |
|
| 31 | - unset($this->settings['active']); |
|
| 32 | - $config = $this->settings + \phpFastCache::$config; |
|
| 33 | - $storage = $this->settings['storage']; |
|
| 34 | - $cache = phpFastCache($storage, $config); |
|
| 35 | - ServiceLocator::registerService('Phile_Cache', new PhpFastCache($cache)); |
|
| 36 | - } |
|
| 23 | + /** |
|
| 24 | + * onPluginsLoaded method |
|
| 25 | + */ |
|
| 26 | + public function onPluginsLoaded() { |
|
| 27 | + // phpFastCache not working in CLI mode... |
|
| 28 | + if (PHILE_CLI_MODE) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | + unset($this->settings['active']); |
|
| 32 | + $config = $this->settings + \phpFastCache::$config; |
|
| 33 | + $storage = $this->settings['storage']; |
|
| 34 | + $cache = phpFastCache($storage, $config); |
|
| 35 | + ServiceLocator::registerService('Phile_Cache', new PhpFastCache($cache)); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -1,50 +1,50 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * config file for plugin |
|
| 4 | - */ |
|
| 3 | + * config file for plugin |
|
| 4 | + */ |
|
| 5 | 5 | $config = [ |
| 6 | - /** |
|
| 7 | - * Default storage engine |
|
| 8 | - * |
|
| 9 | - * e.g. "files": $cache = phpFastCache(); <-- will be files cache |
|
| 10 | - * |
|
| 11 | - * auto, files, sqlite, auto, apc, wincache, xcache, memcache, memcached, |
|
| 12 | - */ |
|
| 13 | - 'storage' => 'auto', |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * Default Path for File Cache |
|
| 17 | - * |
|
| 18 | - * Use full PATH like /home/username/cache |
|
| 19 | - * Keep it blank "", it will automatic setup for you |
|
| 20 | - */ |
|
| 21 | - 'path' => CACHE_DIR, |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Permissions for file storage |
|
| 25 | - */ |
|
| 6 | + /** |
|
| 7 | + * Default storage engine |
|
| 8 | + * |
|
| 9 | + * e.g. "files": $cache = phpFastCache(); <-- will be files cache |
|
| 10 | + * |
|
| 11 | + * auto, files, sqlite, auto, apc, wincache, xcache, memcache, memcached, |
|
| 12 | + */ |
|
| 13 | + 'storage' => 'auto', |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * Default Path for File Cache |
|
| 17 | + * |
|
| 18 | + * Use full PATH like /home/username/cache |
|
| 19 | + * Keep it blank "", it will automatic setup for you |
|
| 20 | + */ |
|
| 21 | + 'path' => CACHE_DIR, |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Permissions for file storage |
|
| 25 | + */ |
|
| 26 | 26 | // 'default_chmod' => 0777, // For security, please use 0666 for module and 0644 for cgi. |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | // "securityKey" => "auto", // default will good. It will create a path by PATH/securityKey |
| 30 | 30 | |
| 31 | - /* |
|
| 31 | + /* |
|
| 32 | 32 | * FallBack Driver |
| 33 | 33 | * Example, in your code, you use memcached, apc..etc, but when you moved your web hosting |
| 34 | 34 | * The new hosting don't have memcached, or apc. What you do? Set fallback that driver to other driver. |
| 35 | 35 | */ |
| 36 | 36 | // "fallback" => "files", |
| 37 | 37 | |
| 38 | - /* |
|
| 38 | + /* |
|
| 39 | 39 | * .htaccess protect |
| 40 | 40 | * default will be true |
| 41 | 41 | */ |
| 42 | 42 | // "htaccess" => true, |
| 43 | 43 | |
| 44 | - /* |
|
| 44 | + /* |
|
| 45 | 45 | * Default Memcache Server for all $cache = phpFastCache("memcache"); |
| 46 | 46 | */ |
| 47 | - /* |
|
| 47 | + /* |
|
| 48 | 48 | "memcache" => array( |
| 49 | 49 | array("127.0.0.1",11211,1), |
| 50 | 50 | // array("new.host.ip",11211,1), |