Completed
Branch BETA-4.9-messages-queue-fixed (941081)
by
unknown
33:43 queued 13:37
created

EEM_Post_Meta   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9
Metric Value
wmc 3
lcom 0
cbo 9
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 3
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
/**
3
 * Event Espresso
4
 *
5
 * Event Registration and Management Plugin for WordPress
6
 *
7
 * @ package			Event Espresso
8
 * @ author				Seth Shoultes
9
 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
 * @ link					http://www.eventespresso.com
12
 * @ version		 	4.0
13
 *
14
 * ------------------------------------------------------------------------
15
 *
16
 * Post Meta Model
17
 *
18
 * Model for accessing the wp core postmeta table. Generally it's better to use the
19
 * built-in wp functions directly, but this is useful if you want to use the EE models
20
 * and need a query that factors in an EE custom post type's postmeta (eg, attendees, events or venues).
21
 * Currently, if applying caps to the queries, these are only accessible to site admins;
22
 * however we may devise some strategy for marking specified postmetas as public.
23
 * (Using the wp core convention of prefixing meta keys with an underscore might work,
24
 * see https://codex.wordpress.org/Function_Reference/add_post_meta, but when a postmeta is
25
 * "non-hidden" it's meant to show in the wp admin's post editing page, not necessarily on the frontend)
26
 *
27
 *
28
 * @package			Event Espresso
29
 * @subpackage		includes/models/
30
 * @author				Michael Nelson
31
 *
32
 * ------------------------------------------------------------------------
33
 */
34
require_once ( EE_MODELS . 'EEM_Base.model.php' );
35
36
class EEM_Post_Meta extends EEM_Base {
37
38
  	// private instance of the EE_Post_Meta object
39
	protected static $_instance = NULL;
40
41
	protected function __construct( $timezone = NULL ) {
42
		$this->singular_item = __('Post Meta','event_espresso');
43
		$this->plural_item = __('Post Metas','event_espresso');
44
		$this->_tables = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('Post_Meta' => new...'postmeta', 'meta_id')) of type array<string,object<EE_P...ct<EE_Primary_Table>"}> is incompatible with the declared type array<integer,object<EE_Table_Base>> of property $_tables.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
			'Post_Meta'=> new EE_Primary_Table('postmeta', 'meta_id')
46
		);
47
		$models_this_can_attach_to = array_keys( EE_Registry::instance()->cpt_models() );
48
		$this->_fields = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('Post_Meta' => arr...ent_espresso'), true))) of type array<string,array<strin...ized_Text_Field>\"}>"}> is incompatible with the declared type array<integer,object<EE_Model_Field_Base>> of property $_fields.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
			'Post_Meta'=>array(
50
				'meta_id'=>new EE_Primary_Key_Int_Field('meta_id', __("Meta ID", "event_espresso")),
51
				'post_id'=>new EE_Foreign_Key_Int_Field('post_id', __("Primary Key of Post", "event_espresso"), false, 0, $models_this_can_attach_to),
0 ignored issues
show
Documentation introduced by
$models_this_can_attach_to is of type array<integer,integer|string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52
				'meta_key'=>new EE_Plain_Text_Field('meta_key', __("Meta Key", "event_espresso"), false, ''),
53
				'meta_value'=>new EE_Maybe_Serialized_Text_Field('meta_value', __("Meta Value", "event_espresso"), true)
54
			));
55
		$this->_model_relations = array();
56
		foreach($models_this_can_attach_to as $model){
57
			$this->_model_relations[$model] = new EE_Belongs_To_Relation();
58
		}
59
		foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ) {
60
			$this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( 'meta_key', 'meta_value' );
61
		}
62
		parent::__construct( $timezone );
63
	}
64
65
66
}
67
// End of file EEM_Post_Meta.model.php
68
// Location: /includes/models/EEM_Post_Meta.model.php
69