| Conditions | 8 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function Fields() |
||
| 17 | { |
||
| 18 | if (empty(self::$myCache)) { |
||
| 19 | $types = ['has_one', 'has_many', 'many_many', 'belongs_many_many', 'belongs_to']; |
||
| 20 | $classNames = ClassInfo::subclassesFor(DataObject::class, false); |
||
| 21 | foreach ($classNames as $className) { |
||
| 22 | $obj = Injector::inst()->get($className); |
||
| 23 | $fieldLabels = $obj->fieldLabels(true); |
||
| 24 | foreach ($types as $type) { |
||
| 25 | $rels = Config::inst()->get($className, $type, Config::UNINHERITED); |
||
| 26 | if (is_array($rels) && ! empty($rels)) { |
||
| 27 | foreach ($rels as $relName => $relType) { |
||
| 28 | if (is_a($relType, File::class, true)) { |
||
| 29 | $title = $obj->i18n_singular_name() . ' - ' . ($fieldLabels[$relName] ?? $relName); |
||
| 30 | $key = $className . ',' . $relName . ',' . $type; |
||
| 31 | self::$myCache[$key] = $title; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | asort(self::$myCache); |
||
| 39 | } |
||
| 40 | |||
| 41 | return self::$myCache; |
||
| 42 | } |
||
| 44 |