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 / 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
{
/**
@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 / 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 / .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 / 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 / Carousel.html
Last active October 20, 2015 07:41
Fatal cached fluid template
@smichaelsen
smichaelsen / kata1.md
Created October 1, 2015 12:47
MySQL Kata #1
+------+-------+
| type | value |
+------+-------+
| a    | 2     |
+------+-------+
| a    | 5     |
+------+-------+
| c    | 1     |
+------+-------+

| b | 8 |

<?php
namespace Smichaelsen\MyExt\Backend\View;
use FluidTYPO3\Flux\Service\ContentService;
class BackendLayoutView extends \TYPO3\CMS\Backend\View\BackendLayoutView {
/**
* Flux doesn't work well with TYPO3 backend layouts. The colPos item that is added in ext_tables.php is discarded by TYPO3's
* BackendLayoutView. That's why we re-add it here.
@smichaelsen
smichaelsen / ExtbaseViewHelper.php
Created September 16, 2015 13:36
ExtbaseViewHelper
<?php
namespace AppZap\Tripshop\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Core\Bootstrap;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Renders an extbase action into your template
*
@smichaelsen
smichaelsen / Favicons.html
Last active October 12, 2023 17:52
Multiple Favicons in TypoScript
<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers">
<link rel="apple-touch-icon" sizes="57x57" href="{f:uri.resource(path:'Favicons/apple-touch-icon-57x57.png')}">
<link rel="apple-touch-icon" sizes="60x60" href="{f:uri.resource(path:'Favicons/apple-touch-icon-60x60.png')}">
<link rel="apple-touch-icon" sizes="72x72" href="{f:uri.resource(path:'Favicons/apple-touch-icon-72x72.png')}">
<link rel="apple-touch-icon" sizes="76x76" href="{f:uri.resource(path:'Favicons/apple-touch-icon-76x76.png')}">
<link rel="apple-touch-icon" sizes="114x114" href="{f:uri.resource(path:'Favicons/apple-touch-icon-114x114.png')}">
<link rel="apple-touch-icon" sizes="120x120" href="{f:uri.resource(path:'Favicons/apple-touch-icon-120x120.png')}">
<link rel="apple-touch-icon" sizes="144x144" href="{f:uri.resource(path:'Favicons/apple-touch-icon-144x144.png')}">
<link rel="apple-touch-icon" sizes="152x152" href="{f:uri.resource(path:'Favicons/apple-touch-icon-152x152.png')}">