Skip to content

Commit

Permalink
Inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jun 28, 2022
1 parent e5d00ba commit aa621bc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/fields/Buttons.php
Expand Up @@ -8,6 +8,7 @@
use craft\fields\BaseOptionsField;
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use craft\helpers\Cp;
use craft\helpers\UrlHelper;

use yii\db\Schema;
Expand All @@ -25,7 +26,7 @@ public static function displayName(): string

// Properties
// =========================================================================

public ?bool $displayAsGraphic = null;
public ?bool $displayFullwidth = null;
public array $options = [];
Expand All @@ -39,7 +40,7 @@ public function getContentColumnType(): string
return Schema::TYPE_TEXT;
}

public function normalizeValue(mixed $value, ElementInterface $element = null): mixed
public function normalizeValue(mixed $value, ElementInterface $element = null): SingleOptionFieldData
{
if (!$value) {
$value = $this->defaultValue();
Expand Down
5 changes: 3 additions & 2 deletions src/fields/Colours.php
Expand Up @@ -8,6 +8,7 @@
use craft\fields\BaseOptionsField;
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use craft\helpers\Cp;

use yii\db\Schema;

Expand All @@ -24,7 +25,7 @@ public static function displayName(): string

// Properties
// =========================================================================

public array $options = [];


Expand Down Expand Up @@ -162,7 +163,7 @@ protected function translatedOptions(bool $encode = false): array
$translatedOptions = [];

foreach ($this->options as $option) {
$cssColour = strpos($option['cssColour'], '#') === false ? '#' . $option['cssColour'] : $option['cssColour'];
$cssColour = !str_contains($option['cssColour'], '#') ? '#' . $option['cssColour'] : $option['cssColour'];

$translatedOptions[] = [
'label' => Craft::t('site', $option['label']),
Expand Down
5 changes: 3 additions & 2 deletions src/fields/TextSize.php
Expand Up @@ -8,6 +8,7 @@
use craft\fields\BaseOptionsField;
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use craft\helpers\Cp;

use yii\db\Schema;

Expand Down Expand Up @@ -36,7 +37,7 @@ public function getContentColumnType(): string
return Schema::TYPE_TEXT;
}

public function normalizeValue(mixed $value, ElementInterface $element = null): mixed
public function normalizeValue(mixed $value, ElementInterface $element = null): SingleOptionFieldData
{
if (!$value) {
$value = $this->defaultValue();
Expand Down Expand Up @@ -85,7 +86,7 @@ public function getSettingsHtml(): ?string
'instructions' => Craft::t('buttonbox', 'Pixel Size is optional and should be a single number.'),
'id' => 'options',
'name' => 'options',
'addRowLabel' => Craft::t('buttonbox', 'Add an option'),
'addRowLabel' => Craft::t('buttonbox', 'Add an option'),
'cols' => [
'label' => [
'heading' => Craft::t('buttonbox', 'Option Label'),
Expand Down
5 changes: 3 additions & 2 deletions src/fields/Triggers.php
Expand Up @@ -6,6 +6,7 @@
use Craft;
use craft\base\ElementInterface;
use craft\fields\BaseOptionsField;
use craft\helpers\Cp;
use craft\helpers\UrlHelper;

class Triggers extends BaseOptionsField
Expand All @@ -26,11 +27,11 @@ public static function hasContentColumn(): bool

// Properties
// =========================================================================

public array $options = [];
public ?bool $displayAsGraphic = null;
public ?bool $displayFullwidth = null;


// Public Methods
// =========================================================================
Expand Down
3 changes: 2 additions & 1 deletion src/fields/Width.php
Expand Up @@ -8,6 +8,7 @@
use craft\fields\BaseOptionsField;
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use craft\helpers\Cp;

use yii\db\Schema;

Expand Down Expand Up @@ -36,7 +37,7 @@ public function getContentColumnType(): string
return Schema::TYPE_TEXT;
}

public function normalizeValue(mixed $value, ElementInterface $element = null): mixed
public function normalizeValue(mixed $value, ElementInterface $element = null): SingleOptionFieldData
{
if (!$value) {
$value = $this->defaultValue();
Expand Down

0 comments on commit aa621bc

Please sign in to comment.