Esempio n. 1
0
 /**
  * Constructor
  *
  * @param Pandamp_BeanContext_Decoratable $mixed  The table class to model, or the classname
  * as a string of the model to decorate. The class will then try to
  * load the class and instantiate it with no arguments.
  * @param Pandamp_Filter_Input $filter An optional filter that gets processed before the
  * data is returned. The flter will only be used if teh data is decorated as dto or entity
  * @param boolean $strict if set to false, mising setters for any property available will not
  * throw an exception
  *
  * @throws Exception
  */
 public final function __construct($mixed, Pandamp_Filter_Input $filter = null, $strict = true)
 {
     $this->_filter = $filter;
     $this->_strict = $strict;
     if (is_string($mixed)) {
         Pandamp_BeanContext_Inspector::loadClass($mixed);
         if (!class_exists($mixed)) {
             throw new Exception("Could not find class to decorate \"{$mixed}\".");
         }
         $this->_decoratedModel = new $mixed();
     } else {
         $this->_decoratedModel = $mixed;
     }
     if (!$this->_decoratedModel instanceof Pandamp_BeanContext_Decoratable) {
         throw new Exception("Decorated class is no subclass of \"Pandamp_BeanContext_Decoratable\"");
     }
     $this->_decoratedMethods = $this->_decoratedModel->getDecoratableMethods();
     $this->_entity = $this->_decoratedModel->getRepresentedEntity();
     Pandamp_BeanContext_Inspector::loadClass($this->_entity);
     if (!class_exists($this->_entity)) {
         throw new Exception("Could not find entity \"" . $this->_entity . "\".");
     }
     $refC = new ReflectionClass($this->_entity);
     if (!$refC->implementsInterface('Pandamp_BeanContext')) {
         throw new Exception("Entity \"" . $this->_entity . "\" is not a \"Pandamp_BeanContext\"-class.");
     }
 }