mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Core] Add menu taxon to Channel entity
This commit is contained in:
parent
1d2361571e
commit
9b86215312
6 changed files with 65 additions and 0 deletions
31
app/migrations/Version20200110132702.php
Normal file
31
app/migrations/Version20200110132702.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20200110132702 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_channel ADD menu_taxon_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119EF242B1E6 FOREIGN KEY (menu_taxon_id) REFERENCES sylius_taxon (id) ON DELETE SET NULL');
|
||||
$this->addSql('CREATE INDEX IDX_16C8119EF242B1E6 ON sylius_channel (menu_taxon_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119EF242B1E6');
|
||||
$this->addSql('DROP INDEX IDX_16C8119EF242B1E6 ON sylius_channel');
|
||||
$this->addSql('ALTER TABLE sylius_channel DROP menu_taxon_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,9 @@
|
|||
<many-to-one field="defaultTaxZone" target-entity="Sylius\Component\Addressing\Model\ZoneInterface">
|
||||
<join-column name="default_tax_zone_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
</many-to-one>
|
||||
<many-to-one field="menuTaxon" target-entity="Sylius\Component\Core\Model\TaxonInterface">
|
||||
<join-column name="menu_taxon_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
</many-to-one>
|
||||
<many-to-many field="currencies" target-entity="Sylius\Component\Currency\Model\CurrencyInterface" fetch="EAGER">
|
||||
<join-table name="sylius_channel_currencies">
|
||||
<join-columns>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace spec\Sylius\Component\Channel\Model;
|
|||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Channel\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
|
||||
final class ChannelSpec extends ObjectBehavior
|
||||
{
|
||||
|
|
@ -93,4 +94,10 @@ final class ChannelSpec extends ObjectBehavior
|
|||
$this->setUpdatedAt($date);
|
||||
$this->getUpdatedAt()->shouldReturn($date);
|
||||
}
|
||||
|
||||
function its_type_is_mutable(): void
|
||||
{
|
||||
$this->setType('mobile');
|
||||
$this->getType()->shouldReturn('mobile');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ class Channel extends BaseChannel implements ChannelInterface
|
|||
/** @var ShopBillingDataInterface|null */
|
||||
protected $shopBillingData;
|
||||
|
||||
/** @var TaxonInterface|null */
|
||||
protected $menuTaxon;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
@ -301,4 +304,14 @@ class Channel extends BaseChannel implements ChannelInterface
|
|||
{
|
||||
$this->shopBillingData = $shopBillingData;
|
||||
}
|
||||
|
||||
public function getMenuTaxon(): ?TaxonInterface
|
||||
{
|
||||
return $this->menuTaxon;
|
||||
}
|
||||
|
||||
public function setMenuTaxon(?TaxonInterface $menuTaxon): void
|
||||
{
|
||||
$this->menuTaxon = $menuTaxon;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,8 @@ interface ChannelInterface extends
|
|||
public function getShopBillingData(): ?ShopBillingDataInterface;
|
||||
|
||||
public function setShopBillingData(ShopBillingDataInterface $shopBillingData): void;
|
||||
|
||||
public function getMenuTaxon(): ?TaxonInterface;
|
||||
|
||||
public function setMenuTaxon(?TaxonInterface $menuTaxon): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use PhpSpec\ObjectBehavior;
|
|||
use Sylius\Component\Addressing\Model\ZoneInterface;
|
||||
use Sylius\Component\Channel\Model\Channel as BaseChannel;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
use Sylius\Component\Currency\Model\CurrencyInterface;
|
||||
use Sylius\Component\Locale\Model\LocaleInterface;
|
||||
|
||||
|
|
@ -159,4 +160,10 @@ final class ChannelSpec extends ObjectBehavior
|
|||
$this->setAccountVerificationRequired(false);
|
||||
$this->isAccountVerificationRequired()->shouldReturn(false);
|
||||
}
|
||||
|
||||
function its_menu_taxon_is_mutable(TaxonInterface $taxon): void
|
||||
{
|
||||
$this->setMenuTaxon($taxon);
|
||||
$this->getMenuTaxon()->shouldReturn($taxon);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue