[TYPO3-german] Extension: Eine der properties soll eine ipv4 sein... Andere Eingaben müssen abgefangen werden

Birgit lists at berlin-typo3.de
Tue Nov 28 16:47:41 CET 2017


Müsste ungefähr so gehen wie hier:


<?php
namespace TYPO3\CMS\Core\DataHandling;

use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

...
class DataHandler
{

/**
 * If $value is not a valid e-mail address,
 * $set will be set to false and a flash error
 * message will be added
 *
 * @param string $value Value to evaluate
 * @param bool $set TRUE if an update should be done
 * @throws \InvalidArgumentException
 * @throws \TYPO3\CMS\Core\Exception
 * @return void
 */
protected function checkValue_input_ValidateEmail($value, &$set)
{
    if (GeneralUtility::validEmail($value)) {
        return;
    }

    $set = false;
    /** @var FlashMessage $message */
    $message = GeneralUtility::makeInstance(FlashMessage::class,
        sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:error.invalidEmail'), $value),
        '', // header is optional
        FlashMessage::ERROR,
        true // whether message should be stored in session
    );
    /** @var $flashMessageService FlashMessageService */
    $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
    $flashMessageService->getMessageQueueByIdentifier()->enqueue($message);
}

}

viele Grüße
Birgit


> Am 28.11.2017 um 14:48 schrieb christian ewigfrost <christian-kulozik at gmx.net>:
> 
> OK, jetzt stehe ich vor weiteren Fragezeichen: wo füge ich den folgenden code überhaupt ein?
> 
> $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class,
>  'My message text',
>  'Message Header', // [optional] the header
>  \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, // [optional] the severity defaults to \TYPO3\CMS\Core\Messaging\FlashMessage::OK
>  true // [optional] whether the message should be stored in the session or only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is false)
> );
> 
> Ich verstehe den code, keine Frage, aber ich weiß nicht wie ich das jetzt mit meiner 'eval' Klasse in der der code steht überhaupt zusammenbringe. 
> class IPv4Evaluation
> {
> 
>   /**
>    * Server-side validation/evaluation on saving the record
>    *
>    * @param string $value The field value to be evaluated
>    * @param string $is_in The "is_in" value of the field configuration from TCA
>    * @param bool $set Boolean defining if the value is written to the database or not.
>    * @return string Evaluated field value
>    */
>   public function evaluateFieldValue($value, $is_in, &$set)
>   {
> 		if (!filter_var($value, FILTER_VALIDATE_IP)){
> 			$value = 'Fehlerhafte Eingabe (IPv4): .conf wird nicht angelegt';
> 		}
> 		
> 		
>       return $value;
>   }
> }
> 
> Hier hab ich massive Verständnissprobleme und die Doku sagt gar nichts dazu wo der code überhaupt hingehört.
> _______________________________________________
> TYPO3-german mailing list
> TYPO3-german at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german



More information about the TYPO3-german mailing list