findByFromStartToEnd

public function findByFromStartToEnd() {
	$query = $this->createQuery();
	$constraints = null;
	$constraints[] =  $query->equals('hidden', 0);
	$constraints[] =  $query->equals('deleted', 0);
	$constraints[] =  $query->lessThanOrEqual('start_date', date('Y-m-d'));
	$constraints[] =  $query->greaterThanOrEqual('end_date', date('Y-m-d'));
	return $query->matching(
		$query->logicalAnd( $constraints)
	)->execute();
}

Make Typo3 superfast

GIT: https://github.com/wallpageNET/superfasttypo3

Extbase ist langsam…. Typo3 ist langsam… Typo3-Performance-Tuning kostet zuviel Zeit und Geld…

Warum dann nicht die Ausgabe direkt über Marker modifizieren für dynamische Anwendungen???

Damit Typo3 ein dynamischen schnelles CMS ist und kein statisches CMS…

Vorteile

  • Weniger Energieverbrauch / Weniger Treibhauseffekt
  • Einfacher
  • Billiger
  • Schneller

index.php

if (version_compare(PHP_VERSION, '5.5.0', '<')) { die('TYPO3 CMS requires PHP 5.5 or above'); } ob_start(); // Set up the application for the Frontend call_user_func(function () { $classLoader = require rtrim(realpath(__DIR__ . '/typo3'), '\\/') . '/../vendor/autoload.php'; (new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
});
$output = ob_get_contents();
ob_end_clean();
$output = str_replace("###superfasttypo3.hallowelt###", "<strong>Make Typo3 superfast!</strong>", $output);
echo ($output);

Jetzt nur noch einen Plugin-Loader programmieren und schon kann man eigene Plugins programmieren mit ganz einfachem PHP und man muss keine super teueren OOP-Entwickler mehr bezahlen…

index.php

if (version_compare(PHP_VERSION, '5.5.0', '<')) { die('TYPO3 CMS requires PHP 5.5 or above'); } ob_start(); // Set up the application for the Frontend call_user_func(function () { $classLoader = require rtrim(realpath(__DIR__ . '/typo3'), '\\/') . '/../vendor/autoload.php'; (new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
});
$output = ob_get_contents();
ob_end_clean();
require_once 'superfasttypo3/api.php';
echo (superfasttypo3_api_modify_output($output));

GIT: https://github.com/wallpageNET/superfasttypo3

Extbase FeUser Example Extension

GIT: https://github.com/wallpageNET/infochy_feuserexample
TER: https://typo3.org/extensions/repository/view/infochy_feuserexample

Model

    /**
     * user
     *
     * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
     */
    protected $user;
    
    /**
     * Returns the user
     *
     * @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user
     */
    public function getUser() {
        return $this->user;
    }

    /**
     * Sets the user
     *
     * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user
     * @return void
     */
    public function setUser($user) {
        $this->user = $user;
    }

Controller

    /**
     * action create
     *
     * @param \Infochy\InfochyFeuserexample\Domain\Model\MyData $newMyData
     * @return void
     */
    public function createAction(\Infochy\InfochyFeuserexample\Domain\Model\MyData $newMyData)
    {
        $this->addFlashMessage('createAction ADD FrontendUser', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);       

		
	$newMyData->getUser()->addUsergroup($this->getFrontendUserGroup());          
        $this->myDataRepository->add($newMyData);
        $this->redirect('list');
    }
    
    private function getFrontendUserGroup(){
    	$frontendUserGroups = $this->frontendUserGroupRepository->findByTitle('InfochyFeuserexample');
		$frontendUserGroup = $frontendUserGroups->getFirst();
		if(!is_null($frontendUserGroup)){
			return $frontendUserGroup;
		}else{
			$frontendUserGroup = $this->objectManager->get('TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup');
			$frontendUserGroup->setTitle('InfochyFeuserexample');
			$frontendUserGroup->setDescription('Title display only on Sys-Pages');
			$this->frontendUserGroupRepository->add($frontendUserGroup);
			$persistenceManager =  $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
			$persistenceManager->persistAll();	
	    	$frontendUserGroups = $this->frontendUserGroupRepository->findByTitle('InfochyFeuserexample');
			return $frontendUserGroups->getFirst();					
		}
    }

Controller -> frontendUserGroupRepository

    /**
     * frontendUserGroupRepository
     *
     * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
     * @inject
     */
    protected $frontendUserGroupRepository = NULL;

TCA

		'user' => array(
			'exclude' => 1,
			'label' => 'Fe User',
			'config' => array(
				'type' => 'inline',
				'foreign_table' => 'fe_users',
				'minitems' => 0,
				'maxitems' => 1,
				'appearance' => array(
					'collapseAll' => 0,
					'levelLinksPosition' => 'top',
					'showSynchronizationLink' => 1,
					'showPossibleLocalizationRecords' => 1,
					'showAllLocalizationLink' => 1
				),
			),
		),	

Fluid-HTML

<label for="user.username">
	FeUser->username
</label><br />
	<f:form.textfield property="user.username" /><br />
	
<label for="user.password">
	FeUser->password
</label><br />
	<f:form.textfield property="user.password" /><br />
	
<label for="user.name">
	FeUser->name
</label><br />
	<f:form.textfield property="user.name" /><br />
	
<label for="user.email">
	FeUser->email
