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 / Settings.yaml
Last active December 28, 2015 16:29
Example usage for the ``TYPO3.JobQueue.Common`` TYPO3 Flow package (Annotation)
TYPO3:
Jobqueue:
Common:
queues:
'test':
className: 'TYPO3\Jobqueue\Beanstalkd\Queue\BeanstalkdQueue' # or TYPO3\Jobqueue\Redis\Queue\RedisQueue, ...
@bwaidelich
bwaidelich / CacheViewHelper.php
Created November 13, 2013 11:43
A simple TYPO3 Fluid ViewHelper that caches its content based on some variables
<?php
namespace Your\Package\ViewHelpers;
/* *
* This script belongs to the TYPO3 Flow package "Your.Package". *
* */
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Cache\Frontend\StringFrontend;
use TYPO3\Flow\Persistence\PersistenceManagerInterface;
@bwaidelich
bwaidelich / magicMethodBenchmark.php
Created November 6, 2013 11:34
A simple script to compare performance of magic __call methods to real implementations
<?php
class MagicMethodFixture {
/**
* @var array
*/
protected $configurations;
public function __construct() {
$this->configurations = array(
@bwaidelich
bwaidelich / Repository.php
Last active December 27, 2015 11:18
Suggestion for how to get rid of magic __call functions in TYPO3 Flow repository classes
<?php
class Repository {
public function __call($method, $arguments) {
$query = $this->createQuery();
$caseSensitive = isset($arguments[1]) ? (boolean)$arguments[1] : TRUE;
if (substr($method, 0, 6) === 'findBy' && strlen($method) > 7) {
$propertyName = lcfirst(substr($method, 6));
return $query->matching($query->equals($propertyName, $arguments[0], $caseSensitive))->execute();
} elseif (substr($method, 0, 7) === 'countBy' && strlen($method) > 8) {
@bwaidelich
bwaidelich / User.php
Created August 21, 2013 09:20
Simple example for a custom User domain object with some convenience methods in TYPO3 Flow
<?php
namespace Some\Package\Domain\Model;
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
use TYPO3\Flow\Security\Policy\Role;
use TYPO3\Party\Domain\Model\AbstractParty;
/**
* A User
@bwaidelich
bwaidelich / EmailService.php
Last active May 23, 2016 13:35
Simple Email Service for TYPO3 Flow
<?php
namespace My\Package\Service;
use TYPO3\Flow\Annotations as Flow;
/**
* @Flow\Scope("singleton")
*/
class EmailService {
<?php
namespace TYPO3\Fluid\ViewHelpers\Format;
/* *
* This script belongs to the TYPO3 Flow package "Fluid". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License, either version 3 *
* of the License, or (at your option) any later version. *
* *
@bwaidelich
bwaidelich / FileSizeViewHelper.php
Created June 14, 2013 11:21
FileSizeViewHelper
<?php
namespace Your\Package\ViewHelpers\Format;
/* *
* This script belongs to the TYPO3 Flow package "Your.Package. *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
@bwaidelich
bwaidelich / ProductRepository.php
Last active December 16, 2015 12:19
This snippet shows you how you can use Fluid widgets with DQL queries in TYPO3.Flow today with a little hack
<?php
namespace Your\Package\Domain\Repository;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Persistence\Doctrine\Repository;
use TYPO3\Flow\Reflection\ObjectAccess;
/**
* @Flow\Scope("singleton")
*/
@bwaidelich
bwaidelich / FceRenderer.php
Created March 19, 2013 10:01
Custom "Flexible Content Element" renderer based on Fluid, supporting Flexforms etc.
<?php
/**
* Renders a Fluidtemplate similar to the FLUIDTEMPLATE content object but with some additional features:
* * $this->cObj->data variables will be available directly in the template (no need to prefix with "data."
* * Flexform fields are parsed and all Flexform variables will be directly available in the template
*
* Usage:
*
* lib.someObject = USER