fix docs and allow set field type by name

This commit is contained in:
Eduardo humberto 2017-12-05 16:20:55 -02:00
parent 917efc276a
commit 68b25a3283
2 changed files with 32 additions and 49 deletions

View File

@ -82,9 +82,9 @@ class Filter extends Entity {
}
/**
* Retorna o objeto Filter Type
* Return the an object child of \Tainacan\Filter_Types\Filter_Type with options
*
* @return array || object
* @return \Tainacan\Filter_Types\Filter_Type The filter type class with filled options
*/
function get_filter_type_object(){
$class_name = $this->get_filter_type();
@ -94,18 +94,18 @@ class Filter extends Entity {
}
/**
* Retorna o objeto field type
* Return the class name for the filter type
*
* @return array || object
* @return string The
*/
function get_filter_type(){
return $this->get_mapped_property('filter_type');
}
/**
* Retorna o objeto Metadado
* Return the actual options for the current filter type
*
* @return array || object
* @return array Configurations for the filter type object
*/
function get_filter_options(){
return $this->get_mapped_property('filter_type_options');
@ -164,28 +164,11 @@ class Filter extends Entity {
}
/**
* Atribui o próprio objeto do filter type de forma serializada
*
* @param \Tainacan\Filter_Types\Filter_Type $value
* @return void
*/
// function set_filter_type_object( \Tainacan\Filter_Types\Filter_Type $value ){
// // TODO: validate primitive type with filter
// //if filter matches the metadata type
// //if( in_array( $type->get_primitive_type(), $value->get_supported_types() ) ){
// $this->set_filter_type( get_class( $value ) );
// $this->set_mapped_property('filter_type_object', base64_encode( serialize($value) ) );
// //}
// }
/**
* Atribui o filter type.
* Este metodo é privado, porque é é utilizado apenas neste contexto pelo metodo set_filter_type_object
*
* @param string
* save the filter type class name
*
* @param string | \Tainacan\Filter_Types\Filter_Type $value The name of the class or the instance
*/
public function set_filter_type($value){
$this->set_mapped_property('filter_type', get_class( $value ) );
$this->set_mapped_property('filter_type', ( is_object( $value ) ) ? get_class( $value ) : $value );
}
}

View File

@ -145,9 +145,9 @@ class Metadata extends Entity {
}
/**
* Retorna o objeto Metadado
* Return the an object child of \Tainacan\Field_Types\Field_Type with options
*
* @return array || object
* @return \Tainacan\Field_Types\Field_Type The field type class with filled options
*/
function get_field_type_object(){
$class_name = $this->get_field_type();
@ -157,25 +157,25 @@ class Metadata extends Entity {
}
/**
* Retorna o objeto field type
* Return the class name for the field type
*
* @return array || object
* @return string The
*/
function get_field_type(){
return $this->get_mapped_property('field_type');
}
/**
* Retorna o objeto Metadado
* Return the actual options for the current field type
*
* @return array || object
* @return array Configurations for the field type object
*/
function get_field_options(){
return $this->get_mapped_property('get_field_options');
}
/**
* Atribui nome
* Set the metadata name
*
* @param [string] $value
* @return void
@ -185,7 +185,7 @@ class Metadata extends Entity {
}
/**
* Atribui o tipo de ordenação
* Set manually the order of the metadata
*
* @param [string] $value
* @return void
@ -195,9 +195,9 @@ class Metadata extends Entity {
}
/**
* Atribui ID do parent
* Set the metadata parent ID
*
* @param [integer] $value
* @param [integer] $value The ID from parent
* @return void
*/
function set_parent($value) {
@ -205,9 +205,9 @@ class Metadata extends Entity {
}
/**
* Atribui descrição
* Set metadata description
*
* @param [string] $value
* @param [string] $value The text description
* @return void
*/
function set_description($value) {
@ -215,7 +215,7 @@ class Metadata extends Entity {
}
/**
* Define se é obrigatório
* Allow the metadata be required
*
* @param [boolean] $value
* @return void
@ -225,7 +225,7 @@ class Metadata extends Entity {
}
/**
* Define se é multiplo
* Allow multiple fields
*
* @param [boolean] $value
* @return void
@ -235,7 +235,7 @@ class Metadata extends Entity {
}
/**
* Define a cardinalidade
* The number of possible fields
*
* @param [string] $value
* @return void
@ -245,7 +245,7 @@ class Metadata extends Entity {
}
/**
* Define se é chave
* Define if the value is key on the collection
*
* @param [string] $value
* @return void
@ -255,7 +255,7 @@ class Metadata extends Entity {
}
/**
* Atribui máscara
* Set mask for the metadata
*
* @param [string] $value
* @return void
@ -265,7 +265,7 @@ class Metadata extends Entity {
}
/**
* Define o nível de privacidade
* Set privacy
*
* @param [string] $value
* @return void
@ -275,7 +275,7 @@ class Metadata extends Entity {
}
/**
* Define o valor padrão
* Set default value
*
* @param [string || integer] $value
* @return void
@ -285,12 +285,12 @@ class Metadata extends Entity {
}
/**
* save the class field class name
* save the field type class name
*
* @param $value
* @param string | \Tainacan\Field_Types\Field_Type $value The name of the class or the instance
*/
public function set_field_type($value){
$this->set_mapped_property('field_type', get_class( $value ) ) ; // Encode to avoid backslaches removal
public function set_field_type( $value ){
$this->set_mapped_property('field_type', ( is_object( $value ) ) ? get_class( $value ) : $value ) ; // Encode to avoid backslaches removal
}
// helpers