1. Go to this page and download the library: Download jeyroik/extas-patterns 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/ */
namespace my\extas\interafces\extensions;
interface ILevelsPatternExtension
{
public function getLevel1(): array;
public function getLevel1_1(): string;
public function getLevel2(): array;
public function getLevel2_1(): string;
public function getLevel3(): string;
}
namespace my\extas\components\extensions;
use extas\components\extensions\Extension;
use extas\interfaces\patterns\IPattern;
class LevelsPatternExtension extends Extension implements ILevelsPatternExtension
{
public function getLevel1(IPattern $pattern = null)
{
$schema = $pattern->getImportedData();
return $schema['level1'] ?? [];
}
public function getLevel1_1(IPattern $pattern)
{
$schema = $pattern->getImportedData();
return $schema['level1.1'] ?? '';
}
public function getLevel2(IPattern $pattern = null)
{
$level1 = $this->getLevel1($pattern);
return $level1['level2'] ?? [];
}
public function getLevel2_1(IPattern $pattern = null)
{
$level1 = $this->getLevel1($pattern);
return $level1['level2.1'] ?? '';
}
public function getLevel3(IPattern $pattern = null)
{
$level2 = $this->getLevel2($pattern);
return $level2['level3'] ?? '';
}
}