class Controller extends StartingPointPackage (View source)

Constants

E_PACKAGE_NOT_FOUND

Error code: Invalid Package.

E_PACKAGE_INSTALLED

Error code: You've already installed that package.

E_PACKAGE_VERSION

Error code: This package requires Concrete version %s or greater.

E_PACKAGE_DOWNLOAD

Error code: An error occurred while downloading the package.

E_PACKAGE_SAVE

Error code: Concrete was not able to save the package after download.

E_PACKAGE_UNZIP

Error code: An error occurred while trying to unzip the package.

E_PACKAGE_INSTALL

Error code: An error occurred while trying to install the package.

E_PACKAGE_MIGRATE_BACKUP

Error code: Unable to backup old package directory to %s.

E_PACKAGE_INVALID_APP_VERSION

Error code: This package isn't currently available for this version of Concrete.

E_PACKAGE_THEME_ACTIVE

Error code: This package contains the active site theme, please change the theme before uninstalling.

E_PACKAGE_PHP_VERSION

Error code: This package requires PHP version %1$s or greater (the current PHP version is %2$s).

Properties

protected $DIR_PACKAGES_CORE from  StartingPointPackage
protected $DIR_PACKAGES from  StartingPointPackage
protected $REL_DIR_PACKAGES_CORE from  StartingPointPackage
protected $REL_DIR_PACKAGES from  StartingPointPackage
protected Package|null $entity

Associated package entity.

from  Package
protected Application $app

The Application instance.

from  Package
protected Liaison|null $config

The database configuration liaison.

from  Package
protected Liaison|null $fileConfig

The file configuration liaison.

from  Package
protected bool deprecated $pkgEnableLegacyNamespace from  Package
protected array $pkgAutoloaderRegistries

The custom autoloader prefixes to be automatically added to the class loader.

from  Package
protected string $appVersionRequired

The minimum Concrete version compatible with the package.

from  Package
protected string $phpVersionRequired

The minimum PHP version compatible with the package.

from  Package
protected bool $pkgAllowsFullContentSwap

Override this value and set it to true if your package clears all existing website content when it's being installed.

from  Package
protected array $pkgContentSwapFiles

Override this value to add additional content swap templates.

from  Package
protected $pkgContentProvidesFileThumbnails
protected string|null $backedUpFname

The full path of the package directory moved to the trash folder.

from  Package
protected array $packageDependencies

An array describing the package dependencies.

from  Package
protected $routines from  StartingPointPackage
protected InstallerOptions|null $installerOptions from  StartingPointPackage
protected $pkgHandle

Methods

__construct(Application $app)

Initialize the instance.

Package|null
getPackageEntity()

Get the associated package entity (if available).

from  Package
setPackageEntity(Package $entity)

Set the associated package entity.

from  Package
array
getContentSwapFiles()

No description

from  Package
setContentSwapFiles(array $pkgContentSwapFiles)

No description

from  Package
getApplication()

Get the Application instance.

from  Package
getContentSwapper()

Get the content swapper.

from  Package
installContentFile(string $file)

Import a concrete5-cif XML file.

from  Package
bool
shouldEnableLegacyNamespace()

Should this package enable legacy namespaces?

from  Package
getConfig()

Get the default configuration liaison.

from  Package
getDatabaseConfig()

Get the database configuration liaison.

from  Package
getFileConfig()

Get the filesystem configuration liaison.

from  Package
array
getPackageAutoloaderRegistries()

Get the custom autoloader prefixes to be automatically added to the class loader.

from  Package
string
getPackageHandle()

Get the package handle.

from  Package
string
getPackageName()

Get the translated name of the package.

string
getPackageDescription()

Get the translated package description.

string
getPackageVersion()

Get the installed package version.

from  Package
string
getApplicationVersionRequired()

Get the minimum Concrete version compatible with the package.

from  Package
string
getPHPVersionRequired()

Get the minimum PHP version compatible with the package.

from  Package
bool
showInstallOptionsScreen()

Should the install options page be shown? The install options page may be for install notes and/or full contents swap confirmation.

from  Package
bool
hasInstallNotes()

Does this package have install notes?

from  Package
bool
hasUninstallNotes()

Does this package have uninstall notes?

from  Package
bool
hasInstallPostScreen()

Does this package have a post-install page?

from  Package
bool
allowsFullContentSwap()

Does this package clear all existing website content when it's being installed?

from  Package
string
getPackagePath()

Get the absolute path to the package.

from  Package
string
getRelativePath()

Get the path to the package relative to the web root.

from  Package
string
getRelativePathFromInstallFolder()

Get the path to the package relative to the Concrete installation folder.

from  Package
getTranslationFile($locale)

No description

from  Package
bool
contentProvidesFileThumbnails()

