/** * get name restrictions * * @param $entityCode * @return array */ protected function getNamingRestrictions($entityCode) { $restrict = []; $restrictions = $this->restrictionConfig->getRestrictions($entityCode, []); foreach ($restrictions as $restriction) { $groupRestriction = []; foreach ($restriction['val'] as $val) { $message = isset($val['message']) ? __($val['message'])->render() : __('value is not permitted.')->render(); if (!isset($groupRestriction[$restriction['id']])) { $groupRestriction[$restriction['id']] = []; } if (!isset($groupRestriction[$restriction['id']][$message])) { $groupRestriction[$restriction['id']][$message] = []; } $groupRestriction[$restriction['id']][$message][] = $val['real_val']; } foreach ($groupRestriction as $fieldId => $messages) { foreach ($messages as $oneMessage => $restrictedValues) { $restrict[] = ['field' => $this->formConfig->getFieldLabelByCode($entityCode, $fieldId, $fieldId), 'value' => implode(', ', $restrictedValues), 'message' => $oneMessage]; } } if ($this->restrictionConfig->getBoolValue($restriction, 'reserved')) { $restrict[] = ['field' => $this->formConfig->getFieldLabelByCode($entityCode, $restriction['id'], $restriction['id']), 'value' => implode(', ', $this->restrictionConfig->getReservedKeywords()), 'message' => __('These are PHP reserved keywords')]; } if (isset($restriction['class'])) { $magic = $this->restrictionConfig->getMagicRestrictedValues($restriction['class']); if (count($magic)) { $restrict[] = ['field' => $this->formConfig->getFieldLabelByCode($entityCode, $restriction['id'], $restriction['id']), 'value' => implode(', ', $magic), 'message' => __('These values would conflict with the magic getters and setters of the generated model')]; } } } return $restrict; }