Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Default event handlers are registered lazily on first call to event() #39

Merged
merged 1 commit into from
Mar 18, 2013

Conversation

lox
Copy link
Owner

@lox lox commented Mar 18, 2013

As mentioned in bug #30, the default event handlers weren't being created for objects created by DomainObject::fromArray.

The fix is to simply register them lazily, right after the first call to DomainObject::events(), which is the gateway for the Events object.

$builder = new \Pheasant\SchemaBuilder();
$initializer = $callback ? $callback : array($subject, 'initialize');
$initializer = $callback ? $callback : $class.'::initialize';
Copy link
Owner Author

Choose a reason for hiding this comment

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

I wasn't sure why this was done in the first place. The initialize method should be static, creating an instance just to call the method seems wasteful and can cause infinite loops if fromArray calls initialize.

lox added a commit that referenced this pull request Mar 18, 2013
Default event handlers are registered lazily on first call to event()
@lox lox merged commit 492fba2 into master Mar 18, 2013
@bjornpost bjornpost deleted the lazy-eventhandler-creation branch April 27, 2015 14:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant