Commit 098a6c70 authored by Dirk Wildt's avatar Dirk Wildt

0.0.8

parent 7a71ecd4
......@@ -78,7 +78,6 @@ class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $title = '';
/**
* type
*
......@@ -86,6 +85,13 @@ class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $type = 'record';
/**
* uid
*
* @var integer
*/
protected $uid = null;
/**
* Returns the description
*
......@@ -275,4 +281,25 @@ class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->type = $type;
}
/**
* Returns the uid
*
* @return string $uid
*/
public function getUid()
{
return $this->uid;
}
/**
* Sets the uid
*
* @param string $uid
* @return void
*/
public function setUid( $uid )
{
$this->uid = $uid;
}
}
\ No newline at end of file
<?php
//declare(strict_types=1);
namespace Netzmacher\Tile\ViewHelpers\Get;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class AbstractBaseViewhelper
*
* @version 0.0.8
* @since 0.0.8
*/
class AbstractBaseViewHelper extends AbstractViewHelper
{
/**
* _getFlexformValue():
*
* @param string method
* @param string line
* @param string flexform
* @param string label of the sheet
* @param string label of the field
* @return mixed value from flexform
* @access protected
* @version 0.0.8
* @since 0.0.8
*/
protected function _getFlexformValue( $method, $line, $xmlFlexform, $sheet, $field )
{
$NSprefix = '';
$reportDocTag = false;
$arrFlexform = GeneralUtility::xml2array( $xmlFlexform, $NSprefix, $reportDocTag );
if( !isset( $arrFlexform[ 'data' ][ $sheet ][ 'lDEF' ][ $field ][ 'vDEF' ] ) )
{
$this->_getFlexformValueDiePrompt( $method, $line, $sheet, $field );
}
return $arrFlexform[ 'data' ][ $sheet ][ 'lDEF' ][ $field ][ 'vDEF' ];
}
/**
* _getFlexformValueDiePrompt():
*
* @param string method
* @param string line
* @param string label of the sheet
* @param string label of the field
* @return mixed value from flexform
* @access protected
* @version 0.0.8
* @since 0.0.8
*/
private function _getFlexformValueDiePrompt( $method, $line, $sheet, $field )
{
$prompt = ''
. '<h1>'
. 'ERROR'
. '</h1>'
. 'Current flexform doesn\'t contain a sheet ' . $sheet . ' with field ' . $field . '<br />'
. 'Maybe the flexform wasn\'t saved once. Please save it and try again.<br />'
. '<br />'
. 'Error occurs @ ' . $method . ' (#' . $line . ')'
;
die( $prompt );
}
}
......@@ -5,14 +5,12 @@
namespace Netzmacher\Tile\ViewHelpers\Get;
use Netzmacher\Tile\Domain\Repository\CategoryRepository;
use Netzmacher\Tile\Domain\Repository\CellRepository;
use Netzmacher\Tile\Domain\Repository\CssRepository;
use Netzmacher\Tile\Domain\Repository\GroupRepository;
use Netzmacher\Tile\Domain\Repository\ContentRepository;
use Netzmacher\Tile\Domain\Repository\TicketRepository;
use Netzmacher\Tile\Utility\Caddy\CaddySessionUtility;
use Netzmacher\Tile\Utility\ObjectUtility;
use Netzmacher\Tile\Utility\SessionUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class CellClassViewHelper
......@@ -21,9 +19,16 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
* @since 0.0.8
* @internal #t3816
*/
class CellClassViewHelper extends AbstractViewHelper
class CellClassViewHelper extends AbstractBaseViewHelper
{
/**
* Data of the current content object
*
* @var array
*/
private $_cData = null;
/**
* Current cell
*
......@@ -43,7 +48,7 @@ class CellClassViewHelper extends AbstractViewHelper
*
* @var boolean
*/
private $_promptStatic = true;
private $_promptStatic = false;
/**
* Session class
......@@ -218,17 +223,18 @@ class CellClassViewHelper extends AbstractViewHelper
return $class;
}
$uidTicket = $ticket->getUid();
$uidProductsInTheCaddy = $this->_getUidsFromCaddy();
$uidProduct = $this->_cell->getTxTileProduct()->getUid();
switch( true )
{
case('caddy'):
case(in_array( $uidProduct, $uidProductsInTheCaddy )):
$status = 'caddy';
break;
case($this->_cell->txTileProduct->stockquantity() >= 1):
case($this->_cell->getTxTileProduct()->getStockquantity() >= 1):
$status = 'default';
break;
case($this->_cell->txTileProduct):
case($this->_cell->getTxTileProduct()):
$status = 'selled';
break;
default:
......@@ -236,9 +242,11 @@ class CellClassViewHelper extends AbstractViewHelper
die( $prompt );
}
if( isset( $classTickets[ $uidTicket ][ $status ] ) )
//var_dump(__METHOD__, __LINE__, $this->_cell->getTxTileProduct()->getUid());
if( isset( $classTickets[ $uidProduct ][ $status ] ) )
{
return $classTickets[ $uidTicket ][ $status ];
$additionalClass = $classTickets[ $uidProduct ][ $status ];
return $this->_classConcatenator( $class, $additionalClass );
}
switch( $status )
......@@ -262,11 +270,12 @@ class CellClassViewHelper extends AbstractViewHelper
$this->_getClassTicketsPromptDie( __METHOD__, __LINE__, $ticket );
}
$prompt = '[#' . $uidTicket . '][' . $status . '] This prompt should display once only! Check of static variables:';
$this->_promptStatic( __METHOD__, __LINE__, $prompt );
$prompt = '[#' . $uidProduct . '][' . $status . '] This prompt should display once only! Check of static variables:';
//var_dump( __METHOD__, __LINE__, $this->_cell->getTxTileGroup()->getUid(), $uidProduct, $prompt );
$this->_promptStatic( __METHOD__, __LINE__, $prompt, false );
$classTickets[ $uidTicket ][ $status ] = $css->getClass();
$additionalClass = $this->_getClassCategoryOfCurrentCell();
$classTickets[ $uidProduct ][ $status ] = $css->getClass();
$additionalClass = $classTickets[ $uidProduct ][ $status ];
return $this->_classConcatenator( $class, $additionalClass );
}
......@@ -309,6 +318,48 @@ class CellClassViewHelper extends AbstractViewHelper
return $classes[ $uidCategory ];
}
/**
* @return array
*/
private function _getUidsFromCaddy()
{
static $uids = null;
if( !empty( $uids ) )
{
return $uids;
}
$xmlFlexform = $this->_cData[ 'pi_flexform' ];
$sheet = 'caddy';
$field = 'settings.flexform.pi1.caddy.uid';
$caddyUid = $this->_getFlexformValue( __METHOD__, __LINE__, $xmlFlexform, $sheet, $field );
if( empty( $caddyUid ) )
{
$this->addFlashMessage( 'Die Anwendung ist mit keinem Warenkorb verbunden.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR );
$this->addFlashMessage( 'Aktualisiere bitte das Plugin.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO );
return false;
}
$contentRepository = ObjectUtility::getObjectManager()->get( ContentRepository::class );
$content = $contentRepository->findByUid( $caddyUid );
$caddyPid = $content->getPid();
$CaddySessionUtility = GeneralUtility::makeInstance( CaddySessionUtility::class, $caddyPid );
$sessionData = $CaddySessionUtility->GetSessionData();
// var_dump( __METHOD__, __LINE__,$sessionData[ 'items' ] );
foreach( ( array ) $sessionData[ 'items' ] as $item )
{
$uids[] = $item[ 'uid' ];
}
$this->_promptStatic( __METHOD__, __LINE__ );
return $uids;
}
/**
* Init the Category Repository once
*
......@@ -354,24 +405,22 @@ class CellClassViewHelper extends AbstractViewHelper
/**
* Init the session class once
*
* @param array $cData content data of current object
*
* @return void
*/
private function _initSessionObject( $cData )
private function _initSessionObject()
{
static $sessionUtility = null;
if( $sessionUtility !== null )
{
$this->_sessionUtility = $sessionUtility;
$this->_sessionUtility->setCData( $cData );
$this->_sessionUtility->setCData( $this->_cData );
return;
}
$sessionUtility = GeneralUtility::makeInstance( SessionUtility::class );
$this->_sessionUtility = $sessionUtility;
$this->_sessionUtility->setCData( $cData );
$this->_sessionUtility->setCData( $this->_cData );
$this->_promptStatic( __METHOD__, __LINE__ );
}
......@@ -381,14 +430,19 @@ class CellClassViewHelper extends AbstractViewHelper
* @param string $method
* @param string $line
* @param string $prompt
* @param boolean $display
*
* @return void
*/
private function _promptStatic( $method, $line, $prompt = 'This prompt should display once only! Check of static variables:' )
private function _promptStatic( $method, $line, $prompt = 'This prompt should display once only! Check of static variables:', $display = false )
{
if( !$this->_promptStatic )
switch( true )
{
return;
case($display):
//follow the workflow
break;
case(!$this->_promptStatic ):
return;
}
echo '[#' . $line . '] ' . $prompt . ' @ ' . $method . ' (#' . $line . ')<br />' . PHP_EOL;
}
......@@ -410,7 +464,7 @@ class CellClassViewHelper extends AbstractViewHelper
{
$class = null;
$cell = $this->arguments[ 'cell' ];
$cData = $this->arguments[ 'cData' ];
$this->_cData = $this->arguments[ 'cData' ];
if( empty( $cell ) )
{
......@@ -418,7 +472,7 @@ class CellClassViewHelper extends AbstractViewHelper
}
$this->_cell = $cell;
$this->_initSessionObject( $cData );
$this->_initSessionObject();
$class = $this->_getClassCategory( $class );
$class = $this->_getClassCategoryUndefined( $class );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment