本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::extension方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::extension方法的具体用法?PHP Filesystem::extension怎么用?PHP Filesystem::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::extension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importTranslations
public function importTranslations($replace = false)
{
$counter = 0;
foreach ($this->files->directories($this->app->langPath()) as $langPath) {
$locale = basename($langPath);
foreach ($this->files->allFiles($langPath) as $file) {
$group = $file->getRelativePathname();
$group = str_replace('.' . $this->files->extension($group), '', $group);
if (in_array($group, $this->config['exclude_groups'])) {
continue;
}
$translations = \Lang::getLoader()->load($locale, $group);
if ($translations && is_array($translations)) {
foreach (array_dot($translations) as $key => $value) {
$value = (string) $value;
$translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
// Check if the database is different then the files
$newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
if ($newStatus !== (int) $translation->status) {
$translation->status = $newStatus;
}
// Only replace when empty, or explicitly told so
if ($replace || !$translation->value) {
$translation->value = $value;
}
$translation->save();
$counter++;
}
}
}
}
return $counter;
}
示例2: 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);
}
示例3: normalizeName
/**
* Normalize the Twig template name to a name the ViewFinder can use
*
* @param string $name Template file name.
* @return string The parsed name
*/
protected function normalizeName($name)
{
if ($this->files->extension($name) === $this->extension) {
$name = substr($name, 0, -(strlen($this->extension) + 1));
}
return $name;
}
示例4: publishMigration
public function publishMigration($filePath)
{
if ($this->files->extension($filePath) === 'php') {
$fullPath = $this->createBaseMigration($filePath);
$originalMigration = $this->files->get($filePath);
$this->files->put($fullPath, $originalMigration);
}
}
示例5: enqueue
public function enqueue($handle, $path, $dependencies = [], $version = 0, $footer = false, $area = self::FRONT, $type = null)
{
if (empty($type) && $this->filesystem->exists($path)) {
$extension = $this->filesystem->extension($path);
$type = $extension == 'css' ? 'style' : 'script';
}
$path = str_replace(public_path(), '', $path);
$this->add($handle, $path, $dependencies, $version, $footer, $area, $type);
}
示例6: getFilePath
/**
* Get file path based on request pathinfo
*
* @param \Illuminate\Http\Request $request
* @return string
*/
public function getFilePath(Request $request)
{
$pathinfo = $request->getPathInfo();
if ('' == $this->filesystem->extension($pathinfo)) {
$file = 'index.html';
$dir = trim($pathinfo, '/');
} else {
$file = basename($pathinfo);
$dir = trim(dirname($pathinfo), '/');
}
if (true === empty($dir)) {
return "{$this->outputDir}/{$file}";
}
return "{$this->outputDir}/{$dir}/{$file}";
}
示例7: handle
/**
* Handle the command
*
* @param $command
* @return mixed
*/
public function handle($command)
{
$client = S3Client::factory(array('key' => $this->config->get('services.s3.key'), 'secret' => $this->config->get('services.s3.secret')));
/*
* Upload image to S3
*/
$filesystem = new Flysystem(new Adapter($client, $this->config->get('sightseeing.s3-bucket')));
$extension = $this->filesystem->extension($command->image->getClientOriginalName());
$filename = sha1(time() . time()) . ".{$extension}";
$filesystem->write($filename, file_get_contents($command->image), ['visibility' => 'public']);
/*
* Create record on the database
*/
$this->sightRepository->addImageById($command->id, $filename);
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// 从数据库中获取的ArticleTag集合
$tags = \App\Model\Tag::all();
// 初始化博客的路径
$dir = "/root/blog";
$file_system = new Filesystem();
$files = $file_system->allFiles($dir);
foreach ($files as $file) {
$file_extension = $file_system->extension($file);
if ($file_extension != 'md') {
continue;
}
$create_time_stamp = $file_system->lastModified($file);
$create_time = gmdate("Y-m-d", $create_time_stamp);
$file_content = $file_system->get($file);
$file_name = preg_replace('/^.+[\\\\\\/]/', '', $file);
$file_name = explode(".md", $file_name);
$blog_name = $file_name[0];
$last_dir = dirname($file);
$current_tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir);
$article_type_id = 0;
foreach ($tags as $tag) {
$tag_name = $tag->name;
if (strcmp($current_tag_name, $tag_name) == 0) {
$article_type_id = $tag->id;
break;
}
}
$article_id = \App\Model\Article::create(['cate_id' => $article_type_id, 'user_id' => 1, 'title' => $blog_name, 'content' => $file_content, 'tags' => $article_type_id, 'created_at' => $create_time, 'updated_at' => $create_time])->id;
\App\Model\ArticleStatus::create(['art_id' => $article_id, 'view_number' => 0]);
}
}
示例9: execute
public function execute($basepath, $filename)
{
$path = $basepath . '/' . $filename;
$extension = $this->filesystem->extension($filename);
$filename = str_replace('.' . $extension, null, $filename);
$count = 0;
while ($this->filesystem->exists($path) || in_array($path, static::$names)) {
$count++;
$path = $basepath . '/' . $filename . '-' . $count . '.' . $extension;
}
static::$names[] = $path;
if ($count === 0) {
return $filename . '.' . $extension;
}
return $filename . '-' . $count . '.' . $extension;
}
示例10: getImageHomolog
/**
* Retorna a imagem de homologacao em formato image inline.
*
* @return null|string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function getImageHomolog()
{
$img = __DIR__ . '/Templates/homologacao.png';
// Verificar se arquivo da logo existe
if ($this->files->exists($img) != true) {
return;
}
$ext = strtolower($this->files->extension($img));
$buffer = $this->files->get($img);
return 'data:image/' . $ext . ';base64,' . base64_encode($buffer);
}
示例11: getMessages
/**
* Return all language messages.
*
* @return array
*
* @throws \Exception
*/
protected function getMessages()
{
$messages = [];
$path = $this->sourcePath;
if (!$this->file->exists($path)) {
throw new \Exception("{$path} doesn't exists!");
}
foreach ($this->file->allFiles($path) as $file) {
$pathName = $file->getRelativePathName();
if ($this->file->extension($pathName) !== 'php') {
continue;
}
if ($this->isMessagesExcluded($pathName)) {
continue;
}
$key = substr($pathName, 0, -4);
$key = str_replace('\\', '.', $key);
$key = str_replace('/', '.', $key);
$messages[$key] = (include "{$path}/{$pathName}");
}
return $messages;
}
示例12: dumpAssetsAsString
/**
* Return assets as a string
*
* @param type
* @return string
*/
public function dumpAssetsAsString($type)
{
$fs = new Filesystem();
$files = $fs->allFiles(__DIR__ . '/Assets');
$content = '';
foreach ($files as $file) {
if ($fs->extension($file) != $type) {
continue;
}
$content .= file_get_contents($file) . "\n";
}
return $content;
}
示例13: getLogo
/**
* Retorna a logo informada em formato image inline.
*
* @return null|string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function getLogo()
{
// Verificar se logo foi informada
if ($this->logo === false || is_null($this->logo) || $this->logo == '') {
return;
}
// Verificar se foi informado direto o buffer
if (@is_file($this->logo) != true) {
return 'data:image/png;base64,' . base64_encode($this->logo);
}
// Verificar se arquivo da logo existe
if ($this->files->exists($this->logo) != true) {
return;
}
$ext = strtolower($this->files->extension($this->logo));
$buffer = $this->files->get($this->logo);
return 'data:image/' . $ext . ';base64,' . base64_encode($buffer);
}
示例14: position
/**
* @param $key
* @param array $opinions
* @return mixed
*/
public function position($key, $opinions = [])
{
$config = $this->config->get('page.recommends');
$config = array_merge($config[$key], $opinions);
$articles = ArticleRecommend::wherePosition($key);
if (isset($opinions['limit']) && $opinions['limit'] > 0) {
$articles->take($config['limit']);
}
$articles = $articles->orderBy('created_at', 'desc')->get();
if (isset($config['thumbnail']) && is_array($config['thumbnail'])) {
foreach ($articles as $k => $article) {
$article = Article::find($article->article_id);
if ($article) {
preg_match_all("/<img([^>]*)\\s*src=('|\")([^'\"]+)('|\")/", $article->content, $matches);
$hash = '';
$thumbnail = '';
if ($matches && $matches[3]) {
$matches = array_unique($matches[3]);
if ($matches[0] && $this->file->exists(public_path($matches[0]))) {
$thumbnail = $matches[0];
$hash = hash_file('md5', public_path($matches[0]), false);
}
}
if ($thumbnail && $hash) {
$path = '/uploads/thumbnails/' . $config['thumbnail']['width'] . 'X' . $config['thumbnail']['height'] . '/' . $hash . '.' . $this->file->extension(public_path($thumbnail));
$directory = public_path('/uploads/thumbnails/' . $config['thumbnail']['width'] . 'X' . $config['thumbnail']['height'] . '/');
if (!$this->file->isDirectory($directory)) {
$this->file->makeDirectory($directory, 0777, true, true);
}
if (!$this->file->exists(public_path($path))) {
$image = Image::make($thumbnail, $config['thumbnail']);
$image->save(public_path($path));
}
$article->thumbnail = $path;
}
$articles->put($k, $article);
} else {
$articles->forget($k);
}
}
}
return $this->view->make($config['template'])->withArticles($articles);
}
示例15: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$tag_array = array();
$first_add = true;
$dir = "/root/blog";
$file_system = new Filesystem();
$files = $file_system->allFiles($dir);
foreach ($files as $file) {
$file_extension = $file_system->extension($file);
if ($file_extension != 'md') {
continue;
}
$last_dir = dirname($file);
$tag_name = preg_replace('/^.+[\\\\\\/]/', '', $last_dir);
$create_time_stamp = $file_system->lastModified($file);
$create_time = gmdate("Y-m-d", $create_time_stamp);
if ($first_add) {
$tag_info = array();
$tag_info[0] = $tag_name;
$tag_info[1] = $create_time;
$tag_array[0] = $tag_info;
$first_add = false;
}
$is_new = true;
foreach ($tag_array as $tag) {
if (strcmp($tag[0], $tag_name) == 0) {
$is_new = false;
}
}
if ($is_new) {
$tag_count = count($tag_array);
$tag_info = array();
$tag_info[0] = $tag_name;
$tag_info[1] = $create_time;
$tag_array[$tag_count] = $tag_info;
}
}
foreach ($tag_array as $tag_io) {
\App\Model\Tag::create(['name' => $tag_io[0]]);
\App\Model\Category::create(['cate_name' => $tag_io[0], 'as_name' => $tag_io[0], 'parent_id' => 0, 'seo_key' => $tag_io[0], 'seo_desc' => $tag_io[0], 'created_at' => $tag_io[1], 'updated_at' => $tag_io[1]]);
}
}