getType($typeName); $context = $this->extension . '.item'; $catidField = 'catid'; if ($typeName === 'category') { $context = 'com_categories.item'; $catidField = ''; } // Get the associations. $associations = Associations::getAssociations($this->extension, $type['tables']['a'], $context, $id, 'id', 'alias', $catidField); return $associations; } /** * Get item information * * @param string $typeName The item type * @param int $id The id of item for which we need the associated items * * @return Table|null * * @since __DEPLOY_VERSION__ */ public function getItem($typeName, $id) { if (empty($id)) { return null; } $table = null; switch ($typeName) { case 'weblink': $table = Table::getInstance('WeblinkTable', 'Joomla\\Component\\Weblinks\\Administrator\\Table\\'); break; case 'category': $table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\'); break; } if (empty($table)) { return null; } $table->load($id); return $table; } /** * Get information about the type * * @param string $typeName The item type * * @return array Array of item types * * @since __DEPLOY_VERSION__ */ public function getType($typeName = '') { $fields = $this->getFieldsTemplate(); $tables = []; $joins = []; $support = $this->getSupportTemplate(); $title = ''; if (in_array($typeName, $this->itemTypes)) { switch ($typeName) { case 'weblink': $support['state'] = true; $support['acl'] = true; $support['checkout'] = true; $support['category'] = true; $support['save2copy'] = true; $tables = [ 'a' => '#__weblinks', ]; $title = 'weblink'; break; case 'category': $fields['created_user_id'] = 'a.created_user_id'; $fields['ordering'] = 'a.lft'; $fields['level'] = 'a.level'; $fields['catid'] = ''; $fields['state'] = 'a.published'; $support['state'] = true; $support['acl'] = true; $support['checkout'] = true; $support['level'] = true; $tables = [ 'a' => '#__categories', ]; $title = 'category'; break; } } return [ 'fields' => $fields, 'support' => $support, 'tables' => $tables, 'joins' => $joins, 'title' => $title, ]; } }