<?php
/* Copyright (c) 2022-2024 Aimy Extensions, Netzum Sorglos Software GmbH
 *
 * https://www.aimy-extensions.com/
 *
 * License: GNU GPLv2, see LICENSE.txt within distribution and/or
 *          http://www.aimy-extensions.com/software-license.html
 */
 namespace Aimy\IndexNow\Helpers; defined( '_JEXEC' ) or die(); require_once( __DIR__ . '/PluginHelper.php' ); use Aimy\IndexNow\Helpers\PluginHelper; use Joomla\CMS\Table\Table; abstract class ComponentDataHelper { static public function get( $context, $primaryKey ) { $handler = sprintf( '%s::getData__%s', __CLASS__, PluginHelper::getCtxComponent( $context ) ); if ( ! is_callable( $handler ) ) { return false; } return $handler( PluginHelper::getCtxView( $context ), $primaryKey ); } static private function getData__com_content( $view, $primaryKey ) { if ( $view != 'article' ) { return false; } return self::getUsingJTable( 'Content', $primaryKey ); } static private function getData__com_categories( $view, $primaryKey ) { if ( $view != 'category' ) { return false; } return self::getUsingJTable( 'Category', $primaryKey ); } static private function getData__com_tags( $view, $primaryKey ) { if ( $view != 'tag' ) { return false; } return self::getUsingJTable( 'Tag', $primaryKey, 'TagsTable' ); } static private function getUsingJTable( $type, $primaryKey, $tablePrefix = 'JTable' ) { $t = Table::GetInstance( $type, $tablePrefix ); if ( $t && is_object( $t ) && $t->load( $primaryKey ) ) { return $t; } return false; } } 
