Ejemplo n.º 1
0
 /**
  * Validate a model being operated on fits the context settings of the class so we do not get into any
  * undesirable states.
  *
  * @param $model
  * return boolean
  */
 public function validateModel($model)
 {
     $modelName = $this->getConfig()->modelName;
     if (Introspection::getClassName($model) !== $modelName) {
         return false;
     }
     $modelFactory = $this->getConfig()->getModelFactory();
     return $modelFactory->willCreate($model);
 }
 /**
  * Function tests if the passed in object can be created by this instance creator based on current configuration
  * settings on the class
  * @param object
  * @return boolean
  */
 public function willCreate($object)
 {
     $class = Introspection::getClassName($object);
     $namespaceClass = get_class($object);
     try {
         $createdName = $this->getFullClass($class);
     } catch (ClassNotFoundException $e) {
         return false;
     }
     if ($createdName[0] === "\\") {
         $namespaceClass = "\\{$namespaceClass}";
     }
     return $namespaceClass === $createdName;
 }