Changeset 1459
- Timestamp:
- 03/25/08 09:57:21 (3 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/websites/cache/stubAbstractWebsiteCache.php (modified) (6 diffs)
- trunk/src/main/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactory.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/cache/stubCachableProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/cache/stubCachingProcessor.php (added)
- trunk/src/main/php/net/stubbles/websites/cache/stubDefaultWebsiteCache.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/cache/stubGzipWebsiteCache.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCache.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCacheFactory.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php (modified) (8 diffs)
- trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/processors/stubProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/stubFrontController.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactoryTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheTestCase.php (modified) (10 diffs)
- trunk/src/test/php/net/stubbles/websites/cache/stubDefaultWebsiteCacheTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/websites/cache/stubGzipWebsiteCacheTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/websites/memphis/stubDummyWebsiteCache.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorCachableTestCase.php (added)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php (modified) (10 diffs)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestHelper.php (added)
- trunk/src/test/php/net/stubbles/websites/processors/stubAbstractProcessorTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/websites/stubFrontControllerTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/cache/stubAbstractWebsiteCache.php
r1301 r1459 47 47 * 48 48 * @param stubRequest $request 49 * @param stubSession $session 50 * @param stubResponse $response 51 * @param string $page name of the page to be cached 49 * @param stubResponse $response 50 * @param string $pageName name of the page to be cached 52 51 * @return bool true if data was retrieved from cache, else false 53 52 */ 54 public function retrieve(stubRequest $request, stub Session $session, stubResponse $response, $page)55 { 56 $cacheKey = $this->generateCacheKey($page );53 public function retrieve(stubRequest $request, stubResponse $response, $pageName) 54 { 55 $cacheKey = $this->generateCacheKey($pageName); 57 56 if ($this->isCached($cacheKey) === false) { 58 $this->log($page , $cacheKey, stubWebsiteCache::MISS);57 $this->log($pageName, $cacheKey, stubWebsiteCache::MISS); 59 58 return false; 60 59 } … … 64 63 } 65 64 66 if ($this->doRetrieve($request, $ session, $response, $cacheKey) === true) {67 $this->log($page , $cacheKey, stubWebsiteCache::HIT);65 if ($this->doRetrieve($request, $response, $cacheKey) === true) { 66 $this->log($pageName, $cacheKey, stubWebsiteCache::HIT); 68 67 return true; 69 68 } 70 69 71 $this->log($page , $cacheKey, stubWebsiteCache::MISS);70 $this->log($pageName, $cacheKey, stubWebsiteCache::MISS); 72 71 return false; 73 72 } … … 77 76 * 78 77 * @param stubRequest $request 79 * @param stubSession $session80 78 * @param stubResponse $response 81 79 * @param string $cacheKey 82 80 * @return bool true if data was retrieved from cache, else false 83 81 */ 84 protected abstract function doRetrieve(stubRequest $request, stub Session $session, stubResponse $response, $cacheKey);82 protected abstract function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey); 85 83 86 84 /** … … 89 87 * @param stubRequest $request 90 88 * @param stubResponse $response 91 * @param string $page name of the page to be cached89 * @param string $pageName name of the page to be cached 92 90 * @return bool true if successfully stored, else false 93 91 */ 94 public function store(stubRequest $request, stubResponse $response, $page )92 public function store(stubRequest $request, stubResponse $response, $pageName) 95 93 { 96 94 if (stubMode::$CURRENT->isCacheEnabled() === false) { … … 98 96 } 99 97 100 return $this->doStore($request, $response, $this->generateCacheKey($page ));98 return $this->doStore($request, $response, $this->generateCacheKey($pageName)); 101 99 } 102 100 … … 136 134 clearstatcache(); 137 135 foreach ($this->getUsedFiles() as $fileName) { 138 if (is_readable($file name) === false) {136 if (is_readable($fileName) === false) { 139 137 continue; 140 138 } trunk/src/main/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactory.php
r1458 r1459 8 8 */ 9 9 stubClassLoader::load('net::stubbles::websites::cache::stubCachableProcessor', 10 'net::stubbles::websites::cache::stubCachingProcessor', 10 11 'net::stubbles::websites::cache::stubWebsiteCache', 11 12 'net::stubbles::websites::cache::stubWebsiteCacheFactory' … … 20 21 { 21 22 /** 22 * configures the processor with a website cache factory 23 * configures the processor with a website cache factory and returns the 24 * configured processor 23 25 * 24 * @param stubProcessor $processor 26 * @param stubProcessor $processor 27 * @return stubProcessor 25 28 */ 26 29 public function configure(stubProcessor $processor) 27 30 { 28 31 if (($processor instanceof stubCachableProcessor) === false) { 29 return ;32 return $processor; 30 33 } 31 34 35 $processor = new stubCachingProcessor($processor); 32 36 $processor->setWebsiteCache($this->getWebsiteCache()); 37 return $processor; 33 38 } 34 39 trunk/src/main/php/net/stubbles/websites/cache/stubCachableProcessor.php
r1231 r1459 19 19 { 20 20 /** 21 * sets the website cache to be used by the processor 21 * adds the cache variables for the current request and returns whether 22 * response is cachable or not 22 23 * 23 * @param stubWebsiteCache $websiteCache 24 * @param stubWebsiteCache $websiteCache 25 * @return bool 24 26 */ 25 public function setWebsiteCache(stubWebsiteCache $websiteCache); 27 public function addCacheVars(stubWebsiteCache $cache); 28 29 /** 30 * returns the name of the current page 31 * 32 * Non-page-based processors should return another unique identifier for 33 * the current request if they want to implement this interface. 34 * 35 * @return string 36 */ 37 public function getPageName(); 26 38 } 27 39 ?> trunk/src/main/php/net/stubbles/websites/cache/stubDefaultWebsiteCache.php
r1301 r1459 104 104 * 105 105 * @param stubRequest $request 106 * @param stubSession $session107 106 * @param stubResponse $response 108 107 * @param string $cacheKey 109 108 * @return bool true if successfully retrieved, else false 110 109 */ 111 protected function doRetrieve(stubRequest $request, stub Session $session, stubResponse $response, $cacheKey)110 protected function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey) 112 111 { 113 $contents = $this->cache->get($cacheKey); 114 $contents = str_replace('$SID', $session->getName() . '=' . $session->getId(), $contents); 115 $contents = str_replace('$SESSION_NAME', $session->getName(), $contents); 116 $contents = str_replace('$SESSION_ID', $session->getId(), $contents); 117 $response->write($contents); 112 $response->write($this->cache->get($cacheKey)); 118 113 return true; 119 114 } trunk/src/main/php/net/stubbles/websites/cache/stubGzipWebsiteCache.php
r1301 r1459 113 113 * 114 114 * @param stubRequest $request 115 * @param stubSession $session 116 * @param stubResponse $response 117 * @param string $page name of the page to be cached 115 * @param stubResponse $response 116 * @param string $pageName name of the page to be cached 118 117 * @return bool true if data was retrieved from cache, else false 119 118 */ 120 public function retrieve(stubRequest $request, stub Session $session, stubResponse $response, $page)121 { 122 if (parent::retrieve($request, $ session, $response, $page) === true) {119 public function retrieve(stubRequest $request, stubResponse $response, $pageName) 120 { 121 if (parent::retrieve($request, $response, $pageName) === true) { 123 122 return true; 124 123 } 125 124 126 return $this->websiteCache->retrieve($request, $ session, $response, $page);125 return $this->websiteCache->retrieve($request, $response, $pageName); 127 126 } 128 127 … … 131 130 * 132 131 * @param stubRequest $request 133 * @param stubSession $session134 132 * @param stubResponse $response 135 133 * @param string $cacheKey 136 134 * @return bool true if data was retrieved from cache, else false 137 135 */ 138 protected function doRetrieve(stubRequest $request, stub Session $session, stubResponse $response, $cacheKey)136 protected function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey) 139 137 { 140 138 // we do not use gzipped content because we probably have to insert trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCache.php
r1307 r1459 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ipo::request::stubRequest', 10 'net::stubbles::ipo::response::stubResponse', 11 'net::stubbles::ipo::session::stubSession' 10 'net::stubbles::ipo::response::stubResponse' 12 11 ); 13 12 /** … … 75 74 * 76 75 * @param stubRequest $request 77 * @param stubSession $session78 76 * @param stubResponse $response 79 * @param string $page name of the page to be cached77 * @param string $pageName name of the page to be cached 80 78 * @return bool true if data was retrieved from cache, else false 81 79 */ 82 public function retrieve(stubRequest $request, stub Session $session, stubResponse $response, $page);80 public function retrieve(stubRequest $request, stubResponse $response, $pageName); 83 81 84 82 /** … … 87 85 * @param stubRequest $request 88 86 * @param stubResponse $response 89 * @param string $page name of the page to be cached87 * @param string $pageName name of the page to be cached 90 88 * @return bool true if successfully stored, else false 91 89 */ 92 public function store(stubRequest $request, stubResponse $response, $page );90 public function store(stubRequest $request, stubResponse $response, $pageName); 93 91 } 94 92 ?> trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCacheFactory.php
r1231 r1459 17 17 { 18 18 /** 19 * configures the processor with a website cache factory 19 * configures the processor with a website cache factory and returns the 20 * configured processor 20 21 * 21 * @param stubProcessor $processor 22 * @param stubProcessor $processor 23 * @return stubProcessor 22 24 */ 23 25 public function configure(stubProcessor $processor); trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php
r1442 r1459 40 40 protected $config; 41 41 /** 42 * website cache to be used 43 * 44 * @var stubWebsiteCache 45 */ 46 protected $cache; 47 /** 48 * page to display 49 * 50 * @var stubPage 51 */ 52 protected $page; 53 /** 54 * name of page to display 55 * 56 * @var string 57 */ 58 protected $pageName; 42 * context 43 * 44 * @var array<string,mixed> 45 */ 46 protected $context = array('part' => null, 47 'page' => null, 48 'pageName' => '', 49 'frameId' => '' 50 ); 51 /** 52 * decorated request 53 * 54 * @var stubRequestPrefixDecorator 55 */ 56 protected $prefixRequest; 59 57 60 58 /** … … 67 65 public function __construct(stubRequest $request, stubSession $session, stubResponse $response) 68 66 { 67 $this->prefixRequest = new stubRequestPrefixDecorator($request, ''); 69 68 parent::__construct($request, $session, $response); 70 69 $this->config = $this->createConfig(); … … 72 71 73 72 /** 74 * sets the website cache to be used by the processor 75 * 76 * @param stubWebsiteCache $websiteCache 77 */ 78 public function setWebsiteCache(stubWebsiteCache $websiteCache) 79 { 80 $this->cache = $websiteCache; 81 } 73 * helper method to create the config object 74 * 75 * @return stubMemphisConfig 76 */ 77 // @codeCoverageIgnoreStart 78 protected function createConfig() 79 { 80 return new stubMemphisConfig(); 81 } 82 // @codeCoverageIgnoreEnd 82 83 83 84 /** … … 88 89 public function selectPage(stubPageFactory $pageFactory) 89 90 { 90 $this->pageName = $pageFactory->getPageName($this->request); 91 $this->page = $pageFactory->getPage($this->pageName); 92 $this->session->putValue('net.stubbles.websites.lastPage', $this->pageName); 93 } 94 95 /** 96 * helper method to create the config object 97 * 98 * @return stubMemphisConfig 99 * @throws stubException 100 */ 101 protected function createConfig() 102 { 103 return new stubMemphisConfig(); 104 } 105 106 /** 107 * helper method to create the template 108 * 109 * @return stubMemphisTemplate 110 */ 111 protected function createTemplate() 112 { 113 $template = new stubMemphisTemplate(stubRegistry::getConfig(stubMemphisTemplate::REGISTRY_KEY_DIR, stubConfig::getPagePath() . '/../templates')); 114 if (stubMode::$CURRENT->isCacheEnabled() === true) { 115 $template->enableCache(); 116 } 117 118 return $template; 119 } 120 121 /** 122 * processes the request 123 */ 124 public function process() 125 { 126 $elements = $this->page->getElements(); 127 $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); 128 $context = array('part' => null, 129 'page' => $this->page 130 ); 131 $frameId = $this->getFrameId(); 132 if (null !== $this->cache) { 133 $cachable = $this->processCacheVars($prefixRequest, $elements, $frameId, $context); 134 if (true === $cachable && $this->cache->retrieve($this->request, $this->session, $this->response, $this->pageName) === true) { 135 return; 136 } 137 } 138 139 $this->template = $this->createTemplate(); 140 $context['template'] = $this->template; 141 $this->template->readTemplatesFromInput($this->config->getFrame($frameId)); 142 $this->setTemplateVars($frameId); 143 $this->processPageElements($prefixRequest, $elements, $context); 144 if (null !== $this->cache) { 145 if (true === $cachable) { 146 $this->cache->store($this->request, $this->response, $this->pageName); 147 } 148 149 $contents = str_replace('$SID', $this->session->getName() . '=' . $this->session->getId(), $this->response->getData()); 150 $contents = str_replace('$SESSION_NAME', $this->session->getName(), $contents); 151 $this->response->replaceData(str_replace('$SESSION_ID', $this->session->getId(), $contents)); 152 } 153 } 154 155 /** 156 * helper method to set the cache variables 157 * 158 * @param stubRequest $prefixRequest 159 * @param array $elements 160 * @param string $frameId 161 * @param array $context 162 * @return bool true if page is cachable, else false 163 */ 164 protected function processCacheVars(stubRequest $prefixRequest, array $elements, $frameId, array $context) 165 { 166 $this->cache->addCacheVar('page', $this->pageName); 167 $this->cache->addCacheVar('frame', $frameId); 168 $this->cache->addCacheVar('variant', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 169 $sslMode = 'no'; 170 if ($this->isSSL() === true) { 171 $sslMode = 'yes'; 172 } 173 174 $this->cache->addCacheVar('ssl', $sslMode); 175 foreach ($this->config->getParts() as $part) { 176 $context['part'] = $part; 177 foreach ($this->config->getDefaultElements($part) as $defaultElement) { 178 $prefixRequest->setPrefix($defaultElement->getName()); 179 $defaultElement->init($prefixRequest, $this->session, $this->response, $context); 180 if ($defaultElement->isAvailable() === false) { 181 continue; 182 } elseif ($defaultElement->isCachable() === false) { 183 return false; 184 } 185 186 $this->cache->addCacheVars($defaultElement->getCacheVars()); 187 $this->cache->addUsedFiles($defaultElement->getUsedFiles()); 188 } 189 190 foreach ($elements as $name => $element) { 191 $prefixRequest->setPrefix($name); 192 $element->init($prefixRequest, $this->session, $this->response, $context); 193 if ($element->isAvailable() === false) { 194 continue; 195 } elseif ($element->isCachable() === false) { 196 return false; 197 } 198 199 $this->cache->addCacheVars($element->getCacheVars()); 200 $this->cache->addUsedFiles($element->getUsedFiles()); 201 } 202 } 203 204 return true; 205 } 206 207 /** 208 * helper method to process the page elements 209 * 210 * @param stubRequest $prefixRequest 211 * @param array $elements 212 * @param array $context 213 */ 214 protected function processPageElements(stubRequest $prefixRequest, array $elements, array $context) 215 { 216 foreach ($this->config->getParts() as $part) { 217 $content = ''; 218 $context['part'] = $part; 219 foreach ($this->config->getDefaultElements($part) as $defaultElement) { 220 $prefixRequest->setPrefix($defaultElement->getName()); 221 $defaultElement->init($prefixRequest, $this->session, $this->response, $context); 222 if ($defaultElement->isAvailable() === false) { 223 continue; 224 } 225 226 $content .= $defaultElement->process(); 227 if ($prefixRequest->isCancelled() === true) { 228 return; 229 } 230 } 231 232 foreach ($elements as $name => $element) { 233 $prefixRequest->setPrefix($name); 234 $element->init($prefixRequest, $this->session, $this->response, $context); 235 if ($element->isAvailable() === false) { 236 continue; 237 } 238 239 $content .= $element->process(); 240 if ($prefixRequest->isCancelled() === true) { 241 return; 242 } 243 } 244 245 $this->template->addGlobalVar($part, $content); 246 } 247 248 $this->response->write($this->template->getParsedTemplate('frame')); 91 $this->context['pageName'] = $pageFactory->getPageName($this->request); 92 $this->context['page'] = $pageFactory->getPage($this->context['pageName']); 93 $this->session->putValue('net.stubbles.websites.lastPage', $this->context['pageName']); 94 $this->context['frameId'] = $this->getFrameId(); 249 95 } 250 96 … … 256 102 protected function getFrameId() 257 103 { 258 if ($this-> page->hasProperty('frame_fixed') === true && $this->page->getProperty('frame_fixed') === true) {259 return $this-> page->getProperty('frame');104 if ($this->context['page']->hasProperty('frame_fixed') === true && $this->context['page']->getProperty('frame_fixed') === true) { 105 return $this->context['page']->getProperty('frame'); 260 106 } 261 107 … … 265 111 $frame = $this->session->getValue('net.stubbles.websites.memphis.frame'); 266 112 } else { 267 $frame = $this-> page->getProperty('frame');113 $frame = $this->context['page']->getProperty('frame'); 268 114 } 269 115 … … 276 122 277 123 /** 124 * adds the cache variables for the current request and returns whether 125 * response is cachable or not 126 * 127 * @param stubWebsiteCache $websiteCache 128 * @return bool 129 */ 130 public function addCacheVars(stubWebsiteCache $cache) 131 { 132 $cache->addCacheVar('page', $this->context['pageName']); 133 $cache->addCacheVar('frame', $this->context['frameId']); 134 $cache->addCacheVar('variant', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 135 foreach ($this->config->getParts() as $part) { 136 $this->context['part'] = $part; 137 foreach ($this->config->getDefaultElements($part) as $defaultElement) { 138 $this->prefixRequest->setPrefix($defaultElement->getName()); 139 $defaultElement->init($this->prefixRequest, $this->session, $this->response, $this->context); 140 if ($defaultElement->isAvailable() === true) { 141 if ($defaultElement->isCachable() === false) { 142 return false; 143 } 144 145 $cache->addCacheVars($defaultElement->getCacheVars()); 146 $cache->addUsedFiles($defaultElement->getUsedFiles()); 147 } 148 } 149 150 foreach ($this->context['page']->getElements() as $name => $element) { 151 $this->prefixRequest->setPrefix($name); 152 $element->init($this->prefixRequest, $this->session, $this->response, $this->context); 153 if ($element->isAvailable() === true) { 154 if ($element->isCachable() === false) { 155 return false; 156 } 157 158 $cache->addCacheVars($element->getCacheVars()); 159 $cache->addUsedFiles($element->getUsedFiles()); 160 } 161 } 162 } 163 164 return true; 165 } 166 167 /** 168 * returns the name of the current page 169 * 170 * @return string 171 */ 172 public function getPageName() 173 { 174 return $this->context['pageName']; 175 } 176 177 /** 178 * processes the request 179 */ 180 public function process() 181 { 182 $this->template = $this->createTemplate(); 183 $this->context['template'] = $this->template; 184 $this->template->readTemplatesFromInput($this->config->getFrame($this->context['frameId'])); 185 $this->setTemplateVars(); 186 foreach ($this->config->getParts() as $part) { 187 $content = ''; 188 $this->context['part'] = $part; 189 foreach ($this->config->getDefaultElements($part) as $defaultElement) { 190 $this->prefixRequest->setPrefix($defaultElement->getName()); 191 $defaultElement->init($this->prefixRequest, $this->session, $this->response, $this->context); 192 if ($defaultElement->isAvailable() === true) { 193 $content .= $defaultElement->process(); 194 if ($this->prefixRequest->isCancelled() === true) { 195 return; 196 } 197 } 198 } 199 200 foreach ($this->context['page']->getElements() as $name => $element) { 201 $this->prefixRequest->setPrefix($name); 202 $element->init($this->prefixRequest, $this->session, $this->response, $this->context); 203 if ($element->isAvailable() === true) { 204 $content .= $element->process(); 205 if ($this->prefixRequest->isCancelled() === true) { 206 return; 207 } 208 } 209 } 210 211 $this->template->addGlobalVar($part, $content); 212 } 213 214 $this->response->write($this->template->getParsedTemplate('frame')); 215 } 216 217 /** 218 * helper method to create the template 219 * 220 * @return stubMemphisTemplate 221 */ 222 // @codeCoverageIgnoreStart 223 protected function createTemplate() 224 { 225 $template = new stubMemphisTemplate(stubRegistry::getConfig(stubMemphisTemplate::REGISTRY_KEY_DIR, stubConfig::getPagePath() . '/../templates')); 226 if (stubMode::$CURRENT->isCacheEnabled() === true) { 227 $template->enableCache(); 228 } 229 230 return $template; 231 } 232 // @codeCoverageIgnoreEnd 233 234 /** 278 235 * helper method to set the template vars 279 * 280 * @param string $frameId 281 */ 282 protected function setTemplateVars($frameId) 283 { 284 $this->template->addGlobalVar('UCUO_FRAME', $frameId); 285 $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->page->getProperty('title'))); 286 $this->template->addGlobalVar('PAGE_NAME', $this->pageName); 236 */ 237 protected function setTemplateVars() 238 { 239 $this->template->addGlobalVar('UCUO_FRAME', $this->context['frameId']); 240 $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->context['page']->getProperty('title'))); 241 $this->template->addGlobalVar('PAGE_NAME', $this->context['pageName']); 287 242 $this->template->addGlobalVar('VARIANT', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 288 243 $this->template->addGlobalVar('VARIANT_ALIAS', $this->session->getValue('net.stubbles.websites.variantmanager.variant.alias', '')); … … 293 248 $this->template->addGlobalVar('SERVICE_URL', $serviceUrl); 294 249 295 if (null === $this->cache) { 296 $this->template->addGlobalVar('SID', $this->session->getName() . '=' . $this->session->getId()); 297 $this->template->addGlobalVar('SESSION_NAME', $this->session->getName()); 298 $this->template->addGlobalVar('SESSION_ID', $this->session->getId()); 299 } else { 300 $this->template->addGlobalVar('SID', '$SID'); 301 $this->template->addGlobalVar('SESSION_NAME', '$SESSION_NAME'); 302 $this->template->addGlobalVar('SESSION_ID', '$SESSION_ID'); 303 } 304 250 $this->template->addGlobalVar('SID', '$SID'); 251 $this->template->addGlobalVar('SESSION_NAME', '$SESSION_NAME'); 252 $this->template->addGlobalVar('SESSION_ID', '$SESSION_ID'); 305 253 // add meta information to the page 306 254 foreach ($this->config->getMetaTags() as $key => $value) { trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php
r1442 r1459 65 65 66 66 /** 67 * returns the request instance 68 * 69 * @return stubRequest 70 */ 71 public function getRequest() 72 { 73 return $this->request; 74 } 75 76 /** 77 * returns the session instance 78 * 79 * @return stubSession 80 */ 81 public function getSession() 82 { 83 return $this->session; 84 } 85 86 /** 87 * returns the response instance 88 * 89 * @return stubResponse 90 */ 91 public function getResponse() 92 { 93 return $this->response; 94 } 95 96 /** 67 97 * sets the interceptor descriptor 68 98 * trunk/src/main/php/net/stubbles/websites/processors/stubProcessor.php
r1457 r1459 28 28 */ 29 29 #public function __construct(stubRequest $request, stubSession $session, , stubResponse $response); 30 31 /** 32 * returns the request instance 33 * 34 * @return stubRequest 35 */ 36 public function getRequest(); 37 38 /** 39 * returns the session instance 40 * 41 * @return stubSession 42 */ 43 public function getSession(); 44 45 /** 46 * returns the response instance 47 * 48 * @return stubResponse 49 */ 50 public function getResponse(); 30 51 31 52 /** trunk/src/main/php/net/stubbles/websites/stubFrontController.php
r1441 r1459 139 139 140 140 if (null !== $this->websiteCacheFactory) { 141 $ this->websiteCacheFactory->configure($processor);141 $processor = $this->websiteCacheFactory->configure($processor); 142 142 } 143 143 trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r1458 r1459 39 39 $suite->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php'); 40 40 $suite->addTestFile($dir . '/memphis/stubMemphisPageElementTestCase.php'); 41 $suite->addTestFile($dir . '/memphis/stubMemphisProcessorCachableTestCase.php'); 41 42 $suite->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php'); 42 43 trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactoryTestCase.php
r1458 r1459 40 40 public function nonCachableProcessor() 41 41 { 42 $mockProcessor = $this->getMock('stubProcessor'); 42 43 $this->abstractWebsiteCacheFactory->expects($this->never()) 43 44 ->method('getWebsiteCache'); 44 $this->a bstractWebsiteCacheFactory->configure($this->getMock('stubProcessor'));45 $this->assertSame($mockProcessor, $this->abstractWebsiteCacheFactory->configure($mockProcessor)); 45 46 } 46 47 … … 54 55 $mockWebsiteCache = $this->getMock('stubWebsiteCache'); 55 56 $cachableProcessor = $this->getMock('stubCachableProcessor'); 56 $cachableProcessor->expects($this->once())57 ->method('setWebsiteCache')58 ->with($this->equalTo($mockWebsiteCache));59 57 $this->abstractWebsiteCacheFactory->expects($this->once()) 60 58 ->method('getWebsiteCache') 61 59 ->will($this->returnValue($mockWebsiteCache)); 62 $this->abstractWebsiteCacheFactory->configure($cachableProcessor); 60 $cachingProcessor = $this->abstractWebsiteCacheFactory->configure($cachableProcessor); 61 $this->assertType('stubCachingProcessor', $cachingProcessor); 62 $this->assertSame($cachableProcessor, $cachingProcessor->getProcessor()); 63 63 } 64 64 } trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheTestCase.php
r1252 r1459 62 62 */ 63 63 protected $mockRequest; 64 /**65 * mocked session instance66 *67 * @var PHPUnit_Framework_MockObject_MockObject68 */69 protected $mockSession;70 64 /** 71 65 * mocked response instance … … 99 93 ->will($this->returnValue(array('foo' => 'bar'))); 100 94 $this->mockRequest = $this->getMock('stubRequest'); 101 $this->mockSession = $this->getMock('stubSession');102 95 $this->mockResponse = $this->getMock('stubResponse'); 103 96 stubMode::setCurrent(stubMode::$PROD); … … 118 111 $this->mockResponse->expects($this->never())->method('addHeader'); 119 112 $this->mockCacheContainer->expects($this->never())->method('has'); 120 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mock Session, $this->mockResponse, 'baz'));113 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockResponse, 'baz')); 121 114 $this->assertEquals('disabled', $this->abstractWebsiteCache->getMissReason()); 122 115 } … … 135 128 $this->mockResponse->expects($this->never())->method('addHeader'); 136 129 $this->mockCacheContainer->expects($this->once())->method('has')->will($this->returnValue(false)); 137 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockSession,$this->mockResponse, 'baz'));130 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest,$this->mockResponse, 'baz')); 138 131 $this->assertEquals('no cache file', $this->abstractWebsiteCache->getMissReason()); 139 132 } … … 151 144 $this->abstractWebsiteCache->expects($this->once()) 152 145 ->method('doRetrieve') 153 ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mock Session), $this->equalTo($this->mockResponse))146 ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mockResponse)) 154 147 ->will($this->returnValue(false)); 155 148 $this->abstractWebsiteCache->expects($this->once())->method('isUsedFilesCheckEnabled')->will($this->returnValue(false)); … … 157 150 $this->mockResponse->expects($this->never())->method('addHeader'); 158 151 $this->mockCacheContainer->expects($this->once())->method('has')->will($this->returnValue(true)); 159 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mock Session, $this->mockResponse, 'baz'));152 $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockResponse, 'baz')); 160 153 $this->assertEquals('', $this->abstractWebsiteCache->getMissReason()); 161 154 } … … 173 166 $this->abstractWebsiteCache->expects($this->once()) 174 167 ->method('doRetrieve') 175 ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mock Session), $this->equalTo($this->mockResponse))168 &nbs
