PHP Classes

File: tests/src/packages.php

Recommend this page to a friend!
  Packages of Thierry Feuzeu   Jaxon   tests/src/packages.php   Download  
File: tests/src/packages.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change:
Date: 4 months ago
Size: 1,359 bytes
 

Contents

Class file image Download
<?php

use Jaxon\App\FuncComponent;
use
Jaxon\Plugin\AbstractPackage;

class
SamplePackageClass extends FuncComponent
{
    public function
home()
    {
       
$this->response->debug('This class is registered by a package!!');
    }
}

class
SamplePackage extends AbstractPackage
{
   
/**
     * @inheritDoc
     */
   
public static function config(): array
    {
        return [
           
'classes' => [
               
SamplePackageClass::class,
            ],
           
'views' => [
               
'test' => [
                   
'directory' => realpath(__DIR__ . '/../views'),
                   
'extension' => '.php',
                   
// 'renderer' => 'jaxon', // This is the default value.
                   
'template' => [
                       
'option' => 'template',
                       
'default' => 'test',
                    ],
                ],
            ],
        ];
    }

   
/**
     * @inheritDoc
     */
   
public function getHtml(): string
   
{
        return
'';
    }
}

class
BadConfigPackage extends AbstractPackage
{
   
/**
     * @inheritDoc
     */
   
public static function config(): string|array
    {
        return
true; // This is wrong. The return value must be a string or an array.
   
}

   
/**
     * @inheritDoc
     */
   
public function getHtml(): string
   
{
        return
'';
    }
}