| @@ 34-54 (lines=21) @@ | ||
| 31 | * |
|
| 32 | * @return string |
|
| 33 | */ |
|
| 34 | public function getEntityLabel() |
|
| 35 | { |
|
| 36 | $label = ''; |
|
| 37 | $accessor = PropertyAccess::createPropertyAccessor(); |
|
| 38 | $entity = $this->getUniqueEntity(); |
|
| 39 | ||
| 40 | if ($accessor->isReadable($entity, 'label')) { |
|
| 41 | $label = $accessor->getValue($entity, 'label'); |
|
| 42 | } else if ($accessor->isReadable($entity, 'title')) { |
|
| 43 | $label = $accessor->getValue($entity, 'title'); |
|
| 44 | } else if ($accessor->isReadable($entity, 'name')) { |
|
| 45 | $label = $accessor->getValue($entity, 'name'); |
|
| 46 | } else if ($accessor->isReadable($entity, '__toString')) { |
|
| 47 | $label = $accessor->getValue($entity, '__toString'); |
|
| 48 | } else if ($accessor->isReadable($entity, 'content')) { |
|
| 49 | $label = strip_tags(substr($label = $accessor->getValue($entity, 'content'), 0, 100)); |
|
| 50 | } else if ($accessor->isReadable($entity, 'id')) { |
|
| 51 | $label = $accessor->getValue($entity, 'id'); |
|
| 52 | } |
|
| 53 | return $label; |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| @@ 16-35 (lines=20) @@ | ||
| 13 | * @param $entity |
|
| 14 | * @return string |
|
| 15 | */ |
|
| 16 | public function getEntityLabel($entity) |
|
| 17 | { |
|
| 18 | $label = ''; |
|
| 19 | $accessor = PropertyAccess::createPropertyAccessor(); |
|
| 20 | ||
| 21 | if ($accessor->isReadable($entity, 'label')) { |
|
| 22 | $label = $accessor->getValue($entity, 'label'); |
|
| 23 | } else if ($accessor->isReadable($entity, 'title')) { |
|
| 24 | $label = $accessor->getValue($entity, 'title'); |
|
| 25 | } else if ($accessor->isReadable($entity, 'name')) { |
|
| 26 | $label = $accessor->getValue($entity, 'name'); |
|
| 27 | } else if ($accessor->isReadable($entity, '__toString')) { |
|
| 28 | $label = $accessor->getValue($entity, '__toString'); |
|
| 29 | } else if ($accessor->isReadable($entity, 'content')) { |
|
| 30 | $label = strip_tags(substr($label = $accessor->getValue($entity, 'content'), 0, 100)); |
|
| 31 | } else if ($accessor->isReadable($entity, 'id')) { |
|
| 32 | $label = $accessor->getValue($entity, 'id'); |
|
| 33 | } |
|
| 34 | return $label; |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||