/**
  * Add inheritance tables to target to show inherited activities
  *
  * @param Schema $schema
  * @param string $targetTableName Target entity table name
  * @param string $inheritanceTableName Inheritance entity table name
  * @param string[] $path Path of relations to target entity
  */
 public function addInheritanceTargets(Schema $schema, $targetTableName, $inheritanceTableName, $path)
 {
     $targetTable = $schema->getTable($targetTableName);
     $options = new OroOptions();
     $inheritance['target'] = $this->extendExtension->getEntityClassByTableName($inheritanceTableName);
     $inheritance['path'] = $path;
     $inheritances[] = $inheritance;
     $options->append('activity', 'inheritance_targets', $inheritances);
     $targetTable->addOption(OroOptions::KEY, $options);
 }
Example #2
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]]);
 }
 /**
  * @param string $scope
  * @param string $code
  * @param string $val
  * @return array
  */
 protected function getAppendedOption($scope, $code, $val)
 {
     $options = new OroOptions();
     $options->append($scope, $code, $val);
     return $options->toArray();
 }