mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Builders: allow pre_ops and post_ops in build overrides
https://fedorahosted.org/freeipa/ticket/3235
This commit is contained in:
parent
f188fcdfa7
commit
2cf0542b0d
@ -51,10 +51,24 @@ define(['dojo/_base/declare',
|
|||||||
|
|
||||||
ctor: null,
|
ctor: null,
|
||||||
|
|
||||||
post_ops: null,
|
/**
|
||||||
|
* Array of spec modifiers.
|
||||||
|
*
|
||||||
|
* Spec modifier is a function which is called before build.
|
||||||
|
* takes params: spec, context
|
||||||
|
* returns spec
|
||||||
|
*/
|
||||||
pre_ops: null,
|
pre_ops: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of object modifiers.
|
||||||
|
*
|
||||||
|
* Object modifier is a function which is after build.
|
||||||
|
* takes params: built object, spec, context
|
||||||
|
* returns object
|
||||||
|
*/
|
||||||
|
post_ops: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls what builder do when spec is a string. Possible values:
|
* Controls what builder do when spec is a string. Possible values:
|
||||||
* * 'type'
|
* * 'type'
|
||||||
@ -104,16 +118,19 @@ define(['dojo/_base/declare',
|
|||||||
*/
|
*/
|
||||||
build: function(spec, context, overrides) {
|
build: function(spec, context, overrides) {
|
||||||
|
|
||||||
var f,c;
|
var f,c, pre, post;
|
||||||
|
|
||||||
if (spec === undefined || spec === null) return null;
|
if (spec === undefined || spec === null) return null;
|
||||||
if (!construct.is_spec(spec)) return spec;
|
if (!construct.is_spec(spec)) return spec;
|
||||||
|
|
||||||
context = context || {};
|
context = context || {};
|
||||||
|
|
||||||
|
// save
|
||||||
if (overrides) {
|
if (overrides) {
|
||||||
f = this.factory;
|
f = this.factory;
|
||||||
c = this.ctor;
|
c = this.ctor;
|
||||||
|
pre = this.pre_ops;
|
||||||
|
post = this.post_ops;
|
||||||
if (typeof overrides === 'function') {
|
if (typeof overrides === 'function') {
|
||||||
if (construct.is_ctor(overrides)) {
|
if (construct.is_ctor(overrides)) {
|
||||||
overrides = { $ctor: overrides };
|
overrides = { $ctor: overrides };
|
||||||
@ -123,8 +140,11 @@ define(['dojo/_base/declare',
|
|||||||
}
|
}
|
||||||
this.factory = overrides.$factory;
|
this.factory = overrides.$factory;
|
||||||
this.ctor = overrides.$ctor;
|
this.ctor = overrides.$ctor;
|
||||||
|
if (overrides.$pre_ops) this.pre_ops = overrides.$pre_ops;
|
||||||
|
if (overrides.$post_ops) this.post_ops = overrides.$post_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// build
|
||||||
var objects;
|
var objects;
|
||||||
if (lang.isArray(spec)) {
|
if (lang.isArray(spec)) {
|
||||||
objects = [];
|
objects = [];
|
||||||
@ -136,9 +156,12 @@ define(['dojo/_base/declare',
|
|||||||
objects = this._build(spec, context);
|
objects = this._build(spec, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restore
|
||||||
if (overrides) {
|
if (overrides) {
|
||||||
this.factory = f;
|
this.factory = f;
|
||||||
this.ctor = c;
|
this.ctor = c;
|
||||||
|
this.pre_ops = pre;
|
||||||
|
this.post_ops = post;
|
||||||
}
|
}
|
||||||
|
|
||||||
return objects;
|
return objects;
|
||||||
|
Loading…
Reference in New Issue
Block a user