public abstract class Symphony

class.symphony.php #13

The Symphony class is an abstract class that implements the Singleton interface. It provides the glue that forms the Symphony CMS and initialises the toolkit classes. Symphony is extended by the Frontend and Administration classes

Properties

static Author $Author

An instance of the currently logged in Author

static Cookie $Cookie

An instance of the Cookie class

Methods

static Author Author()

Accessor for the current $Author instance.

static Configuration Configuration()

Accessor for the current Configuration instance. This contains representation of the the Symphony config file.

static MySQL Database()

Accessor for the current $Database instance.

static Symphony Engine()

Accessor for the Symphony instance, whether it be Frontend or Administration

static ExtensionManager ExtensionManager()

Accessor for the current $ExtensionManager instance.

static Log Log()

Accessor for the current Log instance

static Profiler Profiler()

Accessor for the current Profiler instance.

static Throwable|null getException()

Accessor for self::$exception.

static string|boolean getMigrationVersion()

Returns the most recent version found in the /install/migrations folder. Returns a version string to be used in version_compare() if an updater has been found. Returns FALSE otherwise.

static string getPageNamespace()

Returns the page namespace based on the current URL. A few examples:

/login /publish /blueprints/datasources [...] /extension/$extensionname/$pagename

This method is especially useful in couple with the translation function.

Returns

The page namespace, without any action string (e.g. "new", "saved") or any value that depends upon the single setup (e.g. the section handle in /publish/$handle)

See Also
static void initialiseConfiguration(array $data)

Setter for $Configuration. This function initialise the configuration object and populate its properties based on the given $array. Since Symphony 2.6.5, it will also set Symphony's date constants.

Parameters
  • $data arrayAn array of settings to be stored into the Configuration object

static void initialiseCookie()

Setter for $Cookie. This will use PHP's parseurl function on the current URL to set a cookie using the cookieprefix defined in the Symphony configuration. The cookie will last two weeks.

This function also defines two constants, __SYM_COOKIE_PATH__ and __SYM_COOKIE_PREFIX__.

Deprecated

Prior to Symphony 2.3.2, the constant __SYM_COOKIE_PREFIX_ had a typo where it was missing the second underscore. Symphony will support both constants, __SYM_COOKIE_PREFIX_ and __SYM_COOKIE_PREFIX__ until Symphony 3.0

static boolean initialiseDatabase()

This will initialise the Database class and attempt to create a connection using the connection details provided in the Symphony configuration. If any errors occur whilst doing so, a Symphony Error Page is displayed.

Returns

This function will return true if the $Database was initialised successfully.

static void initialiseErrorHandler()

Setter for the Symphony Log and Error Handling system

static void initialiseExtensionManager(Boolean $force)

Setter for $ExtensionManager using the current Symphony instance as the parent. If for some reason this fails, a Symphony Error page will be thrown

Parameters
  • $force Boolean(optional) When set to true, this function will always create a new instance of ExtensionManager, replacing self::$ExtensionManager.

static bool|void initialiseLog(string $filename)

Setter for $Log. This function uses the configuration settings in the 'log' group in the Configuration to create an instance. Date formatting options are also retrieved from the configuration.

Parameters
  • $filename string(optional) The file to write the log to, if omitted this will default to ACTIVITY_LOG

static boolean isInstallerAvailable()

Checks if the installer/upgrader is available.

static boolean isLoggedIn()

This function determines whether an there is a currently logged in Author for Symphony by using the $Cookie's username and password. If the instance is not found, they will be logged in using the cookied credentials.

See Also
static boolean isUpgradeAvailable()

Checks if an update is available and applicable for the current installation.

static boolean isXSRFEnabled()

Is XSRF enabled for this Symphony install?

static boolean login(string $username, string $password, boolean $isHash)

Attempts to log an Author in given a username and password. If the password is not hashed, it will be hashed using the sha1 algorithm. The username and password will be sanitized before being used to query the Database. If an Author is found, they will be logged in and the sanitized username and password (also hashed) will be saved as values in the $Cookie.

Parameters
  • $username stringThe Author's username. This will be sanitized before use.

  • $password stringThe Author's password. This will be sanitized and then hashed before use

  • $isHash booleanIf the password provided is already hashed, setting this parameter to true will stop it becoming rehashed. By default it is false.

Returns

true if the Author was logged in, false otherwise

See Also
static boolean loginFromToken(string $token)

Symphony allows Authors to login via the use of tokens instead of a username and password. A token is derived from concatenating the Author's username and password and applying the sha1 hash to it, from this, a portion of the hash is used as the token. This is a useful feature often used when setting up other Authors accounts or if an Author forgets their password.

Parameters
  • $token stringThe Author token, which is a portion of the hashed string concatenation of the Author's username and password

Returns

true if the Author is logged in, false otherwise

static void logout()

This function will destroy the currently logged in $Author session, essentially logging them out.

See Also
static boolean setDatabase(StdClass $database)

Setter for $Database, accepts a Database object. If $database is omitted, this function will set $Database to be of the MySQL class.

Parameters
  • $database StdClass(optional) The class to handle all Database operations, if omitted this function will set self::$Database to be an instance of the MySQL class.

Returns

This function will always return true

static void setException(Throwable $ex)

Setter accepts a previous Throwable. Useful for determining the context of a current Throwable (ie. detecting recursion).

static void throwCustomError(string|XMLElement $message, string $heading, integer $status, string $template, array $additional)

A wrapper for throwing a new Symphony Error page.

This methods sets the GenericExceptionHandler::$enabled value to true.

Parameters
  • $message string|XMLElementA description for this error, which can be provided as a string or as an XMLElement.

  • $heading stringA heading for the error page

  • $status integerProperly sets the HTTP status code for the response. Defaults to Page::HTTP_STATUS_ERROR. Use Page::HTTP_STATUS_XXX to set this value.

  • $template stringA string for the error page template to use, defaults to 'generic'. This can be the name of any template file in the TEMPLATES directory. A template using the naming convention of tpl.*.php.

  • $additional arrayAllows custom information to be passed to the Symphony Error Page that the template may want to expose, such as custom Headers etc.

See Also

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details