Skip to content

Instantly share code, notes, and snippets.

View derhansen's full-sized avatar

Torben Hansen derhansen

View GitHub Profile
@derhansen
derhansen / AdditionalRegistrationsViewHelper.php
Created March 26, 2024 18:16
sf_event_mgt_multireg - AdditionalRegistrationsViewHelper
<?php
namespace Derhansen\SfEventMgtMultireg\ViewHelpers\Registration;
use DERHANSEN\SfEventMgt\Domain\Model\Registration;
use DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
@derhansen
derhansen / SwitchableControllerActionsPluginUpdater.php
Created March 20, 2021 11:23
SwitchableControllerActionsPluginUpdater for TYPO3 extension "Plain FAQ"
<?php
declare(strict_types=1);
/*
* This file is part of the Extension "plain_faq" for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
@derhansen
derhansen / gist:e0751d896ba0d48917dccd44bd4e4d1e
Created January 20, 2024 13:59
TYPO3 GeneralUtility::intExplode() performance test
<?php
// Current intExplode function in v13
function intExplodeOld($delimiter, $string, $removeEmptyValues = false)
{
$result = explode($delimiter, $string);
foreach ($result as $key => &$value) {
if ($removeEmptyValues && trim($value) === '') {
unset($result[$key]);
} else {
@derhansen
derhansen / CropVariantUtility.php
Created December 24, 2021 12:10
TYPO3 CMS CropVariantUtility to manually calculate the default crop variant string for a given image
<?php
declare(strict_types=1);
namespace Derhansen\Typo3Dev\Utility;
use TYPO3\CMS\Core\Imaging\ImageManipulation\Area;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Imaging\ImageManipulation\InvalidConfigurationException;
use TYPO3\CMS\Core\Resource\File;
@derhansen
derhansen / removeJobsRedisDriver.php
Last active November 10, 2022 17:17
Laravel 5 - remove all jobs from a queue (redis driver)
Redis::connection()->del('queues:myqueue');
// The use statements for the fileheader
use MyVendor\MyExtension\Domain\Model\Mymodel;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
/**
* Returns all matching records for the given list of uids and applies the uidList sorting for the result
*
@derhansen
derhansen / numJobsDatabaseDriver.php
Last active July 15, 2021 17:16
Laravel 5 - get amount of jobs in a queue (database driver)
$numJobs = DB::table('jobs')->where('queue', 'myqueue')->count();
<?php
phpinfo();
@derhansen
derhansen / numJobsRedisDriver.php
Last active April 8, 2020 09:48
Laravel 5 - get amount of jobs in a queue (redis driver)
$numJobs = Redis::connection()->llen('queues:myqueue');
@derhansen
derhansen / gist:c56ff4df72d6b83121bea99bd83271cd
Created March 9, 2019 06:39
TYPO3 - Extbase stream file from resourceStorage using streamFile PSR-7 Response
public function downloadAction()
{
$storage = $this->resourceFactory->getDefaultStorage();
$file = $storage->getFile('test.jpg');
$response = $storage->streamFile($file, true, 'test-filename.jpg');
$this->sendResponse($response);
exit();
}
protected function sendResponse($response)