public function __construct(Mapper $mapper, array $eagerLoads)
 {
     $this->mapper = $mapper;
     $this->entityMap = $mapper->getEntityMap();
     $this->eagerLoads = $eagerLoads;
     $this->lazyLoads = $this->prepareLazyLoading();
     $this->entityMap = $mapper->getEntityMap();
 }
 /**
  * 
  * @param \Analogue\ORM\Mappable $entity 
  * @param \Analogue\ORM\System\Mapper $mapper 
  */
 public function __construct(Mappable $entity, Mapper $mapper)
 {
     $this->entity = $entity;
     $this->mapper = $mapper;
     $this->entityMap = $mapper->getEntityMap();
     $this->keyName = $this->entityMap->getKeyName();
 }
Exemple #3
0
 /**
  * Create a new has many relationship instance.
  *
  * @param  \Analogue\ORM\Query  $query
  * @param  \Analogue\ORM\Entityl  $parent
  * @param  string  $name
  * @param  string  $table
  * @param  string  $foreignKey
  * @param  string  $otherKey
  * @param  string  $relationName
  * @param  bool   $inverse
  * @return void
  */
 public function __construct(Mapper $mapper, $parent, $name, $table, $foreignKey, $otherKey, $relationName = null, $inverse = false)
 {
     $this->inverse = $inverse;
     $this->morphType = $name . '_type';
     $this->morphClass = $inverse ? $mapper->getEntityMap()->getClass() : get_class($parent);
     parent::__construct($mapper, $parent, $table, $foreignKey, $otherKey, $relationName);
 }
Exemple #4
0
 public function __construct(Mappable $entity, Mapper $mapper, QueryAdapter $query)
 {
     $this->entity = $entity;
     $this->mapper = $mapper;
     $this->entityState = new StateChecker($entity, $mapper);
     $this->entityMap = $mapper->getEntityMap();
     $this->query = $query->from($this->entityMap->getTable());
 }
Exemple #5
0
 /**
  * Create a new Analogue Query Builder instance.
  *
  * @param \Analogue\ORM\Drivers\QueryAdapter  $query
  * @param \Analogue\ORM\System\Mapper $mapper
  * @return void
  */
 public function __construct(Mapper $mapper, DBAdapter $adapter)
 {
     $this->mapper = $mapper;
     $this->adapter = $adapter;
     $this->entityMap = $mapper->getEntityMap();
     // Specify the table to work on
     $this->query = $adapter->getQuery()->from($this->entityMap->getTable());
     $this->with($this->entityMap->getEagerloadedRelationships());
 }
 /**
  * By hooking to the mapper initialization event, we can extend it
  * with the softDelete capacity.
  * 
  * @param  \Analogue\ORM\System\Mapper 	$mapper 
  * @return void
  */
 protected function registerSoftDelete(Mapper $mapper)
 {
     $entityMap = $mapper->getEntityMap();
     // Add Scopes
     $mapper->addGlobalScope(new SoftDeletingScope());
     $host = $this;
     // Register 'deleting' events
     $mapper->registerEvent('deleting', function ($entity) use($entityMap, $host) {
         $deletedAtField = $entityMap->getQualifiedDeletedAtColumn();
         if (!is_null($entity->getEntityAttribute($deletedAtField))) {
             return true;
         } else {
             $time = new Carbon();
             $entity->{$deletedAtField} = $time;
             // Launch an update instead
             $host->manager->mapper(get_class($entity))->store($entity);
             return false;
         }
     });
     // Register RestoreCommand
     $mapper->addCustomCommand('Analogue\\ORM\\Plugins\\SoftDeletes\\Restore');
 }
Exemple #7
0
 /**
  * Create a new relation instance.
  *
  * @param  \Analogue\ORM\System\Mapper $mapper
  * @param  Mappable $parent
  * @return void
  */
 public function __construct(Mapper $mapper, $parent)
 {
     $this->relatedMapper = $mapper;
     $this->query = $mapper->getQuery();
     $this->parent = $parent;
     $this->parentMapper = $mapper->getManager()->getMapper($parent);
     $this->parentMap = $this->parentMapper->getEntityMap();
     $this->related = $this->query->getEntityInstance();
     $this->relatedMap = $mapper->getEntityMap();
     $this->addConstraints();
 }