Initialize attributes with default value

@return null
961417
protected function initAttrs()
    {
        $attrs = self::getAttrs();
        foreach ($attrs as $key => $attr) {
            if (! isset($attr['default'])) continue;
            if (! isset($this->cleanData[$key])) {
                $this->$key = $attr['default'];
            }
        }
    }
819990
public function init()
    {
        if ($this->initialized) {
            return;
        }

        $parameters = [];

        foreach ($this->parameterRepository->getAllParameters() as $parameter) {
            $configurationName = $parameter->getConfigurationName();

            if (!isset($parameters[$configurationName])) {
                $parameters[$configurationName] = [];
            }

            $parameters[$configurationName][$parameter->getName()] = $parameter;
        }

        $this->persistedParameters = $parameters;

        foreach ($this->configurations as $configuration) {
            $configurationName = $configuration->getName();
            $this->initConfiguration(
                $configuration,
                isset($parameters[$configurationName]) ? $parameters[$configurationName] : []
            );
        }

        $this->initialized = true;
    }
449243
protected function init()
    {
        if (empty($this->data['databaseRow']['config'])) {
            $rows = [[['colspan' => 1, 'rowspan' => 1, 'spanned' => 0, 'name' => '0x0']]];
            $colCount = 1;
            $rowCount = 1;
        } else {
            /** @var LayoutSetup $layoutSetup */
            $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0);
            if ($this->data['tableName'] === 'tx-gridelements_backend_layout') {
                $layoutId = $this->data['databaseRow']['alias'] ?: (int)$this->data['databaseRow']['uid'];
                $layout = $layoutSetup->getLayoutSetup($layoutId);
            } else {
                $parser = GeneralUtility::makeInstance(TypoScriptParser::class);
                $parser->parse($this->data['databaseRow']['config']);
                $layout = ['config' => $parser->setup['backend_layout.']];
                if (!empty($layout['config']['rows.'])) {
                    $columns = $layoutSetup->checkAvailableColumns($layout);
                    if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) {
                        $layout['columns'] = $columns;
                        unset($layout['columns']['allowed']);
                        $layout['allowed'] = $columns['allowed'] ?: [];
                        $layout['disallowed'] = $columns['disallowed'] ?: [];
                        $layout['maxitems'] = $columns['maxitems'] ?: [];
                    }
                }
            }
            $rows = [];
            $colCount = $layout['config']['colCount'];
            $rowCount = $layout['config']['rowCount'];
            $dataRows = $layout['config']['rows.'];
            $spannedMatrix = [];
            for ($i = 1; $i <= $rowCount; $i++) {
                $cells = [];
                $row = array_shift($dataRows);
                $columns = $row['columns.'];
                for ($j = 1; $j <= $colCount; $j++) {
                    $cellData = [];
                    if (!$spannedMatrix[$i][$j]) {
                        if (is_array($columns) && !empty($columns)) {
                            $column = array_shift($columns);
                            if (isset($column['colspan'])) {
                                $cellData['colspan'] = (int)$column['colspan'];
                                $columnColSpan = (int)$column['colspan'];
                                if (isset($column['rowspan'])) {
                                    $columnRowSpan = (int)$column['rowspan'];
                                    for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) {
                                        for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) {
                                            $spannedMatrix[$i + $spanRow][$j + $spanColumn] = 1;
                                        }
                                    }
                                } else {
                                    for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) {
                                        $spannedMatrix[$i][$j + $spanColumn] = 1;
                                    }
                                }
                            } else {
                                $cellData['colspan'] = 1;
                                if (isset($column['rowspan'])) {
                                    $columnRowSpan = (int)$column['rowspan'];
                                    for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) {
                                        $spannedMatrix[$i + $spanRow][$j] = 1;
                                    }
                                }
                            }
                            if (isset($column['rowspan'])) {
                                $cellData['rowspan'] = (int)$column['rowspan'];
                            } else {
                                $cellData['rowspan'] = 1;
                            }
                            if (isset($column['name'])) {
                                $cellData['name'] = $column['name'];
                            }
                            if (isset($column['colPos'])) {
                                $colPos = (int)$column['colPos'];
                                $cellData['column'] = $colPos;
                                $cellData['allowed'] = [];
                                if (isset($layout['allowed'][$colPos])) {
                                    foreach ($layout['allowed'][$colPos] as $key => $valueArray) {
                                        $cellData['allowed'][$key] = implode(',', array_keys($valueArray));
                                    }
                                }
                                $cellData['disallowed'] = [];
                                if (isset($layout['disallowed'][$colPos])) {
                                    foreach ($layout['disallowed'][$colPos] as $key => $valueArray) {
                                        $cellData['disallowed'][$key] = implode(',', array_keys($valueArray));
                                    }
                                }
                                $cellData['maxitems'] = (int)$layout['maxitems'][$colPos];
                            }
                        }
                    } else {
                        $cellData = ['colspan' => 1, 'rowspan' => 1, 'spanned' => 1];
                    }
                    $cells[] = $cellData;
                }
                $rows[] = $cells;
                if (!empty($spannedMatrix[$i]) && is_array($spannedMatrix[$i])) {
                    ksort($spannedMatrix[$i]);
                }
            }
        }
        $this->rows = $rows;
        $this->colCount = (int)$colCount;
        $this->rowCount = (int)$rowCount;
    }
