Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include shopping cart in frontend #4

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions app/src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Psr\Cache\CacheItemPoolInterface;
use Stash\Pool;
use Wambo\Catalog\CachedProductRepository;
use Wambo\Catalog\Mapper\ContentMapper;
use Wambo\Catalog\Mapper\ProductMapper;
use Wambo\Catalog\ProductRepository;
use Wambo\Catalog\ProductRepositoryInterface;
use Wambo\Core\Module\JSONModuleStorage;
use Wambo\Core\Module\ModuleMapper;
use Wambo\Core\Module\ModuleRepository;
use Wambo\Cart\Service\Storage\CartRepositoryInterface;
use Wambo\Cart\Service\Storage\CartRepository;

return [
'settings.httpVersion' => '1.1',
Expand All @@ -15,19 +24,47 @@
'settings.displayErrorDetails' => true,
'settings.addContentLengthHeader' => true,
'settings.routerCacheFile' => false,
'filesystem_adapter' => function ($c) {
return new Local(WAMBO_ROOT_DIR);


// local filesystem
Filesystem::class => function () {
return new Filesystem(new Local(WAMBO_ROOT_DIR));
},
'filesystem' => function ($c) {
return new Filesystem($c->get('filesystem_adapter'));

// cache
CacheItemPoolInterface::class => function () {
$cache = new Pool();
return $cache;
},
'module_repository' => function ($c) {
/** @var Filesystem $filesystem */
$filesystem = $c->get('filesystem');

// Wambo modules
ModuleRepository::class => function (Filesystem $filesystem) {
$storage = new JSONModuleStorage($filesystem, 'vendor/modules.json');
$mapper = new ModuleMapper();

return new ModuleRepository($storage, $mapper);
}
];
},

// product repository
ProductRepositoryInterface::class => function (CacheItemPoolInterface $cache, Filesystem $filesystem) {
$storage = new JSONModuleStorage($filesystem, "data/catalog.json");

// product mapper
$contentMapper = new ContentMapper();
$productMapper = new ProductMapper($contentMapper);

// create the product repository
$productRepository = new ProductRepository($storage, $productMapper);

// create a cached version of the product repository
$cachedProductRepository = new CachedProductRepository($cache, $productRepository);
return $cachedProductRepository;
},

// Cart Repository
CartRepositoryInterface::class => function (Filesystem $filesystem) {
$cartStorage = new JSONModuleStorage($filesystem, "var/carts.json");
return new CartRepository($cartStorage);
},

];
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
},
"require": {
"slim/slim": "v3.4.2",
"wambo/module-core": "v0.2.0",
"wambo/module-core": "dev-feature/cart",
"wambo/module-cart": "dev-feature/base",
"wambo/module-checkout": "dev-feature/base",
"wambo/module-test": "dev-develop",
"wambo/module-frontend": "dev-develop",
"wambo/module-frontend": "dev-feature/cart",
"wambo/module-performance-tester": "dev-develop",
"wambo/wambo-composer-installer": "dev-develop",
"tedivm/stash": "^0.14.1",
Expand Down
16 changes: 16 additions & 0 deletions data/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"sku": "t-shirt-no-1",
"slug": "t-shirt-no-1",
"title": "T-Shirt No. 1",
"summary": "Our T-Shirt No. 1",
"description": "Our fancy T-Shirt No. 1 is ..."
},
{
"sku": "t-shirt-no-2",
"slug": "t-shirt-no-2",
"title": "T-Shirt No. 2",
"summary": "Our T-Shirt No. 2",
"description": "Our fancy T-Shirt No. 2 is ..."
}
]
2 changes: 2 additions & 0 deletions var/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore