在WordPress中,插件是作为其他WordPress用户的安装包创建和分发的。Doctrine 2 ORM和WordPress - 集中化多个相关应用程序的Doctrine管理
我创建的每个插件在核心插件中共享某些常见实体。我正在努力创建和管理在这些插件中使用的EntitiyManager
。
我已经想出了两种方法来实现这一点,并想继续之前听到一些反馈:
选项1:单一的全球性的EntityManager
// Example Plugin
// Unique Entities
// Add Unique Entity Paths and REQUIRED Entity Paths from Core Entities to EntityManager
// Example Plugin
// Unique Entities
// Add Unique Entity Paths and REQUIRED Entity Paths from Core Entities to EntityManager
// Core Plugin
// Core Entities
// Contains EntityManager
与此问题版本是,虽然为路径添加到MetadataDriver
道:
$entityManager->getConfig()->getMetadataDriverImpl()->addPaths();
我不确定这是否会实际更新此EntityManager
的config
内的MetadataDriver
。我担心的是,这只会返回已更新为新路径的config
,而不会更新EntityManager
的配置。
这是真的吗?
注意,没有setConfig
功能,所以如果是这样,我将不得不重新从每个插件EntityManager
,击败的集中EntityManager
目的。
选项2:多EntityManagers
// Example Plugin
// Unique Entities
// Create EntityManager with Unique Entity path and path to Core Entities that are required for this plugin.
// Core Plugin
// Core Entities
这种实现的问题是,它似乎效率不高。我注意到WordPress有一个Doctrine插件,虽然它是Doctrine 1.2.3,它允许你有一个集中的地方,因为我认为它适合于管理像核心实体那样共享资源的应用程序。
对于这种情况下使用Doctrine有什么想法。有没有办法集中操作,以便通过其他人依赖的一个中央插件来管理ORM?