Push a badge to indicate the language that owns the current item

@param DBField|null $badgeField
507018
public function updateBadge(&$badgeField)
    {
        /** @var DataObject $record */
        $record = $this->owner->getRecord();

        $badgeField = $this->addFluentBadge($badgeField, $record);
    }
895424
public function view(string $id = null)
    {
        $translation = $this->Translations->get($id, [
            'contain' => ['Languages']
        ]);

        $this->set('translation', $translation);
        $this->set('_serialize', ['translation']);
    }
383571
public function setLanguage(CNabuLanguage $nb_language)
    {
        if ($nb_language->isValueNumeric(NABU_LANG_FIELD_ID) || $nb_language->isValueGUID(NABU_LANG_FIELD_ID)) {
            $nb_language_id = $nb_language->getValue(NABU_LANG_FIELD_ID);
            $this->languages_list->addItem($nb_language);
        }
    }
1216018
def add_badge(self, kind):
        ''''''
        badge = self.get_badge(kind)
        if badge:
            return badge
        if kind not in getattr(self, '__badges__', {}):
            msg = 'Unknown badge type for {model}: {kind}'
            raise db.ValidationError(msg.format(model=self.__class__.__name__,
                                                kind=kind))
        badge = Badge(kind=kind)
        if current_user.is_authenticated:
            badge.created_by = current_user.id

        self.update(__raw__={
            '$push': {
                'badges': {
                    '$each': [badge.to_mongo()],
                    '$position': 0
                }
            }
        })
        self.reload()
        post_save.send(self.__class__, document=self)
        on_badge_added.send(self, kind=kind)
        return self.get_badge(kind)
135659
public static function setValue(DBField $dbField, $value, $record = null)
    {
        $canEdit = Controller::has_curr() && (Controller::curr() instanceof Page_Controller && Controller::curr()->data()->canEdit());
        if (!$canEdit) {
            $canEdit = is_object($record) && in_array(get_class($record), self::$EditableClasses) && method_exists($record, 'canEdit') && $record->canEdit();
        }
        if ($canEdit && $record && is_object($record) && $dbField->getName()) {
            $dbField->makeEditable  = true;
            $dbField->editClassName = $record->ClassName;
            $dbField->editID        = $record->ID;
        }
    }
917062
public function onBeforeAddLanguageCommit(BeforeAddLanguageCommitEvent $event)
    {
        if ($event->isAborted()) {
            return;
        }

        $this->languageManager = $event->getContentManager();
        $languageRepository = $this->languageManager->getLanguageRepository();

        $this->mainLanguage = $languageRepository->mainLanguage();
        if (null === $this->mainLanguage) {
            $event->abort();

            return;
        }

        $this->sourceObjects = $this->setUpSourceObjects();
        if (count($this->sourceObjects) > 0) {
            try {
                $result = true;
                $languageRepository->startTransaction();
                foreach ($this->sourceObjects as $sourceObject) {
                    $values = $sourceObject->toArray();
                    $result = $this->copy($values);
                    if (!$result) {
                        break;
                    }
                }

                if (false !== $result) {
                    $languageRepository->commit();
                } else {
                    $languageRepository->rollBack();

                    $event->abort();
                }
            } catch (\Exception $e) {
                $event->abort();
                if (isset($languageRepository) && $languageRepository !== null) {
                    $languageRepository->rollBack();
                }

                throw $e;
            }
        }
    }
651340
private function parsePreferences($serverField, $field, $fromField)
    {
        $tokenList = $this->tokenizer->tokenize($field, $fromField);

        return $this->parser->parse($tokenList, $serverField, $fromField);
    }
709771
public static function badge($label, $htmlOptions = array())
    {
        self::addCssClass('badge', $htmlOptions);
        $color = TbArray::popValue('color', $htmlOptions);
        if (!empty($color)) {
            self::addCssClass('badge-' . $color, $htmlOptions);
        }
        return self::tag('span', $htmlOptions, $label);
    }
1202519
public function push(FormField $field)
    {
        if ($field instanceof Tab || $field instanceof TabSet) {
            $field->setTabSet($this);
        }
        parent::push($field);
    }
1210279
protected function makePage($badge = null)
    {
        $page = new Page($this);
        $page->setPriority($this->getPriority())
            ->setIcon($this->getIcon())
            ->setId($this->getPageId())
            ->setAccessLogic(function () {
                return $this->isDisplay();
            });

        if ($badge) {
            if (! ($badge instanceof BadgeInterface)) {
                $badge = new Badge($badge);
            }
            $page->addBadge($badge);
        }

        return $page;
    }
129691
public function edit($id)
    {
        $this->loadModel('Locale.Languages');
        $language = $this->Languages->get($id);
        $languages = LocaleToolbox::languagesList(true);
        $icons = LocaleToolbox::flagsList();

        if ($this->request->data()) {
            $language = $this->Languages->patchEntity($language, $this->request->data, [
                'fieldList' => [
                    'name',
                    'direction',
                    'icon',
                ]
            ]);

            if ($this->Languages->save($language)) {
                $this->Flash->success(__d('locale', 'Language was successfully saved!'));
                $this->redirect($this->referer());
            } else {
                $this->Flash->success(__d('locale', 'Language could not be saved, please check your information.'));
            }
        }

        $this->title(__d('locale', 'Editing Language'));
        $this->set(compact('language', 'languages', 'icons'));
        $this->Breadcrumb
            ->push('/admin/locale')
            ->push(__d('locale', 'Editing language'), '');
    }
370360
public function setBuyerTitleAttachment(\AgentSIB\Diadoc\Api\Proto\Docflow\SignedAttachment $value = null)
    {
        $this->BuyerTitleAttachment = $value;
    }
90713
public function setDocumentAttachment(\AgentSIB\Diadoc\Api\Proto\Docflow\SignedAttachment $value = null)
    {
        $this->DocumentAttachment = $value;
    }
1050529
final public function sqlIsNull(string $field, bool $positive = true): string
    {
        if (! $positive) {
            trigger_error(
                __METHOD__ . ' with argument $positive = false is deprecated, use DBAL::sqlIsNotNull',
                E_USER_NOTICE
            );
            return $this->sqlIsNotNull($field);
        }
        return $field . ' IS NULL';
    }
318771
public function onGenerateFormField($field, $nb) {
		if ($field instanceof HtmlFormInput) {
			if ($field->getDataField ()->getProperty ( 'type' ) == "datetime-local") {
				$v = $field->getDataField ()->getProperty ( 'value' );
				$field->getDataField ()->setValue ( date ( "Y-m-d\TH:i:s", strtotime ( $v ) ) );
			}
		}
		return;
	}
606319
protected function processToken(): void
    {
        $prevStatement = null;

        foreach ($this->useStatements as $useStatement) {
            if ($prevStatement && ($this->compareUseStatements($prevStatement, $useStatement) > 0)) {
                $exception = new CodeError(
                    static::CODE_INCORRECT_ORDER,
                    'Use statements should be sorted alphabetically. The first wrong one is %s.',
                    $useStatement->getPointer()
                );

                $exception
                    ->setPayload([$useStatement->getFullyQualifiedTypeName()])
                    ->isFixable(true);

                throw $exception;
            }

            $prevStatement = $useStatement;
        }
    }
1322037
protected static function pushToken(&$context, $token) {
        if ($token === '') {
            return;
        }
        if (is_string($token)) {
            if (is_string(end($context['parsed'][0]))) {
                $context['parsed'][0][key($context['parsed'][0])] .= $token;
                return;
            }
        }
        $context['parsed'][0][] = $token;
    }