本文整理汇总了PHP中Gantry\Component\Filesystem\Folder::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::all方法的具体用法?PHP Folder::all怎么用?PHP Folder::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gantry\Component\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThemes
/**
* @return array
*/
public static function getThemes()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$files = Folder::all('gantry-themes://', ['recursive' => false]);
/** @var array|ThemeDetails[] $list */
$list = [];
ksort($files);
foreach ($files as $theme) {
if (!is_dir($theme)) {
continue;
}
if ($locator('gantry-themes://' . $theme . '/gantry/theme.yaml')) {
$details = new ThemeDetails($theme);
// Stream needs to be valid URL.
$streamName = 'gantry-themes-' . preg_replace('|[^a-z\\d+.-]|ui', '-', $theme);
if (!$locator->schemeExists($streamName)) {
$locator->addPath($streamName, '', $details->getPaths());
}
$details['name'] = $theme;
$details['title'] = $details['details.name'];
$details['preview_url'] = $locator('gantry-themes://' . $theme);
// FIXME:
$details['admin_url'] = 'FIXME';
$details['params'] = [];
$list[$details->name] = $details;
}
}
// Add Thumbnails links after adding all the paths to the locator.
foreach ($list as $details) {
$details['thumbnail'] = $details->getUrl("details.images.thumbnail");
}
return $list;
}
示例2: getThemes
/**
* @return array
*/
public static function getThemes()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$files = Folder::all('gantry-themes://', ['recursive' => false]);
/** @var array|ThemeDetails[] $list */
$list = [];
ksort($files);
foreach ($files as $theme) {
if (file_exists(PRIME_ROOT . '/themes/' . $theme . '/gantry/theme.yaml')) {
$details = new ThemeDetails($theme);
if (!$locator->schemeExists('gantry-theme-' . $theme)) {
$locator->addPath('gantry-themes-' . $theme, '', $details->getPaths());
}
$details['name'] = $theme;
$details['title'] = $details['details.name'];
$details['preview_url'] = rtrim(PRIME_URI, '/') . '/' . $theme;
$details['admin_url'] = rtrim(PRIME_URI, '/') . '/' . $theme . '/admin/configurations/styles';
$details['params'] = [];
$list[$details->name] = $details;
}
}
// Add Thumbnails links after adding all the paths to the locator.
foreach ($list as $details) {
$details['thumbnail'] = $details->getUrl("details.images.thumbnail");
}
return $list;
}
示例3: getStyles
/**
* @return array
*/
public static function getStyles()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$files = Folder::all('gantry-themes://', ['recursive' => false]);
$list = array();
foreach ($files as $theme) {
if (file_exists($locator('gantry-themes://' . $theme . '/default/gantry/theme.yaml'))) {
$details = new ThemeDetails($theme);
if (!$locator->schemeExists('gantry-theme-' . $theme)) {
$locator->addPath('gantry-themes-' . $theme, '', $details->getPaths());
}
$details['name'] = $theme;
$details['title'] = ucfirst($theme);
$details['preview_url'] = '/' . $theme;
$details['admin_url'] = '/' . $theme . '/admin';
$details['params'] = [];
$list[$details->name] = $details;
}
}
// Add Thumbnails links.
foreach ($list as $details) {
$details['thumbnail'] = self::getImage($locator, $details, 'thumbnail');
}
return $list;
}
示例4: index
public function index()
{
throw new \Exception('Deprecated');
$options = ['compare' => 'Filename', 'pattern' => '|\\.json|', 'filters' => ['key' => '|\\.json|'], 'key' => 'SubPathname', 'value' => 'Pathname'];
/** @var UniformResourceLocator $locator */
$locator = $this->container['locator'];
$files = Folder::all($locator->findResource('gantry-theme://layouts/presets'), $options);
$response = ['layouts'];
foreach ($files as $name => $structure) {
$content = JsonFile::instance($structure)->content();
$response['layouts'][$name] = $content;
}
$response['html'] = $this->container['admin.theme']->render('@gantry-admin/layouts/picker.html.twig', ['presets' => $response]);
return new JsonResponse($response);
}
示例5: detectAll
/**
* Detects all plugins with a configuration file and returns them with last modification time.
*
* @param string $folder Location to look up from.
* @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
* @param int $levels Maximum number of recursive directories.
* @return array
* @internal
*/
protected function detectAll($folder, $pattern, $levels)
{
$path = trim(Folder::getRelativePath($folder), '/');
if (is_dir($folder)) {
// Find all system and user configuration files.
$options = ['levels' => $levels, 'compare' => 'Filename', 'pattern' => $pattern, 'filters' => ['pre-key' => $this->base, 'key' => $pattern, 'value' => function (\RecursiveDirectoryIterator $file) use($path) {
return ["{$path}/{$file->getSubPathname()}" => $file->getMTime()];
}], 'key' => 'SubPathname'];
$list = Folder::all($folder, $options);
ksort($list);
} else {
$list = [];
}
return $list;
}