Does this package provide the file thumbnails? If false, the file thumbnails are generated during the install process.

from  Package
install()

Install the package info row and the database (doctrine entities and db.xml).

from  Package
uninstall()

Uninstall the package:

  • delete the installed items associated to the package
  • destroy the package proxy classes of entities
  • remove the package info row.

from  Package
string
getChangelogContents()

Get the contents of the package's CHANGELOG file.

from  Package
static Package[]
getInstalledList() deprecated

No description

from  Package
static string[]
getInstalledHandles() deprecated

No description

from  Package
static Package|null
getByHandle(string $pkgHandle) deprecated

No description

from  Package
static Package[]
getLocalUpgradeablePackages() deprecated

No description

from  Package
static Package[]
getRemotelyUpgradeablePackages() deprecated

No description

from  Package
static Package[]
getAvailablePackages(bool $filterInstalled = true) deprecated

No description

from  Package
static Package|null
getByID(int $pkgID) deprecated

No description

from  Package
static Package
getClass(string $pkgHandle)

No description

ErrorList|true
testForInstall(bool $testForAlreadyInstalled = true)

Perform tests before this package is installed.

from  Package
ErrorList|true
testForUpgrade()

Perform tests before this package is upgraded.

from  Package
ErrorList|true
testForUninstall()

Perform tests before this package is uninstalled.

from  Package
backup()

Move the current package directory to the trash directory, and rename it with the package handle and a date code.

from  Package
bool
restore()

If a package was just backed up by this instance of the package object and the packages/package handle directory doesn't exist, this will restore the package from the trash.

from  Package
getPackageEntityPaths() deprecated

No description

from  Package
installDatabase()

Installs the packages database through doctrine entities and db.xml database definitions.

from  Package
installEntitiesDatabase()

No description

from  Package
static bool|stdClass
installDB(string $xmlFile)

Installs a package database from an XML file.

from  Package
upgradeCoreData()

Updates the package entity name, description and version using the current class properties.

from  Package
upgrade()

Upgrades a package's database and refreshes all blocks.

from  Package
upgradeDatabase()

Updates a package's database using entities and a db.xml.

from  Package
string
getNamespace(bool $withLeadingBackslash = false)

Get the namespace of the package by the package handle.

from  Package
EntityManager|null
getPackageEntityManager()

Create an entity manager used for the package install, upgrade and unistall process.

from  Package
EntityManagerInterface
getEntityManager() deprecated

No description

from  Package
int|null
getPackageID() deprecated

No description

from  Package
getTranslatableStrings(Translations $translations)

Override this method in your package controller to add strings to the translator, so that you can translate dynamically generated strings.

from  Package
array
getPackageDependencies()

Return the package dependencies.

from  Package
string
getErrorText(array|int $errorCode)

Get the error text corresponsing to an error code.

from  Package
destroyProxyClasses(EntityManagerInterface $em)

Destroys all proxies related to a package.

from  Package
int|null
getPHPVersionIDRequired()

Get the minimum PHP version compatible with the package.

from  Package
setInstallerOptions(InstallerOptions $installerOptions = null)

No description

static 
hasCustomList()

No description

static 
getAvailableList()

No description

executeInstallRoutine(string $routineName)

No description

add_home_page()

No description

install_attributes()

No description

install_dashboard()

No description

install_boards()

No description

install_page_types()

No description

install_blocktypes() deprecated

No description

install_themes()

No description

install_tasks()

No description

install_config()

No description

install_file_manager()

No description

import_files()

No description

install_content()

No description

install_desktops()

No description

install_api()

No description

install_database()

No description

add_users()

No description

make_directories()

No description

finish()

No description

install_site()

No description

Details

__construct(Application $app)

Initialize the instance.

Parameters

Application $app

the application instance

Package|null getPackageEntity()

Get the associated package entity (if available).

Return Value

Package|null

May return NULL if the package is invalid and/or if it's not installed

setPackageEntity(Package $entity)

Set the associated package entity.

Parameters

Package $entity

array getContentSwapFiles()

No description

Return Value

array

Package setContentSwapFiles(array $pkgContentSwapFiles)

No description

Parameters

array $pkgContentSwapFiles

Return Value

Package

Application getApplication()

Get the Application instance.

Return Value

Application

ContentSwapperInterface getContentSwapper()

Get the content swapper.

installContentFile(string $file)

Import a concrete5-cif XML file.

Parameters

string $file

the path to the file, relative to the package directory

bool shouldEnableLegacyNamespace()

Should this package enable legacy namespaces?

This returns true IF:

  1. $this->pkgAutoloaderMapCoreExtensions is false or unset
  2. The required package version > 7.9.9 meaning version 8 or newer
  3. $this->pkgEnableLegacyNamespace is true

