HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/tandartsmaas.komma.pro/app/controllers/BaseController.php
<?php

use Komma\Navigation\NavigationService;
use Komma\Pages\PageRepository;

abstract class BaseController extends Controller
{
    /**
     * @var NavigationService
     */
    protected $navigationService;
    /**
     * @var \Komma\Pages\PageRepository
     */
    protected $currentPageEntity;

    /**
     * @param NavigationService $navigationService
     */
    public function __construct(NavigationService $navigationService)
    {
        $this->navigationService = $navigationService;
        \View::share('navigation', $this->navigationService);
        \View::share('komma',
            strpos(Request::getHttpHost(), 'komma') !== false ||
            strpos(Request::getHttpHost(), 'local') !== false);
    }

    /**
     * @param $param
     * @param $pageEntity
     * @param null $method
     * @return mixed
     */
    public function routeProcessor($param, $pageEntity, $method = null)
    {
        /*
        |--------------------------------------------------------------------------
        | Set CurrentPageEntity data for the controller and the view
        |--------------------------------------------------------------------------
        */

        $this->currentPageEntity = $pageEntity;
        \View::share('currentPageEntity', $this->currentPageEntity);

        /*
        |--------------------------------------------------------------------------
        | Check for method
        |--------------------------------------------------------------------------
        */

        if($method != null) return $this->{$method}();

        /*
        |--------------------------------------------------------------------------
        | If no method specified and no param, go to index
        |--------------------------------------------------------------------------
        */

        if(empty($param) || $param == '/') return $this->index();

        /*
        |--------------------------------------------------------------------------
        | If a param is found, check if the param is and existing method
        |--------------------------------------------------------------------------
        */

        // Get urls
        $urls = explode('?',$param);
        $urlsWithoutGet = $urls[0];

        $urls = explode('/', $urlsWithoutGet);

        // First url is the method
        $method = camel_case($urls[0]);

        // Get the parameters
        unset($urls[0]);
        $arguments = array_values($urls);

        // Call a dynamic method with the arguments
        if(method_exists($this, $method))
        {
            return call_user_func_array([$this, $method], $arguments);
        }

        /*
        |--------------------------------------------------------------------------
        | If nothing found, trow a 404 exception
        |--------------------------------------------------------------------------
        */

        return App::abort(404);
    }

    /**
     * @param $view
     * @param $title
     * @return mixed
     */
    public function renderView($view,$pageEntity)
    {
        /*
        |--------------------------------------------------------------------------
        | Return normal view
        |--------------------------------------------------------------------------
        */

        if ( ! Request::ajax()) return $view;

        /*
        |--------------------------------------------------------------------------
        | Return data as json
        |--------------------------------------------------------------------------
        */

        return Response::json([
            'view' => $view,
            'title' => $pageEntity->metaTitle,
            'name' => $pageEntity->name
        ]);
    }
}