Answer the question
In order to leave comments, you need to log in
Modx how to initialize fenom object in console?
I want to create a modifier for fenom through the console
I know how to do it through the plugin and the pdoToolsOnFenomInit event
<?php
/** @var modX $modx */
switch ($modx->event->name) {
case 'pdoToolsOnFenomInit':
/** @var Fenom $fenom
Мы получаем переменную $fenom при его первой инициализации и можем вызывать его методы.
Например, добавим модификатор вывода имени домена сайта из произвольной ссылки.
*/
$fenom->addModifier('myModif', function ($input) {
return ($input + 2);
});
break;
}
<?php
include 'core/components/pdotools/vendor/fenom/fenom/src/Fenom.php';
$fenom = new Fenom();
$fenom->addModifier('mymodif2', function ($input) {
return ($input + 5);
});
Answer the question
In order to leave comments, you need to log in
You need to initialize pdoTools and then use fenom:
<?php
/** @var array $scriptProperties */
/** @var pdoFetch $pdoFetch */
$fqn = $modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
$path = $modx->getOption('pdofetch_class_path', null, MODX_CORE_PATH . 'components/pdotools/model/', true);
if ($pdoClass = $modx->loadClass($fqn, $path, false, true)) {
$pdoFetch = new $pdoClass($modx, $scriptProperties);
} else {
return false;
}
$pdoFetch->addTime('pdoTools loaded');
$modx->log(1, 'test: ' . $test);
$modx->log(1, 'array: ' . print_r($array, 1));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question