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
<?php
namespace FluidTYPO3\Vhs\ViewHelpers\Media;
/*
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
@smichaelsen
smichaelsen / gist:47e066ba84e268bd1fe1
Created June 19, 2015 21:11
FluidTYPO3 data access

What is FluidTYPO3 general approach towards database access?

We really like to create content elements with fluidcontent, but sometimes we lack the option to prepare some variables for the template. In our current project we use Viewhelper to get records from the database, but of course that's far from best practice (though it works nicely).

I thought it would be nice I was able to create Controller classes based on naming conventions, e.g. I have a Downloads.html fluidcontent template and create a controller in Classes/Controller/Content/DownloadsController which extends fluidcontent's ContentController and gives me the ability to prepare template variables.

What do you think? What's your approach towards this?

<?php
namespace Smichaelsen\MyExtension\ViewHelpers\Format;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Usage example
*
@smichaelsen
smichaelsen / .bashrc
Last active March 9, 2016 13:29
TYPO3 Deployment File (jweiland.net specific)
# Add Home directory to path so that you can have executables there.
export PATH=~:$PATH
# Fine, now do the following:
# Put a PHP shortcut into your home directory: ln -s /usr/local/bin/php5.6.2-cli php
# Download composer and rename the composer.phar to composer in your home directory
@smichaelsen
smichaelsen / gist:cc53bf4e4a07919101cb
Created December 11, 2014 14:04
git branch slashes
✗ git checkout -b feature/admin-interface/materialize feature/admin-interface
error: unable to resolve reference refs/heads/feature/admin-interface/materialize: Not a directory
fatal: Failed to lock ref for update: Not a directory
@smichaelsen
smichaelsen / typo3_unit.md
Created November 26, 2014 11:24
Run TYPO3 Core Unit tests
  1. Run the tests from within the VM (if you have one).
  2. cd to the web root
  3. composer install
  4. ./vendor/phpunit/phpunit/phpunit -c typo3/sysext/core/Build/UnitTests.xml
@smichaelsen
smichaelsen / fluid_inline_viewhelper.md
Created November 13, 2014 09:54
TYPO3 Fluid inline viewhelper in array

I regularly fail to remember the correct syntax to do this. So here it is:

<f:form.select
 property="gender"
 id="user_gender"
 options="{1: '{f:translate(key: \'orderform.customer_data.gender.w\')}', 2: '{f:translate(key: \'orderform.customer_data.gender.m\')}'}

"/>

@smichaelsen
smichaelsen / check_regex.php
Last active January 25, 2025 05:35
PHP: Check if string is valid regular expression
<?php
function isRegularExpression($string) {
set_error_handler(function() {}, E_WARNING);
$isRegularExpression = preg_match($string, "") !== FALSE;
restore_error_handler();
return isRegularExpression;
}
@smichaelsen
smichaelsen / pdo_test.php
Created November 6, 2014 07:48
PDO: prepared statement problem
<?php
$dbhost = '127.0.0.1';
$dbname = 'dname';
$dbuser = 'dbuser';
$dbpass = '123';
$dsn = sprintf('mysql:host=%s;dbname=%s', $dbhost, $dbname);
$connection = new \PDO($dsn, $dbuser, $dbpass);
@smichaelsen
smichaelsen / extbase_properties.md
Last active August 29, 2015 14:08
Extbase: Modifying properties via request

Extbase: Modifying properties via request

An extbase problem and my solution

Problem

A client contacted me and told me that his extbase extension ceases to work when upgrading from TYPO3 4.5 to 6.2. AJAX requests that aimed to modify a certain model ended in exceptions.

The request looked similar to this: