当前位置: 首页>>代码示例>>PHP>>正文


PHP ExtendHelper::buildAssociationName方法代码示例

本文整理汇总了PHP中Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper::buildAssociationName方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtendHelper::buildAssociationName方法的具体用法?PHP ExtendHelper::buildAssociationName怎么用?PHP ExtendHelper::buildAssociationName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper的用法示例。


在下文中一共展示了ExtendHelper::buildAssociationName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAssociationTableName

 /**
  * Gets a table name for many-to-many relation
  *
  * @param string $activityTableName Activity entity table name. It is owning side of the association.
  * @param string $targetTableName   Target entity table name.
  *
  * @return string
  */
 public function getAssociationTableName($activityTableName, $targetTableName)
 {
     $sourceClassName = $this->extendExtension->getEntityClassByTableName($activityTableName);
     $targetClassName = $this->extendExtension->getEntityClassByTableName($targetTableName);
     $associationName = ExtendHelper::buildAssociationName($targetClassName, ActivityScope::ASSOCIATION_KIND);
     return $this->nameGenerator->generateManyToManyJoinTableName($sourceClassName, $associationName, $targetClassName);
 }
开发者ID:woei66,项目名称:platform,代码行数:15,代码来源:ActivityExtension.php

示例2: runActivityLists

 /**
  * @param LoggerInterface $logger
  * @param bool            $dryRun
  */
 protected function runActivityLists(LoggerInterface $logger, $dryRun = false)
 {
     // @todo: this workaround should be removed in BAP-9156
     $this->configManager->clear();
     $targetEntities = $this->provider->getTargetEntityClasses(false);
     $toSchema = clone $this->schema;
     $hasSchemaChanges = false;
     foreach ($targetEntities as $targetEntity) {
         $associationName = ExtendHelper::buildAssociationName($targetEntity, ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
         $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName(ActivityListEntityConfigDumperExtension::ENTITY_CLASS, $associationName, $targetEntity);
         if (!$toSchema->hasTable($relationTableName)) {
             $hasSchemaChanges = true;
             $this->activityListExtension->addActivityListAssociation($toSchema, $this->metadataHelper->getTableNameByEntityClass($targetEntity));
         }
     }
     if ($hasSchemaChanges) {
         $comparator = new Comparator();
         $platform = $this->connection->getDatabasePlatform();
         $schemaDiff = $comparator->compare($this->schema, $toSchema);
         $queries = $schemaDiff->toSql($platform);
         foreach ($queries as $query) {
             $this->logQuery($logger, $query);
             if (!$dryRun) {
                 $this->connection->executeQuery($query);
             }
         }
     }
 }
开发者ID:woei66,项目名称:platform,代码行数:32,代码来源:ActivityListMigrationQuery.php

示例3: getBaseAssociatedNotesQB

 /**
  * @param $entityClassName
  * @param $entityId
  * @return QueryBuilder
  */
 public function getBaseAssociatedNotesQB($entityClassName, $entityId)
 {
     $ids = is_array($entityId) ? $entityId : [$entityId];
     $queryBuilder = $this->createQueryBuilder('note')->innerJoin($entityClassName, 'e', 'WITH', sprintf('note.%s = e', ExtendHelper::buildAssociationName($entityClassName)));
     $queryBuilder->where($queryBuilder->expr()->in('e.id', $ids));
     return $queryBuilder;
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:NoteRepository.php

示例4: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName('Oro\\Bundle\\EmailBundle\\Entity\\Email', ExtendHelper::buildAssociationName('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer', ActivityScope::ASSOCIATION_KIND), 'OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer');
     if (!$schema->hasTable($relationTableName)) {
         $this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_sales_b2bcustomer');
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:10,代码来源:OroCRMSalesBundle.php

示例5: isAttachmentAssociationEnabled

 /**
  * Checks if the entity can has notes
  *
  * @param object $entity
  * @return bool
  */
 public function isAttachmentAssociationEnabled($entity)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->attachmentConfigProvider->hasConfig($className) && $this->attachmentConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(AttachmentScope::ATTACHMENT, ExtendHelper::buildAssociationName($className));
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:AttachmentConfig.php

示例6: isAttachmentAssociationAccessible

 /**
  * Check if an association between a given entity type and attachments is ready to be used in a business logic.
  * It means that the association should exist and should not be marked as deleted.
  *
  * @param string $entityClass The target entity class
  *
  * @return bool
  */
 protected function isAttachmentAssociationAccessible($entityClass)
 {
     $associationName = ExtendHelper::buildAssociationName($entityClass);
     if (!$this->configManager->hasConfig(self::ATTACHMENT_ENTITY, $associationName)) {
         return false;
     }
     return ExtendHelper::isFieldAccessible($this->configManager->getFieldConfig('extend', self::ATTACHMENT_ENTITY, $associationName));
 }
开发者ID:snorchel,项目名称:platform,代码行数:16,代码来源:AttachmentAssociationHelper.php

示例7: isApplicable

 /**
  * Checks if the entity can have comments
  *
  * @param object|null $entity
  *
  * @return bool
  */
 public function isApplicable($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || !$this->securityFacade->isGranted('oro_comment_view')) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->commentConfigProvider->hasConfig($className) && $this->commentConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(Comment::ENTITY_NAME, ExtendHelper::buildAssociationName($className));
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:CommentPlaceholderFilter.php

示例8: isNoteAssociationEnabled

 /**
  * Checks if the entity can has notes
  *
  * @param object $entity
  * @return bool
  */
 public function isNoteAssociationEnabled($entity)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->noteConfigProvider->hasConfig($className) && $this->noteConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(Note::ENTITY_NAME, ExtendHelper::buildAssociationName($className));
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:PlaceholderFilter.php

示例9: isActivityAssociationAccessible

 /**
  * Check if an association between a given entity type and activity type is ready to be used in a business logic.
  * It means that the association should exist and should not be marked as deleted.
  *
  * @param string $entityClass   The target entity class
  * @param string $activityClass The activity entity class
  *
  * @return bool
  */
 protected function isActivityAssociationAccessible($entityClass, $activityClass)
 {
     $associationName = ExtendHelper::buildAssociationName($entityClass, ActivityScope::ASSOCIATION_KIND);
     if (!$this->configManager->hasConfig($activityClass, $associationName)) {
         return false;
     }
     return ExtendHelper::isFieldAccessible($this->configManager->getFieldConfig('extend', $activityClass, $associationName));
 }
开发者ID:woei66,项目名称:platform,代码行数:17,代码来源:ActivityAssociationHelper.php

示例10: testIsNoteAssociationEnabled

 public function testIsNoteAssociationEnabled()
 {
     $config = new Config(new EntityConfigId('note', static::TEST_ENTITY_REFERENCE));
     $config->set('enabled', true);
     $this->noteConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
     $this->noteConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
     $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Note::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true));
     $this->assertTrue($this->filter->isNoteAssociationEnabled(new TestEntity(1)));
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:PlaceholderFilterTest.php

示例11: testIsAttachmentAssociationEnabled

 public function testIsAttachmentAssociationEnabled()
 {
     $config = new Config(new EntityConfigId('attachment', 'stdClass'));
     $config->set('enabled', true);
     $this->attachmentConfigProvider->expects($this->once())->method('hasConfig')->with('stdClass')->will($this->returnValue(true));
     $this->attachmentConfigProvider->expects($this->once())->method('getConfig')->with('stdClass')->will($this->returnValue($config));
     $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(AttachmentScope::ATTACHMENT, ExtendHelper::buildAssociationName('stdClass'))->will($this->returnValue(true));
     $this->assertTrue($this->filter->isAttachmentAssociationEnabled(new \stdClass()));
 }
开发者ID:xamin123,项目名称:platform,代码行数:9,代码来源:PlaceholderFilterTest.php

示例12: testGenerate

 public function testGenerate()
 {
     $schema = ['relationData' => [['field_id' => new FieldConfigId('extend', 'Test\\Entity', ExtendHelper::buildAssociationName('Test\\TargetEntity1', ActivityScope::ASSOCIATION_KIND), 'manyToMany'), 'target_entity' => 'Test\\TargetEntity1'], ['field_id' => new FieldConfigId('extend', 'Test\\Entity', ExtendHelper::buildAssociationName('Test\\TargetEntity2', ActivityScope::ASSOCIATION_KIND), 'manyToMany'), 'target_entity' => 'Test\\TargetEntity2'], ['field_id' => new FieldConfigId('extend', 'Test\\Entity', ExtendHelper::buildAssociationName('Test\\TargetEntity3', ActivityScope::ASSOCIATION_KIND), 'manyToOne'), 'target_entity' => 'Test\\TargetEntity3'], ['field_id' => new FieldConfigId('extend', 'Test\\Entity', 'testField', 'manyToMany'), 'target_entity' => 'Test\\TargetEntity4']]];
     $class = PhpClass::create('Test\\Entity');
     $this->extension->generate($schema, $class);
     $strategy = new DefaultGeneratorStrategy();
     $classBody = $strategy->generate($class);
     $expectedBody = file_get_contents(__DIR__ . '/Fixtures/generationResult.txt');
     $this->assertEquals(trim($expectedBody), $classBody);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:ActivityEntityGeneratorExtensionTest.php

示例13: testIsApplicable

 public function testIsApplicable()
 {
     $config = new Config(new EntityConfigId('comment', static::TEST_ENTITY_REFERENCE));
     $config->set('enabled', true);
     $this->securityFacade->expects($this->once())->method('isGranted')->with('oro_comment_view')->willReturn(true);
     $this->commentConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
     $this->commentConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
     $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Comment::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true));
     $this->assertTrue($this->filter->isApplicable(new TestEntity()));
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:CommentPlaceholderTest.php

示例14: addIdentifierAssociation

 /**
  * Adds the association between the target table and the visit table
  *
  * @param Schema $schema
  * @param string $targetTableName  Target entity table name
  * @param string $targetColumnName A column name is used to show related entity
  */
 public function addIdentifierAssociation(Schema $schema, $targetTableName, $targetColumnName = null)
 {
     $visitTable = $schema->getTable(self::VISIT_TABLE_NAME);
     $targetTable = $schema->getTable($targetTableName);
     if (empty($targetColumnName)) {
         $primaryKeyColumns = $targetTable->getPrimaryKeyColumns();
         $targetColumnName = array_shift($primaryKeyColumns);
     }
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), self::ASSOCIATION_KIND);
     $this->extendExtension->addManyToOneRelation($schema, $visitTable, $associationName, $targetTable, $targetColumnName);
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:IdentifierEventExtension.php

示例15: getAssociatedNotesQueryBuilder

 /**
  * @param string   $entityClassName
  * @param mixed    $entityId
  * @param int|null $page
  * @param int|null $limit
  *
  * @return QueryBuilder
  */
 public function getAssociatedNotesQueryBuilder($entityClassName, $entityId, $page = null, $limit = null)
 {
     $qb = $this->createQueryBuilder('note')->select('partial note.{id, message, owner, createdAt, updatedBy, updatedAt}, c, u')->innerJoin($entityClassName, 'e', 'WITH', sprintf('note.%s = e', ExtendHelper::buildAssociationName($entityClassName)))->leftJoin('note.owner', 'c')->leftJoin('note.updatedBy', 'u')->where('e.id = :entity_id')->setParameter('entity_id', $entityId);
     if (null !== $page) {
         $qb->setFirstResult($this->getOffset($page) * $limit);
     }
     if (null !== $limit) {
         $qb->setMaxResults($limit);
     }
     return $qb;
 }
开发者ID:antrampa,项目名称:platform,代码行数:19,代码来源:NoteRepository.php


注:本文中的Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper::buildAssociationName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。