Skip to content

Commit

Permalink
Merge pull request #14 from mia3/dimension-handling
Browse files Browse the repository at this point in the history
DimensionMapping
  • Loading branch information
Marc Neuhaus authored Feb 2, 2018
2 parents ff3aee5 + 15ab8bf commit 46d8851
Show file tree
Hide file tree
Showing 12 changed files with 553 additions and 33 deletions.
1 change: 1 addition & 0 deletions Classes/Command/FourallportalCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ public function processEvent($event, $updateEventId = true)
} catch(\Exception $exception) {
$event->setStatus('failed');
$event->setMessage($exception->getMessage() . ' (code: ' . $exception->getCode() . ')' . $exception->getFile() . ':' . $exception->getLine());
$this->response->appendContent($exception->getMessage() . ' (code: ' . $exception->getCode() . ')' . $exception->getFile() . ':' . $exception->getLine() . PHP_EOL);
if ($updateEventId) {
$event->getModule()->setLastEventId(max($event->getEventId(), $event->getModule()->getLastEventId()));
}
Expand Down
88 changes: 88 additions & 0 deletions Classes/Domain/Model/Dimension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
namespace Crossmedia\Fourallportal\Domain\Model;

/***
*
* This file is part of the "4AllPortal Connector" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2017 Marc Neuhaus <[email protected]>, MIA3 GmbH & Co. KG
*
***/
use Crossmedia\Fourallportal\Domain\Repository\ModuleRepository;
use Crossmedia\Fourallportal\Mapping\MappingInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* Module
*/
class Dimension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
protected $name = '';

/**
* @var string
*/
protected $value = '';

/**
* server
*
* @var \Crossmedia\Fourallportal\Domain\Model\DimensionMapping
*/
protected $mapping = null;

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}

/**
* @return string
*/
public function getValue()
{
return $this->value;
}

/**
* @param string $value
*/
public function setValue($value)
{
$this->value = $value;
}

/**
* @return DimensionMapping
*/
public function getMapping()
{
return $this->mapping;
}

/**
* @param DimensionMapping $mapping
*/
public function setMapping($mapping)
{
$this->mapping = $mapping;
}
}
100 changes: 100 additions & 0 deletions Classes/Domain/Model/DimensionMapping.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
namespace Crossmedia\Fourallportal\Domain\Model;

/***
*
* This file is part of the "4AllPortal Connector" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2017 Marc Neuhaus <[email protected]>, MIA3 GmbH & Co. KG
*
***/
use Crossmedia\Fourallportal\Domain\Repository\ModuleRepository;
use Crossmedia\Fourallportal\Mapping\MappingInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* Module
*/
class DimensionMapping extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var int
*/
protected $language = '';

/**
* server
*
* @var \Crossmedia\Fourallportal\Domain\Model\Server
*/
protected $server = null;

/**
* modules
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Crossmedia\Fourallportal\Domain\Model\Dimension>
* @cascade remove
*/
protected $dimensions = null;

/**
* @return int
*/
public function getLanguage()
{
return $this->language;
}

/**
* @param int $language
*/
public function setLanguage($language)
{
$this->language = $language;
}

/**
* @return Server
*/
public function getServer()
{
return $this->server;
}

/**
* @param Server $server
*/
public function setServer($server)
{
$this->server = $server;
}

/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getDimensions()
{
return $this->dimensions;
}

/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $dimensions
*/
public function setDimensions($dimensions)
{
$this->dimensions = $dimensions;
}

public function matches($dimensions) {
foreach ($this->dimensions as $dimension) {
if ($dimensions[$dimension->getName()] != $dimension->getValue()) {
return false;
}
}
return true;
}
}
25 changes: 25 additions & 0 deletions Classes/Domain/Model/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ class Server extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $modules = null;

/**
* modules
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Crossmedia\Fourallportal\Domain\Model\DimensionMapping>
* @cascade remove
*/
protected $dimensionMappings = null;

/**
* __construct
*/
Expand Down Expand Up @@ -283,4 +291,21 @@ public function getClient()
$client->login();
return $client;
}

/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getDimensionMappings()
{
return $this->dimensionMappings;
}

/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $dimensionMappings
*/
public function setDimensionMappings($dimensionMappings)
{
$this->dimensionMappings = $dimensionMappings;
}

}
28 changes: 19 additions & 9 deletions Classes/DynamicModel/DynamicModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,25 @@ public function generateAbstractModelForModule(Module $module, $strict = false,
// PHP/SQL representations, either errors will be raised or the remaining safe properties
// will be written - depending on the context of the TYPO3 site (Development = errors thrown)
$propertyConfiguration = $this->getPropertyConfigurationFromConnector($module);

$propertyConfiguration['remoteId'] = [
"column"=> "remote_id",
"type"=> "string",
"schema" => "varchar(255) default ''",
"config" => [
"type"=> "input",
"size" => 255
]
];
$propertyConfiguration['l10nParent'] = [
"column"=> 'l10n_parent',
"type"=> '\\' . $entityClassName,
"schema" => "INT(11) DEFAULT '0' NOT NULL",
"config" => [
"type"=> "passthrough"
]
];

$sourceCode = $this->generateCachedClassFile($abstractModelClassName, AbstractEntity::class, $propertyConfiguration, $strict);
}
return $sourceCode;
Expand Down Expand Up @@ -1029,15 +1048,6 @@ public function set%s(%s%s)

$functionsAndProperties = '';
$objectStorageInitializations = '';
$propertyConfiguration['remoteId'] = [
"column"=> "remote_id",
"type"=> "string",
"schema" => "varchar(255) default ''",
"config" => [
"type"=> "input",
"size" => 255
]
];
foreach ($propertyConfiguration as $propertyName => $property) {

$variableType = $property['type'];
Expand Down
Loading

0 comments on commit 46d8851

Please sign in to comment.