#!/usr/bin/php <?php $config = ['git_urls' => ['https://github.com/yfix/flysystem.git' => 'flysystem/'], 'autoload_config' => ['flysystem/src/' => 'League\\Flysystem'], 'example' => function () { $filesystem = new League\Flysystem\Filesystem(new League\Flysystem\Adapter\Local(__DIR__)); foreach ($filesystem->listContents() as $p) { echo $p['path'] . PHP_EOL; } }]; if ($return_config) { return $config; } require_once __DIR__ . '/_yf_autoloader.php'; new yf_autoloader($config);
/** * setup configuration for Doctrine ORM * * @param array $db_config array config for override the default configuration. */ public function setupConfigurationOrm(array $db_config = []) { // setup entity paths. // @todo [cms][modules] load models path from modules folder where module is enabled on certain site in db. Pending: decide to use Doctrine ORM or Spot ORM first. $paths = []; $fs = new \League\Flysystem\Filesystem(new \League\Flysystem\Adapter\Local(MODULE_PATH)); $modules = $fs->listContents(); if (is_array($modules)) { foreach ($modules as $module) { if (is_array($module) && array_key_exists('path', $module)) { $module_dirs = $fs->listContents($module['path']); if (is_array($module_dirs)) { foreach ($module_dirs as $module_dir) { if (is_array($module_dir) && array_key_exists('type', $module_dir) && $module_dir['type'] == 'dir' && array_key_exists('path', $module_dir) && array_key_exists('basename', $module_dir) && $module_dir['basename'] == 'Models') { $paths[] = MODULE_PATH . DS . $module_dir['path']; } } // endforeach; unset($module_dir); } unset($module_dirs); } } // endforeach; unset($module); } unset($fs, $modules); // setup isDevmode. $config = new SystemConfig(); $config->load('app'); $is_devMode = $config->get('debug', 'app'); //setup connection configuration. if (empty($db_config)) { $config->load('db'); $db_params = $config->get('ALL', 'db'); $table_prefix = $db_params['table_prefix']; unset($config, $db_params['table_prefix']); } else { // incase that there is overriden configuration. $db_params = $db_config; if (is_array($db_config)) { if (array_key_exists('table_prefix', $db_config)) { $table_prefix = $db_config['table_prefix']; } if (array_key_exists('table_siteid_prefix', $db_config)) { $table_siteid_prefix = $db_config['table_siteid_prefix']; } } unset($db_params['table_prefix'], $db_params['table_siteid_prefix']); } $evm = new EventManager(); $table_prefix_class = new TablePrefix($table_prefix, isset($table_siteid_prefix) ? $table_siteid_prefix : ''); $evm->addEventListener(Events::loadClassMetadata, $table_prefix_class); unset($table_prefix, $table_prefix_class); $doctrine_config = Setup::createAnnotationMetadataConfiguration($paths, $is_devMode); $doctrine_config->setSQLLogger(new \System\Libraries\Db\Logger()); $this->EntityManager = EntityManager::create($db_params, $doctrine_config, $evm); unset($db_params, $doctrine_config, $evm, $is_devMode); }
/** * Checks to see if the filename is in filesystem file list. * * @since 1.0.0 * @param League\Flysystem\Filesystem $filesystem The filesystem object * @param string $filename The filename * @access public * @return boolean Returns true if file was found otherwise false */ public function filename_in_filesystem($filesystem, $filename) { //Iterate each file in the remote cloud and check if the filename of the //$file is in this list, if so then its found, otherwise not foreach ($filesystem->listContents(DIRECTORY_SEPARATOR, FALSE) as $file) { if ($file['basename'] === $filename) { return TRUE; } } return FALSE; }