本文整理汇总了PHP中Pagekit\Application::locator方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::locator方法的具体用法?PHP Application::locator怎么用?PHP Application::locator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagekit\Application
的用法示例。
在下文中一共展示了Application::locator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStyles
/**
* @return array
*/
public function getStyles()
{
if (!static::$styles) {
$paths = glob($this->app->locator()->get('theme:styles') . '/*/style.less', GLOB_NOSORT) ?: [];
static::$styles = ['default'];
foreach ($paths as $p) {
static::$styles[] = basename(dirname($p));
}
}
return static::$styles;
}
示例2: getTypes
/**
* @return array
*/
public function getTypes()
{
//todo cache this
if (!$this->types) {
$this->types = [];
$paths = glob(App::locator()->get('formmaker:app/fields') . '/*.php', GLOB_NOSORT) ?: [];
foreach ($paths as $p) {
$package = array_merge(['id' => '', 'hasOptions' => 0, 'required' => 0, 'multiple' => 0, 'dependancies' => [], 'style' => [], 'prepareValue' => function (Field $field, $value) {
return $value;
}, 'formatValue' => function (Field $field, $value) {
if (count($field->options)) {
$options = $field->getOptionsRef();
if (is_array($value) && count($value)) {
return array_map(function ($val) use($options) {
return isset($options[$val]) ? $options[$val] : $val;
}, $value);
} else {
return $value ? isset($options[$value]) ? [$options[$value]] : [$value] : ['-'];
}
} else {
return is_array($value) ? count($value) ? $value : ['-'] : [$value ?: '-'];
}
}], include $p);
$this->registerType($package);
}
}
return $this->types;
}
示例3: configAction
/**
* Returns several config settings needed for the settings view.
*/
public function configAction()
{
$styles = array_map(function ($fn) {
return basename($fn, '.css');
}, glob(App::locator()->get('highlight:assets/styles') . '/*.css'));
return compact('styles');
}
示例4: getTypes
/**
* @return array
*/
public function getTypes()
{
//todo cache this
if (!$this->types) {
$this->types = [];
$paths = glob(App::locator()->get('userprofile:app/fields') . '/*.json', GLOB_NOSORT) ?: [];
foreach ($paths as $p) {
$package = json_decode(file_get_contents($p), true);
$this->registerType($package);
}
}
return $this->types;
}
示例5: getImageCachepath
/**
* @return bool|string
*/
public function getImageCachepath()
{
if ($folder = App::locator()->get(App::module('bixie/framework')->config('image_cache_path')) and is_writable($folder)) {
//all fine, quick return
return $folder;
}
//try to create user-folder
App::file()->makeDir($folder, 0755);
if (!file_exists($folder)) {
//create default folder
$folder = $this->app['path.storage'] . '/bixframework';
if (!file_exists($folder)) {
App::file()->makeDir($folder, 0755);
}
}
if (!file_exists($folder) || !is_writable($folder)) {
//give up
return false;
}
return $folder;
}
示例6: resizeImage
/**
* @param string $source
* @param array $options
* @return bool|mixed
*/
protected function resizeImage($source, $options)
{
try {
$image_path = App::locator()->get($source);
$cachepath = $this->getCachePath($image_path, $options);
if (!file_exists($cachepath)) {
$image = new SimpleImage($image_path);
if (!empty($options['width']) && empty($options['height'])) {
$image->fit_to_width($options['width']);
}
if (!empty($options['height']) && empty($options['width'])) {
$image->fit_to_height($options['height']);
}
if (!empty($options['height']) && !empty($options['width'])) {
$image->thumbnail($options['width'], $options['height']);
}
$image->save($cachepath);
}
return $this->basePath($cachepath);
} catch (\Exception $e) {
return false;
}
}
示例7: parse
/**
* @param string $file
* @return array|null
*/
protected function parse($file)
{
static $data = [];
if (!isset($data[$file])) {
$data[$file] = ($file = App::locator()->get($file)) ? json_decode(file_get_contents($file), true) : null;
}
return $data[$file];
}
示例8: getPath
/**
* {@inheritdoc}
*/
public function getPath()
{
return App::locator()->get($this->source) ?: false;
}