Skip to content

Instantly share code, notes, and snippets.

View smichaelsen's full-sized avatar
🥋
Changing the world in code

Sebastian Michaelsen smichaelsen

🥋
Changing the world in code
View GitHub Profile
@smichaelsen
smichaelsen / Carousel.html
Last active October 20, 2015 07:41
Fatal cached fluid template
@smichaelsen
smichaelsen / QueryResult.php
Created November 12, 2015 08:19
Extend extbase QueryResult to fix count() of queries with a custom $statement
<?php
namespace AppZap\Tripshop\Persistence;
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement;
class QueryResult extends \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult
{
/**
* Overwrites the original implementation of Extbase
*
@smichaelsen
smichaelsen / .htaccess
Created November 18, 2015 10:58
TYPO3 .htaccess: Prevent HTTP download of sensible files
<FilesMatch ".(bak|config|sql|fla|psd|ini|log|sh|inc|~|swp|gitignore)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
<FilesMatch "(^ChangeLog|INSTALL\.md|LICENSE\.txt|NEWS.md|README.md|_\.htaccess)$">
Order deny,allow
Deny from all
Satisfy All
</FilesMatch>
@smichaelsen
smichaelsen / DateInterval.php
Last active November 26, 2015 09:19
Example how to use the TypeInterface to let extbase initialize objects from your database records
<?php
namespace AppZap\MyExt\Type;
use TYPO3\CMS\Core\Type\TypeInterface;
/**
* In our application we have fields that store time intervals as minutes in the database.
* In our code we want proper DateInterval objects, so we use a TypeInterface to let extbase take care of the conversion.
*
* Usage example on a model property:
@smichaelsen
smichaelsen / ValidationService.php
Created December 8, 2015 08:07
ValidationService for Extbase
<?php
namespace Smichaelsen\Gist\Service;
use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
use TYPO3\CMS\Extbase\Error\Result;
use TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator;
use TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface;
/**
* Provides stand alone validation for domain objects.
@smichaelsen
smichaelsen / ObjectStorageService.php
Created December 10, 2015 15:16
ObjectStorageService that groups your objects by property (PHP 5.5 required)
<?php
namespace Smichaelsen\Gist\Service;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
class ObjectStorageService
{
/**
vagrantfile:
target: local
vm:
box: puphpet/debian75-x64
box_url: puphpet/debian75-x64
hostname: ''
memory: '512'
cpus: '1'
chosen_provider: parallels
box_version: ''
@smichaelsen
smichaelsen / n26.js
Created February 3, 2016 22:48
Number26 running balance
// this script displays the running balance for each day in the transaction list of your number26 bank account
// attention: you should not execute any random code you found in the internet on your online banking!
var getBalance = function(string) {
var amountParts = string.split(',');
return parseInt(amountParts[0]) + parseInt(amountParts[1]) / 100;
};
var getDayOverviewNodes = function() {
return $('.activities').find('.node.delim');
@smichaelsen
smichaelsen / A.php
Last active March 11, 2016 16:17
Idea: Injection Traits #typo3 #extbase
<?php
class A
{
/**
* In TYPO3 (Extbase) you can use a simple @inject annotation to get an instance of the class specified with
* the @var annotation ready-to-use when your class is instanciated.
* However you're discouraged to use that variant for performance reasons.
*
@smichaelsen
smichaelsen / RelationHandler.php
Last active April 3, 2023 03:14
TCA bidirectional mm relation to same field
<?php
namespace Smichaelsen\Gist\Database;
/**
* @see https://gist.github.com/smichaelsen/4e99a0d19d81a42caeac
* As of TYPO3 7 it's not possible in TCA to define bidirectional MM relations with each side of
* the relation being the same field. (e.g. "related news").
*
* As a fix this extension of the relation handler just stores the relation in both ways into the
* MM table when it detects a MM relation with both sides being the same field.