當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。