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

[WIP] Implemented model observers #50

Merged
merged 5 commits into from
Mar 7, 2017
Merged

[WIP] Implemented model observers #50

merged 5 commits into from
Mar 7, 2017

Conversation

wouterj
Copy link
Owner

@wouterj wouterj commented Mar 5, 2017

/fixes #6, #42

Todo

  • Allow observers to be services
  • Docs

/** @dataProvider getEventsData */
public function testEvents($setup, $execute, array $expectedEvents)
{
ob_start();
Copy link
Contributor

Choose a reason for hiding this comment

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

is it necessary?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nope, just back from a holiday and my brain isn't thinking 100% straight yet ;) Used a better technique now.

@wouterj
Copy link
Owner Author

wouterj commented Mar 6, 2017

Ready to merge imo. Will wait for a day or 2 before merging and releasing 0.4.0. If anyone has some time to review, please do.

Copy link
Contributor

@theofidry theofidry left a comment

Choose a reason for hiding this comment

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

Nice one!

I left a few comments. Besides that WDYT of making those classes final? I think it's better to have everything as final by default.

{
public function boot()
{
User::observer('app.user_observer');
Copy link
Contributor

Choose a reason for hiding this comment

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

if the observers are registered as services, wouldn't it be possible to avoid that step to the user?

Copy link
Owner Author

Choose a reason for hiding this comment

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

At first, I thought: Awesome idea!

However it turns out it's quite a bit harder than you think. So I created a new issue for it: #52

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair, I'll try to have a look at the end of the week, I don't recall when what is booted and when to be booted

private $symfonyContainer;
private $observers;

public function __construct(ContainerInterface $symfonyContainer, array $observers)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing typehint

Copy link
Owner Author

Choose a reason for hiding this comment

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

What do you mean? I can't typehint array any more specific, right?

/**
* @author Wouter J <wouter@wouterj.nl>
*/
class Events_ClassTest extends EventsTest
Copy link
Contributor

Choose a reason for hiding this comment

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

why the partial snake case here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, a bit weird personal convention :) Will remove the _

/**
* @author Wouter J <wouter@wouterj.nl>
*/
class Events_ServiceTest extends EventsTest
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well

@wouterj
Copy link
Owner Author

wouterj commented Mar 6, 2017

I left a few comments. Besides that WDYT of making those classes final? I think it's better to have everything as final by default.

I would agree with tagging everything @final, but I'm not in favor of marking them final in PHP. I don't think I should enforce people not to extend them, but I can tell them I don't help/support them if they do :)

@theofidry
Copy link
Contributor

theofidry commented Mar 6, 2017 via email

@wouterj
Copy link
Owner Author

wouterj commented Mar 6, 2017

I don't think the PHPdoc will explain more than the method signature. I'll add all finals in a follow up PR after merging this one.

Thanks for your review!

@theofidry
Copy link
Contributor

You're welcome. Do you have any ETA for a stable release or a beta/RC? Not urgent but I would prefer this lib to be somewhat stable when releasing the stable version of https://github.com/theofidry/AliceDataFixtures.

@wouterj
Copy link
Owner Author

wouterj commented Mar 6, 2017

@theofidry I'm hoping to release 0.4 stable this week. After that, I only have "nice to have" features left in the issue list afaics. So that means 0.5 might as well become 1.0. I'm not sure when I'll release 0.5/1.0, but it shouldn't take that long as there aren't much things left (other than Laravel 5.4 support).

The 0.x versions are already quite stable though.

@wouterj wouterj merged commit 919df81 into master Mar 7, 2017
@wouterj wouterj deleted the issue-6/events branch March 7, 2017 13:45
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.

Integrate model events
2 participants