setPluginData()} method, receive data back using {@see * $this->getPluginData()} and detach once attached data using {@link * $this->removePluginData()}. A check if data is available for a given plugin * namespace and key can be checked using {@link $this->hasPluginData()}. * * NOTE: The plugin API is not public, yet, and will be released in a later * version of this component. * * @see ezcWebdavRequest * @see ezcWebdavResponse * @see ezcWebdavProperty * * @package Webdav * @version 1.0rc1 * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License */ abstract class ezcWebdavInfrastructureBase { /** * Storage for the plugin data. * * @var array */ protected $pluginData = array(); /** * Sets plugin data in the storage. * * This method is used to set plugin data in the internal data storage. The * $namespace parameter must be the valid namespace of a plugin registered * with the {@link ezcWebdavPluginRegistry}. If this is not the case, an * {@link ezcBaseValueException} will be thrown. * * The $key parameter is a string used to identify the data added uniquely * inside the private storage area of the client. The $key is needed to * retrieve the data back using {@link $this->getPluginData()}. * * The $data to store can be of any arbitrary PHP type. If there is already * $data stored in the position of the data store it will be overwritten. * * @param string $namespace * @param string $key * @param mixed $data * @return void * * @throws ezcBaseValueException * if the $namespace is unknown by the {@link * ezcWebdavPluginRegistry} or if $key is not a string. */ public function setPluginData( $namespace, $key, $data ) { if ( !ezcWebdavServer::getInstance()->pluginRegistry->hasPlugin( $namespace ) ) { throw new ezcBaseValueException( 'namespace', $namespace, 'known by ezcWebdavPluginRegistry' ); } if ( !is_string( $key ) ) { throw new ezcBaseValueException( 'key', $key, 'string' ); } $this->pluginData[$namespace][$key] = $data; } /** * Removes plugin data from the storage. * * Completly removes the data identified by the given plugin $namespace and * the data $key. If the $namespace is not a known by the global {@link * ezcWebdavPluginRegistry} an {@link ezcBaseValueException} will * be thrown. If the given $key has no data assigned inside the plugins * private data store, this call is silently ignored. * * @param string $namespace * @param string $key * @return void * * @throws ezcBaseValueException * if the $namespace is unknown by the {@link * ezcWebdavPluginRegistry} or if $key is not a string. */ public function removePluginData( $namespace, $key ) { if ( !ezcWebdavServer::getInstance()->pluginRegistry->hasPlugin( $namespace ) ) { throw new ezcBaseValueException( 'namespace', $namespace, 'known by ezcWebdavPluginRegistry' ); } if ( !is_string( $key ) ) { throw new ezcBaseValueException( 'key', $key, 'string' ); } if ( isset( $this->pluginData[$namespace][$key] ) ) { unset( $this->pluginData[$namespace][$key] ); } } /** * Retrieves plugin data from the storage. * * This method returns the data that was stored under the given plugin * $namespace and data $key. If the given $namespace is unknown by the * global {@link ezcWebdavPluginRegistry} an {@link * ezcBaseValueException} will be thrown. If no data exists with * the given $key, null will be returned. * * @param string $namespace * @param string $key * @return mixed * * @throws ezcBaseValueException * if the $namespace is unknown by the {@link * ezcWebdavPluginRegistry} or if $key is not a string. */ public function getPluginData( $namespace, $key ) { if ( !ezcWebdavServer::getInstance()->pluginRegistry->hasPlugin( $namespace ) ) { throw new ezcBaseValueException( 'namespace', $namespace, 'known by ezcWebdavPluginRegistry' ); } if ( !is_string( $key ) ) { throw new ezcBaseValueException( 'key', $key, 'string' ); } if ( isset( $this->pluginData[$namespace][$key] ) ) { return $this->pluginData[$namespace][$key]; } return null; } /** * Returns if plugin data is available in the storage. * * This method checks if there is data available for the given plugin * $namespace and data $key. If the given $namespace is unknown by the * global {@link ezcWebdavPluginRegistry} an {@link * ezcBaseValueException} will be thrown. If data (not null) is * assigned to the given key this method returns true, otherwise false. * * @param string $namespace * @param string $key * @return bool * * @throws ezcBaseValueException * if the $namespace is unknown by the {@link * ezcWebdavPluginRegistry} or if $key is not a string. */ public function hasPluginData( $namespace, $key ) { if ( !ezcWebdavServer::getInstance()->pluginRegistry->hasPlugin( $namespace ) ) { throw new ezcBaseValueException( 'namespace', $namespace, 'known by ezcWebdavPluginRegistry' ); } if ( !is_string( $key ) ) { throw new ezcBaseValueException( 'key', $key, 'string' ); } return ( isset( $this->pluginData[$namespace][$key] ) ); } } ?>