<?php

/**
 * @package         Tassos Code Snippets
 * @version         1.0.1-RC2 Free
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            https://www.tassos.gr
 * @copyright       Copyright © 2026 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

namespace Tassos\CodeSnippets\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Tassos\Framework\Extension;

/**
 * Default Controller
 */
class DisplayController extends BaseController
{
    /**
     * The default view.
     *
     * @var    string
     */
    protected $default_view = 'snippets';

    /**
     * Method to display a view.
     *
     * @param   boolean  $cachable   If true, the view output will be cached
     * @param   array    $urlparams  An array of safe URL parameters and their variable types
     *
     * @return  static|boolean  This object to support chaining or false on failure.
     */
    public function display($cachable = false, $urlparams = [])
    {
        if (!Extension::pluginIsEnabled('nrframework'))
        {
            \Tassos\Framework\Functions::loadLanguage();
            $this->app->enqueueMessage(
                Text::sprintf('NR_EXTENSION_REQUIRED', Text::_('COM_TASSOSCODESNIPPETS'), Text::_('PLG_SYSTEM_NRFRAMEWORK')), 
                'error'
            );
        }

        if (!Extension::pluginIsEnabled('tassoscodesnippets'))
        {
            $this->app->enqueueMessage(
                Text::sprintf('NR_EXTENSION_REQUIRED', Text::_('COM_TASSOSCODESNIPPETS'), Text::_('COM_TASSOSCODESNIPPETS') . ' System'), 
                'error'
            );
        }

        return parent::display($cachable, $urlparams);
    }
}