Skip to content

Instantly share code, notes, and snippets.

View bwaidelich's full-sized avatar
🏠
Working from home

Bastian Waidelich bwaidelich

🏠
Working from home
View GitHub Profile
@bwaidelich
bwaidelich / ActionIfGrantedViewHelper.php
Created June 15, 2016 10:04
A simple Neos Flow ViewHelper that only renders an action link if the target action is granted by the currently authenticated account. Otherwise it will only render the link text
<?php
namespace Your\Package\ViewHelpers\Link;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Aop\JoinPoint;
use TYPO3\Flow\Mvc\ActionRequest;
use TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilegeInterface;
use TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilegeSubject;
use TYPO3\Flow\Security\Authorization\PrivilegeManagerInterface;
use TYPO3\Fluid\ViewHelpers\Link\ActionViewHelper;
@bwaidelich
bwaidelich / DetectSubdomainComponent.php
Created May 6, 2016 09:50
Tamper Routing MatchResults from a Flow HTTP Component
<?php
namespace Your\Package;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Http\Component\ComponentContext;
use TYPO3\Flow\Http\Component\ComponentInterface;
use TYPO3\Flow\Mvc\Routing\RoutingComponent;
use TYPO3\Flow\Utility\Arrays;
class DetectSubdomainComponent implements ComponentInterface
@bwaidelich
bwaidelich / Index.html
Created April 30, 2016 12:27
Upload multiple resources in Neos Flow
<f:form action="upload" enctype="multipart/form-data">
<f:form.upload name="resources[]" additionalAttributes="{multiple: true}" />
<f:form.submit value="Upload new resources"/>
</f:form>
@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 / Settings.yaml
Created October 30, 2015 09:04
Using HTTP Basic Authentication in TYPO3 Flow
TYPO3:
Flow:
security:
authentication:
providers:
'HttpBasicProvider':
provider: 'PersistedUsernamePasswordProvider'
token: 'TYPO3\Flow\Security\Authentication\Token\UsernamePasswordHttpBasic'
entryPoint: 'HttpBasic'
@bwaidelich
bwaidelich / PurifyViewHelper.php
Created July 20, 2015 14:36
Fluid ViewHelper integrating HTMLPurifier to sanitize/tidy HTML output
<?php
namespace Your\Package\ViewHelpers\Format;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* ViewHelper rendering the given HTML string through HTMLPurifier
*/
class PurifyViewHelper extends AbstractViewHelper {
<?php
namespace TomasNorre\GolfnetInvitational\Domain\Model;
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
/**
* @Flow\Entity
*/
class Player {
@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;