Skip to content

Instantly share code, notes, and snippets.

@Digi92
Digi92 / BaseEntity.php
Created April 15, 2017 20:57
Doctrine Beispiel zum Erstellen einer Base Entity Klasse so das alle anderen Klassen die diese Extenden die Felder auch in der Datenbank bekommen. Die Base Entity Klasse benötigt nur "@Orm\MappedSuperclass" als Annotation.
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class BaseEntity
* @package AppBundle\Entity
* @ORM\MappedSuperclass
@Digi92
Digi92 / doctrine_example_id_field.php
Last active April 15, 2017 21:00
Doctrine Example ID Field Annotation Configuration
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Example
* @package AppBundle\Entity
* @ORM\Entity
OLD: export PHP_IDE_CONFIG="serverName=example.dev"; /Applications/MAMP/bin/php/php7.0.12/bin/php -dxdebug.remote_autostart=1 -dxdebug.remote_host=127.0.0.1 /Volumes/Daten/Work/Example/htdocs/typo3/cli_dispatch.phpsh extbase example:cache:cleare exampleenviorment exampleenviorment
NEW: export PHP_IDE_CONFIG="serverName=example.dev"; /Applications/MAMP/bin/php/php7.0.12/bin/php -dxdebug.remote_autostart=1 -dxdebug.remote_host=127.0.0.1 /Volumes/Daten/Work/Example/htdocs/typo3/cli_dispatch.phpsh extbase exampleenviorment example:cache:cleare
@Digi92
Digi92 / If with "AND"
Created November 2, 2017 08:54
Example for an "AND"-If in TypoScript
// Add language parameter on shortcuts when the field tx_shortcut_language is not null
3.IFSUB.additionalParams = &L={field:tx_shortcut_language}
3.IFSUB.additionalParams.insertData = 1
3.IFSUB.additionalParams.if {
value = 4
equals.field = doktype
}
3.IFSUB.additionalParams.if.isTrue = 1
3.IFSUB.additionalParams.if.isTrue.if {
value = -1
@Digi92
Digi92 / getNameFromNumber
Last active May 13, 2021 07:51
This function will convert a number to an excel-like column name. For example: 1 => A 2 => B 27 => AA 28 => AB 14558 => UMX URL: https://stackoverflow.com/questions/3302857/algorithm-to-get-the-excel-like-column-name-of-a-number#answer-3302991
<?php
function getNameFromNumber($num) {
$numeric = $num % 26;
$letter = chr(65 + $numeric);
$num2 = intval($num / 26);
if ($num2 > 0) {
return $this->getNameFromNumber($num2 - 1) . $letter;
} else {
return $letter;
@Digi92
Digi92 / Steps
Created July 31, 2018 12:19
Das Entfernen umfasst sowohl das Löschen der VirtualBox-VM als auch der Vagrant-Boxen. Alle Befehle funktionieren nur, wenn man im Arbeitsverzeichnis des Projektes ist.
1. Feststellen des korrekten Namens der Box: vagrant status
2. Entfernen der VirtualBox-VM: vagrant destroy
3. Entfernen der Vagrant-Box: vagrant box remove <Box-Name aus Schritt 1>
@Digi92
Digi92 / Remove segmentation information from translation
Last active January 18, 2019 10:02
TYPO3 won't use translation files with segmentation informations and they look like: <trans-unit id="example"> <source>Beispiel</source> <seg-source> <mrk mtype="seg" mid="108">Beispiel</mrk> </seg-source>
TYPO3 won't use translation files they look like:
<trans-unit id="example">
<source>Beispiel</source>
<seg-source>
<mrk mtype="seg" mid="108">Beispiel</mrk>
</seg-source>
<target state="final">
<mrk mtype="seg" mid="108">Example</mrk>
</target>
</trans-unit>
<?php
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;
/**
* The repository for ExampleRepository
*/
@Digi92
Digi92 / FilterUrl
Created April 15, 2019 08:58
This function will remove all suspicious characters from a $_GET parameter. This has only a security reason. Source: https://stackoverflow.com/a/1886296
/**
* This function will remove all suspicious characters from a $_GET parameter
*
* @param $url
* @return array|string|string[]|null
*/
protected function filterUrl($url)
{
if (is_array($url))
{
@Digi92
Digi92 / AdditionalConfiguration.php
Created July 29, 2019 09:07
Functionality to shorten beautiful URLs, like the RealUrl functions "user_encodeSpURL_postProc" and "user_decodeSpURL_preProc" This is a copy of https://gist.github.com/Nimmermaer/2feab3af3cc0fa8f5f79be64ebd00d20
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['extensionkey']['UrlReplacements'] = [
'newsroom/presse/details/tx_news/' => 'newsroom/presse/',
'newsroom/aktuelles/details/tx_news/' => 'newsroom/aktuelles/',
'newsroom/veranstaltungskalender/details/tx_news/' => 'newsroom/veranstaltungskalender/'
];