</label><br />
	<f:form.textfield property="user.email" /><br />

save FeUser To Model

/**
* action createFrontendUserAction
*
* @param \Vendor\extName\Domain\Model\Example $newExample
*/
public function createFrontendUserAction(\Vendor\extName\Domain\Model\Example $newExample) {
	$feuser = $this->objectManager->create('TYPO3\CMS\Extbase\Domain\Model\FrontendUser');
	$feuser->setName('Name');
	$feuser->setEmail('example@email.de');
	$feuser->setUsername('Username');
	$feuser->setPassword('Password');
	$newExample->setUser($feuser);
	$this->ExampleRepository->add($newExample);
}

FeUserService

class

namespace Infochy\InfochyFeuserexample\Domain\Service;

use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;

class FeUserService implements \TYPO3\CMS\Core\SingletonInterface {

  /**
   * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
   * @inject
   */
  protected $frontendUserRepository;

  /**
   * @return boolean
   */
  public function isUserActive() {
    return $this->getFrontendController()->loginUser;
  }

  /**
   * @return FrontendUser
   */
  public function getFrontendUser() {
    return $this->frontendUserRepository->findByIdentifier($this->getFrontendController()->fe_user->user['uid']);
  }

  /**
   * @param DomainObjectInterface $user
   * @return void
   */
  public function setFeUserActiv(DomainObjectInterface $user) {
    $frontendController = $this->getFrontendController();
    $frontendController->fe_user->createUserSession($user->_getCleanProperties());
    $frontendController->fe_user->loginSessionStarted = TRUE;
    $frontendController->fe_user->user = $frontendController->fe_user->fetchUserSession();
    $frontendController->loginUser = TRUE;
  }

  /**
   * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
   */
  protected function getFrontendController() {
    return $GLOBALS['TSFE'];
  }
}

inject

    /**
     * @var \Infochy\InfochyFeuserexample\Domain\Service\FeUserService
     * @inject
     */
    protected $feUserService;

FluidMail

class

use TYPO3\CMS\Extbase\Object\ObjectManager;

class FluidMail {
    protected $templateFolder = 'Resources/Private/Templates/Email/';

    protected $objectManager;
    protected $extKey;

    protected $recipient = array();
    protected $sender = array();
    protected $subject = '';

    protected $templateName;
    protected $viewArrayMultiple = array();

    public function __construct() {
        $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
    }
    public function setObjectManager($objectManager){
        $this->objectManager = $objectManager;
    }
    public function setExtKey($extKey){
        $this->extKey = $extKey;
    }
    public function setTemplateName($templateName){
        $this->templateName = $templateName;
    }
    public function setArrayToViewObject($viewArrayMultiple){
        $this->viewArrayMultiple = $viewArrayMultiple;
    }
    public function setTemplateFolder($templateFolder){
        $this->templateFolder = $templateFolder;
    }
    public function setMailParams(array $recipient, array $sender, $subject){
        $this->recipient = $recipient;
        $this->sender = $sender;
        $this->subject = $subject;
    }
    public function send(){
        $emailBody = $this->getHtmlTemplate();
        $message = $this->objectManager->get('TYPO3\CMS\Core\Mail\MailMessage');
        $message->setTo($this->recipient)
            ->setFrom($this->sender)
            ->setSubject($this->subject);
        $message->setBody($emailBody, 'text/html');
        $message->send();
        return $message->isSent();
    }
    protected function getHtmlTemplate(){
        $emailView = $this->objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView');
        $emailView->setTemplatePathAndFilename($this->getTemplatePathAndFilename());
        $emailView->assignMultiple($this->viewArrayMultiple);
        return $emailView->render();

    }
    protected function getTemplatePathAndFilename(){
        return \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:'.$this->extKey.'/'.$this->templateFolder ) . $this->templateName . '.html';
    }
}

Use FluidMail

$fluidMail = new \Vendor\extName\Utility\FluidMail();
$fluidMail->setExtKey($this->extKey);
$fluidMail->setTemplateName('templateName');
$fluidMail->setArrayToViewObject(array('key' => 'value'));
$fluidMail->setMailParams(array('mail@to.de' => 'To'),array('mail@from.de' => 'From'),'hallo');
$fluidMail->send();

Simple FeUser Session

$GLOBALS['TSFE']->fe_user->setKey('ses', 'extensionKey', $data);
$GLOBALS['TSFE']->fe_user->storeSessionData();	
$GLOBALS['TSFE']->fe_user->setKey('ses', 'extensionKey', null);
$GLOBALS['TSFE']->fe_user->storeSessionData();

findByUidsString (3,5,7)

public function findByUidsString($uids) {
    $uidArray = explode(",", $uids);
    $query = $this->createQuery();
    $query->getQuerySettings()->setRespectStoragePage(false);
    $query->matching(
        $query->in('uid', $uidArray),
        $query->logicalAnd(
            $query->equals('hidden', 0),
            $query->equals('deleted', 0)
        )
    );
    $query->setOrderings($this->orderByUidsString('uid', $uidArray)); 
    return $query->execute();
}
protected function orderByUidsString($field, $values) {
    $orderArray = array();
    foreach ($values as $value) {
        $orderArray["$field={$value}"] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
    }
    return $orderArray;
}

executeSqlString

$query = $this->createQuery();    
$query->statement($sqlString);
$model = $query->execute();