當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::locator方法代碼示例

本文整理匯總了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;
 }
開發者ID:Bixie,項目名稱:pagekit-bixbase,代碼行數:14,代碼來源:StyleManager.php

示例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;
 }
開發者ID:4nxiety,項目名稱:pagekit-formmaker,代碼行數:31,代碼來源:FormmakerExtension.php

示例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');
 }
開發者ID:pagekit,項目名稱:extension-highlight,代碼行數:10,代碼來源:HighlightController.php

示例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;
 }
開發者ID:4nxiety,項目名稱:pagekit-userprofile,代碼行數:16,代碼來源:UserprofileModule.php

示例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;
 }
開發者ID:Bixie,項目名稱:pagekit-framework,代碼行數:24,代碼來源:FrameworkModule.php

示例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;
     }
 }
開發者ID:Bixie,項目名稱:pagekit-framework,代碼行數:28,代碼來源:ImageHelper.php

示例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];
 }
開發者ID:pagekit,項目名稱:pagekit,代碼行數:12,代碼來源:IntlModule.php

示例8: getPath

 /**
  * {@inheritdoc}
  */
 public function getPath()
 {
     return App::locator()->get($this->source) ?: false;
 }
開發者ID:rifal89,項目名稱:pagekit,代碼行數:7,代碼來源:FileLocatorAsset.php


注:本文中的Pagekit\Application::locator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。