Completed
Branch master (163d15)
by
unknown
18:49 queued 09:51
created

AdminPageFramework_TaxonomyField::__construct()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 25
rs 8.5806
cc 4
eloc 17
nc 5
nop 4
1
<?php
2
/**
3
 * Admin Page Framework
4
 * 
5
 * http://en.michaeluno.jp/admin-page-framework/
6
 * Copyright (c) 2013-2016 Michael Uno; Licensed MIT
7
 * 
8
 */
9
10
/**
11
 * Provides methods for creating fields in the taxonomy page (edit-tags.php).
12
 * 
13
 * @abstract
14
 * @since       3.0.0
15
 * @package     AdminPageFramework
16
 * @subpackage  TaxonomyField
17
 * @extends     AdminPageFramework_TaxonomyField_Controller
18
 */
19
abstract class AdminPageFramework_TaxonomyField extends AdminPageFramework_TaxonomyField_Controller {
20
    
21
    /**
22
     * Defines the class object structure type.
23
     * 
24
     * This is used to create a property object as well as to define the form element structure.
25
     * 
26
     * @since       3.0.0
27
     * @since       3.7.0      Changed the name from `$_sFieldsType`. Changed the default value from `taxonomy`.
28
     * @internal
29
     */
30
    protected $_sStructureType = 'taxonomy_field';
31
    
32
    /**
33
     * Constructs the class object instance of AdminPageFramework_TaxonomyField.
34
     * 
35
     * Handles setting up properties and hooks.
36
     * 
37
     * <h4>Examples</h4>
38
     * <code>
39
     * new APF_TaxonomyField( 'apf_sample_taxonomy' ); // taxonomy slug
40
     * </code>
41
     * 
42
     * @since       3.0.0
43
     * @param       array|string    The taxonomy slug(s). If multiple slugs need to be passed, enclose them in an array and pass the array.
44
     * @param       string          The option key used for the options table to save the data. By default, the instantiated class name will be applied.
45
     * @param       string          The access rights. Default: `manage_options`.
46
     * @param       string          The text domain. Default: `admin-page-framework`.
47
     * @return      void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
48
     */ 
49
    function __construct( $asTaxonomySlug, $sOptionKey='', $sCapability='manage_options', $sTextDomain='admin-page-framework' ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
50
        
51
        if ( empty( $asTaxonomySlug ) ) { 
52
            return; 
53
        }
54
        
55
        // Properties 
56
        $_sProprtyClassName = isset( $this->aSubClassNames[ 'oProp' ] )
57
            ? $this->aSubClassNames[ 'oProp' ]
58
            : 'AdminPageFramework_Property_' . $this->_sStructureType;        
59
        $this->oProp        = new $_sProprtyClassName( 
60
            $this, 
61
            get_class( $this ), 
62
            $sCapability, 
63
            $sTextDomain, 
64
            $this->_sStructureType 
65
        );     
66
        $this->oProp->aTaxonomySlugs    = ( array ) $asTaxonomySlug;
67
        $this->oProp->sOptionKey        = $sOptionKey 
68
            ? $sOptionKey 
69
            : $this->oProp->sClassName;
70
        
71
        parent::__construct( $this->oProp );
72
        
73
    }
74
75
}
76