for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* 2016 Romain CANON <[email protected]>
*
* This file is part of the TYPO3 Formz project.
* It is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, either
* version 3 of the License, or any later version.
* For the full copyright and license information, see:
* http://www.gnu.org/licenses/gpl-3.0.html
*/
namespace Romm\Formz\Condition\Parser;
use Romm\Formz\Configuration\Form\Condition\Activation\ActivationInterface;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* @todo
class ConditionParserFactory implements SingletonInterface
{
* @var ConditionParserFactory
private static $instance;
* @var ConditionTree[]
private $trees = [];
* @return ConditionParserFactory
public static function get()
if (null === self::$instance) {
self::$instance = GeneralUtility::makeInstance(self::class);
}
return self::$instance;
* @param ActivationInterface $condition The condition instance.
* @return ConditionTree
public function parse(ActivationInterface $condition)
$hash = sha1(serialize([
$condition->getCondition(),
$condition->getItems()
]));
if (false === array_key_exists($hash, $this->trees)) {
$this->trees[$hash] = ConditionParser::get()->parse($condition);
return $this->trees[$hash];