本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::getRequire方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getRequire方法的具体用法?PHP Filesystem::getRequire怎么用?PHP Filesystem::getRequire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getRequire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire(Filesystem $files)
{
$langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
$diff = [];
foreach (ModulesLoader::getRegisteredModules() as $module) {
if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
continue;
}
$locale = $this->input->getOption('locale');
foreach ($files->directories($module->getLocalePath()) as $localeDir) {
foreach ($files->allFiles($localeDir) as $localeFile) {
$vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
$vendorFilePath = $langDirectory . $vendorFileDir;
if (file_exists($vendorFilePath)) {
$localArray = $files->getRequire($localeFile->getRealPath());
$vendorArray = $files->getRequire($vendorFilePath);
$array = array_keys_exists_recursive($localArray, $vendorArray);
$arrayDiff = '';
foreach (array_dot($array) as $key => $value) {
$arrayDiff .= "{$key}: {$value}\n";
}
if (empty($arrayDiff)) {
continue;
}
$diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
$diff[] = new TableSeparator();
$diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
$diff[] = new TableSeparator();
}
}
}
}
$this->table($this->headers, $diff);
}
示例2: save
public function save($item, $value, $environment, $group, $namespace = null)
{
$path = DIR_APPLICATION . '/config/generated_overrides';
if (!$this->files->exists($path)) {
$this->files->makeDirectory($path, 0777);
} elseif (!$this->files->isDirectory($path)) {
$this->files->delete($path);
$this->files->makeDirectory($path, 0777);
}
if ($namespace) {
$path = "{$path}/{$namespace}";
if (!$this->files->exists($path)) {
$this->files->makeDirectory($path, 0777);
} elseif (!$this->files->isDirectory($path)) {
$this->files->delete($path);
$this->files->makeDirectory($path, 0777);
}
}
$file = "{$path}/{$group}.php";
$current = array();
if ($this->files->exists($file)) {
$current = $this->files->getRequire($file);
}
array_set($current, $item, $value);
$renderer = new Renderer($current);
return $this->files->put($file, $renderer->render()) !== false;
}
示例3: handle
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$roles = $this->file->getRequire(base_path(config('trust.permissions')));
$this->call('trust:permissions');
$all = Permission::all(['id', 'slug']);
$create = 0;
$update = 0;
foreach ($roles as $slug => $attributes) {
$role = $this->findRole($slug);
if ($role) {
if ($this->option('force')) {
++$update;
$role->update($attributes + compact('slug'));
}
} else {
++$create;
$role = Role::create($attributes + compact('slug'));
}
$permissions = array_reduce(Arr::get($attributes, 'permissions', []), function (Collection $result, string $name) use($all) {
if (hash_equals('*', $name)) {
return $all->pluck('id');
}
if ($all->count() === $result->count()) {
return $result;
}
$filtered = $all->filter(function (Permission $permission) use($name) {
return Str::is($name, $permission->slug);
})->pluck('id');
return $result->merge($filtered);
}, new Collection());
$role->permissions()->sync($permissions->toArray());
}
$total = $create + $update;
$this->line("Installed {$total} roles. <info>({$create} new roles, {$update} roles synced)</info>");
}
示例4: loadPath
/**
* Load a locale from a given path.
*
* @param string $path
* @param string $locale
* @param string $group
* @return array
*/
protected function loadPath($path, $locale, $group)
{
if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
return $this->files->getRequire($full);
}
return array();
}
示例5: findExtensions
/**
* Find the extensions.
*
* @param array $paths
* @return array
*/
public function findExtensions(array $paths)
{
$files = array();
// Iterate over the paths.
foreach ($paths as $path) {
// Find the extension files.
$found = $this->filesystem->glob($path . '/*/*/extension.php');
// Check if we found some files.
if (is_array($found)) {
// Merge the files.
$files = array_merge($files, $found);
}
}
$extensions = array();
// Iterate over the files.
foreach ($files as $file) {
// Get the extension attributes.
$attributes = $this->filesystem->getRequire($file);
// Check if the attributes are valid.
if (is_array($attributes) && isset($attributes['slug'])) {
// Initialise the extension class.
$extensions[$attributes['slug']] = new Extension(dirname($file), $attributes);
}
}
return $extensions;
}
示例6: get
/**
* @param string $locale
* @param string $group
* @return array
*/
public function get($locale, $group)
{
if ($this->fs->exists($path = $this->path . "/{$locale}/{$group}.php")) {
return $this->fs->getRequire($path);
}
return [];
}
示例7: getRequire
public function getRequire($fullPath)
{
if (!$this->filesystem->exists($fullPath)) {
return null;
}
return $this->filesystem->getRequire($fullPath);
}
示例8: get
public function get($path, array $data = array())
{
$filename = $this->files->name($path) . '.' . $this->files->extension($path);
$compile_path = \Config::get('view.compiled') . DIRECTORY_SEPARATOR . $filename;
$template_last_modified = $this->files->lastModified($path);
$cache_last_modified = $this->files->isFile($compile_path) ? $this->files->lastModified($compile_path) : $template_last_modified;
$view = $this->files->get($path);
$app = app();
// $m = new Mustache_Engine($app['config']->get('handlelars'));
// Configuration
$cache_disabled = false;
$helpers = \Config::get('handlelars.helpers');
// Precompile templates to view cache when necessary
$compile = $template_last_modified >= $cache_last_modified || $cache_disabled;
if ($compile) {
$tpl = LightnCandy::compile($view, compact('helpers'));
$this->files->put($compile_path, $tpl);
}
if (isset($data['__context']) && is_object($data['__context'])) {
$data = $data['__context'];
} else {
$data = array_map(function ($item) {
return is_object($item) && method_exists($item, 'toArray') ? $item->toArray() : $item;
}, $data);
}
$renderer = $this->files->getRequire($compile_path);
return $renderer($data);
}
示例9: load
/**
* Load the settings from the cache.
*
* @param string $env
*
* @return array|false
*/
public function load($env)
{
try {
return $this->files->getRequire($this->path($env));
} catch (Exception $e) {
return false;
}
}
示例10: load
/**
* Load the environment variables for the given environment.
*
* @param string $environment
* @return array
*/
public function load($environment = null)
{
if ($environment == 'production') {
$environment = null;
}
if (!$this->files->exists($path = $this->getFile($environment))) {
return array();
}
return array_dot($this->files->getRequire($path));
}
示例11: loadManifest
/**
* Load the service provider manifest JSON file.
*
* @return array|null
*/
public function loadManifest()
{
// The service manifest is a file containing a JSON representation of every
// service provided by the application and whether its provider is using
// deferred loading or should be eagerly loaded on each request to us.
if ($this->files->exists($this->manifestPath)) {
$manifest = $this->files->getRequire($this->manifestPath);
return array_merge(['when' => []], $manifest);
}
}
示例12: __construct
private function __construct()
{
$this->_http = new Http();
// Инициализация конфигов
$fileSystem = new Filesystem();
$files = $fileSystem->allFiles('config');
foreach ($files as $file) {
if (is_array($fileSystem->getRequire($file))) {
$this->setConfig($fileSystem->getRequire($file), $fileSystem->name($file));
}
}
}
示例13: getById
/**
* Get a user by its ID.
*
* @param mixed $id
* @return \Stidges\LaravelDbNormalizer\Entity
*/
public function getById($id)
{
$users = $this->files->getRequire($this->path);
$result = [];
foreach ($users as $user) {
if ($user['id'] == $id) {
$result = $user;
break;
}
}
return $this->normalizer->normalize($result);
}
示例14: addNamespaceOverrides
/**
* Add namespace overrides to configuration.
*
* @param $namespace
* @param $directory
*/
public function addNamespaceOverrides($namespace, $directory)
{
if (!$this->files->isDirectory($directory)) {
return;
}
/* @var SplFileInfo $file */
foreach ($this->files->allFiles($directory) as $file) {
$key = trim(str_replace($directory, '', $file->getPath()) . DIRECTORY_SEPARATOR . $file->getBaseName('.php'), DIRECTORY_SEPARATOR);
// Normalize key slashes.
$key = str_replace('\\', '/', $key);
$this->config->set($namespace . '::' . $key, array_replace($this->config->get($namespace . '::' . $key, []), $this->files->getRequire($file->getPathname())));
}
}
示例15: loadExtensions
/**
* Load extensions in memory
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function loadExtensions()
{
$extensions = $this->filesystem->directories($this->path);
foreach ($extensions as $extension) {
$name = basename($extension);
$class = $this->extensionClass($name);
$this->filesystem->getRequire($extension . '/start.php');
$extensionInstance = new $class($extension, $name);
if (in_array($name, $this->settings->get('extensions', []))) {
$extensionInstance->setActive();
}
$this->extensions->push($extensionInstance);
}
}