Skip to content

Commit

Permalink
Merge pull request #6 from osu-wams/code_style_updates
Browse files Browse the repository at this point in the history
Code style updates
  • Loading branch information
emerham authored Jun 8, 2023
2 parents 9d37c47 + 3eee2a9 commit d668c67
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
10 changes: 7 additions & 3 deletions osu_icon_field.install
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

use Drupal\Core\Database\Database;
/**
* @file
* Install, update, and uninstall functions for the OSU Icon Field module.
*/

use Drupal\Core\Entity\SQL\SqlContentEntityStorage;

/**
* Add a new column for size to all icon fields.
Expand All @@ -23,7 +28,6 @@ function osu_icon_field_update_9001(&$sandbox) {
* @param string $new_property
* The Name of the new column to add.
*
* @return void
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
Expand All @@ -36,7 +40,7 @@ function osu_icon_field_add_helper($field_type, $new_property) {
$field_storage_definition = $manager->getFieldStorageDefinition($field_name, $entity_type_id);
$storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);

if ($storage instanceof \Drupal\Core\Entity\SQL\SqlContentEntityStorage) {
if ($storage instanceof SqlContentEntityStorage) {
$table_mapping = $storage->getTableMapping([$field_name => $field_storage_definition]);
$tables_names = $table_mapping->getDedicatedTableNames();
$columns = $table_mapping->getColumnNames($field_name);
Expand Down
1 change: 0 additions & 1 deletion osu_icon_field.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ osu-icon:
- core/drupal
- core/drupalSettings
- core/once

1 change: 0 additions & 1 deletion osu_icon_field.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function osu_icon_field_theme() {
];
}


/**
* Implements hook_page_attachments().
*/
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<file>.</file>
<arg name="extensions" value="php,module,inc,install,test,profile,theme,info,txt,md,yml"/>
<arg name="ignore" value="dist,node_modules,vendor"/>
<config name="drupal_core_version" value="9"/>
<config name="drupal_core_version" value="10"/>
<rule ref="Drupal">
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>
</rule>
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/OsuIconFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];

foreach ($items as $delta => $item) {
$icon = isset($item->getValue('values')['value']) ? $item->getValue('values')['value'] : '';
$iconSize = isset($item->getValue('values')['size']) ? $item->getValue('values')['size'] : '';
$icon = $item->getValue('values')['value'] ?? '';
$iconSize = $item->getValue('values')['size'] ?? '';

$elements[$delta] = [
'#theme' => 'osu_icon_field_formatter',
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldType/OsuIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class OsuIcon extends FieldItemBase {
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
// columns contains the values that the field will store
// Columns contains the values that the field will store.
'columns' => [
// List the values that the field will save. This
// field will only save a single value, 'value'
// field will only save a single value, 'value'.
'value' => [
'description' => 'The icon name.',
'type' => 'text',
Expand Down
6 changes: 2 additions & 4 deletions src/Plugin/Field/FieldWidget/OsuIconWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Link;

/**
* A widget for OSU Icon.
Expand All @@ -25,8 +23,8 @@ class OsuIconWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = isset($items[$delta]->value) ? $items[$delta]->value : '';
$size = isset($items[$delta]->size) ? $items[$delta]->size : '';
$value = $items[$delta]->value ?? '';
$size = $items[$delta]->size ?? '';
$element['value'] = [
'#type' => 'textfield',
'#title' => $this->t('Icon name'),
Expand Down

0 comments on commit d668c67

Please sign in to comment.