Skip to content

Instantly share code, notes, and snippets.

Avatar

Torben Hansen derhansen

View GitHub Profile
@derhansen
derhansen / gist:c56ff4df72d6b83121bea99bd83271cd
Created Mar 9, 2019
TYPO3 - Extbase stream file from resourceStorage using streamFile PSR-7 Response
View gist:c56ff4df72d6b83121bea99bd83271cd
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)
@derhansen
derhansen / InlineReadOnly
Last active Jul 24, 2019
TYPO3 InlineReadOnly FormDataProvider
View InlineReadOnly
<?php
namespace Vendor\Extension\Backend\Form\FormDataProvider;
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
/**
* Disables all IRRE Controls and sets fields of IRRE records to readonly
*
* Note: Depending on the TYPO3 backend user permissions, a user may still be able to edit record content
* (e.g. if table is available in record list and user has sufficient rights to edit data). But for inline integration,
@derhansen
derhansen / gist:1eee357e472be595692bf655a28a1557
Created Feb 4, 2018
Extended LocalizationUtility for TYPO3
View gist:1eee357e472be595692bf655a28a1557
<?php
namespace Vendor\Namespace\Utility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility as LocalizationUtilityExtbase;
/**
* Class LocalizationUtility
*/
class LocalizationUtility extends LocalizationUtilityExtbase
{
View gist:735520628bc2a2e103d9d0dfa8ca3723
### Keybase proof
I hereby claim:
* I am derhansen on github.
* I am derhansen (https://keybase.io/derhansen) on keybase.
* I have a public key ASC1s3gh8BEHLu7mPaudKjFkQNCPbDlV4u0ty5tpMyf9lwo
To claim this, I am signing this object:
View rootpage.php
protected function getRootPage($uid)
{
/** @var PageRepository $pageRepository */
$pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(PageRepository::class);
$rootLinePages = $pageRepository->getRootLine($uid);
$rootPage = null;
foreach ($rootLinePages as $page) {
if ($page['is_siteroot'] === '1') {
$rootPage = $page;
break;
View ExtbaseMySQLOrderFunction.php
// 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
*
View setup.txt
plugin.tx_myext_myplugin {
persistence {
storagePid = {$plugin.tx_myext_myplugin.persistence.storagePid}
}
}
View constants.txt
plugin.tx_myext_myplugin {
persistence {
# cat=plugin.tx_myext_myplugin//a; type=string; label=Default storage PID
storagePid =
}
}
@derhansen
derhansen / DateTime.php
Last active Jan 24, 2016
DateTime for the string 1.1.1 using \DateTime::createfromformat('d.m.Y', '1.1.1')
View DateTime.php
class DateTime#1 (3) {
public $date =>
string(26) "0001-01-01 19:12:17.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(13) "Europe/Berlin"
}
@derhansen
derhansen / DateTime.php
Created Jan 24, 2016
DateTime object for the 01.01.16 using \DateTime::createfromformat('d.m.Y', '1.1.16')
View DateTime.php
class DateTime#1 (3) {
public $date =>
string(26) "0016-01-01 18:56:23.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(13) "Europe/Berlin"
}