To obtain an instance of this class, call method wa()->getConfig()
; e.g.:
wa->getConfig()->getName();
Methods
-
getAppConfigPath
Returns path to specified configuration file.
-
getApplication
Returns app's id.
-
getAppPath
Returns path to app's source files.
-
getConfigPath
Returns path to app's configuration file.
-
getInfo
Returns information from app's file
lib/config/app.php
. -
getName
Returns app's name from its configuration file
lib/config/app.php
. -
getOption
Returns app configuration parameter values.
-
getPluginInfo
Returns information about an installed plugin of an app.
-
getPluginPath
Returns path to the source files of an installed app plugin.
-
getPlugins
Returns information about all installed plugins of an app.
-
setCount
Sets or clears the value of an app's indicator displayed next to its icon in the main backend menu.
-
getWidgetPath
Returns path to the source files of an installed app widget.
-
getWidgets
Returns information about all installed widgets of an app.
-
getLogActions
Returns information about user actions that are logged to be displayed in the dashboard.
public function getAppConfigPath ($name)
Returns path to specified configuration file of an app, located in lib/config/
directory.
Parameters
-
$name
Имя файла.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getAppConfigPath('routing');
Result
/var/www/wa-apps/blog/lib/config/routing.php
public function getApplication()
Returns app's id.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getApplication();
Result
blog
public function getAppPath ($path = null)
Returns path to app's source files.
Parameters
-
$path
Optional path to a subdirectory inside app's directory
wa-apps/[app_id]/lib/
.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getAppPath('templates/');
Result
/var/www/wa-apps/blog/templates/
public function getConfigPath ($name, $user_config = true, $app = null)
Returns path to app's configuration file.
Parameters
-
$name
Name of the configuration file whose path must be returned.
-
$user_config
Flag requiring to return the path to a file in directory
wa-config/apps/[app_id]/
, which is used for storing custom user configuration. Iffalse
is specified, the method will return path to a file located in directorywa-apps/[app_id]/lib/config/
. -
$app
The id of the app whose configuration file's path must be returned. If not specified, the current app's id is used by default.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getConfigPath('routing.php', false);
Result
/var/www/wa-apps/blog/lib/config/routing.php
public function getInfo ($name = null)
Returns information from app's file lib/config/app.php
.
Parameters
-
$name
Name of the parameter whose value must be returned. If not specified, the method returns an associative array of all parameters contained in the configuration file.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getInfo('name');
Result
Blog
public function getName()
Returns app's name from its configuration file lib/config/app.php
.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getName();
Result
Blog
public function getOption ($name = null)
Returns app configuration parameter values.
Parameters
-
$name
The name of the configuration parameter whose value must be returned.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getOption('posts_per_page');
Result
10
public function getPluginInfo ($plugin_id)
Returns information about an installed plugin of an app.
Parameters
-
$plugin_id
Plugin id.
Example
$app_config = wa()->getConfig()->getAppConfig('shop'); $app_config->getPluginInfo('migrate');
Result
[ [name] => Migrate to Shop-Script [description] => Transfer data from other ecommerce platforms to Shop-Script [img] => wa-apps/shop/plugins/migrate/img/migrate.png [vendor] => webasyst [version] => 1.0.0 [importexport] => 1 [handlers] => [] [id] => migrate ]
public function getPluginPath ($plugin_id)
Returns path to the source files of an installed app plugin.
Parameters
-
$plugin_id
Plugin id.
Example
$app_config = wa()->getConfig()->getAppConfig('shop'); $app_config->getPluginPath('migrate');
Result
/var/www/wa-apps/shop/plugins/migrate
public function getPlugins()
Returns information about all installed plugins of an app.
Example
$app_config = wa()->getConfig()->getAppConfig('blog'); $app_config->getPlugins();
Result
[ [watermark] => [ [name] => Watermark [description] => Applies watermark text or image on uploaded photos [img] => wa-apps/shop/plugins/yandexmarket/img/watermark.png [vendor] => webasyst [version] => 1.0.0 [rights] => false [handlers] => [ [image_upload] => imageUpload ] [id] => watermark ] [migrate] => [ [name] => Migrate to Shop-Script [description] => Transfer data from other ecommerce platforms to Shop-Script [img] => wa-apps/shop/plugins/migrate/img/migrate.png [vendor] => webasyst [version] => 1.0.0 [importexport] => 1 [handlers] => [] [id] => migrate ] ]
public function setCount ($n = null)
Sets or clears the value of an app's indicator displayed next to its icon in the main backend menu.
Parameters
-
$n
Indicator value. If an empty value is specified, the indicator's value will be cleared.
Example
$app_config = wa()->getConfig()->getAppConfig('shop'); $app_config->setCount(100);
public function getWidgetPath ($widget_id)
Returns path to the source files of an installed app plugin.
Parameters
-
$widget_id
Widget ID.
Example
$app_config = wa()->getConfig()->getAppConfig('shop'); $app_config->getWidgetPath('orders');
Result
/var/www/wa-apps/shop/widgets/orders
public function getWidgets()
Returns information about all installed widgets of an app.
Example
$app_config = wa()->getConfig()->getAppConfig('shop'); $app_config->getWidgets();
Result
[ 'orders' => [ 'name' => 'Заказы', 'size' => [ '2x2', '2x1', '1x1', ], 'img' => 'wa-apps/shop/widgets/orders/img/orders.png', 'version' => '1.2', 'vendor' => 'webasyst', 'rights' => [ 'shop' => [ 'orders' => true, ], ], 'has_settings' => false, 'sizes' => [ [ '2', '2', ], [ '2', '1', ], [ '1', '1', ], ], 'widget' => 'orders', 'app_id' => 'shop', ], ]
public function getLogActions ($full = false, $ignore_system = false)
Returns information about user actions that are logged to be displayed in the dashboard.
Parameters
-
$full
Flag denoting that the method must return action names according to the specified app’s localization. Otherwise it returns only localization keys as action names.
-
$ignore_system/em>
Flag denoting that the method must exclude system actions, not belonging only to the specified app, from the returned array.
Example
wa('site')->getConfig()->getLogActions(true, true);
Результат
[ 'site_add' => [ 'name' => 'added a new site', ], 'site_edit' => [ 'name' => 'edited site settings', ], 'site_delete' => [ 'name' => 'deleted site', ], 'file_upload' => [ 'name' => 'uploaded file', ], 'file_delete' => [ 'name' => 'deleted file', ], 'block_add' => [ 'name' => 'added a new block for site', ], 'block_edit' => [ 'name' => 'edited block for site', ], 'block_delete' => [ 'name' => 'deleted block for site', ], 'route_add' => [ 'name' => 'added a new routing rule', ], 'route_edit' => [ 'name' => 'edited routing rule', ], 'route_delete' => [ 'name' => 'deleted routing rule', ], ]