Skip to content

Instantly share code, notes, and snippets.

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

Wolfgang wazum

😼
I may be slow to respond.
View GitHub Profile
@wazum
wazum / rename-commits.sh
Last active July 9, 2025 09:14
Simple bash script to prefix (with replace) a bunch of git commit messages in bulk
#!/bin/bash
PREFIX="[SOMETHING]"
# Add commit hashes from newest to oldest (oldest at the end).
COMMITS=(
90f94f6174d9efe74d5f63a53049a063124bdff8
eb17a70cf18ea6662c045b95ac5ba6a36640b30c
91026eec2b324e6999b07fc24071fa0e55dd2795
411df442fbe4860f6b25fc41d8a4fc64190a95fa
1f5cf10b34fc67677f00fe7850730bdfe38c1ff9
@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