Skip to content

Instantly share code, notes, and snippets.

@froemken
froemken / BeforeParsingSignalSlot.php
Created September 21, 2020 13:56
Make use of page individual TypoScript configuration for Luxletter NewsletterContainer
<?php
declare(strict_types=1);
namespace JWeiland\LuxletterExtended\SignalSlot;
use In2code\Luxletter\Domain\Model\User;
use JWeiland\LuxletterExtended\Domain\Service\ParseNewsletterUrlService;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\UserAspect;
use TYPO3\CMS\Core\Context\WorkspaceAspect;
# Show possible errors
config.contentObjectExceptionHandler = 0
lib.categories = CONTENT
lib.categories {
table = sys_category
select {
# Adapt to your needs
pidInList = root
# Set a recursive level if needed
@froemken
froemken / BenchIO.php
Created May 5, 2020 09:09
A very simple PHP script to write, read and delete 1000 random files
<?php
$sum = [];
$sum['all'] = microtime(true);
$fileNames = [];
$start = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$fileName = uniqid('FileIO', true);
file_put_contents($fileName, bin2hex(random_bytes(5)));
@froemken
froemken / export_typo3_database.sh
Last active August 23, 2023 06:48
mysqldump command for TYPO3 Databases. It excludes various cache and log tables
#!/bin/bash
PASSWORD=XXXXXX
HOST=XXXXXX
USER=XXXXXX
DATABASE=XXXXXX
DB_FILE=dump.sql
EXCLUDED_TABLES=(
be_sessions
cf_adminpanel_requestcache
cf_adminpanel_requestcache_tags
@froemken
froemken / TemplateControllerTest.php
Created March 3, 2020 09:20
This is an example how to build Functional UnitTests for an Extbase Controller where the Controller is NOT a Mock.
<?php
namespace JWeiland\Drstmplmodule\Tests\Functional\Ajax;
/*
* This file is part of the drstmplmodule project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
@froemken
froemken / ExtendedJsonView.php
Created December 10, 2019 12:22
Extended Extbase Json View with a configuration to call additional Methods of Object
<?php
namespace JWeiland\MyExt\Mvc\View;
/*
* This file is part of the my_ext project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
@froemken
froemken / UpdatePiFlexformInTtContent.sql
Created December 6, 2019 12:21
How to update, change, modify pi_flexform values and fields in tt_content
UPDATE tt_content
SET pi_flexform = REPLACE(
pi_flexform,
CONCAT(
'<field index="settings.classForTable">',
CHAR(10),
' <value index="vDEF">HpTableST1</value>',
CHAR(10),
' </field>'
),
# Delete all duplicate sys_file_records, where one and the same sys_file UID
# is related to the same tt_content record
DELETE t_orig
FROM sys_file_reference t_orig
INNER JOIN sys_file_reference t_copy
WHERE t_orig.tablenames='tt_content'
AND t_orig.fieldname='image'
AND t_orig.deleted=0
AND t_copy.tablenames='tt_content'
AND t_copy.fieldname='image'
@froemken
froemken / PhpUnitPhpStormDDev.txt
Last active February 11, 2021 21:40
Configure PhpStorm for DDev xdebug
Wichtig: Der nfs_mount des ddev-Container darf nicht aktiviert sein. Da gibt's irgendwelche driver-Konflikte.
In PhpStorm -> Settings -> Build, Execution, Deployment -> Docker -> Docker for Mac einrichten.
--> Path /Users -> /Users
In PhpStorm -> Settings -> Languages & Frameworks -> PHP
Language Level auswählen: Beispiel: PHP 7.2
CLI Interpreter konfigurieren -> Button: ...
Neuen CLI Interpreter anlegen: From Docker, Vagrant, Vm, ...
Radio-Select auf "Docker Compose" setzen. Es geht auch "Docker", dann jedoch nur UnitTests. Nicht Functional Tests.
@froemken
froemken / MoveOldFlexFormSettingsHook.php
Created April 1, 2019 13:00
Nice idea to convert old FlexForm settings to another sheet. Problem: Customer has to save all plugin records again. New: Move setting by Updatewizard
<?php
declare(strict_types=1);
namespace JWeiland\Maps2\Hook;
/*
* This file is part of the maps2 project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.