Explorar el Código

Points de vente partagés : domain

feature/rotating_product
Guillaume Bourgeois hace 5 meses
padre
commit
92a7eb81fb
Se han modificado 5 ficheros con 187 adiciones y 0 borrados
  1. +97
    -0
      domain/PointSale/SharedPointSale/SharedPointSale.php
  2. +22
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleBuilder.php
  3. +13
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleDefinition.php
  4. +23
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleManager.php
  5. +32
    -0
      domain/PointSale/SharedPointSale/SharedPointSaleModule.php

+ 97
- 0
domain/PointSale/SharedPointSale/SharedPointSale.php Ver fichero

@@ -0,0 +1,97 @@
<?php

namespace domain\PointSale\SharedPointSale;

use common\components\ActiveRecordCommon;
use domain\PointSale\PointSale\PointSale;
use domain\Producer\Producer\Producer;

class SharedPointSale extends ActiveRecordCommon
{
public function getPointSale(): PointSale
{
return $this->pointSaleRelation;
}

public function setPointSale(PointSale $pointSale): self
{
$this->populateFieldObject('id_point_sale', 'pointSaleRelation', $pointSale);
return $this;
}

public function getProducerWithSharing(): Producer
{
return $this->producerWithSharingRelation;
}

public function setProducerWithSharing(Producer $producerWithSharing): self
{
$this->populateFieldObject('id_producer_with_sharing', 'producerWithSharingRelation', $producerWithSharing);

return $this;
}

public function getPointSaleWithSharing(): ?PointSale
{
return $this->pointSaleWithSharing;
}

public function setPointSaleWithSharing(PointSale $pointSaleWithSharing = null): self
{
if($pointSaleWithSharing) {
$this->populateFieldObject('id_point_sale_with_sharing', 'pointSaleWithSharingRelation', $pointSaleWithSharing);
}

return $this;
}

public function getStatus(): int
{
return $this->status;
}

public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}

public static function tableName()
{
return 'shared_point_sale';
}

public function rules()
{
return [
[['id_point_sale', 'id_producer_with_sharing'], 'required'],
[['id_point_sale', 'id_producer_with_sharing', 'id_point_sale_with_sharing', 'status'], 'integer'],
];
}

public function attributeLabels()
{
return [
'id_point_sale' => 'Point de vente que vous souhaitez partager',
'id_producer_with_sharing' => 'Producteur avec qui vous souhaitez partager un point de vente',
'id_point_sale_with_sharing' => 'Point de vente du producteur avec qui vous souhaitez partager un point de vente',
];
}

/* Relations */

public function getPointSaleRelation()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
}

public function getProducerWithSharingRelation()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer_with_sharing']);
}

public function getPointSaleWithSharingRelation()
{
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale_with_sharing']);
}
}

+ 22
- 0
domain/PointSale/SharedPointSale/SharedPointSaleBuilder.php Ver fichero

@@ -0,0 +1,22 @@
<?php

namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractBuilder;
use domain\_\StatusInterface;
use domain\PointSale\PointSale\PointSale;
use domain\Producer\Producer\Producer;

class SharedPointSaleBuilder extends AbstractBuilder
{
public function instanciateSharedPointSale(PointSale $pointSale, Producer $producerWithSharing): SharedPointSale
{
$sharedPointSale = new SharedPointSale();

$sharedPointSale->setPointSale($pointSale);
$sharedPointSale->setProducerWithSharing($producerWithSharing);
$sharedPointSale->setStatus(StatusInterface::STATUS_ONLINE);

return $sharedPointSale;
}
}

+ 13
- 0
domain/PointSale/SharedPointSale/SharedPointSaleDefinition.php Ver fichero

@@ -0,0 +1,13 @@
<?php

namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractDefinition;

class SharedPointSaleDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return SharedPointSale::class;
}
}

+ 23
- 0
domain/PointSale/SharedPointSale/SharedPointSaleManager.php Ver fichero

@@ -0,0 +1,23 @@
<?php

namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractManager;
use domain\PointSale\PointSale\PointSale;
use domain\Producer\Producer\Producer;

class SharedPointSaleManager extends AbstractManager
{
protected SharedPointSaleBuilder $sharedPointSaleBuilder;

public function loadDependencies(): void
{
$this->sharedPointSaleBuilder = $this->loadService(SharedPointSaleBuilder::class);
}

public function createSharedPointSale(PointSale $pointSale, Producer $producerWithSharing)
{
$sharedPointSale = $this->sharedPointSaleBuilder->instanciateSharedPointSale($pointSale, $producerWithSharing);
$this->sharedPointSaleBuilder->create($sharedPointSale);
}
}

+ 32
- 0
domain/PointSale/SharedPointSale/SharedPointSaleModule.php Ver fichero

@@ -0,0 +1,32 @@
<?php

namespace domain\PointSale\SharedPointSale;

use domain\_\AbstractModule;

class SharedPointSaleModule extends AbstractModule
{
public function getServices(): array
{
return [
SharedPointSaleDefinition::class,
SharedPointSaleBuilder::class,
SharedPointSaleManager::class
];
}

public function getDefinition(): SharedPointSaleDefinition
{
return SharedPointSaleDefinition::getInstance();
}

public function getBuilder(): SharedPointSaleBuilder
{
return SharedPointSaleBuilder::getInstance();
}

public function getManager(): SharedPointSaleManager
{
return SharedPointSaleManager::getInstance();
}
}

Cargando…
Cancelar
Guardar