Skip to content

Commit

Permalink
Merge pull request FluidTYPO3#299 from xf-/php7fix
Browse files Browse the repository at this point in the history
[TASK] Rename injection method and property for PHP7 compatibility
  • Loading branch information
NamelessCoder committed Dec 26, 2015
2 parents cf7cf34 + 4093187 commit c3e3ce4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
20 changes: 9 additions & 11 deletions Classes/Provider/PageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PageProvider extends AbstractProvider implements ProviderInterface {
/**
* @var ConfigurationService
*/
protected $configurationService;
protected $pageConfigurationService;

/**
* @var array
Expand Down Expand Up @@ -117,11 +117,11 @@ public function injectPageService(PageService $pageService) {
}

/**
* @param ConfigurationService $configurationService
* @param ConfigurationService $pageConfigurationService
* @return void
*/
public function injectConfigurationService(ConfigurationService $configurationService) {
$this->configurationService = $configurationService;
public function injectPageConfigurationService(ConfigurationService $pageConfigurationService) {
$this->pageConfigurationService = $pageConfigurationService;
}

/**
Expand Down Expand Up @@ -189,7 +189,7 @@ public function getControllerActionFromRecord(array $row) {
}
$action = $this->getControllerActionReferenceFromRecord($row);
if (TRUE === empty($action)) {
$this->configurationService->message('No page template selected and no template was inherited from parent page(s)');
$this->pageConfigurationService->message('No page template selected and no template was inherited from parent page(s)');
return 'default';
}
$controllerActionName = array_pop(explode('->', $action));
Expand All @@ -215,13 +215,11 @@ public function getControllerActionReferenceFromRecord(array $row) {
public function getFlexFormValues(array $row) {
$fieldName = $this->getFieldName($row);
$form = $this->getForm($row);

$immediateConfiguration = $this->getFlexFormValuesSingle($row);
$inheritedConfiguration = $this->getInheritedConfiguration($row);
$merged = RecursiveArrayUtility::merge($inheritedConfiguration, $immediateConfiguration);

return $merged;
}
}

/**
* @param array $row source record row
Expand All @@ -233,7 +231,7 @@ public function overlayFlexFormValues($row, $configuration, $form) {
$fieldName = $this->getFieldName($row);
if (count($overlays) > 0) {
foreach ($overlays as $overlay) {
$overlayConfiguration = $this->configurationService->convertFlexFormContentToArray($overlay[$fieldName], $form, NULL, NULL);
$overlayConfiguration = $this->pageConfigurationService->convertFlexFormContentToArray($overlay[$fieldName], $form, NULL, NULL);
$configuration = RecursiveArrayUtility::merge($configuration, $overlayConfiguration);
}
}
Expand All @@ -255,7 +253,7 @@ public function getFlexFormValuesSingle(array $row) {
if ($GLOBALS['TSFE']->sys_language_uid > 0) {
$languageRef = 'l' . $GLOBALS['TSFE']->config['config']['language'];
}
$immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, $languageRef, NULL);
$immediateConfiguration = $this->pageConfigurationService->convertFlexFormContentToArray($row[$fieldName], $form, $languageRef, NULL);

// replacement for the deprecated language handling (Deprecation: #70138 - Flex form language handling)
$immediateConfiguration = $this->overlayFlexFormValues($row, $immediateConfiguration, $form);
Expand Down Expand Up @@ -351,7 +349,7 @@ protected function getInheritedConfiguration(array $row) {
$data = array();
foreach ($tree as $branch) {
/** @var SubPageProvider $provider */
$provider = $this->configurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch);
$provider = $this->pageConfigurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch);
$form = $provider->getForm($branch);
if (NULL === $form) {
break;
Expand Down
10 changes: 5 additions & 5 deletions Tests/Unit/Provider/PageProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testPerformsInjections() {
->get('FluidTYPO3\\Fluidpages\\Provider\\PageProvider');
$this->assertAttributeInstanceOf('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools', 'flexformTool', $instance);
$this->assertAttributeInstanceOf('FluidTYPO3\\Fluidpages\\Service\\PageService', 'pageService', $instance);
$this->assertAttributeInstanceOf('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService', 'configurationService', $instance);
$this->assertAttributeInstanceOf('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService', 'pageConfigurationService', $instance);
}

public function testGetExtensionKey() {
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testGetControllerActionFromRecord(array $record, $fieldName, $ex
/** @var ConfigurationService|\PHPUnit_Framework_MockObject_MockObject $configurationService */
$configurationService = $this->getMock('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService', array('message'));
$configurationService->expects($this->once())->method('message');
$instance->injectConfigurationService($configurationService);
$instance->injectPageConfigurationService($configurationService);
}
// make sure PageProvider is now using the right field name
$instance->trigger($record, NULL, $fieldName);
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testGetFlexFormValuesReturnsCollectedDataWhenEncounteringNullFor
$provider->expects($this->any())->method('unsetInheritedValues');
$provider->expects($this->any())->method('getForm')->willReturn(Form::create());
$provider->setTemplatePathAndFilename($this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL));
$provider->injectConfigurationService($mockConfigurationService);
$provider->injectPageConfigurationService($mockConfigurationService);
$values = $provider->getFlexformValues($record);
$this->assertEquals($values, array());
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public function canGetFlexformValuesUnderInheritanceConditions() {
$provider->expects($this->any())->method('unsetInheritedValues');
$provider->expects($this->any())->method('getForm')->willReturn(Form::create());
$provider->setTemplatePathAndFilename($this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL));
$provider->injectConfigurationService($mockConfigurationService);
$provider->injectPageConfigurationService($mockConfigurationService);
$values = $provider->getFlexformValues($record);
$this->assertEquals($values, array());
}
Expand Down Expand Up @@ -388,7 +388,7 @@ public function canPostProcessRecord() {
$configurationService = $this->getMock('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService', array('message'));
$configurationService->expects($this->any())->method('message');
$provider->injectRecordService($recordService);
$provider->injectConfigurationService($configurationService);
$provider->injectPageConfigurationService($configurationService);
$provider->postProcessRecord('update', $id, $record, $parentInstance);
$this->assertIsString($record[$fieldName]);
$this->assertNotContains('settings.input', $record[$fieldName]);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Provider/SubPageProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testGetControllerActionFromRecord(array $record, $fieldName, $ex
/** @var ConfigurationService|\PHPUnit_Framework_MockObject_MockObject $configurationService */
$configurationService = $this->getMock('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService', array('message'));
$configurationService->expects($this->once())->method('message');
$instance->injectConfigurationService($configurationService);
$instance->injectPageConfigurationService($configurationService);
}
// make sure PageProvider is now using the right field name
$instance->trigger($record, NULL, $fieldName);
Expand Down

0 comments on commit c3e3ce4

Please sign in to comment.