tiny lints

This commit is contained in:
Rodrigo de Oliveira 2021-04-06 01:21:22 -03:00
parent b9017f85e0
commit 5e4dd01e08
3 changed files with 6 additions and 38 deletions

View File

@ -158,13 +158,10 @@ class Relationship extends Metadata_Type {
* @return string The HTML representation of the value, containing one or multiple items names, linked to the item page * @return string The HTML representation of the value, containing one or multiple items names, linked to the item page
*/ */
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) { public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value(); $value = $item_metadata->get_value();
$return = ''; $return = '';
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$count = 1; $count = 1;
$total = sizeof($value); $total = sizeof($value);
$prefix = $item_metadata->get_multivalue_prefix(); $prefix = $item_metadata->get_multivalue_prefix();
@ -172,43 +169,30 @@ class Relationship extends Metadata_Type {
$separator = $item_metadata->get_multivalue_separator(); $separator = $item_metadata->get_multivalue_separator();
foreach ( $value as $item_id ) { foreach ( $value as $item_id ) {
try { try {
//$item = new \Tainacan\Entities\Item($item_id); //$item = new \Tainacan\Entities\Item($item_id);
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance(); $Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$item = $Tainacan_Items->fetch( (int) $item_id); $item = $Tainacan_Items->fetch( (int) $item_id);
$count ++; $count ++;
if ( $item instanceof \Tainacan\Entities\Item ) { if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $prefix; $return .= $prefix;
$return .= $this->get_item_html($item); $return .= $this->get_item_html($item);
$return .= $suffix; $return .= $suffix;
if ( $count <= $total ) { if ( $count <= $total ) {
$return .= $separator; $return .= $separator;
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
// item not found // item not found
} }
} }
} else { } else {
try { try {
$item = new \Tainacan\Entities\Item($value); $item = new \Tainacan\Entities\Item($value);
if ( $item instanceof \Tainacan\Entities\Item ) { if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $this->get_item_html($item); $return .= $this->get_item_html($item);
} }
@ -216,22 +200,18 @@ class Relationship extends Metadata_Type {
} catch (\Exception $e) { } catch (\Exception $e) {
// item not found // item not found
} }
} }
return $return; return $return;
} }
private function get_item_html($item) { private function get_item_html($item) {
$return = ''; $return = '';
$id = $item->get_id(); $id = $item->get_id();
$search_meta_id = $this->get_option('search'); $search_meta_id = $this->get_option('search');
if ( $id && $search_meta_id ) { if ( $id && $search_meta_id ) {
$link = get_permalink( (int) $id ); $link = get_permalink( (int) $id );
$search_meta_id = $this->get_option('search'); $search_meta_id = $this->get_option('search');
@ -250,17 +230,13 @@ class Relationship extends Metadata_Type {
} }
if (is_string($link)) { if (is_string($link)) {
$return = "<a data-linkto='item' data-id='$id' href='$link'>"; $return = "<a data-linkto='item' data-id='$id' href='$link'>";
$return.= $label; $return.= $label;
$return .= "</a>"; $return .= "</a>";
} }
} }
return $return; return $return;
} }
/** /**
@ -268,7 +244,6 @@ class Relationship extends Metadata_Type {
* @return \Tainacan\Entities\Collection|false The Collection object or false * @return \Tainacan\Entities\Collection|false The Collection object or false
*/ */
public function get_collection() { public function get_collection() {
$collection_id = $this->get_option('collection_id'); $collection_id = $this->get_option('collection_id');
if ( is_numeric($collection_id) ) { if ( is_numeric($collection_id) ) {
@ -279,7 +254,6 @@ class Relationship extends Metadata_Type {
} }
return false; return false;
} }
/** /**

View File

@ -118,5 +118,3 @@ class Entity_Factory {
return $this->entity; return $this->entity;
} }
} }
?>

View File

@ -200,7 +200,6 @@ class Metadata extends TAINACAN_UnitTestCase {
$this->assertEquals( 9, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) ); $this->assertEquals( 9, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) );
} }
/** /**
* *
*/ */
@ -426,9 +425,7 @@ class Metadata extends TAINACAN_UnitTestCase {
} }
function test_relatioship_get_collection_method() { function test_relationship_get_collection_method() {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$collection = $this->tainacan_entity_factory->create_entity( $collection = $this->tainacan_entity_factory->create_entity(
'collection', 'collection',
array( array(
@ -467,10 +464,9 @@ class Metadata extends TAINACAN_UnitTestCase {
$this->assertTrue( $colCheck instanceof \Tainacan\Entities\Collection ); $this->assertTrue( $colCheck instanceof \Tainacan\Entities\Collection );
$this->assertEquals($collection2->get_id(), $colCheck->get_id()); $this->assertEquals($collection2->get_id(), $colCheck->get_id());
} }
public function test_update_taxonomy_cascate_status() { function test_update_taxonomy_cascate_status() {
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();