/** * Tests that the storage location is a directory and is writable. */ public function __construct($filename) { // Get the directory name $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/'; // Set the filename from the real directory path $filename = $directory . basename($filename); // Make sure the cache directory is writable if (!is_dir($directory) or !is_writable($directory)) { throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory)); } // Make sure the cache database is writable if (is_file($filename) and !is_writable($filename)) { throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename)); } // Open up an instance of the database $this->db = new SQLiteDatabase($filename, '0666', $error); // Throw an exception if there's an error if (!empty($error)) { throw new KoException('Cache: Driver error - ' . sqlite_error_string($error)); } $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'"; $tables = $this->db->query($query, SQLITE_BOTH, $error); // Throw an exception if there's an error if (!empty($error)) { throw new KoException('Cache: Driver error - ' . sqlite_error_string($error)); } if ($tables->numRows() == 0) { // Issue a CREATE TABLE command $this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $path = $input->getArgument('path'); if (!file_exists($path)) { $output->writeln("{$path} is not a file or a path"); } $filePaths = []; if (is_file($path)) { $filePaths = [realpath($path)]; } elseif (is_dir($path)) { $filePaths = array_diff(scandir($path), array('..', '.')); } else { $output->writeln("{$path} is not known."); } $generator = new StopwordGenerator($filePaths); if ($input->getArgument('type') === 'json') { echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE); echo json_last_error_msg(); die; $output->write(json_encode($this->toArray($generator->getStopwords()))); } else { $stopwords = $generator->getStopwords(); $stdout = fopen('php://stdout', 'w'); echo 'token,freq' . PHP_EOL; foreach ($stopwords as $token => $freq) { fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL; } fclose($stdout); } }
function display($tmpl_file, $app_id = null) { array_unshift($this->_files, $tmpl_file); $this->_vars = $this->pagedata; if ($p = strpos($tmpl_file, ':')) { $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p)); if ($object) { $tmpl_file_path = substr($tmpl_file, $p + 1); $last_modified = $object->last_modified($tmpl_file_path); } } else { $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file); $last_modified = filemtime($tmpl_file); } if (!$last_modified) { //无文件 } $compile_id = $this->compile_id($tmpl_file); if ($object) { $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path)); } else { $compile_code = $this->_compiler()->compile_file($tmpl_file); } eval('?>' . $compile_code); array_shift($this->_files); }
function __construct() { parent::__construct(); $this->gallery_path = realpath(APPPATH . '../images'); /*I also can use BASEPATH rather than APPPATH*/ $this->gallery_path_url = base_url() . 'images/'; }
function entry(&$argv) { if (is_file($argv[0])) { if (0 === substr_compare($argv[0], '.class.php', -10)) { $uri = realpath($argv[0]); if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) { throw new \Exception('Cannot load ' . $uri . ' - not in class path'); } return $cl->loadUri($uri)->literal(); } else { if (0 === substr_compare($argv[0], '.xar', -4)) { $cl = \lang\ClassLoader::registerPath($argv[0]); if (!$cl->providesResource('META-INF/manifest.ini')) { throw new \Exception($cl->toString() . ' does not provide a manifest'); } $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini')); return strtr($manifest['main-class'], '.', '\\'); } else { array_unshift($argv, 'eval'); return 'xp\\runtime\\Evaluate'; } } } else { return strtr($argv[0], '.', '\\'); } }
public function __invoke($ctx) { if (isset($ctx['Directory']['path'])) { $path = $ctx['Directory']['path']; } else { $url = $ctx['env']['PATH_INFO']; if (strpos($url, '..') !== false) { return array(403, array('Content-Type', 'text/plain'), 'Forbidden'); } $path = $this->path . $url; } // Sanity checks if (!file_exists($path)) { return array(404, array('Content-Type', 'text/plain'), 'File not found'); } $path = realpath($path); if (false === $path) { // resolving failed. not enough rights for intermediate folder? return array(404, array('Content-Type', 'text/plain'), 'File not found'); } if (strpos($path, $this->path) !== 0) { // gone out of "chroot"? return array(404, array('Content-Type', 'text/plain'), 'File not found'); } if (!is_readable($path)) { return array(403, array('Content-Type', 'text/plain'), 'Forbidden'); } // Only files are served if (is_dir($path)) { return array(403, array('Content-Type', 'text/plain'), 'Forbidden'); } return $this->serve($path); }
/** * Setup the seeds. * * @param \Illuminate\Contracts\Foundation\Application $app * * @return void */ protected function setupSeeds(Application $app) { $source = realpath(__DIR__ . '/../database/seeds/'); if ($app instanceof LaravelApplication && $app->runningInConsole()) { $this->publishes([$source => database_path('seeds')], 'seeds'); } }
/** * Register the service provider. * * @return void */ public function register() { parent::register(); $configPath = realpath(__DIR__ . '/../config/UEditorUpload.php'); $this->mergeConfigFrom($configPath, 'UEditorUpload'); $this->publishes([$configPath => config_path('UEditorUpload.php')], 'config'); }
/** * Smarty debug_console function plugin * * Type: core<br> * Name: display_debug_console<br> * Purpose: display the javascript debug console window * @param array Format: null * @param Smarty */ function smarty_core_display_debug_console($params, &$smarty) { // we must force compile the debug template in case the environment // changed between separate applications. if (empty($smarty->debug_tpl)) { // set path to debug template from SMARTY_DIR $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; if ($smarty->security && is_file($smarty->debug_tpl)) { $smarty->secure_dir[] = realpath($smarty->debug_tpl); } $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; } $_ldelim_orig = $smarty->left_delimiter; $_rdelim_orig = $smarty->right_delimiter; $smarty->left_delimiter = '{'; $smarty->right_delimiter = '}'; $_compile_id_orig = $smarty->_compile_id; $smarty->_compile_id = null; $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) { ob_start(); $smarty->_include($_compile_path); $_results = ob_get_contents(); ob_end_clean(); } else { $_results = ''; } $smarty->_compile_id = $_compile_id_orig; $smarty->left_delimiter = $_ldelim_orig; $smarty->right_delimiter = $_rdelim_orig; return $_results; }
public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__ . '/../Fixtures/'); require_once self::$fixturesPath . '/includes/foo.php'; require_once self::$fixturesPath . '/includes/ProjectExtension.php'; require_once self::$fixturesPath . '/includes/ProjectWithXsdExtension.php'; }
/** * Function used to auto load the framework classes * * It imlements PSR-0 and PSR-4 autoloading standards * The required class name should be prefixed with a namespace * This lowercaser of the namespace should match the folder name of the class * * @since 1.0.0 * @param string $class_name name of the class that needs to be included */ function autoload_framework_classes($class_name) { error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); /** If the required class is in the global namespace then no need to autoload the class */ if (strpos($class_name, "\\") === false) { return false; } /** The namespace seperator is replaced with directory seperator */ $class_name = str_replace("\\", DIRECTORY_SEPARATOR, $class_name); /** The class name is split into namespace and short class name */ $path_info = explode(DIRECTORY_SEPARATOR, $class_name); /** The namepsace is extracted */ $namespace = implode(DIRECTORY_SEPARATOR, array_slice($path_info, 0, count($path_info) - 1)); /** The class name is extracted */ $class_name = $path_info[count($path_info) - 1]; /** The namespace is converted to lower case */ $namespace_folder = trim(strtolower($namespace), DIRECTORY_SEPARATOR); /** .php is added to class name */ $class_name = $class_name . ".php"; /** The applications folder name */ $framework_folder_path = realpath(dirname(__FILE__)); /** The application folder is checked for file name */ $file_name = $framework_folder_path . DIRECTORY_SEPARATOR . $namespace_folder . DIRECTORY_SEPARATOR . $class_name; if (is_file($file_name)) { include_once $file_name; } }
public function __set($strName, $mixValue) { switch ($strName) { case "HtmlIncludeFilePath": // Passed-in value is null -- use the "default" path name of file".tpl.php" if (!$mixValue) { $strPath = realpath(substr(QApplication::$ScriptFilename, 0, strrpos(QApplication::$ScriptFilename, '.php')) . '.tpl.php'); } else { $strPath = realpath($mixValue); } // Verify File Exists, and if not, throw exception if (is_file($strPath)) { $this->strHtmlIncludeFilePath = $strPath; return $strPath; } else { throw new QCallerException('Accompanying HTML Include File does not exist: "' . $mixValue . '"'); } break; case "CssClass": try { return $this->strCssClass = QType::Cast($mixValue, QType::String); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: try { return parent::__set($strName, $mixValue); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * Takes the included files and breaks up into mutli arrays for use in the debugger * @param array $files * @return Ambigous <multitype:unknown , unknown> */ public function setup_files(array $files) { sort($files); $path_third = realpath(eedt_third_party_path()); $path_ee = realpath(APPPATH); $path_first_modules = realpath(PATH_MOD); $bootstrap_file = FCPATH . SELF; $return = array(); foreach ($files as $file) { if (strpos($file, $path_third) === 0) { $return['third_party_addon'][] = $file; continue; } if (strpos($file, $path_first_modules) === 0) { $return['first_party_modules'][] = $file; continue; } if (strpos($file, $bootstrap_file) === 0) { $return['bootstrap_file'] = $file; continue; } if (strpos($file, $path_ee) === 0) { $return['expressionengine_core'][] = $file; continue; } $return['other_files'][] = $file; } return $return; }
protected function _initView() { // Start initail view $this->bootstrap('layout'); $config = $this->getOption('views'); $resources = $this->getOption('resources'); $view = new Zend_View(); if (isset($resources['layout']['layoutPath'])) { $view->assign('layoutRootPath', $resources['layout']['layoutPath']); } $this->bootstrap('db'); Zend_Loader::loadClass('Ht_Utils_SystemSetting'); $sysSetting = Ht_Utils_SystemSetting::getSettings(); $view->assign('sysSetting', $sysSetting); $view->assign('profile', Zend_Auth::getInstance()->getIdentity()); Zend_Loader::loadClass("Ht_Model_SystemSetting"); $this->setSystemLogConfiguration($sysSetting); // use the viewrenderer to keep the code DRY // instantiate and add the helper in one go $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view); $viewRenderer->setViewSuffix('phtml'); // add it to the action helper broker Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); /** * Set inflector for Zend_Layout */ $inflector = new Zend_Filter_Inflector(':script.:suffix'); $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml')); // Initialise Zend_Layout's MVC helpers $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector); return $this->getResource('layout')->getView(); }
function run_propel_build_sql_diff($task, $args) { if (!count($args)) { throw new Exception('You must provide the application.'); } $app = $args[0]; if (!is_dir(sfConfig::get('sf_app_dir') . DIRECTORY_SEPARATOR . $app)) { throw new Exception(sprintf('The app "%s" does not exist.', $app)); } run_propel_build_sql($task, $args); pake_echo_action('propel-sql-diff', "building database patch"); define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../../..')); define('SF_APP', $app); define('SF_ENVIRONMENT', isset($args[1]) ? $args[1] : 'dev'); define('SF_DEBUG', 1); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $i = new dbInfo(); $i->loadFromDb(); $i2 = new dbInfo(); $i2->loadAllFilesInDir(sfConfig::get('sf_data_dir') . '/sql'); $diff = $i->getDiffWith($i2); $filename = sfConfig::get('sf_data_dir') . '/sql/diff.sql'; if ($diff == '') { pake_echo_comment("no difference found"); } pake_echo_action('propel-sql-diff', "writing file {$filename}"); file_put_contents($filename, $diff); }
/** * Constructor. * * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0 */ public function __construct($classLoader) { $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile'); if ($this->wasFinder) { @trigger_error('The ' . __METHOD__ . ' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED); $this->classLoader = array($classLoader, 'loadClass'); $this->isFinder = true; } else { $this->classLoader = $classLoader; $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); } if (!isset(self::$caseCheck)) { $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR); $i = strrpos($file, DIRECTORY_SEPARATOR); $dir = substr($file, 0, 1 + $i); $file = substr($file, 1 + $i); $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file); $test = realpath($dir . $test); if (false === $test || false === $i) { // filesystem is case sensitive self::$caseCheck = 0; } elseif (substr($test, -strlen($file)) === $file) { // filesystem is case insensitive and realpath() normalizes the case of characters self::$caseCheck = 1; } elseif (false !== stripos(PHP_OS, 'darwin')) { // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters self::$caseCheck = 2; } else { // filesystem case checks failed, fallback to disabling them self::$caseCheck = 0; } } }
public function runUnitTests($tests) { // Build any unit tests $this->make('build-tests'); // Now find all the test programs $root = $this->getProjectRoot(); $test_dir = $root . "/tests/"; $futures = array(); if (!$tests) { $paths = glob($test_dir . "*.t"); } else { $paths = array(); foreach ($tests as $path) { $tpath = preg_replace('/\\.c$/', '.t', $path); if (preg_match("/\\.c\$/", $path) && file_exists($tpath)) { $paths[] = realpath($tpath); } } } foreach ($paths as $test) { $relname = substr($test, strlen($test_dir)); $futures[$relname] = new ExecFuture($test); } $results = array(); $futures = new FutureIterator($futures); foreach ($futures->limit(4) as $test => $future) { list($err, $stdout, $stderr) = $future->resolve(); $results[] = $this->parseTestResults($test, $err, $stdout, $stderr); } return $results; }
/** * Task to run pending migrations * * @return null */ protected function _execute(array $params) { $migrations = new MigrationManager(); Database::$default = $params['db']; $this->db = Database::instance(); $db_config = Kohana::$config->load('database')->{$params['db']}; if (!ORM::factory('Migration')->is_installed()) { /** * Get platform from database config */ $platform = strtolower($db_config['type']); if ('mysqli' == $platform) { $platform = 'mysql'; } /** * Get SQL from file for selected platform */ $file = realpath(substr(__DIR__, 0, strlen(__DIR__) - strlen('classes/Task/Db')) . 'sql/' . $platform . '.sql'); $handle = fopen($file, 'rb'); $sql_create = fread($handle, filesize($file)); $this->db->query(0, $sql_create); $msg = Minion_CLI::color("-----------------------------\n", 'green'); $msg .= Minion_CLI::color("| Migration table create!!! |\n", 'green'); $msg .= Minion_CLI::color("-----------------------------\n", 'green'); Minion_CLI::write($msg); } $migrations->migrate($params['db'], $params['step']); }
/** * Get Test Files * * @param null $directory * @param null $excludes * @return array */ public static function getTestFiles($directory = null, $excludes = null) { if (is_array($directory)) { $files = array(); foreach ($directory as $d) { $files = array_merge($files, self::getTestFiles($d, $excludes)); } return array_unique($files); } if ($excludes !== null) { $excludes = self::getTestFiles((array) $excludes); } if ($directory === null || $directory !== realpath($directory)) { $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS; $directory = str_replace(DS . DS, DS, $basePath . $directory); } $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); $files = array(); while ($it->valid()) { if (!$it->isDot()) { $file = $it->key(); if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) { $files[] = $file; } } $it->next(); } return $files; }
/** * {@inheritdoc} */ public function create() : ResourceNameCollection { $classes = []; $includedFiles = []; if ($this->decorated) { foreach ($this->decorated->create() as $resourceClass) { $classes[$resourceClass] = true; } } foreach ($this->paths as $path) { $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY), '/^.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH); foreach ($iterator as $file) { $sourceFile = $file[0]; if (!preg_match('(^phar:)i', $sourceFile)) { $sourceFile = realpath($sourceFile); } require_once $sourceFile; $includedFiles[$sourceFile] = true; } } $declared = get_declared_classes(); foreach ($declared as $className) { $reflectionClass = new \ReflectionClass($className); $sourceFile = $reflectionClass->getFileName(); if (isset($includedFiles[$sourceFile]) && $this->reader->getClassAnnotation($reflectionClass, ApiResource::class)) { $classes[$className] = true; } } return new ResourceNameCollection(array_keys($classes)); }
public function Zip($source, $destination, $overwrite = false) { if (!extension_loaded('zip') || !file_exists($source)) { return false; } $zip = new ZipArchive(); if (!$zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE)) { return false; } $source = str_replace('\\', '/', realpath($source)); if (is_dir($source) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $file = str_replace('\\', '/', $file); // Ignore "." and ".." folders if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) { continue; } $file = realpath($file); if (is_dir($file) === true) { $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); } else { if (is_file($file) === true) { $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } } } else { if (is_file($source) === true) { $zip->addFromString(basename($source), file_get_contents($source)); } } return $zip->close(); }
protected function ensureDirectory($root) { if (!is_dir($root) && !@mkdir($root, 0755, true)) { return false; } return realpath($root); }
public function setOption($config) { if (isset($config["applicationPath"])) { $this->applicationPath = realpath($config["applicationPath"]); } if (!$this->applicationPath) { throw new Exceptoin("not set 'applicationPath'"); } if (isset($config["controllersPath"])) { $this->controllersPath = realpath($config["controllersPath"]); } else { $this->controllersPath = $this->applicationPath . DIRECTORY_SEPARATOR . self::CONTROLLER_PATH . DIRECTORY_SEPARATOR; } if (isset($config["viewsPath"])) { $this->viewsPath = realpath($config["viewsPath"]); } else { $this->viewsPath = $this->applicationPath . DIRECTORY_SEPARATOR . self::VIEW_PATH . DIRECTORY_SEPARATOR; } if (isset($config["layoutPath"])) { $this->layoutPath = realpath($config["layoutPath"]); } else { $this->layoutPath = $this->applicationPath . DIRECTORY_SEPARATOR . self::LAYOUT_PATH . DIRECTORY_SEPARATOR; } if (isset($config["defaultController"]) and !empty($config["defaultController"])) { $this->defaultController = $config["defaultController"]; } if (isset($config["defaultAction"]) and !empty($config["defaultAction"])) { $this->defaultAction = $config["defaultAction"]; } if (isset($config["debug"]) and !empty($config["debug"])) { $this->debug = $config["debug"]; } }
/** * 项目生成 */ public function action_generator() { //检查来源 if (!($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1')) { FYTOOL::error_ctrl('你所在的主机不允许调用此方法。'); } if (FYTOOL::get_gp_value('submit')) { //通过按钮提交 $path = realpath(FYSCU_ROOT . '/../'); $project = isset($_POST['project']) ? $_POST['project'] : ''; if ($project != '') { $project = str_replace(array('/', '\\'), '', $project); $path = $path . '/' . $project; if (!file_exists($path)) { //创建目录 $fp = mkdir($path); $sig = FYTOOL::r_copy(FYSCU_ROOT . './pro_tpl/', $path); $fp_fyscu = mkdir($path . '/fyscu'); $sig_core = FYTOOL::r_copy(FYSCU_ROOT . './core/', $path . '/fyscu/core'); $sig_init = copy(FYSCU_ROOT . './fyscu.init.php', $path . './fyscu/fyscu.init.php'); $sig_dic = FYTOOL::r_copy(FYSCU_ROOT . './dic/', $path . '/fyscu/dic'); $ct = file_get_contents($path . '/index.php'); $ct = str_replace('UNAME', $project, $ct); file_put_contents($path . '/index.php', $ct); } header('location:/' . $project); } } }
/** * Assure that matching version-specific config files are loaded and others are ignored. */ function ConfigVersionSpecific() { $major = $this->drush_major_version(); // Arbitrarily choose the system search path. $path = realpath(UNISH_SANDBOX . '/etc/drush'); $contents = <<<EOD <?php // Written by Unish. This file is safe to delete. \$options['unish_foo'] = 'bar'; EOD; // Write matched and unmatched files to the system search path. $files = array($path . '/drush' . $major . 'rc.php', $path . '/drush999' . 'rc.php'); mkdir($path . '/drush' . $major); mkdir($path . '/drush999'); foreach ($files as $file) { file_put_contents($file, $contents); } $this->drush('core-status', array('Drush configuration'), array('pipe' => NULL)); $loaded = $this->getOutputFromJSON('drush-conf'); // Next 2 lines needed for Windows compatibility. $loaded = array_map(array(&$this, 'convert_path'), $loaded); $files = array_map(array(&$this, 'convert_path'), $files); $this->assertTrue(in_array($files[0], $loaded), 'Loaded a version-specific config file.'); $this->assertFalse(in_array($files[1], $loaded), 'Did not load a mismatched version-specific config file.'); }
/** * Set file * * @param string $file * @return void */ public function setFile($file) { $file = realpath($file); if ($file) { $this->file = $file; } }
private function formatPath($path) { $root = realpath(__DIR__ . '/../../../'); $path = realpath($path); $relative = substr($path, strlen($root) + 1); return preg_replace('~/([a-z0-9-]+)(\\.[a-z0-9]+)?$~ims', '/<fg=blue>$1</fg=blue>$2', $relative); }
/** * {@inheritdoc} */ public function get($filename, $scope) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $readDirectory = $objectManager->create('Magento\\Framework\\Filesystem\\Directory\\Read', ['config' => ['path' => realpath(__DIR__ . '/../../_files/etc')], 'driver' => $objectManager->create('Magento\\Framework\\Filesystem\\Driver\\File')]); $paths = ['data_object.xml']; return new \Magento\Framework\Config\FileIterator($readDirectory, $paths); }
/** * Initialize the provider * * @return void */ public function initialize() { $this->options = array_merge($this->defaultConfig, $this->options); date_default_timezone_set($this->options['log.timezone']); // Finally, create a formatter $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false); // Create a new directory $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path']; if (!is_dir($logPath)) { mkdir($logPath, 0755); } // Create a handler $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log'); // Set our formatter $stream->setFormatter($formatter); // Create LogWriter $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor()))); // Bind our logger to Bono Container $this->app->container->singleton('log', function ($c) { $log = new Log($c['logWriter']); $log->setEnabled($c['settings']['log.enabled']); $log->setLevel($c['settings']['log.level']); $env = $c['environment']; $env['slim.log'] = $log; return $log; }); // Set the writer $this->app->config('log.writer', $logger); }
/** * Add a View instance to the Collector * * @param \Illuminate\View\View $view */ public function addView(View $view) { $name = $view->getName(); $path = $view->getPath(); if (!is_object($path)) { if ($path) { $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); } if (substr($path, -10) == '.blade.php') { $type = 'blade'; } else { $type = pathinfo($path, PATHINFO_EXTENSION); } } else { $type = get_class($view); $path = ''; } if (!$this->collect_data) { $params = array_keys($view->getData()); } else { $data = array(); foreach ($view->getData() as $key => $value) { $data[$key] = $this->exporter->exportValue($value); } $params = $data; } $this->templates[] = array('name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type); }