<?php
/**
* HTML Cache plugin for Craft CMS
*
* Generate HTML-file based caching for your Craft CMS
*
* @author Chris - CraftAPI
* @copyright Copyright (c) 2016 CraftAPI
* @link https://github.com/craftapi
* @package HTMLCache
* @since 1.0.0
* @version 1.0.1
*/
namespace Craft;
class HtmlcachePlugin extends BasePlugin
{
/**
* Call the service to check if we already have a cache file; register events
*
* @return mixed
*/
public function init()
{
craft()->htmlcache->checkForCacheFile();
craft()->attachEventHandler('onEndRequest', function() {
craft()->htmlcache->createCacheFile();
});
craft()->on('entries.saveEntry', function(Event $event) {
craft()->htmlcache->clearCacheFiles();
});
}
/**
* Returns the user-facing name.
*
* @return mixed
*/
public function getName()
{
return Craft::t('HTML Cache');
}
/**
* Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
* on the primary plugin class:
*
* @return mixed
*/
public function getDescription()
{
return Craft::t('Generate HTML-file based caching for your Craft CMS');
}
/**
* Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
* the primary plugin class:
*
* @return string
*/
public function getDocumentationUrl()
{
return 'https://github.com/craftapi/htmlcache/blob/master/README.md';
}
/**
* Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
* providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
* plugin class.
*
* @return string
*/
public function getReleaseFeedUrl()
{
return 'https://raw.githubusercontent.com/craftapi/htmlcache/master/releases.json';
}
/**
* Returns the version number.
*
* @return string
*/
public function getVersion()
{
return '1.0.1';
}
/**
* As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
* case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
* have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
* their primary plugin class:
*
* @return string
*/
public function getSchemaVersion()
{
return '1.0.0';
}
/**
* Returns the developer’s name.
*
* @return string
*/
public function getDeveloper()
{
return 'CraftAPI';
}
/**
* Returns the developer’s website URL.
*
* @return string
*/
public function getDeveloperUrl()
{
return 'https://github.com/craftapi';
}
/**
* Returns whether the plugin should get its own tab in the CP header.
*
* @return bool
*/
public function hasCpSection()
{
return true;
}
}
Craft CMS Pure HTML Static Caching in beta: https://github.com/craftapi/htmlcache
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.