PHP code example of jeyroik / extas-templates

1. Go to this page and download the library: Download jeyroik/extas-templates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeyroik / extas-templates example snippets



use extas\interfaces\templates\IHasTemplate;

use extas\components\Item;
use extas\components\repositories\Repository;
use extas\components\templates\THasTemplate;

class CarTemplatesRepository extends Repository
{
}

class Car extends Item implements IHasTemplte
{
    use THasTemplate;
    
    public function getTemplateRepository()
    {
        return new CarTemplatesRepository();
    }
}

/**
 * @var $templateRepo CarTemplatesRepository
 */
$mazda = new Template(['name' => 'mazda', 'description' => 'Mazda model']);
$templateRepo->create($mazda);

$car = new Car([IHasTemplate::FIELD__TEMPLATE => 'mazda']);
echo $car->getTemplate()->getDescription(); // 'Mazda model'