Class:SmartestBaseApplication

From The Smartest Wiki
Jump to: navigation, search

SmartestBaseApplication is the class that all Smartest applications must extend. It provides basic functionality for user flow, template data assignment, preferences and cookies.

Since this class is never passed to the template layer it does not have offsets, however it has a number of methods, the most important of which are in bold below.

Methods

protected $string $this->getApplicationDirectory() - returns the main directory where the application (or in Quince terms, module) is located, which is usually of the form ROOT_DIR/Applications/APPLICATION_NAME/ or ROOT_DIR/System/Applications/APPLICATION_NAME/

protected $string $this->getConfigurationDirectory() - returns the directory where the application (or in Quince terms, module) stores configuration files, which is usually of the form ROOT_DIR/Applications/APPLICATION_NAME/Configuration/ or ROOT_DIR/System/Applications/APPLICATION_NAME/Configuration/

protected $string $this->getPresentationDirectory() - returns the directory where the application (or in Quince terms, module) stores template files, which is usually of the form ROOT_DIR/Applications/APPLICATION_NAME/Presentation/ or ROOT_DIR/System/Applications/APPLICATION_NAME/Presentation/

protected $string $this->getRequestParameter(string $parameter_name, [mixed $default_value]); returns the value of a request parameter. Parameters here may come from any of three sources, in increasing order of priority: URL variables, POST variables, GET variables.

protected void $this->setRequestParameter(string $parameter_name, mixed $parameter_value) - allows you to manually override any request variables, which is useful when $this->forward() is being used (see above)

protected boolean $this->requestParameterIsSet(string $parameter_name) - returns true if a value for the variable has been set, otherwise false.

protected array $this->getRequestParameters() - returns all set request parameters as an associative array.

protected object Quince $this->getController() - returns the Quince object as a way to get more information about what Quince is doing internally.

public boolean $this->isSystemApplication() - returns true if the application is a system application. The test of this is two-fold: the application must be an instance of SmartestSystemApplication, and must have specified itself as a system application in its quince.yml file, by having a meta called 'system' with the value 'true'

public boolean $this->isUserApplication() - returns true if the current application class is not an instance of SmartestSystemApplication.

protected mixed $this->loadData(string $cache_entry_name, [boolean $is_smartest=false]) - loads data from Smartest's data cache under $cache_entry_name (note that SmartestCache::load() is preferred)

protected boolean $this->saveData(string $cache_entry_name, mixed $data, [boolean $is_smartest=false]) - saves data to Smartest's data cache under $cache_entry_name. (SmartestCache::save() is preferred.)

protected boolean $this->hasData(string $cache_entry_name) - checks whether the cache contains the data at $cache_entry_name

protected object SmartestEngine (or desendants) $this->getPresentationLayer() - returns the Smarty object that will be used for the current request.

protected mixed $this->getPresentationLayerVariable(string $variable_name) - returns the value of a variable that has already been assigned to the Smarty object that will be used for the current request.

protected object SmartestUserAgentHelper $this->getUserAgent()

protected void $this->send(mixed $value, string $template_variable_name) - assigns a value to the template layer. Note the order of arguments, value first.

protected boolean $this->sent(string $template_variable_name) - checks whether a template variable with the name provided has been assigned or not.

protected integer $this->getUserIdOrZero() - returns the ID of the current user, or zero if there is no logged in user. The purpose of this function is that it will not fail if no user is logged in, unlike with $this->getUser()->getId()

protected integer $this->getSiteIdOrZero() - returns the ID of the current site, or zero if there is none. The purpose of this function is that it will not fail if no site is in use, unlike with $this->getSite()->getId()

protected object SmartestSite $this->getSite() - returns the current active site, for null if none is active.

protected mixed $this->getApplicationPreference(string $preference_name, [mixed $default_value]) - returns the value of the stated application-specific preference. If no value is found and $default value is sent, this value will be returned, meaning that new preferences that don't yet have a value can work "out of the box"

protected boolean $this->setApplicationPreference(string $preference_name, mixed $value) - sets the named application-specific preference with the supplied value.

protected mixed $this->getGlobalPreference(string $preference_name, [mixed $default_value]) - returns the value of the stated global preference. If no value is found and $default value is sent, this value will be returned, meaning that new preferences that don't yet have a value can work "out of the box"

protected boolean $this->setGlobalPreference(string $preference_name, [mixed $value]) - sets the named global preference with the supplied value.

protected string $this->getCookie(string $cookie_name) - gets the value of the cookie with the stated name.

protected boolean $this->setCookie(string $cookie_name, mixed $cookie_value) - sets the value of the cookie with the stated name and value.

protected boolean $this->clearCookie(string $cookie_name) - clears the value of the cookie with the stated name.