-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60ba831
commit d66857b
Showing
18 changed files
with
294 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/DependencyInjection/BitBagSyliusWishlistExtensionSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusWishlistPlugin\DependencyInjection; | ||
|
||
use BitBag\SyliusWishlistPlugin\DependencyInjection\BitBagSyliusWishlistExtension; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; | ||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; | ||
|
||
final class BitBagSyliusWishlistExtensionSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(BitBagSyliusWishlistExtension::class); | ||
} | ||
|
||
function it_is_instance_of_prepend_extension_interface() | ||
{ | ||
$this->shouldHaveType(PrependExtensionInterface::class); | ||
} | ||
|
||
function it_is_extending_abstract_resource_extension() | ||
{ | ||
$this->shouldHaveType(AbstractResourceExtension::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusWishlistPlugin\DependencyInjection; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
final class ConfigurationSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(ConfigurationInterface::class); | ||
} | ||
|
||
function it_returns_tree_builder(): void | ||
{ | ||
$this->getConfigTreeBuilder()->shouldBeAnInstanceOf(TreeBuilder::class ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusWishlistPlugin\DependencyInjection; | ||
|
||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
|
||
final class BitBagSyliusWishlistExtension extends AbstractResourceExtension implements PrependExtensionInterface | ||
{ | ||
public function load(array $config, ContainerBuilder $container): void | ||
{ | ||
$config = $this->processConfiguration($this->getConfiguration([], $container), $config); | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$this->registerResources('bitbag_sylius_wishlist_plugin', 'doctrine/orm', $config['resources'], $container); | ||
$loader->load('services.yml'); | ||
} | ||
|
||
public function prepend(ContainerBuilder $container): void | ||
{ | ||
if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) { | ||
return; | ||
} | ||
|
||
$container->prependExtensionConfig('doctrine_migrations', [ | ||
'migrations_paths' => [ | ||
'BitBag\SyliusWishlistPlugin\Migrations' => '@BitBagSyliusWishlistPlugin/Migrations', | ||
], | ||
]); | ||
|
||
$container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [ | ||
'migrations' => [ | ||
'BitBag\SyliusWishlistPlugin\Migrations' => ['Sylius\Bundle\CoreBundle\Migrations'], | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusWishlistPlugin\DependencyInjection; | ||
|
||
use BitBag\SyliusWishlistPlugin\Entity\Wishlist; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistProduct; | ||
use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; | ||
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepository; | ||
use Sylius\Bundle\ResourceBundle\Controller\ResourceController; | ||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; | ||
use Sylius\Component\Resource\Factory\Factory; | ||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
final class Configuration implements ConfigurationInterface | ||
{ | ||
public function getConfigTreeBuilder(): TreeBuilder | ||
{ | ||
$treeBuilder = new TreeBuilder('bitbag_sylius_wishlist_plugin'); | ||
$rootNode = $treeBuilder->getRootNode(); | ||
$rootNode | ||
->children() | ||
->arrayNode('resources') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->arrayNode('wishlist') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->variableNode('options')->end() | ||
->arrayNode('classes') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->scalarNode('model')->defaultValue(Wishlist::class)->cannotBeEmpty()->end() | ||
->scalarNode('interface')->defaultValue(WishlistInterface::class)->cannotBeEmpty()->end() | ||
->scalarNode('repository')->defaultValue(WishlistRepository::class)->cannotBeEmpty()->end() | ||
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() | ||
->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->arrayNode('wishlist_product') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->variableNode('options')->end() | ||
->arrayNode('classes') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->scalarNode('model')->defaultValue(WishlistProduct::class)->cannotBeEmpty()->end() | ||
->scalarNode('interface')->defaultValue(WishlistProductInterface::class)->cannotBeEmpty()->end() | ||
->scalarNode('repository')->defaultValue(WishlistRepository::class)->cannotBeEmpty()->end() | ||
->scalarNode('controller')->defaultValue(EntityRepository::class)->cannotBeEmpty()->end() | ||
->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
; | ||
|
||
return $treeBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusWishlistPlugin\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20201029161558 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE TABLE bitbag_wishlist (id INT AUTO_INCREMENT NOT NULL, shop_user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_578D4E775F37A13B (token), UNIQUE INDEX UNIQ_578D4E77A45D93BF (shop_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE bitbag_wishlist_product (id INT AUTO_INCREMENT NOT NULL, wishlist_id INT NOT NULL, product_id INT DEFAULT NULL, variant_id INT DEFAULT NULL, INDEX IDX_3DBE67A0FB8E54CD (wishlist_id), INDEX IDX_3DBE67A04584665A (product_id), INDEX IDX_3DBE67A03B69A9AF (variant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE bitbag_wishlist ADD CONSTRAINT FK_578D4E77A45D93BF FOREIGN KEY (shop_user_id) REFERENCES sylius_shop_user (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A0FB8E54CD FOREIGN KEY (wishlist_id) REFERENCES bitbag_wishlist (id)'); | ||
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A04584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id)'); | ||
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A03B69A9AF FOREIGN KEY (variant_id) REFERENCES sylius_product_variant (id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE bitbag_wishlist_product DROP FOREIGN KEY FK_3DBE67A0FB8E54CD'); | ||
$this->addSql('DROP TABLE bitbag_wishlist'); | ||
$this->addSql('DROP TABLE bitbag_wishlist_product'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,10 @@ DATABASE_URL=mysql://[email protected]/sylius_%kernel.environment%?serverVersion=5. | |
# Delivery is disabled by default via "null://localhost" | ||
MAILER_URL=smtp://localhost | ||
###< symfony/swiftmailer-bundle ### | ||
|
||
|
||
###> lexik/jwt-authentication-bundle ### | ||
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem | ||
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem | ||
JWT_PASSPHRASE=YOUR_SECRET_PASSPHRASE | ||
###< lexik/jwt-authentication-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
doctrine_migrations: | ||
dir_name: "%kernel.project_dir%/src/Migrations" | ||
|
||
# Namespace is arbitrary but should be different from App\Migrations as migrations classes should NOT be autoloaded | ||
namespace: DoctrineMigrations | ||
storage: | ||
table_storage: | ||
table_name: sylius_migrations |
4 changes: 4 additions & 0 deletions
4
tests/Application/config/packages/lexik_jwt_authentication.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lexik_jwt_authentication: | ||
secret_key: '%env(resolve:JWT_SECRET_KEY)%' | ||
public_key: '%env(resolve:JWT_PUBLIC_KEY)%' | ||
pass_phrase: '%env(JWT_PASSPHRASE)%' |
Oops, something went wrong.