The following code (which cannot currently work as PHP does not allow
for method overloading) would be perfect for me.

<?php
class DataConnector {
        /**
         * Rules
         *
         * What rules does this data connector use.
         *
         * @param Zend_Config
         */
        private $Rules = Null;

        /**
         * Constructor : Keyed
         *
         * This constructor will access the main registry to determine which
pre-saved rules to use.
         *
         * @param string $Key The registry key.
         *
         * @return DataConnector
         */
        public function __construct($Key) {
         // Use the key to retrieve the rules for this connector.
         $this->__construct(registry::RetrieveViaKey(__CLASS__, $Key));
        }

        /**
         * Constructor : Partial
         *
         * This constructor will construct the rules from the default
template and populate the 3 critical ones.
         *
         * @param string $Part1
         * @param string $Part2
         * @param string $Part3
         *
         * @return DataConnector
         */
        public function __construct($Part1, $Part2, $Part3) {
         // Use the Parts to construct the rules for this connector.
         $Rules = registry::RetrieveDefault(__CLASS__);
         $Rules->setPart1 = $Part1;
         $Rules->setPart2 = $Part2;
         $Rules->setPart3 = $Part3;
         $this->__construct($Rules);
        }

        /**
         * Constructor : Complete
         *
         * This constructor will take the supplied config and apply it to the 
rules.
         *
         * @param Zend_Config $Rules
         *
         * @return DataConnector
         */
        public function __construct(Zend_Config $Rules) {
         // Use the supplied rules
         $this->Rules = $Rules;
         $this->Init();
        }

        /**
         * Post construction processing
         */
        protected function Init() {
        }

        /**
         * Store configuration in the registry.
         *
         * @param string $Key Allow for a new key to be used.
         *
         * @return DataConnector
         */
        public function Store($Key = Null) {
                $this->Rules['Key'] = $Key ?: $this->Rules['Key'];
                registry::Store(__CLASS__, $this->Rules);
                return $this;
        }
}
?>



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to