Skip to content
Snippets Groups Projects

Add a 'Save and activate' action when creating a new workspace.

4 unresolved threads

Closes #3278377

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
47 47 }
48 48
49 /**
50 * Creates and activates a new Workspace through the UI.
51 *
52 * @param string $label
53 * The label of the workspace to create.
54 * @param string $id
55 * The ID of the workspace to create.
56 * @param string $parent
57 * (optional) The ID of the parent workspace. Defaults to '_none'.
58 *
59 * @return \Drupal\workspaces\WorkspaceInterface
60 * The workspace that was just created.
61 */
62 protected function createAndActivateWorkspaceThroughUi($label, $id, $parent = '_none') {
  • 120 95 parent::flagViolations($violations, $form, $form_state);
    121 96 }
    122 97
    98 /**
    99 * {@inheritdoc}
    100 */
    101 protected function actions(array $form, FormStateInterface $form_state) {
  • 49 }
    27 protected WorkspaceManagerInterface $workspaceManager;
    50 28
    51 29 /**
    52 30 * {@inheritdoc}
    53 31 */
    54 32 public static function create(ContainerInterface $container) {
    55 return new static(
    56 $container->get('entity.repository'),
    57 $container->get('messenger'),
    58 $container->get('entity_type.bundle.info'),
    59 $container->get('datetime.time')
    60 );
    33 $instance = parent::create($container);
    34 $instance->workspaceManager = $container->get('workspaces.manager');
    35 return $instance;
    • Interesting that we don't need the __construct() but solution appears to work

    • Maintainer

      Haven't seen us do this anywhere else. On the one hand it removes a tonne of boilerplate, on the other it means it's not possible to instantiate the class directly from the constructor any more, but also does that matter given it's a form.

    • Please register or sign in to reply
  • 120 95 parent::flagViolations($violations, $form, $form_state);
    121 96 }
    122 97
    98 /**
    99 * {@inheritdoc}
    100 */
    101 protected function actions(array $form, FormStateInterface $form_state) {
  • added 1 commit

    • 6f61fb4f - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • 29bbce33 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Please register or sign in to reply
    Loading