Changeset 1402
- Timestamp:
- 03/07/08 15:15:54 (4 months ago)
- Files:
-
- trunk/examples/docroot/websites-memphis/index.php (modified) (2 diffs)
- trunk/examples/docroot/websites-xml/index.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/stubDefaultWebsiteInitializer.php (added)
- trunk/src/main/php/net/stubbles/websites/stubFrontController.php (modified) (6 diffs)
- trunk/src/main/php/net/stubbles/websites/stubWebsiteInitializer.php (added)
- trunk/src/main/php/org/stubbles/examples/pageelements/Shop.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/stubDefaultWebsiteInitializerTestCase.php (added)
- trunk/src/test/php/net/stubbles/websites/stubFrontControllerTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/docroot/websites-memphis/index.php
r1234 r1402 13 13 require '../bootstrap-stubbles.php'; 14 14 15 stubClassLoader::load('net::stubbles::websites::stubFrontController', 16 'net::stubbles::ipo::interceptors::stubInterceptorXJConfInitializer', 17 'net::stubbles::websites::processors::stubProcessorResolverXJConfFactory', 18 'net::stubbles::util::stubRegistryXJConfInitializer' 15 stubClassLoader::load('net::stubbles::websites::stubDefaultWebsiteInitializer', 16 'net::stubbles::websites::stubFrontController' 19 17 ); 20 18 … … 23 21 public static function main() 24 22 { 25 $controller = new stubFrontController(new stubRegistryXJConfInitializer(), 26 new stubInterceptorXJConfInitializer(), 27 new stubProcessorResolverXJConfFactory()); 23 $controller = new stubFrontController(new stubDefaultWebsiteInitializer(false)); 28 24 $controller->process(); 29 25 } trunk/examples/docroot/websites-xml/index.php
r1234 r1402 13 13 require '../bootstrap-stubbles.php'; 14 14 15 stubClassLoader::load('net::stubbles::websites::stubFrontController', 16 'net::stubbles::ipo::interceptors::stubInterceptorXJConfInitializer', 17 'net::stubbles::websites::processors::stubProcessorResolverXJConfFactory', 18 'net::stubbles::util::stubRegistryXJConfInitializer' 15 stubClassLoader::load('net::stubbles::websites::stubDefaultWebsiteInitializer', 16 'net::stubbles::websites::stubFrontController' 19 17 ); 20 18 … … 23 21 public static function main() 24 22 { 25 $controller = new stubFrontController(new stubRegistryXJConfInitializer(), 26 new stubInterceptorXJConfInitializer(), 27 new stubProcessorResolverXJConfFactory()); 23 $controller = new stubFrontController(new stubDefaultWebsiteInitializer(false)); 28 24 $controller->process(); 29 25 } trunk/src/main/php/net/stubbles/websites/stubFrontController.php
r1301 r1402 7 7 * @subpackage websites 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::interceptors::stubInterceptorInitializer', 10 'net::stubbles::ipo::request::stubRequest', 9 stubClassLoader::load('net::stubbles::ipo::request::stubRequest', 11 10 'net::stubbles::ipo::response::stubBaseResponse', 12 11 'net::stubbles::ipo::session::stubSession', 13 'net::stubbles::lang::stubMode',14 12 'net::stubbles::util::stubRegistry', 15 'net::stubbles::util::stubRegistryInitializer', 16 'net::stubbles::websites::cache::stubWebsiteCacheFactory', 17 'net::stubbles::websites::processors::stubProcessorResolverFactory' 13 'net::stubbles::websites::stubWebsiteInitializer', 14 'net::stubbles::websites::cache::stubWebsiteCacheFactory' 18 15 ); 19 16 /** … … 26 23 { 27 24 /** 28 * initializer for the interceptors25 * initializer 29 26 * 30 * @var stub InterceptorInitializer27 * @var stubWebsiteInitializer 31 28 */ 32 protected $interceptorInitializer = array(); 33 /** 34 * the resolver to use for getting the correct processor 35 * 36 * @var stubProcessorResolver 37 */ 38 protected $resolver; 29 protected $websiteInitializer; 39 30 /** 40 31 * contains request data … … 65 56 * constructor 66 57 * 67 * @param stubRegistryInitializer $registryInitializer initializer for the registry 68 * @param stubInterceptorInitializer $interceptorInitializer initializer for the interceptors 69 * @param stubProcessorResolverFactory $processorResolverFactory factory to create the processor resolver 58 * @param stubWebsiteInitializer $websiteInitializer initializer to init basic stuff 70 59 */ 71 public function __construct(stub RegistryInitializer $registryInitializer, stubInterceptorInitializer $interceptorInitializer, stubProcessorResolverFactory $processorResolverFactory)60 public function __construct(stubWebsiteInitializer $websiteInitializer) 72 61 { 73 $registryInitializer->init(); 74 $this->interceptorInitializer = $interceptorInitializer; 75 $processorResolverFactory->init(); 76 $this->resolver = $processorResolverFactory->getResolver(); 62 $websiteInitializer->init(); 63 $websiteInitializer->getRegistryInitializer()->init(); 64 if ($websiteInitializer->isLoggingEnabled() === true) { 65 $websiteInitializer->getLoggerInitializer()->init(); 66 } 67 68 $this->websiteInitializer = $websiteInitializer; 77 69 $this->createInstances(); 78 70 } … … 111 103 112 104 /** 113 * sets the mode to be used114 *115 * @param stubMode $mode116 */117 public function setMode(stubMode $mode)118 {119 $mode->registerErrorHandler();120 $mode->registerExceptionHandler();121 stubMode::setCurrent($mode);122 }123 124 /**125 105 * sets the website cache factory to be used 126 106 * … … 137 117 public function process() 138 118 { 139 $processor = $this->resolver->resolve($this->request, $this->session, $this->response); 140 $this->interceptorInitializer->setDescriptor($processor->getInterceptorDescriptor()); 141 $this->interceptorInitializer->init(); 142 foreach ($this->interceptorInitializer->getPreInterceptors() as $preInterceptor) { 119 $processorResolverFactory = $this->websiteInitializer->getProcessorResolverFactory(); 120 $processorResolverFactory->init(); 121 $processor = $processorResolverFactory->getResolver()->resolve($this->request, $this->session, $this->response); 122 $interceptorInitializer = $this->websiteInitializer->getInterceptorInitializer(); 123 $interceptorInitializer->setDescriptor($processor->getInterceptorDescriptor()); 124 $interceptorInitializer->init(); 125 foreach ($interceptorInitializer->getPreInterceptors() as $preInterceptor) { 143 126 $preInterceptor->preProcess($this->request, $this->session, $this->response); 144 127 if ($this->request->isCancelled() === true) { … … 154 137 $this->response = $processor->process()->getResponse(); 155 138 if ($this->request->isCancelled() === false) { 156 foreach ($ this->interceptorInitializer->getPostInterceptors() as $postInterceptor) {139 foreach ($interceptorInitializer->getPostInterceptors() as $postInterceptor) { 157 140 $postInterceptor->postProcess($this->request, $this->session, $this->response); 158 141 if ($this->request->isCancelled() === true) { trunk/src/main/php/org/stubbles/examples/pageelements/Shop.php
r1234 r1402 33 33 */ 34 34 const ID_REGEX = '/^[A-Z]{2,3}\.[A-Z]{2,3}\.[A-Z]{2}$/'; 35 /** 36 * id of the shop 37 * 38 * @var string 39 */ 40 protected $id; 41 /** 42 * title of the shop 43 * 44 * @var string 45 */ 46 protected $title; 35 47 /** 36 48 * analyzable status trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r1313 r1402 24 24 $suite = new self(); 25 25 $dir = dirname(__FILE__); 26 $suite->addTestFile($dir . '/stubDefaultWebsiteInitializerTestCase.php'); 26 27 $suite->addTestFile($dir . '/stubFrontControllerTestCase.php'); 27 28 $suite->addTestFile($dir . '/stubPageTestCase.php'); trunk/src/test/php/net/stubbles/websites/stubFrontControllerTestCase.php
r1396 r1402 114 114 public function setUp() 115 115 { 116 $mockWebsiteInitializer = $this->getMock('stubWebsiteInitializer'); 116 117 $mockProcessorResolverFactory = $this->getMock('stubProcessorResolverFactory'); 118 $mockWebsiteInitializer->expects($this->once())->method('getProcessorResolverFactory')->will($this->returnValue($mockProcessorResolverFactory)); 117 119 $this->mockProcessorResolver = $this->getMock('stubProcessorResolver'); 118 120 $this->mockProcessor = $this->getMock('stubProcessor'); … … 124 126 ->will($this->returnValue($this->mockProcessor)); 125 127 $this->mockInterceptorInitializer = $this->getMock('stubInterceptorInitializer'); 128 $mockWebsiteInitializer->expects($this->once())->method('getInterceptorInitializer')->will($this->returnValue($this->mockInterceptorInitializer)); 126 129 stubRegistry::setConfig(stubRequest::CLASS_REGISTRY_KEY, get_class($this->getMock('stubRequest'))); 127 130 stubRegistry::setConfig(stubSession::CLASS_REGISTRY_KEY, get_class($this->getMock('stubSession'))); 128 $this->frontController = new TeststubFrontController($this->getMock('stubRegistryInitializer'), $this->mockInterceptorInitializer, $mockProcessorResolverFactory); 131 $mockWebsiteInitializer->expects($this->once())->method('getRegistryInitializer')->will($this->returnValue($this->getMock('stubRegistryInitializer'))); 132 $mockWebsiteInitializer->expects($this->once())->method('isLoggingEnabled')->will($this->returnValue(true)); 133 $mockWebsiteInitializer->expects($this->once())->method('getLoggerInitializer')->will($this->returnValue($this->getMock('stubLoggerInitializer'))); 134 $this->frontController = new TeststubFrontController($mockWebsiteInitializer); 129 135 130 136 $this->mockRequest = $this->frontController->getRequest();
