Using inheritance correctly

This commit is contained in:
weryques 2017-11-21 14:30:37 -02:00
parent cbe4b093a9
commit e3077eabca
12 changed files with 25 additions and 16 deletions

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Checkbox extends Field_Type {
function __construct(){
$this->primitive_type = 'date';
parent::set_primitive_type('date');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Textarea extends Field_Type {
function __construct(){
$this->primitive_type = 'date';
parent::set_primitive_type('date');
}
/**

View File

@ -11,19 +11,24 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
abstract class Field_Type {
var $primitive_type;
private $primitive_type;
abstract function render( $metadata );
function validate($value) {
public function validate($value) {
return true;
}
function get_validation_errors() {
public function get_validation_errors() {
return [];
}
function get_primitive_type(){
public function get_primitive_type(){
return $this->primitive_type;
}
public function set_primitive_type($primitive_type){
$this->primitive_type = $primitive_type;
}
}

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Numeric extends Field_Type {
function __construct(){
$this->primitive_type = 'float';
parent::set_primitive_type('float');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Radio extends Field_Type {
function __construct(){
$this->primitive_type = '';
parent::set_primitive_type('');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Relationship extends Field_Type {
function __construct(){
$this->primitive_type = '';
parent::set_primitive_type('');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Selectbox extends Field_Type {
function __construct(){
$this->primitive_type = '';
parent::set_primitive_type('');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Text extends Field_Type {
function __construct(){
$this->primitive_type = 'string';
parent::set_primitive_type('string');
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Textarea extends Field_Type {
function __construct(){
$this->primitive_type = 'string';
parent::set_primitive_type('string');
}
/**

View File

@ -8,11 +8,15 @@ if ( ! defined( 'ABSPATH' ) ) {
abstract class Filter_Type extends \Tainacan\Entity {
var $supported_types = [];
private $supported_types = [];
abstract function render( $metadata );
function get_supported_types(){
public function get_supported_types(){
return $this->supported_types;
}
public function set_supported_types($supported_types){
$this->supported_types = $supported_types;
}
}

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class List_Filter extends Filter_Type {
function __construct(){
$this->supported_types[] = 'string';
parent::set_supported_types(['string']);
}
/**

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class Range extends Filter_Type {
function __construct(){
$this->supported_types = ['float','date'];
parent::set_supported_types(['float','date']);
}
/**