499725
protected function autoAssignAttributes()
    {
        $attributes = isset($this->defaultAttributes) ? $this->defaultAttributes : [];
        // Default attributes are not counted as "from storage"
        $this->fillAttributes($attributes, false);
    }
72361
public function getDefaultAttributes()
    {
        $default_attributes = [
            new TextAttribute('identifier', $this),
            new IntegerAttribute('revision', $this, [ 'default_value' => 0 ]),
            new UuidAttribute('uuid', $this, [ 'default_value' => 'auto_gen' ]),
            new TextAttribute('language', $this, [ 'default_value' => 'de_DE' ]),
            new IntegerAttribute('version', $this, [ 'default_value' => 1 ]),
            new TextAttribute('workflow_state', $this),
            new KeyValueListAttribute('workflow_parameters', $this)
        ];

        if ($this->isHierarchical()) {
            $default_attributes[] = new TextAttribute('parent_node_id', $this);
        }

        $default_attributes_map = new AttributeMap($default_attributes);
        return parent::getDefaultAttributes()->append($default_attributes_map);
    }
766740
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion != false )
        {
            $dataText = $originalContentObjectAttribute->attribute( "data_text" );
            $contentObjectAttribute->setAttribute( "data_text", $dataText );
        }
    }
1272191
public function init()
    {
        if ($this->attribute === null) {
            throw new InvalidConfigException('Please specify the "attribute" property.');
        }

        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getMdeditorId();
        }
    }
318122
public function initSettingsData()
    {
        $this->html_allow_empty_tags = $this->defaultHtmlAllowEmptyTags;
        $this->html_allow_tags = $this->defaultHtmlAllowTags;
        $this->html_no_wrap_tags = $this->defaultHtmlNoWrapTags;
        $this->html_remove_tags = $this->defaultHtmlRemoveTags;
        $this->html_line_breaker_tags = $this->defaultHtmlLineBreakerTags;
        $this->html_custom_styles = File::get(base_path().'/modules/backend/models/editorsetting/default_styles.less');
        $this->html_style_image = $this->makeStylesForTable($this->defaultHtmlStyleImage);
        $this->html_style_link = $this->makeStylesForTable($this->defaultHtmlStyleLink);
        $this->html_style_paragraph = $this->makeStylesForTable($this->defaultHtmlStyleParagraph);
        $this->html_style_table = $this->makeStylesForTable($this->defaultHtmlStyleTable);
        $this->html_style_table_cell = $this->makeStylesForTable($this->defaultHtmlStyleTableCell);
    }
1179683
private function _initialize()
    {
        $params = $this->getParameters();
        $n = count($params);

        if ($params !== null) {
            for ($i = 0; $i < $n; $i++) {
                if ($params[$i] !== null) {
                    $name = $params[$i]->getName();
                    switch ($name) {
                        case 'begintoken':
                            $this->_beginToken = $params[$i]->getValue();
                            break;
                        case 'endtoken':
                            $this->_endToken = $params[$i]->getValue();
                            break;
                        case 'dir':
                            $this->_dir = $params[$i]->getValue();
                            break;
                        case 'prefix':
                            $this->_prefix = $params[$i]->getValue();
                            break;
                        case 'postfix':
                            $this->_postfix = $params[$i]->getValue();
                            break;
                        case 'translatehtml':
                            $this->_translatehtml = $params[$i]->getValue();
                            break;
                    }
                }
            }
        }
    }
738372
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion != false )
        {
            $dataInt = $originalContentObjectAttribute->attribute( "data_int" );
            $contentObjectAttribute->setAttribute( "data_int", $dataInt );
        }
        else
        {
            $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
            $defaultType = $contentClassAttribute->attribute( self::DEFAULT_FIELD );
            if ( $defaultType == self::DEFAULT_CURRENT_DATE )
            {
                $contentObjectAttribute->setAttribute( "data_int", time() );
            }
            else if ( $defaultType == self::DEFAULT_ADJUSTMENT )
            {
                $adjustments = $this->classAttributeContent( $contentClassAttribute );
                $value = new eZDateTime();
                $secondAdjustment = $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 ? $adjustments['second'] : 0;
                $value->adjustDateTime( $adjustments['hour'], $adjustments['minute'], $secondAdjustment, $adjustments['month'], $adjustments['day'], $adjustments['year'] );
                $contentObjectAttribute->setAttribute( "data_int", $value->timeStamp() );
            }
            else
                $contentObjectAttribute->setAttribute( "data_int", null );
        }
    }
