waSystem

Framework's main system class

Contents...

Methods

public function accountName()

Returns account name saved in Installer settings.

Example

wa()->accountName()

Result

Webasyst

public function appExists ($app_id)

Verifies whether application with specified id exists.

Parameters

Example

wa()->appExists('someapp')

Result

false //there is no installed app with id 'someapp'

public static function getApp()

Returns current app's id.

Example

wa()->getApp()

Result

myapp //method getApp was called in the source code of an app with id 'myapp'; therefore this app is considered as active

public function getAppInfo ($app_id = null)

Returns information about specified app from its file wa-apps/[app_id]/lib/config/app.php.

Parameters

Example

wa()->getAppInfo('blog')

Result

Array
(
    [name] => Blog
    [icon] => Array
        (
            [16] => wa-apps/blog/img/blog16.png
            [24] => wa-apps/blog/img/blog24.png
            [48] => wa-apps/blog/img/blog.png
            [96] => wa-apps/blog/img/blog96.png
        )

    [rights] => 1
    [frontend] => 1
    [auth] => 1
    [themes] => 1
    [plugins] => 1
    [pages] => 1
    [mobile] => 1
    [version] => 1.2.0
    [critical] => 1.0.0
    [vendor] => webasyst
    [csrf] => 1
    [build] => 27730
    [id] => blog
    [img] => wa-apps/blog/img/blog.png
)

public function getAppPath ($path = null, $app_id = null)

Returns path to app's source files directory.

Parameters

Example

wa()->getAppPath('templates', 'blog')

Result

/var/www/wa-apps/blog/templates

public function getAppStaticUrl ($app = null, $absolute = false)

Returns the URL of specified app's source files directory.

Parameters

Example

wa()->getAppStaticUrl('blog', true)

Result

http://yourdomain.com/wa-apps/blog/

public function getAppUrl ($app = null, $script = false)

Returns the relative URL of specified app's main backend page.

Parameters

Example

wa()->getAppUrl('blog')

Result

/webasyst/blog/

public function getConfig()

Returns an instance of the configuration management class (waSystemConfig or waAppConfig).

Example

wa()->getConfig()->getRootPath()

Result

/var/www

public function getConfigPath ($app_id = null)

Returns the path to framework's directory used for storing custom configuration files.

Parameters

Example

wa()->getConfigPath('blog')

Result

/var/www/wa-config/apps/blog

public function getDataPath ($path = null, $public = false, $app_id = null, $create = true)

Returns the path to framework's directory used for storing user data files.

Parameters

Example

wa()->getDataPath('themes', true, 'blog')

Result

/var/www/wa-data/public/blog/themes

public function getDataUrl ($path = null, $public = false, $app_id = null, $absolute = false)

Returns the URL of the directory used for storing user data files for the specified app.

Parameters

Example

wa()->getDataUrl('themes', true, 'blog', true)

Result

http://yourdomain.com/wa-data/public/blog/themes

public function getEnv()

Determines the type of user request environment: backend or frontend.

Example

wa()->getEnv()

Result

backend //method getEnv was called in backend action or controller

public static function getInstance ($name = null, waSystemConfig $config = null, $set_current = false)

Returns an instance of the main system class. Short method of obtaining the same result is to use function wa().

Parameters

Example

waSystem::getInstance()->accountName() //full syntax
wa()->accountName() //short syntax

Example

waSystem::getInstance()->getConfig()->getApplication() //method will return current app's id
waSystem::getInstance('blog')->getConfig()->getApplication() //method will return id of the specified app, i.e. 'blog'

public function getLocale()

Returns current user's locale.

Example

wa()->getLocale()

Result

en_US

public function getResponse()

Returns an instance of the class used for generating response to user requests. (waResponse).

Example

wa()->getResponse()->redirect('http://otherdomain.com')

public function getRootUrl ($absolute = false, $script = false)

Returns the root URL of the framework installation directory.

Parameters

Example

wa()->getRootUrl(true)

Result

http://yourdomain.com/

public function getRouteUrl ($path, $params = array(), $absolute = false, $domain = null, $route = null)

Returns URL corresponding to the specified combination of app's module and action based on the contents of configuration file routing.php of that app.

Parameters

Example

wa()->getRouteUrl('shop/frontend/cart'); //return URL corresponding to the routing rule specified in file routing.php of an app with id 'shop'

Result

/cart/ — settlement for an app with id 'shop' is set up for the domain root directory
/shop/cart/ — settlement for an app with id 'shop' is set up for subdirectory 'shop/'

Example

$params = array(
    'domain' => 'yourdomain.com', //specify the URL of one of multiple websites set up in your backend to take its routing rules into account while generating the URL
    'tag'    => 'sony', //dynamic URL parameter
);
wa()->getRouteUrl('shop/frontend/tag', $params, true);

Result

http://yourdomain.com/tag/sony/

Example

$params = array(
    'domain' => 'yourdomain.com',
    'module' => 'frontend',
    'action' => 'tag',
    'tag'    => 'sony',
);
wa()->getRouteUrl('shop', $params, true); //module and action are specified in the array of optional parameters; therefore, only app id is necessary in the first parameter

Result

http://yourdomain.com/tag/sony/

public static function getSetting ($name, $default = '', $app_id = null)

Returns a setting value for specified app.

Parameters

Example

wa()->getSetting('currency', 'USD', 'shop')

Result

EUR //Euro is selected as the default currency in online store's settings

public function getStorage()

Returns an instance of the class used for managing user sessions. (waSessionStorage).

Example

wa()->getStorage()->getAll()

public function getTempPath ($path = null, $app_id = null)

Returns path to directory used for storing temporary files of an app.

Parameters

Example

wa()->getTempPath(null, 'blog')

Result

/var/www/wa-cache/temp/blog

public function getUrl ($absolute = false)

Returns the main URL of the current frontend or backend section. If a request is sent to frontend, then the method return the frmaework's root frontend URL. If a request is sent to backend, then the method returns the main backend URL of the app responsible for processing the request.

Parameters

Example

wa()->getUrl(true)

Result

http://yourdomain/webasyst/myapp/ //method getUrl was called in the source code of an app with id 'myapp'

public function getUser()

Returns an instance of the class used for accessing user-related information. (waAuthUser, waUser, or waContact).

Example

wa()->getUser()->getId()

public function getVersion ($app_id = null)

Returns version number for specified app.

Parameters

Example

wa()->getVersion('photos')

Result

1.1.0.27730

public function getView ($options = array())

Returns an instance of the class used for generation of web pages (template engine). By default, class waSmarty3View is used, which implements the functionality of Smarty template engine. Read more about use of alternative template engines »

Parameters

Example

wa()->getView()->assign('myvar', $value)
$this->view->assign('myvar', $value) //an instance of the currently used template engine class is accessible via the 'view' variable in the instances of classes waViewAction и waViewActions.

public function setLocale ($locale)

Sets the specified locale for framework's dynamic configuration.

Parameters

Example

wa()->setLocale('en_US')