/** * Can we create a cached object? * * @access public */ public function testCreateCachedObject() { // Load the config file Core\Config::load('MyProject'); Core\Config::set('cache', 'enable', true, true); // Put the cache Core\Cache::put('foo', 'bar'); // The file exists? $this->assertTrue(Core\Cache::has('foo')); // And the file has the correct contents? $this->assertEquals(Core\Cache::get('foo'), 'bar'); }
* @route /base/popup-output * Popup output */ new Core\Route('/popup-output', function (Core\Controller $Controller) use($Base) { return $Controller->h1('Hello!', '/base/popup-output')->menu($Base->menu())->render('popup-output.html'); }); /** * @route /base/comments-and-likes * In this example we look into adding Comments & Likes to your items */ new Core\Route('/comments-and-likes', function (Core\Controller $Controller) use($Base) { // Load the needed classes $ApiFeed = new \Api\Feed(); $Cache = new \Core\Cache(); // Check if we cached a feed ID# earlier $feedId = $Cache->get('test_feed_id'); if (!$feedId) { // Create a new post $feed = $ApiFeed->post(['type_id' => 'PHPfox_Base', 'content' => 'Hello! I am a post.']); // Add post to cache so we don't have to create a new post every time $Cache->set('test_feed_id', $feed->id); $feedId = $feed->id; } /** * Get a feed. When you get a feed it automatically loads the Comment & Like block routine. * You just need to output it in the HTML view file using {{ comments() }} */ $ApiFeed->get($feedId); return $Controller->title('Comments & Likes')->section('PHPfox App Base', '/base')->h1('Comments & Likes', '/base/comments-and-likes')->menu($Base->menu())->render('comments-and-likes.html'); }); /**