1074273
public function init()
    {
        parent::init();

        $this->visible = Yii::$app->user->can('access-subclients');
        if (!$this->visible) {
            return null;
        }

        if (!$this->sortAttribute) {
            $this->sortAttribute = $this->nameAttribute;
        }
        if ($this->value === null) {
            $this->value = function ($model) {
                if (Yii::$app->user->identity->hasSeller($model->{$this->idAttribute})) {
                    return $model->{$this->nameAttribute};
                } else {
                    return Html::a($model->{$this->nameAttribute}, ['@client/view', 'id' => $model->{$this->idAttribute}]);
                }
            };
        }
        if (!empty($this->grid->filterModel)) {
            if (!isset($this->filterInputOptions['id'])) {
                $this->filterInputOptions['id'] = $this->attribute;
            }
            if ($this->filter === null && strpos($this->attribute, '_like') === false) {
                $this->filter = $this->getDefaultFilter();
            }
        }

        return true;
    }
1214995
private function _initialize()
    {
        $params = $this->getParameters();
        if ($params !== null) {
            for ($i = 0, $_i = count($params); $i < $_i; $i++) {
                if ($params[$i]->getType() === null) {
                    if ($params[$i]->getName() === "style") {
                        $this->setStyle($params[$i]->getValue());
                    }
                } elseif ($params[$i]->getType() == "param") {
                    $xp = new XsltParam();
                    $xp->setName($params[$i]->getName());
                    $xp->setExpression($params[$i]->getValue());
                    $this->xsltParams[] = $xp;
                }
            }
        }
    }
443877
private function initialize()
    {
        $this->entity = '';
        $this->source = '';
        $this->mode = self::RSMODE_NOTCONNECTED;
        $this->result = null;
        $this->originalValues = null;
        $this->datafields = [];
        $this->values = [];
        $this->idFields = [];
    }
226449
protected function initDefault()
    {
        if ($this->isCli()) {
            return null;
        }

        $uri = (empty($_SERVER['HTTPS']) ? 'http' : 'https')
            . '://'
            . $_SERVER['HTTP_HOST']
            . $_SERVER['REQUEST_URI'];
        return  rtrim(preg_replace('/\?.*/', '', $uri), '/');
    }
74353
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {

        if ( $currentVersion != false )
        {
            $matrix = $originalContentObjectAttribute->content();
            $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
            // make sure that $matrix contains right columns
            $matrix->adjustColumnsToDefinition( $contentClassAttribute->attribute( 'content' ) );

            $contentObjectAttribute->setAttribute( 'data_text', $matrix->xmlString() );
            $contentObjectAttribute->setContent( $matrix );
        }
        else
        {
            $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
            $numRows = $contentClassAttribute->attribute( 'data_int1' );
            $matrix = new eZMatrix( '', $numRows, $contentClassAttribute->attribute( 'content' ) );
            // 'default name' is never used => just a stub
            // $matrix->setName( $contentClassAttribute->attribute( 'data_text1' ) );
            $contentObjectAttribute->setAttribute( 'data_text', $matrix->xmlString() );
            $contentObjectAttribute->setContent( $matrix );
        }

    }
1038502
public function init()
    {
        // Duplicated init protection
        if ($this->_blInit) {
            return;
        }
        $this->_blInit = true;

        $this->_loadVarsFromFile();
        $this->_setDefaults();
        $this->storedVarTypes = $this->getStoredVarTypes();

        try {
            $sShopID = $this->getShopId();
            $blConfigLoaded = $this->_loadVarsFromDb($sShopID);

            // loading shop config
            if (empty($sShopID) || !$blConfigLoaded) {
                throw oxNew(ConnectionException::class, "Unable to load shop config values from database");
            }

            // loading theme config options
            $this->_loadVarsFromDb(
                $sShopID, null, Config::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme')
            );

            $this->_aConfigParamsParentTheme = $this->_aConfigParams;

            // checking if custom theme (which has defined parent theme) config options should be loaded over parent theme (#3362)
            if ($this->getConfigParam('sCustomTheme')) {
                $this->_loadVarsFromDb(
                    $sShopID, null, Config::OXMODULE_THEME_PREFIX . $this->getConfigParam('sCustomTheme')
                );
            }

            // loading modules config
            $this->_loadVarsFromDb($sShopID, null, Config::OXMODULE_MODULE_PREFIX);

            $aOnlyMainShopVars = array('blMallUsers', 'aSerials', 'IMD', 'IMA', 'IMS');
            $this->_loadVarsFromDb($this->getBaseShopId(), $aOnlyMainShopVars);
        } catch (ConnectionException $oEx) {
            $oEx->debugOut();
            Registry::getUtils()->showMessageAndExit($oEx->getString());
        }
    }
1260206
public function initialize()
    {
        parent::initialize();

        $attributes = Request::all();
        array_unshift($attributes, $this->getName());
        array_unshift($attributes, $this->getModelConfiguration()->getAlias());

        $this->setHtmlAttribute('style', 'width:100%');
        $this->setHtmlAttribute('data-url', route('admin.display.async', $attributes));
        $this->setHtmlAttribute('data-payload', json_encode($this->payload));

        if ($this->getDisplaySearch()) {
            $this->setHtmlAttribute('data-display-search', 1);
        }

        if ($this->getDisplayLength()) {
            $this->setHtmlAttribute('data-display-dtlength', 1);
        }
    }