Skip to content

[make:crud] Rename add method of repository to save. #1169

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

Closed
wants to merge 14 commits into from

Conversation

bdaler
Copy link
Contributor

@bdaler bdaler commented Aug 20, 2022

bdaler and others added 7 commits August 20, 2022 17:11
This PR was merged into the 1.0-dev branch.

Discussion
----------

Add `make:twig-component` maker

Adds a maker for `symfony/ux-twig-component`/`symfony/ux-live-component`.

**Creating a _standard_ twig component:**

```bash
bin/console make:twig-component

 The name of your twig component (ie NotificationComponent):
 > Notification

 Make this a live component? (yes/no) [no]: # (defaults to yes if symfony/ux-live-component installed)
 > no

 created: src/Twig/Components/NotificationComponent.php
 created: templates/components/notification.html.twig

  Success!
```

```php
// src/Twig/Components/NotificationComponent.php

<?php

namespace App\Twig\Components;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent('notification')]
final class NotificationComponent
{
}
```

```twig
{# templates/components/notification.html.twig #}

<div{{ attributes }}>
    <!-- component html -->
</div>
```

---

**Creating a _live_ twig component:**

```bash
bin/console make:twig-component --live # fails if symfony/ux-live-component is not installed

 The name of your twig component (ie NotificationComponent):
 > Notification

 created: src/Twig/Components/NotificationComponent.php
 created: templates/components/notification.html.twig

  Success!
```

```php
// src/Twig/Components/NotificationComponent.php

<?php

namespace App\Twig\Components;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent('notification')]
final class NotificationComponent
{
    use DefaultActionTrait;
}
```

```twig
{# templates/components/notification.html.twig #}

<div{{ attributes }}>
    <!-- component html -->
</div>
```

Ref: symfony/ux#108

Commits
-------

acde364 add make:twig-component maker
@jrushlow
Copy link
Collaborator

@bdaler I just merged in a few CI fixes, can you do a rebase please?

@jrushlow jrushlow added the Feature New Feature label Sep 20, 2022
Copy link
Collaborator

@jrushlow jrushlow 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 to me, we just need passing tests that are related to this PR.

@jrushlow jrushlow added the Status: Reviewed Has been reviewed by a maintainer label Sep 20, 2022
@weaverryan
Copy link
Member

Ping @garak who originally proposed the methods in #788. I don't really care what the methods are called - but I don't like changing them over and over again. So if we are going to make this change, we need some agreement that this is how it should be named.

@garak
Copy link

garak commented Sep 22, 2022

IMHO "add" is more consistent with the concept of collection, but I don't have anything against "save"

@jrushlow
Copy link
Collaborator

The commit history looks a bit mashed up in this PR. Closing in favor of #1204 which contains cherry-picked changes from this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants