/**
  * @param string $boxableType name of an IBoxable class
  * @param DBType $dbType type to use to store the value
  */
 function __construct($boxableType, DBType $dbType)
 {
     Assert::isTrue(TypeUtils::isChild($boxableType, 'IBoxable'));
     $this->boxableType = $boxableType;
     $this->dbType = $dbType;
     parent::__construct($dbType);
 }
 /**
  * All we need to know is the associative entity (the container), because the association
  * is build between this one property and the identifier of the container
  * @throws OrmModelIntegrityException
  */
 function __construct(IQueryable $container, AssociationMultiplicity $multiplicity, AssociationBreakAction $action)
 {
     $identifier = $container->getLogicalSchema()->getIdentifier();
     if (!$identifier) {
         throw new OrmModelIntegrityException('Cannot associate to an entity ' . $container->getLogicalSchema()->getEntityName() . ' without id');
     }
     $this->container = $container;
     Assert::isTrue(TypeUtils::isChild($identifier->getType(), 'IOrmPropertyReferencable'));
     $this->fkType = $identifier->getType()->getReferenceType($multiplicity);
     $this->multiplicity = $multiplicity;
     $this->action = $action;
 }
Ejemplo n.º 3
0
 /**
  * Default error handler, that casts covered errors to their appropriate exceptions
  * @return boolean
  */
 function errorHandler($errno, $errstr, $errfile, $errline)
 {
     if (!error_reporting()) {
         //return false;
     }
     if (!($errno & $this->mask)) {
         if (!$this->supressUncovered) {
             if ($this->previousErrorHandler) {
                 $args = func_get_args();
                 call_user_func_array($this->prevErrorHandler, $args);
             } else {
                 return false;
             }
         }
         return true;
     }
     if (isset($this->exceptionsTable[$errno])) {
         $exceptionClass = $this->exceptionsTable[$errno];
         Assert::isTrue(TypeUtils::isChild($exceptionClass, 'IErrorExceptionFactory'));
         $exceptionObject = call_user_func_array(array($exceptionClass, 'makeException'), array($errstr, $errno, $errfile, $errline));
     } else {
         $exceptionObject = null;
     }
     if (!$exceptionObject instanceof Exception) {
         $exceptionClass = $this->defaultException;
         Assert::isTrue(TypeUtils::isChild($exceptionClass, 'IErrorExceptionFactory'));
         $exceptionObject = call_user_func_array(array($exceptionClass, 'makeException'), array($errstr, $errno, $errfile, $errline));
     }
     throw $exceptionObject;
 }
 /**
  * Resolution order:
  *  - IDaoRelated (check a class existance within the global scope and withing the domain scope) --> AssociationPropertyType
  *  - IOrmRelated --> CompositionPropertyType (not implemented)
  *  - IOrmPropertyAssignable --> IOrmPropertyAssignable::getOrmProperty()
  *  - IBoxable --> BoxablePropertyType
  *  - DBType
  *  - any type with public ctor
  * @return OrmPropertyType
  */
 private function getPropertyType($name, AssociationMultiplicity $multiplicity, array $parameters = array())
 {
     if ($this->ormDomain->classExists($name)) {
         $class = $this->ormDomain->getClass($name);
         if ($class->hasDao() && $class->getIdentifier()) {
             return new AssociationPropertyType($class, $multiplicity, AssociationBreakAction::cascade());
         } else {
             return new CompositePropertyType($class);
         }
     } else {
         if (DBType::hasMember($name)) {
             $parameters['id'] = $name;
             if (!isset($parameters['nullable'])) {
                 $parameters['nullable'] = $multiplicity->isNullable() ? 'true' : 'false';
             }
             $dbType = $this->makeObject('DBType', $parameters);
             return $dbType->getOrmPropertyType();
         } else {
             if (class_exists($name, true)) {
                 if (TypeUtils::isChild($name, 'IDaoRelated')) {
                     return new AssociationPropertyType(call_user_func(array($name, 'orm')), $multiplicity, AssociationBreakAction::cascade());
                 } else {
                     if (TypeUtils::isChild($name, 'IOrmRelated')) {
                         $orm = call_user_func(array($name, 'orm'));
                         return new CompositePropertyType($orm);
                     } else {
                         if (TypeUtils::isChild($name, 'IOrmPropertyAssignable')) {
                             return call_user_func(array($name, 'getOrmPropertyType'), $multiplicity);
                         } else {
                             if (TypeUtils::isChild($name, 'IBoxable')) {
                                 $parameters['id'] = DBType::VARCHAR;
                                 if (!isset($parameters['nullable'])) {
                                     $parameters['nullable'] = $multiplicity->isNullable() ? 'true' : 'false';
                                 }
                                 return new BoxablePropertyType($name, $this->makeObject('DBType', $parameters));
                             } else {
                                 if (TypeUtils::isChild($name, 'ISqlType')) {
                                     // for RawSqlType
                                     return new PrimitivePropertyType($this->makeObject($name, $parameters));
                                 } else {
                                     //$this->makeObject($name, $parameters);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     throw new OrmModelIntegrityException('do not know how to map ' . $name);
 }
 /**
  * Wrapper over ASP.NET-like "CodeBehind" and "Inherits" attributes
  * @return void
  */
 protected final function codeBehind($type)
 {
     $this->assertInsideRenderingContext();
     Assert::isTrue(TypeUtils::isChild($this, $type), 'fatal error: %s should be the only wrapper for invoked layout to handle it successfully', $type);
 }
Ejemplo n.º 6
0
 /**
  * @return IQueryable
  */
 private static function getQueriable($class)
 {
     if (is_object($class) && $class instanceof IOrmRelated) {
         $class = get_class($class);
     }
     if (is_scalar($class) && TypeUtils::isChild($class, 'IOrmRelated')) {
         $class = call_user_func(array($class, 'orm'));
     }
     return $class;
 }