Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Bastian Waidelich bwaidelich

🏠
Working from home
View GitHub Profile
@bwaidelich
bwaidelich / FusionEmailFinisher.php
Created Aug 6, 2020
A Fusion/Eel capable Flow Form Email Finisher
View FusionEmailFinisher.php
<?php
namespace Your\Package\Form\Finishers;
use Neos\Eel\EelEvaluatorInterface;
use Neos\Eel\Exception as EelException;
use Neos\Eel\Package as EelPackage;
use Neos\Eel\Utility as EelUtility;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\ResourceManagement\PersistentResource;
use Neos\Flow\ResourceManagement\ResourceManager;
@bwaidelich
bwaidelich / Customer.php
Last active Jul 29, 2020
Serializable Value Object
View Customer.php
<?php
final class Customer implements \JsonSerializable
{
private CustomerId $id;
private FullName $name;
public function __construct(CustomerId $id, FullName $name)
{
$this->id = $id;
@bwaidelich
bwaidelich / SomeIdentifier.php
Last active Apr 7, 2020
Example of a "constant" value object that can be compared
View SomeIdentifier.php
<?php
final class SomeIdentifier
{
/**
* @var string
*/
private $value;
/**
* @var self[]
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Intro to XState</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="box"></div>
@bwaidelich
bwaidelich / ServerSentComponent.php
Created Nov 14, 2019
Example: Flow HTTP Component for Server-Sent Events
View ServerSentComponent.php
<?php
declare(strict_types=1);
namespace Some\Package\Http;
use Neos\Flow\Http\Component\ComponentContext;
use Neos\Flow\Http\Component\ComponentInterface;
use Neos\Flow\Http\Helper\MediaTypeHelper;
final class ServerSentComponent implements ComponentInterface
{
@bwaidelich
bwaidelich / CacheFlusher.php
Last active Sep 2, 2019
Neos CMS: Get (relative) Node Url upon publishing
View CacheFlusher.php
<?php
namespace Some\Package;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Model\Workspace;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\UriBuilder;
@bwaidelich
bwaidelich / JsonCapableExceptionView.php
Created Jun 19, 2019
Render Neos / Flow exceptions as JSON if a corresponding Accept / Content-Type header is set
View JsonCapableExceptionView.php
<?php
declare(strict_types=1);
namespace Some\Package\Error;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Helper\ResponseInformationHelper;
use Neos\Flow\Http\Request;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Utility\MediaTypes;
@bwaidelich
bwaidelich / SiteRequestPattern.php
Last active Jun 6, 2019
Neos Flow Authentication Provider Request Pattern matching Neos Sites by their node name
View SiteRequestPattern.php
<?php
declare(strict_types=1);
namespace Some\Package;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\RequestInterface;
use Neos\Flow\Security\Context;
use Neos\Flow\Security\Exception as SecurityException;
use Neos\Flow\Security\Exception\InvalidRequestPatternException;
View AuthenticationContext.php
<?php
declare(strict_types=1);
namespace Some\Package\Security;
use Neos\Cache\CacheAwareInterface;
use Neos\Flow\Annotations as Flow;
/**
* @Flow\Scope("singleton")
*/
@bwaidelich
bwaidelich / main.go
Last active Jan 31, 2019
Golang Value Object tests
View main.go
package main
import (
"fmt"
"regexp"
)
// EmailAddress Value Object
type EmailAddress string
You can’t perform that action at this time.