Example #1
0
/**
 * 2016-08-02
 * *) По аналогии с @see \Magento\Config\Block\System\Config\Form::initForm()
 * *) Мы не можем кэшировать результат, потому что возвращаемые объекты - это приспособленцы (fleweights).
 * *) Метод не может вернуть обект класса @see \Magento\Config\Model\Config\Structure\Element\Tab
 * потому что идентификатор вкладки не входит в $path.
 * Для получения данных вкладки используйте метод @see \Df\Config\Model\Config\Structure::tab()
 * Для получения названия вкладки используйте функцию @see df_config_tab_label()
 *
 * @param string $path
 * @param bool $throw [optional]
 * @param string|null $expectedClass [optional]
 * @return IElement|Field|Group|Section|null
 */
function df_config_e($path, $throw = true, $expectedClass = null)
{
    /** @var IElement|Field|Group|Section|null $result */
    $result = df_config_structure()->getElement($path);
    if (!$result && $throw) {
        df_error_html(__("Unable to read the configuration node «<b>%1</b>»", $path));
    }
    return !$result || !$expectedClass || $result instanceof $expectedClass ? $result : df_error_html(__("The configuation node «<b>%1</b>» should be an instance of the <b>%2</b> class, " . "but actually it is an instance of the <b>%3</b> class.", $path, $expectedClass, df_cts($result)));
}
Example #2
0
/**
 * 2016-08-10
 * @param int $offset [optional]
 * @return string
 */
function df_caller_f($offset = 0)
{
    /** @var string $result */
    $result = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3 + $offset)[2 + $offset]['function'];
    /**
     * 2016-09-06
     * Порой бывают случаи, когда @see df_caller_f() ошибочно вызывается из @see \Closure.
     * @see \Df\Payment\Settings::currency()
     * Добавил защиту от таких случаев.
     */
    if (df_contains($result, '{closure}')) {
        df_error_html("The <b>df_caller_f()</b> function is wrongly called from the «<b>{$result}</b>» closure.");
    }
    return $result;
}
Example #3
0
/**
 * @see df_not_implemented()
 * @return void
 * @throws DFE
 */
function df_should_not_be_here()
{
    df_error_html('The method %s is not allowed to call.', df_caller_mh());
}