Falk
Falk

Reputation: 633

Flexform Hook of tx_news not working in TYPO3 8.x

In my Extension I'm using the backendUtility Hook of the tx_news Extension. It works well in previos versions of TYPO3.

/**
 * @param array|string $params
 * @param array $reference
 * @return void
 */
public function updateFlexforms(&$params, &$reference) {
    if ($params['selectedView'] === 'News->calendar') {
        $removedFields = $this->removedFieldsInCalendarView;

        $this->deleteFromStructure($dataStructure, $removedFields);
    }
    
}

In TYPO3 8.3 and 8.4 I got the following warning:

1: PHP Warning: Declaration of \Foo\BarBackendUtility::updateFlexforms(&$params, &$reference) should be compatible with GeorgRinger\News\Hooks\BackendUtility::updateFlexforms(array &$dataStructure, array $row) in /path/to/BackendUtility.php line 0

As it is a hook and it needs these parameters params and reference, I can not change it to the parameters of the original function. This would also lead to an issue.

What am I missing here?

Upvotes: 0

Views: 378

Answers (3)

Pravin Vavadiya
Pravin Vavadiya

Reputation: 3207

This is PHP Warrnig message, Becaue in TYPO3 8 core updateFlexforms() function pass two parameters with always type array. You need to pass array value in this function.

Upvotes: 0

Falk
Falk

Reputation: 633

The first answer and the comment in the same thread (both by Georg Ringer) combined leads to the solution:

/**
 * @param array $params
 * @param array $reference
 * @return void
 */
public function updateFlexformsDatedNews(&$params, &$reference) {
    if ($params['selectedView'] === 'News->calendar') {
        $removedFields = $this->removedFieldsInCalendarView;
        $this->deleteFromStructure($params['dataStructure'], $removedFields);
    }

}

This works with PHP5.6 and 7.0

Upvotes: 1

Georg Ringer
Georg Ringer

Reputation: 7939

Just rename your updateFlexform method to a different name.

Problem is because of php7

Upvotes: 1

Related Questions