Skip to content

Commit

Permalink
make php 8.1 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed May 13, 2022
1 parent 3eeb12b commit 319231b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Read-only Field Changelog

## Unreleased
## 1.0.2 - 2022-05-13

### Added

- Make the field sortable.
- Make php 8.1 compatible.

### Changed

- Fixed background color of icon

## 1.0.1 - 2019-09-14

### Added

- Support for Feed-Me plugin

## 1.0.0 - 2019-04-06

### Added

- Initial release
9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codemonauts/craft-readonly-field",
"description": "Craft CMS plugin to add a simple, read-only plaintext field.",
"version": "1.0.1",
"version": "1.0.2",
"type": "craft-plugin",
"keywords": [
"craft",
Expand Down Expand Up @@ -33,10 +33,7 @@
},
"extra": {
"handle": "readonly",
"class": "codemonauts\\readonly\\Readonly",
"name": "Read-only Field",
"description": "Simple, read-only plaintext field.",
"hasCpSection": false,
"hasSettings": false
"class": "codemonauts\\readonly\\ReadonlyPlugin",
"name": "Read-only Field"
}
}
8 changes: 5 additions & 3 deletions src/Readonly.php → src/ReadonlyPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
use craft\events\RegisterComponentTypesEvent;
use craft\services\Fields;
use yii\base\Event;
use codemonauts\readonly\fields\Readonly as ReadonlyField;
use codemonauts\readonly\feedme\Readonly as ReadonlyFeedme;
use codemonauts\readonly\fields\ReadonlyField;
use codemonauts\readonly\feedme\ReadonlyField as ReadonlyFeedme;
use craft\feedme\events\RegisterFeedMeFieldsEvent;
use craft\feedme\services\Fields as FeedMeFields;

class Readonly extends Plugin
class ReadonlyPlugin extends Plugin
{
public $schemaVersion = '1.0.1';

public function init()
{
parent::init();
Expand Down
4 changes: 2 additions & 2 deletions src/feedme/Readonly.php → src/feedme/ReadonlyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use craft\feedme\base\Field;
use craft\feedme\base\FieldInterface;

class Readonly extends Field implements FieldInterface
class ReadonlyField extends Field implements FieldInterface
{
public static $name = 'Read-only Field';
public static $class = 'codemonauts\readonly\fields\Readonly';
public static $class = 'codemonauts\readonly\fields\ReadonlyField';

public function getMappingTemplate(): string
{
Expand Down
3 changes: 2 additions & 1 deletion src/fields/Readonly.php → src/fields/ReadonlyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
use craft\base\ElementInterface;
use craft\base\Field;
use craft\base\PreviewableFieldInterface;
use craft\base\SortableFieldInterface;
use LitEmoji\LitEmoji;
use yii\db\Schema;

class Readonly extends Field implements PreviewableFieldInterface
class ReadonlyField extends Field implements PreviewableFieldInterface, SortableFieldInterface
{
/**
* @var string The type of database column the field should have in the content table
Expand Down
33 changes: 33 additions & 0 deletions src/migrations/m220429_104217_change_class_name.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace codemonauts\readonly\migrations;

use craft\db\Migration;
use craft\db\Table;

/**
* m220429_104217_change_class_name migration.
*/
class m220429_104217_change_class_name extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
$this->getDb()->createCommand()
->update(Table::FIELDS, ['type' => 'codemonauts\readonly\fields\ReadonlyField'], ['type' => 'codemonauts\readonly\fields\Readonly'])
->execute();

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
echo "m220429_104217_change_class_name cannot be reverted.\n";
return false;
}
}

0 comments on commit 319231b

Please sign in to comment.