Skip to content

Commit

Permalink
[BUGFIX] Some small DimensionMapping followup fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Neuhaus committed Feb 20, 2018
1 parent 3294dd9 commit 1962edb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Classes/Domain/Model/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function __construct()
protected function initStorageObjects()
{
$this->modules = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$this->dimensionMappings = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Classes/Mapping/AbstractMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected function determineDataTypeForProperty($propertyName, $object)
$property = new PropertyReflection($object, $propertyName);
$varTags = $property->getTagValues('var');
if (!empty($varTags)) {
return $varTags[0];
return strpos($varTags[0], ' ') !== false ? substr($varTags[0], 0, strpos($varTags[0], ' ')) : $varTags[0];
}
}

Expand Down Expand Up @@ -448,17 +448,17 @@ protected function importObjectWithDimensionMappings(array $data, $object, Event
}
}

if ($defaultDimensionMapping === null) {
throw new \Exception('No DimensionMapping found for Default Language!');
}

if (!$object) {
$object = $this->createObject($event);
}

$this->mapPropertiesFromDataToObject($data, $object, $event->getModule(), $defaultDimensionMapping);
$this->getObjectRepository()->update($object);

if ($defaultDimensionMapping === null) {
return;
}

$dataMapper = GeneralUtility::makeInstance(DataMapper::class);
foreach ($translationDimensionMappings as $translationDimensionMapping) {
$existingRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->getTableName(), 'sys_language_uid = ' . $translationDimensionMapping->getLanguage() . ' AND l10n_parent = ' . $object->getUid());
Expand Down
6 changes: 4 additions & 2 deletions Classes/Mapping/FalMapping.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Crossmedia\Fourallportal\Mapping;

use Crossmedia\Fourallportal\Domain\Model\DimensionMapping;
use Crossmedia\Fourallportal\Domain\Model\Event;
use Crossmedia\Fourallportal\Domain\Model\Module;
use Crossmedia\Fourallportal\Domain\Model\Server;
Expand Down Expand Up @@ -85,11 +86,12 @@ public function import(array $data, Event $event)
* @param array $data
* @param \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $object
* @param Module $module
* @param DimensionMapping|null $dimensionMapping
* @return AbstractEntity
*/
protected function mapPropertiesFromDataToObject(array $data, $object, Module $module)
protected function mapPropertiesFromDataToObject(array $data, $object, Module $module, DimensionMapping $dimensionMapping = null)
{
parent::mapPropertiesFromDataToObject($data, $object, $module);
parent::mapPropertiesFromDataToObject($data, $object, $module, $dimensionMapping);
$metadata = [];
$map = MappingRegister::resolvePropertyMapForMapper(static::class);

Expand Down

0 comments on commit 1962edb

Please sign in to comment.