Author: ts
Date: Tue Oct  2 14:08:49 2007
New Revision: 6331

Log:
- Added draft of API for ezcWebdavPluginRegistry.
- Added todo about header handling.
- Made mapping properties public and @private in ezcWebdavTransport to access
  those in the plugin registry.

Added:
    trunk/Webdav/src/plugin_registry.php   (with props)
Modified:
    trunk/Webdav/docs/TODO
    trunk/Webdav/src/transport.php

Modified: trunk/Webdav/docs/TODO
==============================================================================
--- trunk/Webdav/docs/TODO [iso-8859-1] (original)
+++ trunk/Webdav/docs/TODO [iso-8859-1] Tue Oct  2 14:08:49 2007
@@ -27,3 +27,5 @@
   that we can not reject invalid XML properly. a) the DAV: namespace is invalid
   by itself. b) DOM does not bail out on loading an XML string without proper
   XML declaration. WebDAV defines to reject "invalid" issues.
+
+- Header handling needs to be refactored to allow plugins to access them.

Added: trunk/Webdav/src/plugin_registry.php
==============================================================================
--- trunk/Webdav/src/plugin_registry.php (added)
+++ trunk/Webdav/src/plugin_registry.php [iso-8859-1] Tue Oct  2 14:08:49 2007
@@ -1,0 +1,245 @@
+<?php
+/**
+ * File containing the ezcWebdavPluginRegistry class.
+ *
+ * @package Webdav
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Global plugin registry class.
+ *
+ * An instance of this class is request wide uniquely responsible for handling
+ * plugins to the Webdav component. It has a number of different hooks
+ * available of the server and transport layer of the component to allow
+ * plugins to interact and integrate with these layers to add extended
+ * funtionality.
+ *
+ * A good overview of the working of the plugin system can be found in its
+ * design document [EMAIL PROTECTED] Webdav/design/extensibility.txt}.
+ *
+ * @see ezcWebdavServer
+ * @see ezcWebdavTransport
+ * @see ezcWebdavPropertyHandler
+ * 
+ * @package Webdav
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+class ezcWebdavPluginRegistry
+{
+
+    /**
+     * Singleton instance.
+     * 
+     * @var ezcWebdavPluginRegistry
+     */
+    private static $instance;
+
+    /**
+     * Known hooks. 
+     * 
+     * <code>
+     *      array(
+     *          '<class>' => array(
+     *              '<method>' => <bitmask>,
+     *              // ...
+     *          )
+     *          // ...
+     *      )
+     * </code>
+     *
+     * @var array(string=>array(string=>bool))
+     */
+    private $hooks = array();
+
+    /**
+     * Registered plugins. 
+     *
+     * <code>
+     *      array(
+     *          '<namespace>' => '<config-object>',
+     *          // ...
+     *      )
+     * </code>
+     * 
+     * @var array(string=>ezcWebdavPluginConfiguration)
+     */
+    private $plugins = array();
+
+    /**
+     * Use singleton.
+     * 
+     * @return void
+     */
+    private function __construct()
+    {
+        // Transport layer hooks
+
+        // Extract parsing methods
+        foreach ( ezcWebdavTransport::$parsingMap as $httpMethod => $method )
+        {
+            $this->createHook( 'ezcWebdavTransport', $method, 'before' );
+            $this->createHook( 'ezcWebdavTransport', $method, 'after' );
+        }
+        // Extract handling methods
+        foreach ( ezcWebdavTransport::$handlingMap as $class => $method )
+        {
+            $this->createHook( 'ezcWebdavTransport', $method, 'before' );
+            $this->createHook( 'ezcWebdavTransport', $method, 'after' );
+        }
+        // Add additional Transport layer hooks
+        $this->createHook( 'ezcWebdavTransport', 'processUnknownRequest' );
+        $this->createHook( 'ezcWebdavTransport', 'handleUnknownResponse' );
+
+        // Property related hooks
+        $this->createHook( 'ezcWebdavTransport', 'extractLiveProperty', 
'before' );
+        $this->createHook( 'ezcWebdavTransport', 'extractLiveProperty', 
'after' );
+
+        $this->createHook( 'ezcWebdavTransport', 'extractDeadProperty', 
'before' );
+        $this->createHook( 'ezcWebdavTransport', 'extractDeadProperty', 
'after' );
+        
+        $this->createHook( 'ezcWebdavTransport', 'serializeLiveProperty', 
'before' );
+        $this->createHook( 'ezcWebdavTransport', 'serializeLiveProperty', 
'after' );
+        
+        $this->createHook( 'ezcWebdavTransport', 'serializeDeadProperty', 
'before' );
+        $this->createHook( 'ezcWebdavTransport', 'serializeDeadProperty', 
'after' );
+
+        $this->createHook( 'ezcWebdavTransport', 'extractUnknownLiveProperty' 
);
+        $this->createHook( 'ezcWebdavTransport', 
'serializeUnknownLiveProperty' );
+        
+        $this->createHook( 'ezcWebdavTransport', 'extractUnknownDeadProperty' 
);
+        $this->createHook( 'ezcWebdavTransport', 
'serializeUnknownDeadProperty' );
+
+        // Server layer hooks
+
+        $this->createHook( 'ezcWebdavServer', 'receivedRequest' );
+        $this->createHook( 'ezcWebdavServer', 'generatedResponse' );
+    }
+
+    /**
+     * Creates a new hook.
+     * 
+     * Helper method. Used in [EMAIL PROTECTED] __construct()} to create a 
hook. The
+     * $class identifies the base class the hook is provided by, $method
+     * specificies the name of the affected method of this class or a "pseudo
+     * method name", if no such is available.
+     * 
+     * @param mixed $class 
+     * @param mixed $method 
+     * @param mixed $prefix 
+     * @return void
+     */
+    private function createHook( $class, $method, $prefix = null )
+    {
+        $this->hooks[$class][( $prefix !== null ? $prefix . ucfirst( $method ) 
 : $method )] = true;
+    }
+
+    /**
+     * Get singleton instance.
+     *
+     * Returns the single instance of this class that may exist per request.
+     * 
+     * @return ezcWebdavPluginRegistry
+     */
+    public static final function getInstance()
+    {
+        if ( self::$instance === null )
+        {
+            self::$instance = new ezcWebdavPluginRegistry();
+        }
+        return self::$instance;
+    }
+
+    /**
+     * Registers a new plugin to be used.
+     *
+     * Receives an instance of [EMAIL PROTECTED] 
ezcWebdavPluginConfiguration}, which is
+     * possible extended for internal use in the plugin. The 'namespace'
+     * property of this class is used to register it internally. Multiple
+     * registrations of the same namespace will lead to an exception.
+     *
+     * @param ezcWebdavPluginConfiguration $config
+     *
+     * @throws ezcWebdavPluginDoubleRegistrationException
+     *         if the namespace of a plugin is registered twice.
+     */
+    public final function registerPlugin( ezcWebdavPluginConfiguration $config 
)
+    {
+
+    }
+
+
+    /**
+     * Can be used to deactivate a plugin.
+     *
+     * Receives an instance of [EMAIL PROTECTED] 
ezcWebdavPluginConfiguration}, which is
+     * possible extended for internal use in the plugin. The 'namespace'
+     * property of this class is used to unregister it internally.
+     * Unregistration of a notregistered $config object will be silently
+     * ignored.
+     *
+     * @param ezcWebdavPluginConfiguration $config
+     */
+    public final function unregisterPlugin( ezcWebdavPluginConfiguration 
$config )
+    {
+
+    }
+
+    /**
+     * Returns a plugins configuration object.
+     *
+     * Returns the instance of [EMAIL PROTECTED] ezcWebdavPluginConfiguration} 
used for
+     * the plugin with a given $namespace. Throws an exception, if the plugin
+     * was not found.
+     * 
+     * @param string $namespace 
+     * @return ezcWebdavPluginConfiguration
+     */
+    public final function getPluginConfig( $namespace )
+    {
+
+    }
+
+    /**
+     * Returns if a plugin is active in the server.
+     *
+     * Checks if a configuration with the given $namespace exists and returns
+     * this information as a boolean value.
+     * 
+     * @param string $namespace 
+     * @return bool
+     */
+    public final function hasPlugin( $namespace )
+    {
+
+    }
+
+    /**
+     * Announces the given hook.
+     *
+     * This class may only be used by [EMAIL PROTECTED] ezcWebdavServer} and 
[EMAIL PROTECTED]
+     * ezcWebdavTransport} to announce the reaching of a hook. Therefore, this
+     * method is marked private. Receives the name of the class issuing the
+     * $hook and the $params that may be used for information extraction and
+     * _careful_ possible manipulation.
+     * 
+     * @param string $class
+     * @param string $hook 
+     * @param ezcWebdavPluginParameters $params 
+     * @return void
+     *
+     * @throws ezcWebdavPluginFailureException
+     *         in case a plugin threw an exception. The original one can be
+     *         accessed for processing through the public $originalException
+     *         attribute.
+     */
+    public final function announceHook( $class, $hook, 
ezcWebdavPluginParameters $params )
+    {
+
+    }
+}
+
+?>

Propchange: trunk/Webdav/src/plugin_registry.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Tue Oct  2 14:08:49 2007
@@ -43,9 +43,13 @@
     /**
      * Map of HTTP methods to object method names for parsing.
      *
+     * Need public access here to retrieve this in [EMAIL PROTECTED]
+     * ezcWebdavPluginRegistry}.
+     *
      * @var array(string=>string)
-     */
-    static protected $parsingMap = array(
+     * @private
+     */
+    static public $parsingMap = array(
         'COPY'      => 'parseCopyRequest',
         'DELETE'    => 'parseDeleteRequest',
         'GET'       => 'parseGetRequest',
@@ -63,9 +67,13 @@
     /**
      * Map of response objects to handling methods.
      *
+     * Need public access here to retrieve this in [EMAIL PROTECTED]
+     * ezcWebdavPluginRegistry}.
+     *
      * @array(string=>string)
-     */
-    static protected $handlingMap = array(
+     * @private
+     */
+    static public $handlingMap = array(
         'ezcWebdavCopyResponse'           => 'processCopyResponse',
         'ezcWebdavDeleteResponse'         => 'processDeleteResponse',
         'ezcWebdavErrorResponse'          => 'processErrorResponse',


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to