{"id":18773119,"url":"https://github.com/webfactory/content-mapping","last_synced_at":"2025-04-13T09:07:21.631Z","repository":{"id":35683980,"uuid":"39960077","full_name":"webfactory/content-mapping","owner":"webfactory","description":"Mini framework for mapping content from a source to a destination system, e.g. from Propel objects to Solr or from Doctrine entities to ElasticSearch.","archived":false,"fork":false,"pushed_at":"2025-02-11T12:12:42.000Z","size":189,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-13T09:07:16.209Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webfactory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-07-30T16:16:33.000Z","updated_at":"2025-02-11T12:11:55.000Z","dependencies_parsed_at":"2024-04-15T09:41:36.740Z","dependency_job_id":"5e81ad1b-5629-4d0f-9394-83d03e28274b","html_url":"https://github.com/webfactory/content-mapping","commit_stats":{"total_commits":94,"total_committers":6,"mean_commits":"15.666666666666666","dds":"0.46808510638297873","last_synced_commit":"eb49593e519277f72b67e703390ce19261b7f1f8"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2Fcontent-mapping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2Fcontent-mapping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2Fcontent-mapping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2Fcontent-mapping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webfactory","download_url":"https://codeload.github.com/webfactory/content-mapping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688568,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T19:32:54.064Z","updated_at":"2025-04-13T09:07:21.610Z","avatar_url":"https://github.com/webfactory.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `content-mapping`\n\n`content-mapping` is a mini framework for mapping content from a source to a destination system. E.g. from Propel objects\nto Solr, from Doctrine entities to ElasticSearch or from one XML structure to another. It features interfaces to guide\nyou on your mapping way and ships with some abstract implementation helpers or magic implementations.\n\nIn easy situations, you may want to consider other libraries instead. E.g. if in a Symfony2 project you want to index\nDoctrine entities in a Solr server, you may want to consider the great [floriansemm/solr-bundle](/floriansemm/SolrBundle).\nBut that and other libraries have shortcomings in more complex situation, e.g. when you want to index attributes of\nrelated entities. That's why we present you content-mapping with a more general approach.\n\n\n## Installation\n\nAdd the content-mapping dependency by running the command (see http://getcomposer.org/):\n\n    php composer.phar require webfactory/content-mapping\n\nand run\n\n    php composer.phar install\n\n## Concept\n\n![Class diagram](doc/class-diagram.png)\n\nThe content-mapping process is based on four parts: the `Synchronizer`, a ``SourceAdapter``, a ``Mapper`` and a\n``DestinationAdapter``. The entry point is ``Synchronizer-\u003esynchronize()``: there, the Synchronizer gets an Iterator\nfrom the ``SourceAdapter-\u003egetObjectsOrderedById()`` as well as an Iterator from the\n``DestinationAdapter-\u003egetObjectsOrderedById()``, and compares the objects in each one. During the comparison, it deletes\noutdated objects (``DestinationAdapter-\u003edelete()``), stores a new objects (``DestinationAdapter-\u003ecreateObject()``) and\nupdates existing objects in the destination system (``Mapper-\u003emap()``).\n \n``DestinationAdapter-\u003eupdated()`` and ``DestinationAdapter-\u003ecommit()`` are only hooks for external change tracking, to\nsay an object has been updated or both Iterators have been processed, i.e. changes can be persisted.\n\n\n## Usage\n\nTo construct a ``Synchronizer``, you need implementations for the ``SourceAdaper``, ``Mapper`` and\n``DestinationAdapter``. Please find abstract templates and ready-to-use generic implementations of SourceAdapters and\nDestinationAdapters in the [webfactory/content-mapping-*](https://github.com/search?q=webfactory%2Fcontent-mapping)\npackages. The Mapper usually is very specific for your project, so you probably want to implement it in your\napplication.\n\n```php\nuse Webfactory\\ContentMapping\\Synchronizer;\nuse Webfactory\\ContentMapping\\SourceAdapter\\Propel\\GenericPropelSourceAdapter;\n\n$sourceAdapter = ...; // see the readme of the corresponding package on how to construct it\n$mapper = ...; // construct your own implementation\n$destinationAdapter = ...; // see the readme of the corresponding package on how to construct it\n$logger = ...; // just a PSR-3 logger\n\n$classNameToSynchronize = 'MyClass';\n$force = false; // if true, objects in destination system will be updated even if no changes are detected\n\n$synchronizer = new Synchronizer($sourceAdapter, $mapper, $destinationAdapter, $logger);\n$synchronizer-\u003esynchronize($classNameToSynchronize, $force);\n```\n\n\n## Credits, Copyright and License\n\nThis project was started at webfactory GmbH, Bonn.\n\n- \u003chttps://www.webfactory.de\u003e\n- \u003chttps://twitter.com/webfactory\u003e\n\nCopyright 2015-2022 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfactory%2Fcontent-mapping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfactory%2Fcontent-mapping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfactory%2Fcontent-mapping/lists"}