root/trunk/src/main/php/net/stubbles/websites/processors/stubProcessorResolverXJConfFactory.php

Revision 1395, 2.1 kB (checked in by mikey, 4 months ago)

created foundation for enhancement #49: introduced new base interface stubInitializer

Line 
1 <?php
2 /**
3  * Class for creating a resolver with XJConf.
4  *
5  * @author      Frank Kleine <mikey@stubbles.net>
6  * @package     stubbles
7  * @subpackage  websites_processors
8  */
9 stubClassLoader::load('net::stubbles::websites::processors::stubProcessorResolverFactory',
10                       'net::stubbles::util::xjconf::xjconf'
11 );
12 /**
13  * Class for creating a resolver with XJConf.
14  *
15  * @package     stubbles
16  * @subpackage  websites_processors
17  */
18 class stubProcessorResolverXJConfFactory extends stubXJConfAbstractInitializer implements stubProcessorResolverFactory
19 {
20     /**
21      * the resolver
22      *
23      * @var  stubProcessorResolver
24      */
25     protected $resolver;
26
27     /**
28      * returns the descriptor that identifies the initializer
29      *
30      * @param   string  $type  type of descriptor: config or definition
31      * @return  string
32      */
33     public function getDescriptor($type)
34     {
35         return 'processors';
36     }
37
38     /**
39      * returns the data to cache
40      *
41      * @return  array
42      */
43     public function getCacheData()
44     {
45         $cacheData = array('resolver' => $this->resolver->getSerialized());
46         return $cacheData;
47     }
48
49     /**
50      * sets the data from the cache
51      *
52      * @param  array  $cacheData
53      */
54     public function setCacheData(array $cacheData)
55     {
56         $this->resolver = $cacheData['resolver']->getUnserialized();
57     }
58
59     /**
60      * will be called in case the stubXJConfProxy did not found the data in the
61      * cache and the initializer has to load values from the facade
62      *
63      * @param  stubXJConfFacade  $xjconf
64      */
65     public function loadData(stubXJConfFacade $xjconf)
66     {
67         $this->resolver = $xjconf->getConfigValue('resolver');
68     }
69
70     /**
71      * sets the resolver
72      *
73      * @param  stubProcessorResolver  $resolver
74      */
75     public function setResolver(stubProcessorResolver $resolver)
76     {
77         $this->resolver = $resolver;
78     }
79
80     /**
81      * returns the resolver
82      *
83      * @return  stubProcessorResolver
84      */
85     public function getResolver()
86     {
87         return $this->resolver;
88     }
89 }
90 ?>
Note: See TracBrowser for help on using the browser.