Skip to content

Instantly share code, notes, and snippets.

View albe's full-sized avatar
:octocat:

Alexander Berl albe

:octocat:
View GitHub Profile
@bwaidelich
bwaidelich / ExampleEvent.php
Created June 1, 2017 11:22
Flow EventSourcing: Use Value Objects as Event Payload / ReadModel primary keys
<?php
namespace Some\Package
use Neos\EventSourcing\Event\EventInterface;
final class ExampleEvent implements EventInterface
{
/**
* @var UserId
*/
@bwaidelich
bwaidelich / Jwt.php
Last active May 13, 2020 11:54
External authentication with Neos Flow and local JWT (http://jwt.io/) as cache
<?php
declare(strict_types=1);
namespace Your\Package\Security\Authentication;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Security\Authentication\Token\AbstractToken;
use Neos\Flow\Security\Authentication\Token\SessionlessTokenInterface;
/**
@bwaidelich
bwaidelich / Routes.CRUD.yaml
Created January 26, 2016 17:23
Example for reusable REST/CRUD sub routes (For the Flow application framework)
-
name: 'NewAction'
uriPattern: 'new'
defaults:
'@action': 'new'
httpMethods: [GET]
-
name: 'CreateAction'
uriPattern: 'create'
@bwaidelich
bwaidelich / Menu.html
Last active April 13, 2017 12:28
A DTO that can be used to create simple menus in a TYPO3 Flow application
<ul class="nav">
<f:for each="{menu.menuItems}" as="menuItem">
<f:render section="menuItem" arguments="{menuItem: menuItem}" />
</f:for>
</ul>
<f:section name="menuItem">
<f:if condition="{menuItem.header}">
<f:then>
<li class="nav-header">{menuItem.label}</li>
@bwaidelich
bwaidelich / DetectLanguageComponent.php
Last active August 31, 2018 13:04
A TYPO3 Flow HTTP component that detects the user agent language and redirects to the corresponding URL if no language has been requested explicitly.
<?php
namespace Wwwision\Test\Http;
/* *
* This script belongs to the TYPO3 Flow package "Wwwision.Test". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Http\Component\ComponentChain;

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A
@bwaidelich
bwaidelich / Jwt.php
Last active February 2, 2017 13:36
Simple JWT based authentication for TYPO3 Flow (see http://jwt.io/).
<?php
namespace Wwwision\Jwt\Security\Authentication\Token;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Mvc\ActionRequest;
use TYPO3\Flow\Security\Authentication\Token\AbstractToken;
use TYPO3\Flow\Security\Authentication\Token\SessionlessTokenInterface;
/**
* An authentication token used for simple username and password authentication.
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active September 24, 2024 14:47
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}