Prado\Web\TCacheHttpSession::init PHP Метод

init() публичный Метод

This method is required by IModule. It reads the CacheModule property.
public init ( $config )
    public function init($config)
    {
        if ($this->_cacheModuleID === '') {
            throw new TConfigurationException('cachesession_cachemoduleid_required');
        } else {
            if (($cache = $this->getApplication()->getModule($this->_cacheModuleID)) === null) {
                throw new TConfigurationException('cachesession_cachemodule_inexistent', $this->_cacheModuleID);
            } else {
                if ($cache instanceof ICache) {
                    $this->_cache = $cache;
                } else {
                    throw new TConfigurationException('cachesession_cachemodule_invalid', $this->_cacheModuleID);
                }
            }
        }
        $this->setUseCustomStorage(true);
        parent::init($config);
    }

Usage Example

Пример #1
0
 public function testInit()
 {
     $session = new TCacheHttpSession();
     try {
         $session->init(null);
         $this->fail("Expected TConfigurationException is not raised");
     } catch (TConfigurationException $e) {
     }
     unset($session);
     $session = new TCacheHttpSession();
     try {
         $session->setCacheModuleID('MaiCache');
         $session->init(null);
         $this->fail("Expected TConfigurationException is not raised");
         $session->open();
     } catch (TConfigurationException $e) {
     }
     unset($session);
     self::$session = new TCacheHttpSession();
     try {
         self::$session->setCacheModuleID('MyCache');
         self::$session->init(null);
     } catch (TConfigurationException $e) {
         $this->fail('TConfigurationException is not expected');
         self::markTestSkipped('Cannot continue this test');
     }
 }