2025-12-12 12:12:07 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 14:37:29 +00:00
2025-12-12 12:12:07 +00:00
2025-11-27 15:17:22 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 14:59:45 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 14:37:29 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 13:22:07 +00:00
2025-11-27 16:02:46 +00:00

PCM Metadata Bundle

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

Installation

  1. Add this repository to composer.json:
"repositories": [
    {
        "type": "vcs",
        "url": "ssh://git@git.pcmdev.co.uk:2222/pcm-libraries/pcm-metadata-bundle.git"
    }
],
  1. Install the bundle:
composer require pcm/metadata-bundle
  1. If not set already add the following config to doctrine.yaml to prevent errors:
doctrine:
    orm:
        enable_native_lazy_objects: true

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.

Description
Add metadata to a Symfony entity.
Readme MIT 60 KiB
Languages
PHP 81.4%
Shell 11.4%
Makefile 5.6%
Dockerfile 1.6%