1. Go to this page and download the library: Download jeyroik/extas-terms 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-terms example snippets
use \extas\interfaces\terms\ITerm;
$terms = $this->terms()->all([ITerm::FIELD__TAGS => 'some.tag']);
use extas\interfaces\terms\ITermCalculatorDescription;
$calculators = $this->termsCalculators()->all();
use extas\interfaces\terms\ITerm;
use extas\interfaces\terms\ITermCalculatorDescription;
use extas\interfaces\terms\ITermCalculationResult;
use extas\interfaces\terms\ITermCalculator;
/**
* @var ITerm[] $terms
* @var ITermCalculatorDescription[] $calculators
*/
$calculated = [];
foreach ($calculators as $calculatorDescription) {
/**
* @var ITermCalculationResult $result
* @var ITermCalculator $calculator
*/
$calculator = $calculatorDescription->buildClassWithParameters([]);
$result = $calculator->calculateTerms($terms, ['some' => 'args']);
/**
* Or you can just
* $result = $calculatorDescription->runWithParameters([], 'calculateTerms', $terms);
*/
/**
* You should iterate terms if you need to pass different arguments to each of them:
* foreach($terms as $terms) {
* if ($calculator->canCalculate($term, ['some1' => 'arg1'])) {
* $calculated[] = $calculator->calculateTerm($term, ['some1' => 'arg1']);
* }
* }
*/
$calculated = array_merge($calculated, $result->getCalculatedTerms());
$terms = array_column($result->getSkippedTerms(), ITermCalculationResult::SKIPPED__TERM);
if (empty($terms)) {
break;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.