| @@ 721-753 (lines=33) @@ | ||
| 718 | * @throws LogicException |
|
| 719 | * @throws InvalidArgumentException |
|
| 720 | */ |
|
| 721 | public function getColumnAttributes($record, $column) { |
|
| 722 | if(!$this->columnDispatch) { |
|
| 723 | $this->buildColumnDispatch(); |
|
| 724 | } |
|
| 725 | ||
| 726 | if(!empty($this->columnDispatch[$column])) { |
|
| 727 | $attributes = array(); |
|
| 728 | ||
| 729 | foreach($this->columnDispatch[$column] as $handler) { |
|
| 730 | /** |
|
| 731 | * @var GridField_ColumnProvider $handler |
|
| 732 | */ |
|
| 733 | $columnAttributes = $handler->getColumnAttributes($this, $record, $column); |
|
| 734 | ||
| 735 | if(is_array($columnAttributes)) { |
|
| 736 | $attributes = array_merge($attributes, $columnAttributes); |
|
| 737 | continue; |
|
| 738 | } |
|
| 739 | ||
| 740 | throw new LogicException(sprintf( |
|
| 741 | 'Non-array response from %s::getColumnAttributes().', |
|
| 742 | get_class($handler) |
|
| 743 | )); |
|
| 744 | } |
|
| 745 | ||
| 746 | return $attributes; |
|
| 747 | } |
|
| 748 | ||
| 749 | throw new InvalidArgumentException(sprintf( |
|
| 750 | 'Bad column "%s"', |
|
| 751 | $column |
|
| 752 | )); |
|
| 753 | } |
|
| 754 | ||
| 755 | /** |
|
| 756 | * Get metadata for a column. |
|
| @@ 767-799 (lines=33) @@ | ||
| 764 | * @throws LogicException |
|
| 765 | * @throws InvalidArgumentException |
|
| 766 | */ |
|
| 767 | public function getColumnMetadata($column) { |
|
| 768 | if(!$this->columnDispatch) { |
|
| 769 | $this->buildColumnDispatch(); |
|
| 770 | } |
|
| 771 | ||
| 772 | if(!empty($this->columnDispatch[$column])) { |
|
| 773 | $metaData = array(); |
|
| 774 | ||
| 775 | foreach($this->columnDispatch[$column] as $handler) { |
|
| 776 | /** |
|
| 777 | * @var GridField_ColumnProvider $handler |
|
| 778 | */ |
|
| 779 | $columnMetaData = $handler->getColumnMetadata($this, $column); |
|
| 780 | ||
| 781 | if(is_array($columnMetaData)) { |
|
| 782 | $metaData = array_merge($metaData, $columnMetaData); |
|
| 783 | continue; |
|
| 784 | } |
|
| 785 | ||
| 786 | throw new LogicException(sprintf( |
|
| 787 | 'Non-array response from %s::getColumnMetadata().', |
|
| 788 | get_class($handler) |
|
| 789 | )); |
|
| 790 | } |
|
| 791 | ||
| 792 | return $metaData; |
|
| 793 | } |
|
| 794 | ||
| 795 | throw new InvalidArgumentException(sprintf( |
|
| 796 | 'Bad column "%s"', |
|
| 797 | $column |
|
| 798 | )); |
|
| 799 | } |
|
| 800 | ||
| 801 | /** |
|
| 802 | * Return how many columns the grid will have. |
|