Bundle that automize the favourite entity usage.
This bundle answer aim to resolve the question, how many times this thing is used.
composer require ggggino/recenty-bundle
services.yaml
services:
...
GGGGino\RecentyBundle\Storage\StorageVolatile:
shared: false
app.strategy.desc:
class: GGGGino\RecentyBundle\Strategy\StrategyDesc
shared: false
arguments: ['@GGGGino\RecentyBundle\Storage\StorageVolatile']
app.strategy.asc:
class: GGGGino\RecentyBundle\Strategy\StrategyAsc
shared: false
arguments: ['@GGGGino\RecentyBundle\Storage\StorageVolatile']
shared: false
permit to instantiate a object every time it is called
recenty_bundle.yaml
ggggino_recenty:
clients:
main:
class: 'app.strategy.desc'
slave:
class: 'app.strategy.asc'
You can use as many client you like.
use GGGGino\RecentyBundle\WrapperManager;
/**
* @Route("/default", name="default")
*/
public function index(WrapperManager $wrapperManager): Response
{
$strategies = $wrapperManager->getStrategies();
/** @var Product $product */
$product = $em->getRepository(Product::class)->find(1);
try {
$wrapperManager->increment('main', new WrapperGenericEntity($product, 'bought', 2));
} catch (EntityNotValidException $e) {
return $this->json([
'message' => 'Wrapper not generable!'
], 500);
}
return $this->json([
'message' => 'Welcome to your new controller!'
]);
}
Strategy is the way a Entity will be stored and retrivied
Storage is the place where the Entity will be stored
./vendor/bin/simple-phpunit