| Conditions | 2 |
| Paths | 2 |
| Total Lines | 94 |
| Code Lines | 66 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
||
| 33 | protected function __construct($timezone = null) |
||
| 34 | { |
||
| 35 | $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
||
| 36 | $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
||
| 37 | $this->_tables = array( |
||
| 38 | 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
||
| 39 | ); |
||
| 40 | $this->_fields = array( |
||
| 41 | 'Term_Taxonomy' => array( |
||
| 42 | 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
||
| 43 | 'term_taxonomy_id', |
||
| 44 | __('Term-Taxonomy ID', 'event_espresso') |
||
| 45 | ), |
||
| 46 | 'term_id' => new EE_Foreign_Key_Int_Field( |
||
| 47 | 'term_id', |
||
| 48 | __("Term Id", "event_espresso"), |
||
| 49 | false, |
||
| 50 | 0, |
||
| 51 | 'Term' |
||
| 52 | ), |
||
| 53 | 'taxonomy' => new EE_Plain_Text_Field( |
||
| 54 | 'taxonomy', |
||
| 55 | __('Taxonomy Name', 'event_espresso'), |
||
| 56 | false, |
||
| 57 | 'category' |
||
| 58 | ), |
||
| 59 | 'description' => new EE_Post_Content_Field( |
||
| 60 | 'description', |
||
| 61 | __("Description of Term", "event_espresso"), |
||
| 62 | false, |
||
| 63 | '' |
||
| 64 | ), |
||
| 65 | 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
||
| 66 | 'term_count' => new EE_Integer_Field( |
||
| 67 | 'count', |
||
| 68 | __("Count of Objects attached", 'event_espresso'), |
||
| 69 | false, |
||
| 70 | 0 |
||
| 71 | ), |
||
| 72 | ), |
||
| 73 | ); |
||
| 74 | $this->_model_relations = array( |
||
| 75 | 'Term_Relationship' => new EE_Has_Many_Relation(), |
||
| 76 | 'Term' => new EE_Belongs_To_Relation(), |
||
| 77 | ); |
||
| 78 | $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
||
| 79 | foreach ($cpt_models as $model_name) { |
||
| 80 | $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
||
| 81 | } |
||
| 82 | $this->_indexes = array( |
||
| 83 | 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
||
| 84 | ); |
||
| 85 | $path_to_tax_model = ''; |
||
| 86 | $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
||
| 87 | $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
||
| 88 | $path_to_tax_model |
||
| 89 | ); |
||
| 90 | $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
||
| 91 | $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
||
| 92 | //add cap restrictions for editing relating to the "ee_edit_*" |
||
| 93 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
||
| 94 | array( |
||
| 95 | $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
||
| 96 | ) |
||
| 97 | ); |
||
| 98 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
||
| 99 | array( |
||
| 100 | $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
||
| 101 | ) |
||
| 102 | ); |
||
| 103 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
||
| 104 | array( |
||
| 105 | $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
||
| 106 | ) |
||
| 107 | ); |
||
| 108 | //add cap restrictions for deleting relating to the "ee_deleting_*" |
||
| 109 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
||
| 110 | array( |
||
| 111 | $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
||
| 112 | ) |
||
| 113 | ); |
||
| 114 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
||
| 115 | array( |
||
| 116 | $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
||
| 117 | ) |
||
| 118 | ); |
||
| 119 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
||
| 120 | array( |
||
| 121 | $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
||
| 122 | ) |
||
| 123 | ); |
||
| 124 | parent::__construct($timezone); |
||
| 125 | add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
||
| 126 | } |
||
| 127 | |||
| 152 |