File modules/cms/generator/BaseGenerator.class.php

Last commit: Thu Mar 4 02:24:45 2021 +0100	Jan Dankert	New: The calculation of the mime types should be done in the generators.
1 <?php 2 3 4 namespace cms\generator; 5 6 7 use util\cache\Cache; 8 use util\cache\FileCache; 9 10 11 /** 12 * Base class for generators. 13 * 14 * @package cms\generator 15 */ 16 abstract class BaseGenerator implements Generator 17 { 18 /** 19 * @var BaseContext 20 */ 21 protected $context; 22 23 /** 24 * Every generator has a cache for its value. 25 * @return Cache 26 */ 27 public function getCache() { 28 29 return new FileCache( $this->context->getCacheKey(),function() { 30 return $this->generate(); 31 }, 0 ); 32 } 33 34 35 /** 36 * Generates a value. 37 * 38 * @return mixed 39 */ 40 protected abstract function generate(); 41 42 43 /** 44 * Calculates the MIME-Type 45 * 46 * @return string 47 */ 48 public abstract function getMimeType(); 49 }
Download modules/cms/generator/BaseGenerator.class.php
History Thu, 4 Mar 2021 02:24:45 +0100 Jan Dankert New: The calculation of the mime types should be done in the generators. Tue, 23 Feb 2021 22:59:12 +0100 Jan Dankert New: Use a default value from a linked page. Mon, 28 Sep 2020 21:07:21 +0200 Jan Dankert Cleanup: Removing unused code. Mon, 21 Sep 2020 22:48:59 +0200 Jan Dankert Complexe refactoring: Moving all generation logic from the model (Value,Page,File) to generators classes.