Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Demonstration on PostLoad listeners not being triggered when loading entities via reference

NotificationsYou must be signed in to change notification settings

webfactory/test-doctrine-postload-event-loading-reference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

This application requires an executable filebin/php that loads the correct PHP binary (as generated by our internaltoolphlough onphlough install).

First, install dependencies and create a new database with the correct schema (will create an SQLite database in ./tmp)

composer installbin/doctrine orm:schema-tool:create

Create an Entity and load it normally

bin/create-new-entity# assume it creates an entity with id 1bin/load-entity 1# Output should contain: PostLoad EventListener called for Entity\Test#1

Load the same entity by reference and access a property to trigger initialisation

bin/load-entity-by-reference-and-access-proprty 1# Output will NOT contain: PostLoad EventListener called

Explanation

When loading entities by first retrieving a reference and then letting it initialise, Doctrine does not trigger PostLoadevents. This happens neither if Doctrine implements the reference as a Proxy (Doctrine < 4.0 default behaviour)nor ifit uses a "ghost object" (EntityManager created with$config->enableNativeLazyObjects(true);, PHP >=8.4) this has notbeen tested yet.

If you depend on the PostLoad event to perform some initialisation logic (e.g. loading binary data into properties),this can lead to incomplete entity objects being used.

About

Demonstration on PostLoad listeners not being triggered when loading entities via reference

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp