MetaModels\DcGeneral\Data\Driver::resetFallback PHP Method

resetFallback() public method

This clears the given property in all items in the data provider to an empty value.
public resetFallback ( string $strField ) : void
$strField string The field to reset.
return void
    public function resetFallback($strField)
    {
        $metaModel = $this->getMetaModel();
        $attribute = $metaModel->getAttribute($strField);
        $ids = $metaModel->getIdsFromFilter(null);
        if ($attribute instanceof IComplex) {
            $attribute->unsetDataFor($ids);
        }
        if ($attribute instanceof ITranslated) {
            $attribute->unsetValueFor($ids, $this->getCurrentLanguage());
        }
        if ($attribute instanceof IAttribute) {
            $data = array();
            foreach ($ids as $id) {
                $data[$id] = null;
            }
            $attribute->setDataFor($data);
        }
        throw new \RuntimeException('Unknown attribute or type ' . $strField);
    }