diff --git a/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php b/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php index bd8b9c2..0595b4e 100644 --- a/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php +++ b/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php @@ -20,7 +20,10 @@ use Joomla\CMS\Component\Router\RouterServiceInterface; use Joomla\CMS\Component\Router\RouterServiceTrait; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; +use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; use Joomla\CMS\HTML\HTMLRegistryAwareTrait; +use Joomla\CMS\Language\Text; use Joomla\CMS\Tag\TagServiceInterface; use Joomla\CMS\Tag\TagServiceTrait; use Joomla\Component\Weblinks\Administrator\Service\HTML\AdministratorService; @@ -33,7 +36,7 @@ use Psr\Container\ContainerInterface; * @since 4.0.0 */ class WeblinksComponent extends MVCComponent implements CategoryServiceInterface, AssociationServiceInterface, - TagServiceInterface, RouterServiceInterface, BootableExtensionInterface + TagServiceInterface, RouterServiceInterface, BootableExtensionInterface, FieldsServiceInterface { use CategoryServiceTrait; use AssociationServiceTrait; @@ -64,6 +67,59 @@ class WeblinksComponent extends MVCComponent implements CategoryServiceInterface $this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class))); } + /** + * Returns a valid section for the given section. If it is not valid then null + * is returned. + * + * @param string $section The section to get the mapping for + * @param object $item The item + * + * @return string|null The new section + * + * @since 4.0.0 + */ + public function validateSection($section, $item = null) + { + if (Factory::getApplication()->isClient('site')) + { + // On the front end we need to map some sections + switch ($section) + { + // Adding/Editing a weblink + case 'form': + $section = 'weblink'; + break; + } + } + + if ($section != 'weblink') + { + // We don't know other sections + return null; + } + + return $section; + } + + /** + * Returns valid contexts + * + * @return array + * + * @since 4.0.0 + */ + public function getContexts(): array + { + Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR); + + $contexts = array( + 'com_weblinks.weblink' => Text::_('COM_WEBLINKS'), + ); + + return $contexts; + } + + /** * Returns the table for the count items functions for the given section. *