123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- /*
- * This file is part of the symfony package.
- * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
- * (c) 2004-2006 Sean Kerr <sean@code-box.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * sfStorage allows you to customize the way symfony stores its persistent data.
- *
- * @package symfony
- * @subpackage storage
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- * @author Sean Kerr <sean@code-box.org>
- * @version SVN: $Id: sfStorage.class.php 9942 2008-06-27 18:00:49Z fabien $
- */
- abstract class sfStorage
- {
- protected
- $options = array();
- /**
- * Class constructor.
- *
- * @see initialize()
- */
- public function __construct($options = array())
- {
- $this->initialize($options);
- if ($this->options['auto_shutdown'])
- {
- register_shutdown_function(array($this, 'shutdown'));
- }
- }
- /**
- * Initializes this Storage instance.
- *
- * Available options:
- *
- * * auto_shutdown: Whether to automatically save the changes to the session (true by default)
- *
- * @param array $options An associative array of options
- *
- * @return bool true, if initialization completes successfully, otherwise false
- *
- * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfStorage
- */
- public function initialize($options = array())
- {
- $this->options = array_merge(array(
- 'auto_shutdown' => true,
- ), $options);
- }
- /**
- * Returns the option array.
- *
- * @return array The array of options
- */
- public function getOptions()
- {
- return $this->options;
- }
- /**
- * Reads data from this storage.
- *
- * The preferred format for a key is directory style so naming conflicts can be avoided.
- *
- * @param string $key A unique key identifying your data
- *
- * @return mixed Data associated with the key
- *
- * @throws <b>sfStorageException</b> If an error occurs while reading data from this storage
- */
- abstract public function read($key);
- /**
- * Regenerates id that represents this storage.
- *
- * @param boolean destroy Destroy session when regenerating?
- *
- * @return boolean True if session regenerated, false if error
- *
- * @throws <b>sfStorageException</b> If an error occurs while regenerating this storage
- */
- abstract public function regenerate($destroy = false);
- /**
- * Removes data from this storage.
- *
- * The preferred format for a key is directory style so naming conflicts can be avoided.
- *
- * @param string $key A unique key identifying your data
- *
- * @return mixed Data associated with the key
- *
- * @throws <b>sfStorageException</b> If an error occurs while removing data from this storage
- */
- abstract public function remove($key);
- /**
- * Executes the shutdown procedure.
- *
- * @throws <b>sfStorageException</b> If an error occurs while shutting down this storage
- */
- abstract public function shutdown();
- /**
- * Writes data to this storage.
- *
- * The preferred format for a key is directory style so naming conflicts can be avoided.
- *
- * @param string $key A unique key identifying your data
- * @param mixed $data Data associated with your key
- *
- * @throws <b>sfStorageException</b> If an error occurs while writing to this storage
- */
- abstract public function write($key, $data);
- }
|