Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new content authoring command: entity:create #5815

Merged
merged 11 commits into from
Feb 20, 2024
Merged

A new content authoring command: entity:create #5815

merged 11 commits into from
Feb 20, 2024

Conversation

weitzman
Copy link
Member

entity:create introduces a novel interaction pattern (inspired by git rebase --interactive). The user populates a yaml document in her text editor. The user may save the document at any time, which triggers entity validation if there are errors, they are reported as comments at the top of the document. The UX feels similar to the iterative cycle of submitting a web form, fixing validation errors, and re-submitting.

Notes:

  • Any field with "skip" as its value will ignore validation for that field.
  • YAML comments highlight required fields, and multiple value fields for easier data entry.
  • After a successful creation, the URL to the entity is presented.

Watch the video below. Feel free to pause as needed.

asciicast.

Create a content entity after prompting for field values.

When entering field values, one may submit an incomplete document and any entity violations
 will be helpfully reported at the top of the document. enter the string 'skip' as
 a value in order to skip validation for that field.

Examples:
 drush entity:create node article --validate=0 Create an article entity and skip validation entirely.
 drush entity:create user user              Create an article omitting a field.
--skip-fields=field_media_image
 drush entity:create user user --editor=nano   Create a user using the Nano text editor.

Arguments:
 entity_type An entity type name.
 bundle      A bundle name

Options:
 --validate[=VALIDATE]     Validate the entity before saving. [default: true]
 --uid=UID                 The entity author ID. Also used by permission checks (e.g. content moderation
 --skip-fields=SKIP-FIELDS A list of field names that skip both data entry and validation. Delimit fields by comma
 --editor=EDITOR           A string of bash which launches user's preferred text editor. Defaults to
                           ${VISUAL-${EDITOR-vi}}.
 --no-validate             Negate --validate option.

Aliases: econ, entity-create

@weitzman
Copy link
Member Author

weitzman commented Nov 22, 2023

@todo Integrate entity editing

@weitzman weitzman added this to the drush13 milestone Feb 4, 2024
@weitzman weitzman changed the base branch from 12.x to 13.x February 4, 2024 15:26
Copy link
Contributor

@DieterHolvoet DieterHolvoet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

src/Commands/core/EntityCreateCommands.php Outdated Show resolved Hide resolved
src/Commands/core/EntityCreateCommands.php Outdated Show resolved Hide resolved
weitzman and others added 6 commits February 4, 2024 11:08
Co-authored-by: Dieter Holvoet <dieter.holvoet@gmail.com>
Co-authored-by: Dieter Holvoet <dieter.holvoet@gmail.com>
@weitzman weitzman merged commit e2b455c into 13.x Feb 20, 2024
1 check passed
@weitzman weitzman deleted the entity-create branch February 20, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants