/** * Overwrites the conf array with parameters from the flexform with the same keys * * @param mixed plugin object, e.g. "tslib_pibase" or any other object (needs a "tslib_cObj" at ->cObj, an array at ->conf and callable methods "pi_getFFvalue()" and "pi_initPIflexForm()") * @param bool (optional) if true the method won't throw an exception if no flexform data is found, default: false * @return void * @throws \PunktDe\PtExtbase\Exception\Exception if no flexform data was found */ public static function mergeConfAndFlexform($pObj, $noExceptionIfNoFlexform = false) { Tx_PtExtbase_Assertions_Assert::isObject($pObj, array('message' => '"$pObj" is no object.')); Tx_PtExtbase_Assertions_Assert::isInstanceOf($pObj->cObj, 'tslib_cObj', array('message' => '"$pObj->cObj" is no instance of "tslib_cObj".')); Tx_PtExtbase_Assertions_Assert::isArray($pObj->conf, array('message' => '"$pObj->conf" is no array.')); if (!is_callable(array($pObj, 'pi_initPIflexForm'))) { throw new \PunktDe\PtExtbase\Exception\Exception('"$pObj needs a callable method "pi_initPIflexForm()"'); } if (!is_callable(array($pObj, 'pi_getFFvalue'))) { throw new \PunktDe\PtExtbase\Exception\Exception('"$pObj needs a callable method "pi_getFFvalue()"'); } $pObj->pi_initPIflexForm(); $piFlexForm = $pObj->cObj->data['pi_flexform']; if (is_array($piFlexForm['data'])) { foreach ($piFlexForm['data'] as $sheet => $data) { foreach ($data as $lang => $value) { foreach ($value as $key => $val) { $ff_value = trim($pObj->pi_getFFvalue($piFlexForm, $key, $sheet)); if ($ff_value != '') { // do not overwrite conf settings with '' $pObj->conf[$key] = $ff_value; unset($pObj->conf[$key . '.']); // unset stdWrap settings if available } } } } } elseif (!$noExceptionIfNoFlexform) { throw new \PunktDe\PtExtbase\Exception\Exception('No plugin configuration found!', 0, 'No flexform data found. Please update your plugin configuration!'); } }