Ejemplo n.º 1
0
Archivo: qa.php Proyecto: mage2pro/core
/**
 * @param int $levelsToSkip
 * Позволяет при записи стека вызовов пропустить несколько последних вызовов функций,
 * которые и так очевидны (например, вызов данной функции, вызов df_bt() и т.п.)
 * @return void
 */
function df_bt($levelsToSkip = 0)
{
    /** @var array $bt */
    $bt = array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), $levelsToSkip);
    /** @var array $compactBT */
    $compactBT = [];
    /** @var int $traceLength */
    $traceLength = count($bt);
    /**
     * 2015-07-23
     * 1) Удаляем часть файлового пути до корневой папки Magento.
     * 2) Заменяем разделитель папок на унифицированный.
     */
    /** @var string $bp */
    $bp = BP . DS;
    /** @var bool $nonStandardDS */
    $nonStandardDS = DS !== '/';
    for ($traceIndex = 0; $traceIndex < $traceLength; $traceIndex++) {
        /** @var array $currentState */
        $currentState = dfa($bt, $traceIndex);
        /** @var array(string => string) $nextState */
        $nextState = dfa($bt, 1 + $traceIndex, []);
        /** @var string $file */
        $file = str_replace($bp, '', dfa($currentState, 'file'));
        if ($nonStandardDS) {
            $file = df_path_n($file);
        }
        $compactBT[] = ['File' => $file, 'Line' => dfa($currentState, 'line'), 'Caller' => !$nextState ? '' : df_cc_method($nextState), 'Callee' => !$currentState ? '' : df_cc_method($currentState)];
    }
    df_report('bt-{date}-{time}.log', print_r($compactBT, true));
}
Ejemplo n.º 2
0
/**
 * 2016-09-03
 * Другой возможный алгоритм: df_explode_multiple(['/', DS], $path)
 * @param string $path
 * @return string[]
 */
function df_explode_path($path)
{
    return df_explode_xpath(df_path_n($path));
}
Ejemplo n.º 3
0
 /**
  * 2016-09-03
  * «vendor/mage2pro/core/Backend/composer.json» => «vendor/mage2pro/core/composer.json»
  * @override
  * @see \Magento\SampleData\Model\Dependency::getModuleComposerPackage()
  * @used-by \Magento\SampleData\Model\Dependency::getSuggestsFromModules()
  * @param string $file
  * @return \Magento\Framework\Config\Composer\Package
  */
 protected function getModuleComposerPackage($file)
 {
     return parent::getModuleComposerPackage(false === strpos($file, 'mage2pro') || file_exists($file) ? $file : preg_replace('#/mage2pro/core/[^/]+/#', '/mage2pro/core/', df_path_n($file)));
 }
Ejemplo n.º 4
0
/**
 * 2015-12-06
 * Левый «/» мы убираем.
 * Результат вызова @uses \Magento\Framework\Filesystem\Directory\Read::getAbsolutePath()
 * завершается на «/»
 * @param string $path
 * @param string $base [optional]
 * @return string
 */
function df_path_relative($path, $base = BP)
{
    return df_trim_ds_left(df_trim_text_left(df_path_n($path), df_trim_ds_left(df_fs_r($base)->getAbsolutePath())));
}