Remove describe.only
from spec file as this was stopping all other
spec files from running.
Closes #7284
1 |
/**
|
|
2 |
* Metadata args utility functions.
|
|
3 |
*/
|
|
4 | 10 |
export class MetadataUtils { |
5 |
|
|
6 |
/**
|
|
7 |
* Gets given's entity all inherited classes.
|
|
8 |
* Gives in order from parents to children.
|
|
9 |
* For example Post extends ContentModel which extends Unit it will give
|
|
10 |
* [Unit, ContentModel, Post]
|
|
11 |
*/
|
|
12 | 10 |
static getInheritanceTree(entity: Function): Function[] { |
13 | 10 |
const tree: Function[] = [entity]; |
14 | 10 |
const getPrototypeOf = (object: Function): void => { |
15 | 10 |
const proto = Object.getPrototypeOf(object); |
16 | 10 |
if (proto && proto.name) { |
17 | 10 |
tree.push(proto); |
18 | 10 |
getPrototypeOf(proto); |
19 |
}
|
|
20 |
};
|
|
21 | 10 |
getPrototypeOf(entity); |
22 | 10 |
return tree; |
23 |
}
|
|
24 |
|
|
25 |
/**
|
|
26 |
* Checks if this table is inherited from another table.
|
|
27 |
*/
|
|
28 | 10 |
static isInherited(target1: Function, target2: Function) { |
29 | 10 |
return target1.prototype instanceof target2; |
30 |
}
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Filters given array of targets by a given classes.
|
|
34 |
* If classes are not given, then it returns array itself.
|
|
35 |
*/
|
|
36 | 10 |
static filterByTarget<T extends { target?: any }>(array: T[], classes?: any[]): T[] { |
37 | 10 |
if (!classes) return array; |
38 | 10 |
return array.filter(item => item.target && classes.indexOf(item.target) !== -1); |
39 |
}
|
|
40 |
|
|
41 | 10 |
}
|
Read our documentation on viewing source code .