本文整理汇总了PHP中Pagekit\Application::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getInstance方法的具体用法?PHP Application::getInstance怎么用?PHP Application::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagekit\Application
的用法示例。
在下文中一共展示了Application::getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldTypes
/**
* @return array
*/
public function getFieldTypes($extension = null)
{
//todo cache this
if (!$this->fieldTypes) {
$this->fieldTypes = [];
/** @noinspection PhpUnusedLocalVariableInspection */
$app = App::getInstance();
//available for index.php files
$paths = [];
foreach (App::module() as $module) {
if ($module->get('fieldtypes')) {
$paths = array_merge($paths, glob(sprintf('%s/%s/*/index.php', $module->path, $module->get('fieldtypes')), GLOB_NOSORT) ?: []);
}
}
foreach ($paths as $p) {
$package = array_merge(['id' => '', 'path' => dirname($p), 'main' => '', 'extensions' => $this->fieldExtensions, 'class' => '\\Bixie\\Framework\\FieldType\\FieldType', 'resource' => 'bixie/framework:app/bundle', 'config' => ['hasOptions' => 0, 'readonlyOptions' => 0, 'required' => 0, 'multiple' => 0], 'dependancies' => [], 'styles' => [], 'getOptions' => '', 'prepareValue' => '', 'formatValue' => ''], include $p);
$this->registerFieldType($package);
}
}
if ($extension) {
return array_filter($this->fieldTypes, function ($fieldType) use($extension) {
/** @var FieldTypeBase $fieldType */
return in_array($extension, $fieldType->getExtensions());
});
}
return $this->fieldTypes;
}
示例2: applyPlugin
/**
* Defines the plugins callback.
*
* @param array $options
* @return string|null
*/
public function applyPlugin(array $options)
{
if (!isset($options['id'])) {
return;
}
$formmaker = App::module('bixie/formmaker');
$app = App::getInstance();
$form_id = $options['id'];
unset($options['id']);
try {
return $formmaker->renderForm($app, $form_id, $options);
} catch (App\Exception $e) {
return $e->getMessage();
}
}
示例3: formAction
/**
* @Route("/{id}", name="form/front")
*/
public function formAction($id = 0)
{
if (!($formmaker = App::module('bixie/formmaker'))) {
return 'Formmaker extension is disabled!';
}
$user = App::user();
/** @var Form $form */
if (!($form = Form::where(['id = ?'], [$id])->where(function ($query) use($user) {
if (!$user->isAdministrator()) {
$query->where('status = 1');
}
})->related('fields')->first())) {
App::abort(404, __('Form not found!'));
}
if (!App::node()->hasAccess(App::user())) {
App::abort(403, __('Insufficient User Rights.'));
}
$app = App::getInstance();
$form->prepareView($app, $formmaker);
return ['$view' => ['title' => __($form->title), 'name' => 'bixie/formmaker/form.php'], '$formmaker' => ['config' => $formmaker->publicConfig(), 'formitem' => $form, 'fields' => array_values($form->getFields())], 'node' => App::node()];
}
示例4: __construct
/**
* Constructor.
*/
public function __construct()
{
$app = App::getInstance();
$this->installer = new Installer($app);
}
示例5: run
/**
* @param array|callable $scripts
*/
protected function run($scripts)
{
array_map(function ($script) {
if (is_callable($script)) {
call_user_func($script, App::getInstance());
}
}, (array) $scripts);
}
示例6: execute
/**
* @param array|callable $scripts
*/
public function execute($scripts)
{
array_map(function ($script) {
call_user_func($script, App::getInstance());
}, (array) $scripts);
}
示例7: loadPackages
/**
* Load packages from paths.
*/
protected function loadPackages()
{
$app = App::getInstance();
foreach ($this->paths as $path) {
$paths = glob($path, GLOB_NOSORT) ?: [];
foreach ($paths as $p) {
if (!($package = $this->load($p))) {
continue;
}
$this->packages[$package->getName()] = $package;
}
}
}