/** * セットアップ */ public function setUp($action, $context) { $action = us($action); switch ($action) { case "get_empty_data": case "get_integer_data": case "get_string_data": case "get_array_data": case "get_boolean_data": case "get_float_data": case "get_object_data": case "set_duration": case "delete": case "delete_wildcard": case "delete_regex": case "touch": case "touch_wildcard": case "touch_regex": $cache_driver = $context->createObject('file', 'cache_driver', 'Charcoal_ICacheDriver'); $this->cache_root = Charcoal_ResourceLocator::getPath('%CHARCOAL_HOME%/tmp/test/cache/'); $config['cache_root'] = $this->cache_root; $config = new Charcoal_Config($this->getSandbox()->getEnvironment(), $config); $cache_driver->configure($config); $this->cache_driver = $cache_driver; $cache_files = glob($this->cache_root . '/*'); if ($cache_files && is_array($cache_files)) { foreach ($cache_files as $cache) { $file = new Charcoal_File(s($cache)); $name = $file->getName(); $ext = $file->getExtension(); if ($file->exists() && $file->isFile() && in_array($ext, array("meta", "data"))) { $file->delete(); echo "removed cache file: [{$cache}]" . eol(); } } } break; default: break; } }
/** * Get framework/project/application path * * @param Charcoal_String $virtual_path virtual path including macro key like '%BASE_DIR%', '%WEBAPP_DIR%', etc. * @param Charcoal_Object $value cache data to save * * @return Charcoal_String full path string * * [macro keyword sample] * * macro keyword | return value(real path) * -------------------------|------------------------------------------------ * %APPLICATION_DIR% | (web_app_root)/webapp/(project_name)/app/(application name)/ * %PROJECT_DIR% | (web_app_root)/webapp/(project_name)/ * %WEBAPP_DIR% | (web_app_root)/webapp/ * * * @see Charcoal_ResourceLocator * */ public function getPath($virtual_path, $filename = NULL) { // Charcoal_ParamTrait::validateString( 1, $virtual_path ); // Charcoal_ParamTrait::validateString( 2, $filename, TRUE ); return Charcoal_ResourceLocator::getPath($this->getSandbox()->getEnvironment(), $virtual_path, $filename); }