Files
pcm-metadata-bundle/README.md
2025-11-27 15:52:44 +00:00

751 B

PCM Metadata Bundle

Easily add scalar metadata to a Symfony entity via the use of a key-value interface.

Usage

  1. Use the MetadataTrait inside an entity:
class MyEntity
{
    use MetadataTrait;
}
  1. Create and execute a new migration. The trait adds a metadata database field and as such we need to create a migration.
  2. Access the metadata object with the readonly property metadata:
$entity->metadata->set("name", "PCM");
$entity->metadata->get("name"); // "PCM"
$entity->metadata->isSet("name"); // true

Like updating the value of a property normally, setting metadata values will not automatically update the database. You must call flush() from the EntityManager as usual when you wish to persist data.