Skip to content

Instantly share code, notes, and snippets.

View wazum's full-sized avatar
😼
I may be slow to respond.

Wolfgang Klinger wazum

😼
I may be slow to respond.
View GitHub Profile
@wazum
wazum / MyBatchHandler.php
Created August 1, 2022 05:14
Symfony Batch Handler example
<?php
class MyBatchHandler implements BatchHandlerInterface
{
use BatchHandlerTrait;
public function __invoke(MyMessage $message, Acknowledger $ack = null)
{
return $this->handle($message, $ack);
}
@wazum
wazum / MyBatchHandler.php
Created July 30, 2022 12:27
My Batch Handler Solr example
<?php
$documents = [];
foreach ($jobs as [$job, $ack]) {
try {
$documents[] = $this->solrService->createDocument($job->something());
$ack->ack($job);
} catch (\Exception $e) {
$ack->nack($e);
}
@wazum
wazum / HandleMessageMiddleware.php
Created July 30, 2022 09:23
Symfony Handle Message Middleware AckStamp
<?php
/** @var AckStamp $ackStamp */
if ($batchHandler && $ackStamp = $envelope->last(AckStamp::class)) {
$ack = new Acknowledger(get_debug_type($batchHandler), static function (\Throwable $e = null, $result = null) use ($envelope, $ackStamp, $handlerDescriptor) {
if (null !== $e) {
$e = new HandlerFailedException($envelope, [$e]);
} else {
$envelope = $envelope->with(HandledStamp::fromDescriptor($handlerDescriptor, $result));
<?php
declare(strict_types=1);
namespace App\Something\Infrastructure\Doctrine\EventSubscriber;
use App\Something\Domain\Contracts\ContainsNullableEmbeddable;
use App\Something\Domain\Contracts\NullableEmbeddable as NullableEmbeddableInterface;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
<?php
declare(strict_types=1);
namespace App\Something\Domain\Entity;
/**
* @ORM\Entity
*/
class Person extends DomainEntity implements ContainsNullableEmbeddable
<?php
declare(strict_types=1);
namespace App\Something\Domain\ValueObject;
use Webmozart\Assert\Assert;
/**
* @Embeddable
<?php
declare(strict_types=1);
namespace App\Something\Domain\Contracts;
interface ContainsNullableEmbeddable
{
}
<?php
declare(strict_types=1);
namespace App\Something\Domain\Contracts;
interface NullableEmbeddable
{
}
@wazum
wazum / Person.php
Created November 14, 2020 10:36
Person entity with nullable EmailAddress value object
<?php
declare(strict_types=1);
namespace App\Something\Domain\Entity;
/**
* @ORM\Entity
*/
class Person extends DomainEntity
@wazum
wazum / Template.html
Created July 22, 2020 10:51
ViewHelper for language menu and news
<f:section name="LanguageMenu">
<f:if condition="({menu.0.active} && {menu.1.available} && {n:translationAvailable(languageId: 1)}) || ({menu.1.active} && {menu.0.available} && {n:translationAvailable(languageId: 0)})">
<div class="language-switch">
<ul>