getButtons(), function ($result, $item) { return array_merge($result, array_keys($item)); }, []); // Ensure that button ID is unique. // @todo Should this do a case-insensitive comparison? $button_id = $form_state->getValue('id'); if (in_array($button_id, $button_ids)) { $form_state->setErrorByName('id', t('A CKEditor button with ID %id already exists.', ['%id' => $button_id])); } }