Urgent.News

What's breaking now, across thousands of outlets.

Tech

PersistentCollection on Doctrine ORM in Symfony

While working on my Modular ERP SystemBundle (the bundle that is responsible to display admin panel and dashboards), I thought that on Doctrine Entities ManyToOne Collections where simple arrays. It was very naive of me considering that I wrote a code that returned a Collection earlier. It seems that when an entity relationship object is fetched, all the objects are not fetched at all. Only a…

In the Modular ERP SystemBundle, a Doctrine Entities ManyToOne Collection was initially perceived as a simple array. However, this proved to be a naive assumption. Upon further investigation, it was discovered that when an entity relationship object is fetched, only a reference to the Collection (ArrayCollection, similar to an array) is delivered to further code manipulation.

This is where PersistentCollection comes into play, which is a lazy collection of elements that has the ability to get initialized (object loaded) and get its snapshot (array of its objects).

The lazy behavior was observed while attempting to get the snapshot of the object using the getSnapshot() function, which returned an empty array. However, when the initialize() method was called first, followed by the getSnapshot() method, the array was populated with the entities of the collection. This behavior is attributed to the initialize() method invoking the EntityManager to retrieve the details from the database.

The PersistentCollection class contains three main methods: initialize(), takeSnapshot(), and getSnapshot(). The initialize() method loads the collection from the database if it has not been initialized yet and if there are new objects added through the add() method. The takeSnapshot() method creates a snapshot of the collection, storing it in the $snapshot property and setting the $isDirty flag to false. Finally, the getSnapshot() method returns the snapshot of the collection.

Despite the curiosity surrounding how the EntityManager class works, particularly the line $this->em->getUnitOfWork()->loadCollection($this), this information is not crucial at the moment.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Mercator Maps Lie: Building 84 Equal-Area 3D Countries & 247 Orthographic Models in Vanilla JS

Most online size comparison games rely on flat black silhouettes—and when they compare countries, they often inherit Web Mercator distortion that makes Greenland look as large as Africa (even though…

  • Created 247 verified 3D models with Lambert Azimuthal Equal-Area projection
  • Calculated fillRatio for accurate comparison of irregular map shapes
  • Implemented symmetric logarithmic scoring for unbiased error measurement

Somebody did their own Tinkercad

Somebody looked at Tinkercad and wanted that same shape-based way of building parts — drag a box onto a workplane, stretch it, punch a hole, group it — but on their own computer, with no account and…

  • DJMcNewgent created DabbleCAD as independent desktop app
  • Combines 3D modeling, shape drawing, and part generation tools
  • Released publicly on 19 November 2026 under Apache-2.0 license

Core ML Concepts for Developers: Datasets, Cleaning, Leak-Free Splits, sklearn Pipelines & Evaluation (LightGBM)

Most "ML basics" articles teach you to call model.fit(X, y) and pretend that's the job. The actual job — where 80% of your time goes and 100% of the mistakes happen — is everything around fit…

  • Dataset, cleaning, and evaluation are core ML concepts, not just model.fit(X, y)
  • sklearn's Pipeline and ColumnTransformer prevent data leakage during preprocessing
  • Time-series and group-aware CV avoid misleadingly high scores during validation

把自建文件浏览器装成 Android APK:只有 64 位,而这一点很要命

如果你一天要打开手机上那个下载文件夹五次,问题不在服务器,而在那个文件夹住在浏览器标签页里:手势一划标签就没了,刷新就忘了上次看到哪,地址栏还吃掉半屏。 Banyan 是一个用 Go 单二进制 发布的自建文件浏览器。一个文件、不用 Docker、不用数据库。同一个二进制既在局域网里跑网页界面,也在同一个页面给你下载 Android APK。但有个条件比别的都更浪费时间: APK 只支持 arm64…

More from Friday 20 November →