Return Value

bool

Liaison getConfig()

Get the default configuration liaison.

Return Value

Liaison

Liaison getDatabaseConfig()

Get the database configuration liaison.

Return Value

Liaison

Liaison getFileConfig()

Get the filesystem configuration liaison.

Return Value

Liaison

array getPackageAutoloaderRegistries()

Get the custom autoloader prefixes to be automatically added to the class loader.

Array keys are the locations (relative to the package directory). Array values are the paths (not relative to the package namespace).

Return Value

array

Examples

['src/PortlandLabs' => \PortlandLabs']

string getPackageHandle()

Get the package handle.

Return Value

string

string getPackageName()

Get the translated name of the package.

Return Value

string

string getPackageDescription()

Get the translated package description.

Return Value

string

string getPackageVersion()

Get the installed package version.

Return Value

string

string getApplicationVersionRequired()

Get the minimum Concrete version compatible with the package.

Return Value

string

string getPHPVersionRequired()

Get the minimum PHP version compatible with the package.

Return Value

string

Examples

'' if the package is compatible with any PHP version that's already compatible with the core
'8' if the package requires PHP 8.0.0 and later
'8.1' if the package requires PHP 8.1.0 and later
'8.1.20' if the package requires PHP 8.1.20 and later

bool showInstallOptionsScreen()

Should the install options page be shown? The install options page may be for install notes and/or full contents swap confirmation.

Return Value

bool

bool hasInstallNotes()

Does this package have install notes?

Return Value

bool

bool hasUninstallNotes()

Does this package have uninstall notes?

Return Value

bool

bool hasInstallPostScreen()

Does this package have a post-install page?

Return Value

bool

bool allowsFullContentSwap()

Does this package clear all existing website content when it's being installed?

Return Value

bool

string getPackagePath()

Get the absolute path to the package.

Return Value

string

string getRelativePath()

Get the path to the package relative to the web root.

Return Value

string

string getRelativePathFromInstallFolder()

Get the path to the package relative to the Concrete installation folder.

Return Value

string

getTranslationFile($locale)

No description

bool contentProvidesFileThumbnails()

Does this package provide the file thumbnails? If false, the file thumbnails are generated during the install process.

Return Value

bool

Package install()

Install the package info row and the database (doctrine entities and db.xml).

Packages installing additional content should override this method, call the parent method (parent::install()).

Return Value

Package

uninstall()

Uninstall the package:

  • delete the installed items associated to the package
  • destroy the package proxy classes of entities
  • remove the package info row.

string getChangelogContents()

Get the contents of the package's CHANGELOG file.

Return Value

string

if no changelog is available an empty string is returned

static Package[] getInstalledList() deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getInstalledList()

No description

Return Value

Package[]

static string[] getInstalledHandles() deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getInstalledHandles()

No description

Return Value

string[]

static Package|null getByHandle(string $pkgHandle) deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getByHandle($pkgHandle)

No description

Parameters

string $pkgHandle

Return Value

Package|null

static Package[] getLocalUpgradeablePackages() deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getLocalUpgradeablePackages()

No description

Return Value

Package[]

static Package[] getRemotelyUpgradeablePackages() deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getRemotelyUpgradeablePackages()

No description

Return Value

Package[]

static Package[] getAvailablePackages(bool $filterInstalled = true) deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getAvailablePackages($filterInstalled)

No description

Parameters

bool $filterInstalled

Return Value

Package[]

static Package|null getByID(int $pkgID) deprecated

deprecated Use $app->make('Concrete\Core\Package\PackageService')->getByID($pkgID)

No description

Parameters

int $pkgID

Return Value

Package|null

static Package getClass(string $pkgHandle)

No description

Parameters

string $pkgHandle

Return Value

Package

ErrorList|true testForInstall(bool $testForAlreadyInstalled = true)

Perform tests before this package is installed.

Parameters

bool $testForAlreadyInstalled

Set to false to skip checking if this package is already installed

Return Value

ErrorList|true

return true if the package can be installed, an ErrorList instance otherwise

ErrorList|true testForUpgrade()

Perform tests before this package is upgraded.

Return Value

ErrorList|true

return null if the package can be upgraded, an ErrorList instance otherwise

ErrorList|true testForUninstall()

Perform tests before this package is uninstalled.

Return Value

ErrorList|true

return true if the package can be uninstalled, an ErrorList instance otherwise

ErrorList|Package backup()

Move the current package directory to the trash directory, and rename it with the package handle and a date code.

Return Value

ErrorList|Package

return the Package instance if the package has been moved, an ErrorList instance otherwise

bool restore()

If a package was just backed up by this instance of the package object and the packages/package handle directory doesn't exist, this will restore the package from the trash.

Return Value

bool

getPackageEntityPaths() deprecated

deprecated This method was limited. It let you specify a location but in V8 with the Doctrine Entity Manager driver chain we also need to specify namespaces. Instead of specifying entity paths this way, update your package controller to implement the Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface, and create a method named getEntityManagerProvider that returns an instance of the Concrete\Core\Database\EntityManager\Provider\ProviderInterface. For example, if I want to specify that my package has entities found at src/PortlandLabs\FooBar\Entity, with the namespace PortlandLabs\FooBar\Entity, my method is simply public function getEntityManagerProvider() { return new StandardPackageProvider($this->app, $this, ['src/MSM/Entity' => 'PortlandLabs\MSM\Entity']); }

No description

installDatabase()

Installs the packages database through doctrine entities and db.xml database definitions.

installEntitiesDatabase()

No description

static bool|stdClass installDB(string $xmlFile)

Installs a package database from an XML file.

Parameters

string $xmlFile

Path to the database XML file

Return Value

bool|stdClass

Returns false if the XML file could not be found

Exceptions

ConnectionException

upgradeCoreData()

Updates the package entity name, description and version using the current class properties.

upgrade()

Upgrades a package's database and refreshes all blocks.

upgradeDatabase()

Updates a package's database using entities and a db.xml.

Exceptions

ConnectionException
Exception

string getNamespace(bool $withLeadingBackslash = false)

Get the namespace of the package by the package handle.

Parameters

bool $withLeadingBackslash

Return Value

string

EntityManager|null getPackageEntityManager()

Create an entity manager used for the package install, upgrade and unistall process.

Return Value

EntityManager|null

EntityManagerInterface getEntityManager() deprecated

deprecated Use $app->make('Doctrine\ORM\EntityManagerInterface')

No description

Return Value

EntityManagerInterface

int|null getPackageID() deprecated

deprecated use the getPackageID method of the package entity

No description

Return Value

int|null

getTranslatableStrings(Translations $translations)

Override this method in your package controller to add strings to the translator, so that you can translate dynamically generated strings.

Parameters

Translations $translations

Examples

If you add to this method these two strings:

<code>
$translations->insert('', 'String without context');
$translations->insert('MyContext', 'String with context');
</code>

Then you'll be able to translate these two strings in the Translator and write translated strings with:

<code>
echo t('String without context');
echo tc('MyContext', 'String with context');
</code>

array getPackageDependencies()

Return the package dependencies.

Return Value

array

See also

Package::$packageDependencies

protected string getErrorText(array|int $errorCode)

Get the error text corresponsing to an error code.

Parameters

array|int $errorCode

one of the Package::EPACKAGE constants, or an array with the first value is one of the Package::EPACKAGE constants and the other values are used to fill in fields

Return Value

string

protected destroyProxyClasses(EntityManagerInterface $em)

Destroys all proxies related to a package.

Parameters

EntityManagerInterface $em

protected int|null getPHPVersionIDRequired()

Get the minimum PHP version compatible with the package.

Return Value

int|null

Examples

null if the package is compatible with any PHP version that's already compatible with the core
80000 if the package requires PHP 8.0.0 and later
80100 if the package requires PHP 8.1.0 and later
80120 if the package requires PHP 8.1.20 and later

setInstallerOptions(InstallerOptions $installerOptions = null)

No description

Parameters

InstallerOptions $installerOptions

static hasCustomList()

No description

static getAvailableList()

No description

StartingPointInstallRoutine[] getInstallRoutines()

No description

executeInstallRoutine(string $routineName)

No description

Parameters

string $routineName

Exceptions

Exception
Throwable

protected add_home_page()

No description

protected install_data_objects()

No description

protected install_attributes()

No description

protected install_dashboard()

No description

protected install_boards()

No description

protected install_page_types()

No description

protected install_required_single_pages()

No description

protected install_blocktypes() deprecated

deprecated This method has been splitted in smaller chunks

No description

protected install_blocktypes_basic()

No description

protected install_blocktypes_navigation()

No description

protected install_blocktypes_form()

No description

protected install_blocktypes_express()

No description

protected install_blocktypes_social()

No description

protected install_blocktypes_calendar()

No description

protected install_blocktypes_multimedia()

No description

protected install_blocktypes_core_desktop()

No description

protected install_blocktypes_other()

No description

protected install_themes()

No description

protected install_tasks()

No description

install_config()

No description

install_file_manager()

No description

import_files()

No description

protected install_content()

No description

protected install_desktops()

No description

protected install_api()

No description

protected install_database()

No description

protected indexAdditionalDatabaseFields()

No description

protected add_users()

No description

protected make_directories()

No description

protected finish()

No description

protected install_permissions()

No description

protected install_site()

No description

protected install_site_permissions()

No description