| 1 |  |  | <?php defined('SYSPATH') OR die('No direct script access.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * I am a taxonamable behavior. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Attach me to models you want to have the `terms` association | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * and the `with_terms()` builder method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @author Haralan Dobrev <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @copyright 2014 Clippings Ltd. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @license http://spdx.org/licenses/BSD-3-Clause | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class Kohana_Jam_Behavior_Taxonomable extends Jam_Behavior { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     protected $_terms_association_name = 'terms'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     protected $_terms_association_options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     protected $_terms_items_association_name = 'terms_items'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     protected $_terms_items_association_options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         'as' => 'item', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         'foreign_model' => 'terms_item' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 | 1 |  |     public function initialize(Jam_Meta $meta, $name) | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 | 1 |  |         parent::initialize($meta, $name); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         $meta | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 30 | 1 |  |             ->association( | 
            
                                                                        
                            
            
                                    
            
            
                | 31 | 1 |  |                 $this->_terms_association_name, | 
            
                                                                        
                            
            
                                    
            
            
                | 32 | 1 |  |                 Jam::association('taxonomy_terms', $this->_terms_association_options) | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             ) | 
            
                                                                        
                            
            
                                    
            
            
                | 34 | 1 |  |             ->association( | 
            
                                                                        
                            
            
                                    
            
            
                | 35 | 1 |  |                 $this->_terms_items_association_name, | 
            
                                                                        
                            
            
                                    
            
            
                | 36 | 1 |  |                 Jam::association('hasmany', $this->_terms_items_association_options) | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 1 |  |     public function builder_call_with_terms(Database_Query $builder, Jam_Event_Data $data, $term_slugs, $operator = 'IN', $nesting_level = 1) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 1 |  |         if ($term_slugs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 1 |  |             if ( ! ($term_slugs instanceof Jam_Query_Builder_Collection) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 1 |  |              AND ! ($term_slugs instanceof Jam_Array_Association)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |                 $term_slugs = Jam::all('term') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  |                     ->slugs_children($term_slugs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  |                     ->order_by('id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 1 |  |             $terms = $term_slugs->as_array('id', 'slug'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |             $terms_ids = array_keys($terms); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |             if ($nesting_level > 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                 $terms = Jam::all('term') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                     ->slugs_children(array_values($terms)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                     ->order_by('id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 $terms_ids = Arr::merge($terms_ids, $terms->ids()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 1 |  |             if ($terms_ids) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 1 |  |                 $unique_alias = 'terms-'.join('-', $terms_ids); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                 $builder | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 1 |  |                     ->join(array('terms_items', $unique_alias)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 1 |  |                     ->on( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 1 |  |                         $unique_alias.'.term_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                         $operator, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |                         DB::expr("(".join(',', $terms_ids).')') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |         return $builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 80 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |  | 
            
                        
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: