Jet\MVC_Base

What is a base and how it works we explained here and here.

In the table you can find an overview of methods of Jet\MVC_Base class and also Jet\MVC_Base_Interface

The class is instantiated principally using the appropriate factory.

Basic methods

Method Meaning
public setId(
string $id
): void
Sets the base ID. Used when creating bases.
Useless for application space. Used by tools.
public getId(
): string
Returns the ID of the base.
public getName(
): string
Returns the internal name of the base.
An internal name is a name that is not intended for regular users. It is used in tools and also in administration.
However, it is not intended for normal visitors.
public setName(
string $name
): void
Setting the internal name.
Again a method intended for tools, not for use in the application space.
public setIsSecret(
bool $is_secret
): void
Set whether the base is secret by default. This means that authentication and authorization is required automatically and for all pages - i.e. user login and verification of their rights.

Also a method designed for toolbars. It really must not be used in the application space.
public getIsSecret(
): bool
Indicates whether the base is/is not secret by default. This means that authentication and authorization is required automatically and for all pages - i.e. user login and authentication of their rights.
public getSSLRequired(
): bool
Indicates whether the base requires an SSL connection by default. If so, all http traffic is automatically redirected to https and this applies to all sites.

But everything should run on https today :-)

You can, for example, run without SSL on your localhost ...
public setSSLRequired(
bool $SSL_required
): void
Sets whether the base requires an SSL connection by default. If it does, all http traffic is automatically redirected to https and this applies to all pages.

Again, a method designed for tools. It really must not be used in the application space.
public getIsDefault(
): bool
Indicates whether the base is/is not the default.

One base must always be the default. Why? Suppose you point a brand new domain to a production server that you don't have set up for any base. Jet will take care of redirecting to the default base in such a situation.
public setIsDefault(
bool $is_default
): void
Sets whether the base is/is not the default.
public getIsActive(
): bool
Indikuje zda báze je / není aktivní.

Není problém nějakou část projektu za nějakým účelem třeba na čas deaktivovat. A může to být klidně součást administrace.
public setIsActive(
bool $is_active
): void
Sets whether the base is active or not.

It is not a problem to deactivate some part of the project for some purpose, for example for a while. And it can be part of the administration.
public setInitializer(
callable $initializer
): void
Sets the initializer.

Another method that is primarily intended for tools.
public getInitializer(
): callable|null
Returns the initializer, or null if none is set.
public getHomepage(
?Locale $locale = null
): MVC_Page_Interface
Returns an instance of the homepage (i.e. the root page) for the given base and the given locale.

If the locale is not specified (i.e. the $locale parameter is null), then the current locale of the request (as evaluated by the router) is used.

Directories and paths

Method Meaning
public setBasePath(
string $path
): void
In case of need, it is possible to force the base its path where its directory is located (other than the given configuration and path creation principle).

It can be useful for tools. Again, not intended for common use.
public getBasePath(
): string
Returns the path to the directory where the database is located. If no optional path is set using setBasePath (which is usually not the case), it returns the path given by the system configuration and the base path creation principle.
public getPagesDataPath(
?Locale $locale = null
): string
Returns the path to the directory that contains the page definitions for the base.

If the $locale parameter is null, then it returns the generic/base path to all locales.

If the $locale parameter is specified, then it returns the direct path to the page definitions of the given locale.
public setLayoutsPath(
string $path
): void
This method can be used to force the path to the directory containing layouts. That is, a path other than the one given by the configuration and the path creation principle.
public getLayoutsPath(
): string
Returns the path to the directory containing the layouts. If an optional path is not set using setLayoutsPath (in common practice it usually is not), it returns a path based on the base path of the base directory.
public setViewsPath(
string $path
): void
This method can be used to force the path to a directory containing general views. That is, a path other than the one given by the configuration and the path creation principle.
public getViewsPath(
): string
Returns the path to the directory containing the general views. If an optional path is not set using setViewsPath (in common practice it usually is not), it returns a path based on the base path of the base directory.

Localization

Method Meaning
public getDefaultLocale(
): Locale|null
Returns the identification of the default locale. (Or null if not already defined)
public getHasLocale(
Locale $locale
): bool
Detects whether the given base has the given localization.
public getLocalizedData(
Locale $locale
): MVC_Base_LocalizedData_Interface
Returns an instance of localized data of the database.
public getLocales(
bool $get_as_string = false
): Locale[]|string[]
Returns a list of all locales that belong to the base.

If $get_as_string is true, then returns an array of text identifiers (e.g. cs_CZ etc.), otherwise returns an array of instances of class Jet\Locale.
public getActiveLocales(
bool $get_as_string = false
): Locale[]|string[]
Returns a list of only active locales that belong to the base.

If $get_as_string is true, then returns an array of text identifiers (e.g. cs_CZ etc.), otherwise returns an array of instances of class Jet\Locale.
public sortLocales(
array $order
): void
Prioritizes the localizations according to the specified order.

The $order parameter is an array of text identifiers for the localizations.
public addLocale(
Locale $locale
): MVC_Base_LocalizedData_Interface
Adds a new locale to the base, identified by an instance of the Jet\Locale class - parameter $locale

Then returns an instance of the localized data of the base.

If the locale already existed, then only returns an instance of the localized data.
public removeLocale(
Locale $locale
): void
Receives the locale identified by the instance of class Jet\Locale - parameter $locale

Storage

Method Meaning
public saveDataFile(
): void
Saves the database definition data file.
public toArray(
): array
Returns the base definition data in the form of an associated array. It is used to store the definition.
Previous chapter
Base
Next chapter
Jet\MVC_Base_LocalizedData