Problem/Motivation

BooleanItem is used for User->status, Node->published, etc.

However when creating a sample version, it is usually expected that the user not be blocked, that the node be published, etc.

Yet other Boolean fields should still be truly random in their samples.

Proposed resolution

Create a dedicated field type for 'status'.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

Wim Leers’s picture

Did you mean @DataType=status?

tim.plunkett’s picture

No, I mean @FieldType.
Alongside \Drupal\Core\Field\Plugin\Field\FieldType\BooleanItem

Because we specifically want to implement \Drupal\Core\Field\FieldItemInterface::generateSampleValue()

tim.plunkett’s picture

Status: Active » Needs review
FileSize
2.16 KB

Something like this

Status: Needs review » Needs work

The last submitted patch, 4: 2936864-status-4.patch, failed testing. View results

Wim Leers’s picture

Okay.

status is a very generic name. I don't think the user module should claim this. Either it should live outside user module, or it should be user_status, to allow contrib/custom and future core to provide a more generic @FieldType=status

Other than that, looks fine :)

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

> I don't think the user module should claim this. Either it should live outside user module

That already seems to be the case in the latest patch.

1.

-    $fields['status'] = BaseFieldDefinition::create('boolean')
+    $fields['status'] = BaseFieldDefinition::create('status')

Aren't we going to need some sort of an entity update to change the type of a field?

2.

Other entity types which do setClass(StatusItem::class); need updating too -- e.g. Taxonomy term.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

petiar’s picture

Within the #2945954: Split “blocked” status into “pending” and “locked-out” it is requested to split the Blocked user status into the Locked out and Pending, so we know exactly why is the user blocked. However, for this purpose the status field type plugin as proposed here would not be sufficient because of it's boolean base. Is it alright if I implement new field type plugin (user_status, as suggested above in this thread) for the User entity or was there an intention to create a status field type plugin which would be applicable for any entity type?