function AttachEventBehavior(bpmnReplace, injector) {
  injector.invoke(CommandInterceptor, this);

  this._bpmnReplace = bpmnReplace;

  var self = this;

  this.postExecuted('elements.create', LOW_PRIORITY, function(context) {
    var elements = context.elements;

    elements = elements.filter(function(shape) {
      var host = shape.host;

      return shouldReplace(shape, host);
    });

    if (elements.length !== 1) {
      return;
    }

    elements.map(function(element) {
      return elements.indexOf(element);
    }).forEach(function(index) {
      var host = elements[ index ];

      context.elements[ index ] = self.replaceShape(elements[ index ], host);
    });
  }, true);


  this.preExecute('elements.move', LOW_PRIORITY, function(context) {
    var shapes = context.shapes,
        host = context.newHost;

    if (shapes.length !== 1) {
      return;
    }

    var shape = shapes[0];

    if (shouldReplace(shape, host)) {
      context.shapes = [ self.replaceShape(shape, host) ];
    }
  }, true);
}
/**
 * Replace intermediate event with boundary event when creating or moving results in attached event.
 */
Replace intermediate event with boundary event when creating or moving results in attached event.
Replace intermediate event with boundary event when creating or moving results in attached event .
function AttachEventBehavior(bpmnReplace, injector) {
  injector.invoke(CommandInterceptor, this);
  this._bpmnReplace = bpmnReplace;
  var self = this;
  this.postExecuted('elements.create', LOW_PRIORITY, function(context) {
    var elements = context.elements;
    elements = elements.filter(function(shape) {
      var host = shape.host;
      return shouldReplace(shape, host);
    });
    if (elements.length !== 1) {
      return;
    }
    elements.map(function(element) {
      return elements.indexOf(element);
    }).forEach(function(index) {
      var host = elements[ index ];
      context.elements[ index ] = self.replaceShape(elements[ index ], host);
    });
  }, true);
  this.preExecute('elements.move', LOW_PRIORITY, function(context) {
    var shapes = context.shapes,
        host = context.newHost;
    if (shapes.length !== 1) {
      return;
    }
    var shape = shapes[0];
    if (shouldReplace(shape, host)) {
      context.shapes = [ self.replaceShape(shape, host) ];
    }
  }, true);
}
function AttachEventBehavior ( bpmnReplace , injector ) { injector . invoke ( CommandInterceptor , this ) ; this . _bpmnReplace = bpmnReplace ; var self = this ; this . postExecuted ( 'elements.create' , LOW_PRIORITY , function ( context ) { var elements = context . elements ; elements = elements . filter ( function ( shape ) { var host = shape . host ; return shouldReplace ( shape , host ) ; } ) ; if ( elements . length !== 1 ) { return ; } elements . map ( function ( element ) { return elements . indexOf ( element ) ; } ) . forEach ( function ( index ) { var host = elements [ index ] ; context . elements [ index ] = self . replaceShape ( elements [ index ] , host ) ; } ) ; } , true ) ; this . preExecute ( 'elements.move' , LOW_PRIORITY , function ( context ) { var shapes = context . shapes , host = context . newHost ; if ( shapes . length !== 1 ) { return ; } var shape = shapes [ 0 ] ; if ( shouldReplace ( shape , host ) ) { context . shapes = [ self . replaceShape ( shape , host ) ] ; } } , true ) ; }
Replace intermediate event with boundary event when creating or moving results in attached event.
Replace intermediate event with boundary event when creating or moving results in attached event .