Exemplo n.º 1
0
 /**
  * Adds the association between the given table and the activity list table
  *
  * @param Schema $schema
  * @param string $targetTableName Target entity table name
  */
 public function addActivityListAssociation(Schema $schema, $targetTableName)
 {
     $targetTable = $schema->getTable($targetTableName);
     // Column names are used to show a title of target entity
     $targetTitleColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show detailed info about target entity
     $targetDetailedColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show target entity in a grid
     $targetGridColumnNames = $targetTable->getPrimaryKeyColumns();
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
     $this->extendExtension->addManyToManyRelation($schema, $schema->getTable('oro_activity_list'), $associationName, $targetTable, $targetTitleColumnNames, $targetDetailedColumnNames, $targetGridColumnNames, ['extend' => ['without_default' => true]]);
 }
 /**
  * Create custom entity tables
  *
  * @param Schema $schema
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function createTestCustomEntityTables(Schema $schema)
 {
     $table1 = $this->extendExtension->createCustomEntityTable($schema, 'TestEntity1');
     $table1->addColumn('name', 'string', ['length' => 255, OroOptions::KEY => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]]);
     $table2 = $this->extendExtension->createCustomEntityTable($schema, 'TestEntity2');
     $table2->addColumn('name', 'string', ['length' => 255, OroOptions::KEY => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]]);
     // unidirectional many-to-one
     $this->extendExtension->addManyToOneRelation($schema, $table1, 'uniM2OTarget', $table2, 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional many-to-one
     $this->extendExtension->addManyToOneRelation($schema, $table1, 'biM2OTarget', $table2, 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addManyToOneInverseRelation($schema, $table1, 'biM2OTarget', $table2, 'biM2OOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional many-to-many
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'uniM2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional many-to-many without default
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'uniM2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     // bidirectional many-to-many
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'biM2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addManyToManyInverseRelation($schema, $table1, 'biM2MTargets', $table2, 'biM2MOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional many-to-many without default
     $this->extendExtension->addManyToManyRelation($schema, $table1, 'biM2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     $this->extendExtension->addManyToManyInverseRelation($schema, $table1, 'biM2MNDTargets', $table2, 'biM2MNDOwners', ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional one-to-many
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'uniO2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // unidirectional one-to-many without default
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'uniO2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     // bidirectional one-to-many
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'biO2MTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     $this->extendExtension->addOneToManyInverseRelation($schema, $table1, 'biO2MTargets', $table2, 'biO2MOwner', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
     // bidirectional one-to-many without default
     $this->extendExtension->addOneToManyRelation($schema, $table1, 'biO2MNDTargets', $table2, ['name'], ['name'], ['name'], ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'without_default' => true]]);
     $this->extendExtension->addOneToManyInverseRelation($schema, $table1, 'biO2MNDTargets', $table2, 'biO2MNDOwner', 'name', ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);
 }
Exemplo n.º 3
0
 /**
  * Adds the association between the given table and the table contains activity records
  *
  * The activity entity must be included in 'activity' group ('groups' attribute of 'grouping' scope)
  *
  * @param Schema $schema
  * @param string $activityTableName Activity entity table name. It is owning side of the association
  * @param string $targetTableName   Target entity table name
  * @param bool   $immutable         Set TRUE to prohibit disabling the activity association from UI
  */
 public function addActivityAssociation(Schema $schema, $activityTableName, $targetTableName, $immutable = false)
 {
     $targetTable = $schema->getTable($targetTableName);
     // Column names are used to show a title of target entity
     $targetTitleColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show detailed info about target entity
     $targetDetailedColumnNames = $targetTable->getPrimaryKeyColumns();
     // Column names are used to show target entity in a grid
     $targetGridColumnNames = $targetTable->getPrimaryKeyColumns();
     $activityClassName = $this->extendExtension->getEntityClassByTableName($activityTableName);
     $options = new OroOptions();
     $options->append('activity', 'activities', $activityClassName);
     if ($immutable) {
         $options->append('activity', 'immutable', $activityClassName);
     }
     $targetTable->addOption(OroOptions::KEY, $options);
     $associationName = ExtendHelper::buildAssociationName($this->extendExtension->getEntityClassByTableName($targetTableName), ActivityScope::ASSOCIATION_KIND);
     $this->extendExtension->addManyToManyRelation($schema, $activityTableName, $associationName, $targetTable, $targetTitleColumnNames, $targetDetailedColumnNames, $targetGridColumnNames, ['extend' => ['without_default' => true]]);
 }