public static function loadYaml($name) { $file = SF_ROOT_DIR . "/plugins/sfMobileCarrierJPPlugin/data/" . $name . ".yml"; $fileCache = new sfFileCache(array('cache_dir' => SF_ROOT_DIR . "/cache/" . SF_APP . "/" . SF_ENVIRONMENT . "/sfMobileCarrierJPPlugin")); $cache = new sfFunctionCache($fileCache); return $cache->call("sfYaml::load", $file); }
public function getYachoPictures($type = 'side') { $res = array(); $toriName = $this->getRandamYachoName(); $res['toriName'] = $toriName; $imageWidth = 150; if (sfConfig::get('app_tori_yacho_picture_image_width_' . $type)) { $imageWidth = sfConfig::get('app_tori_yacho_picture_image_width_' . $type); } $res['imageWidth'] = $imageWidth; $linkUrl = ''; if (Doctrine::getTable('SnsConfig')->get('op_tori_yacho_picture_plugin_use_wiki_link', true)) { $linkUrl = 'http://ja.wikipedia.org/wiki/'; $linkUrl .= urlencode($toriName); } $res['linkUrl'] = $linkUrl; $imageUrl = ''; if (sfConfig::get('app_tori_yacho_picture_is_enable_search_result_cache')) { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . '/function')); $fc = new sfFunctionCache($cache); $results = $fc->call(array('opToriYachoPicturePluginToolkit', 'getYachoPictureSearchResults'), array($toriName)); } else { $results = opToriYachoPicturePluginToolkit::getYachoPictureSearchResults($toriName); } if ($results) { $i = mt_rand(0, count($results)); $imageUrl = $results[$i]->url; } $res['imageUrl'] = $imageUrl; return $res; }
} } $count = 0; function testFunctionCache($arg1, $arg2) { global $count; ++$count; return $arg1 . $arg2; } // ->call() $t->diag('->call()'); $cache = new sfSimpleCache(); $functionCache = new sfFunctionCache($cache); $result = testFunctionCache(1, 2); $t->is($count, 1); $t->is($functionCache->call('testFunctionCache', array(1, 2)), $result, '->call() works with functions'); $t->is($count, 2); $t->is($functionCache->call('testFunctionCache', array(1, 2)), $result, '->call() stores the function call in cache'); $t->is($count, 2); $result = testFunctionCache::test(1, 2); $t->is(testFunctionCache::$count, 1); $t->is($functionCache->call(array('testFunctionCache', 'test'), array(1, 2)), $result, '->call() works with static method calls'); $t->is(testFunctionCache::$count, 2); $t->is($functionCache->call(array('testFunctionCache', 'test'), array(1, 2)), $result, '->call() stores the function call in cache'); $t->is(testFunctionCache::$count, 2); testFunctionCache::$count = 0; $object = new testFunctionCache(); $result = $object->test(1, 2); $t->is(testFunctionCache::$count, 1); $t->is($functionCache->call(array($object, 'test'), array(1, 2)), $result, '->call() works with object methods'); $t->is(testFunctionCache::$count, 2);