本文整理汇总了PHP中Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper::getExtendEntityProxyClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtendHelper::getExtendEntityProxyClassName方法的具体用法?PHP ExtendHelper::getExtendEntityProxyClassName怎么用?PHP ExtendHelper::getExtendEntityProxyClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper
的用法示例。
在下文中一共展示了ExtendHelper::getExtendEntityProxyClassName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateEntity
/**
* @param EntityConfigEvent $event
*/
public function updateEntity(EntityConfigEvent $event)
{
$className = $event->getClassName();
$parentClassName = get_parent_class($className);
if (!$parentClassName) {
return;
}
if (ExtendHelper::isExtendEntityProxy($parentClassName)) {
// When application is installed parent class will be replaced (via class_alias)
$extendClass = $parentClassName;
} else {
// During install parent class is not replaced (via class_alias)
$shortClassName = ExtendHelper::getShortClassName($className);
if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
return;
}
$extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
}
$configManager = $event->getConfigManager();
$config = $configManager->getProvider('extend')->getConfig($className);
$hasChanges = false;
if (!$config->is('is_extend')) {
$config->set('is_extend', true);
$hasChanges = true;
}
if (!$config->is('extend_class', $extendClass)) {
$config->set('extend_class', $extendClass);
$hasChanges = true;
}
if ($hasChanges) {
$configManager->persist($config);
}
}
示例2: updateEntityConfig
/**
* @param EntityConfigEvent $event
*/
public function updateEntityConfig(EntityConfigEvent $event)
{
$parentClassName = get_parent_class($event->getClassName());
if (!$parentClassName) {
return;
}
$shortClassName = ExtendHelper::getShortClassName($event->getClassName());
if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
return;
}
$config = $event->getConfigManager()->getProvider('extend')->getConfig($event->getClassName());
$hasChanges = false;
if (!$config->is('is_extend')) {
$config->set('is_extend', true);
$hasChanges = true;
}
$extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
if (!$config->is('extend_class', $extendClass)) {
$config->set('extend_class', $extendClass);
$hasChanges = true;
}
if ($hasChanges) {
$event->getConfigManager()->persist($config);
}
}
示例3: doExecute
/**
* @param LoggerInterface $logger
* @param bool $dryRun
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function doExecute(LoggerInterface $logger, $dryRun = false)
{
$configs = $this->loadConfigs($logger);
foreach ($configs as $id => $item) {
$data = $item['data'];
if (!isset($data['extend']['is_extend']) || !$data['extend']['is_extend']) {
continue;
}
if (empty($data['extend']['extend_class']) || empty($data['extend']['schema']['parent'])) {
continue;
}
$className = $item['class_name'];
if (ExtendHelper::isCustomEntity($className)) {
continue;
}
$parentClass = $data['extend']['schema']['parent'];
$oldExtendClass = $data['extend']['extend_class'];
$newExtendClass = ExtendHelper::getExtendEntityProxyClassName($parentClass);
if (!$newExtendClass || $newExtendClass === $oldExtendClass) {
continue;
}
$data['extend']['extend_class'] = $newExtendClass;
if (isset($data['extend']['schema']['entity'])) {
$data['extend']['schema']['entity'] = $newExtendClass;
}
if (isset($data['extend']['schema']['doctrine'][$oldExtendClass])) {
$data['extend']['schema']['doctrine'][$newExtendClass] = $data['extend']['schema']['doctrine'][$oldExtendClass];
unset($data['extend']['schema']['doctrine'][$oldExtendClass]);
}
$query = 'UPDATE oro_entity_config SET data = :data WHERE id = :id';
$params = ['data' => $data, 'id' => $id];
$types = ['data' => 'array', 'id' => 'integer'];
$logger->notice(sprintf('Change extend class from "%s" to "%s" for "%s".', $oldExtendClass, $newExtendClass, $className));
$this->logQuery($logger, $query, $params, $types);
if (!$dryRun) {
$this->connection->executeUpdate($query, $params, $types);
}
}
}
示例4: testGetExtendEntityProxyClassName
/**
* @dataProvider getExtendEntityProxyClassNameProvider
*/
public function testGetExtendEntityProxyClassName($className, $expected)
{
$this->assertEquals($expected, ExtendHelper::getExtendEntityProxyClassName($className));
}