abstract class Package implements LocalizablePackageInterface (View source)

Constants

E_PACKAGE_NOT_FOUND

E_PACKAGE_INSTALLED

E_PACKAGE_VERSION

E_PACKAGE_DOWNLOAD

E_PACKAGE_SAVE

E_PACKAGE_UNZIP

E_PACKAGE_INSTALL

E_PACKAGE_MIGRATE_BACKUP

E_PACKAGE_INVALID_APP_VERSION

E_PACKAGE_THEME_ACTIVE

Properties

protected $DIR_PACKAGES_CORE
protected $DIR_PACKAGES
protected $REL_DIR_PACKAGES_CORE
protected $REL_DIR_PACKAGES
protected Package $entity
protected Application $app
protected Liaison $config
protected Liaison $fileConfig
protected bool deprecated $pkgEnableLegacyNamespace
protected array $pkgAutoloaderRegistries

Array of location -> namespace autoloader entries for the package. Will automatically be added to the class loader. (e.g. array('src/PortlandLabs' => \PortlandLabs')).

protected $appVersionRequired
protected $pkgAllowsFullContentSwap
protected $pkgContentProvidesFileThumbnails
protected DatabaseStructureManager $databaseStructureManager

Methods

getPackageEntity()

No description

setPackageEntity(Package $entity)

No description

getApplication()

No description

__construct(Application $app)

No description

getContentSwapper()

No description

installContentFile($file)

No description

bool
shouldEnableLegacyNamespace()

Should this pacakge enable legacy namespaces.

getConfig()

Get the standard database config liaison.

getDatabaseConfig()

Get the standard database config liaison.

getFileConfig()

Get the standard filesystem config liaison.

array
getPackageAutoloaderRegistries()

Returns custom autoloader prefixes registered by the class loader.

getPackageHandle()

No description

string
getPackageName()

Returns the translated name of the package.

string
getPackageDescription()

Returns the translated package description.

string
getPackageVersion()

Returns the installed package version.

string
getApplicationVersionRequired()

Returns the version of concrete5 required by the package.

bool
showInstallOptionsScreen()

Returns true if the package has an install options screen.

hasInstallNotes()

No description

hasUninstallNotes()

No description

bool
hasInstallPostScreen()

Returns true if the package has a post install screen.

allowsFullContentSwap()

No description

getPackagePath()

No description

string
getRelativePath()

Returns the path to the package's folder, relative to the install path.

string
getRelativePathFromInstallFolder()

Returns the path starting from c5 installation folder to the package folder.

getTranslationFile($locale)

No description

string
contentProvidesFileThumbnails()

Returns a path to where the packages files are located.

install()

Installs the package info row and installs the database. Packages installing additional content should override this method, call the parent method, and use the resulting package object for further installs.

uninstall()

No description

string
getChangelogContents()

Gets the contents of the package's CHANGELOG file. If no changelog is available an empty string is returned.

static 
getInstalledList() deprecated

No description

static 
getInstalledHandles() deprecated

No description

static 
getByHandle($pkgHandle) deprecated

No description

static 
getLocalUpgradeablePackages() deprecated

No description

static 
getRemotelyUpgradeablePackages() deprecated

No description

static 
getAvailablePackages($filterInstalled = true) deprecated

No description

static 
getByID($pkgID) deprecated

No description

static 
getClass($pkgHandle) deprecated

No description

array|bool
testForInstall(bool $testForAlreadyInstalled = true)

This is the pre-test routine that packages run through before they are installed. Any errors that come here are to be returned in the form of an array so we can show the user. If it's all good we return true.

getErrorText($result)

No description

bool|int[]
testForUninstall()

No description

backup()

Moves the current package's directory to the trash directory renamed with the package handle and a date code.

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.

getPackageEntityPaths() deprecated

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's database from an XML file.

upgradeCoreData()

Updates a package's name, description, version and ID 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.

string
getNamespace(bool $withLeadingBacksalsh = false)

Get the namespace of the package by the package handle.

EntityManager
getPackageEntityManager()

Create a entity manager used for the package installation, update and unistall process.

destroyProxyClasses(EntityManagerInterface $em)

Destroys all proxies related to a package.

getEntityManager() deprecated

No description

getPackageID() deprecated

No description

getTranslatableStrings(Translations $translations)

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

Details

Package getPackageEntity()

No description

Return Value

Package

setPackageEntity(Package $entity)

No description

Parameters

Package $entity

getApplication()

No description

__construct(Application $app)

No description

Parameters

Application $app

getContentSwapper()

No description

installContentFile($file)

No description

Parameters

$file

bool shouldEnableLegacyNamespace()

Should this pacakge 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 standard database config liaison.

Return Value

Liaison

Liaison getDatabaseConfig()

Get the standard database config liaison.

Return Value

Liaison

Liaison getFileConfig()

Get the standard filesystem config liaison.

Return Value

Liaison

array getPackageAutoloaderRegistries()

Returns custom autoloader prefixes registered by the class loader.

Return Value

array

Keys represent the namespace, not relative to the package's namespace. Values are the path, and are relative to the package directory

getPackageHandle()

No description

string getPackageName()

Returns the translated name of the package.

Return Value

string

string getPackageDescription()

Returns the translated package description.

Return Value

string

string getPackageVersion()

Returns the installed package version.

Return Value

string

string getApplicationVersionRequired()

Returns the version of concrete5 required by the package.

Return Value

string

bool showInstallOptionsScreen()

Returns true if the package has an install options screen.

Return Value

bool

hasInstallNotes()

No description

hasUninstallNotes()

No description

bool hasInstallPostScreen()

Returns true if the package has a post install screen.

Return Value

bool

allowsFullContentSwap()

No description

getPackagePath()

No description

string getRelativePath()

Returns the path to the package's folder, relative to the install path.

Return Value

string

string getRelativePathFromInstallFolder()

Returns the path starting from c5 installation folder to the package folder.

Return Value

string

getTranslationFile($locale)

No description

Parameters

$locale

string contentProvidesFileThumbnails()

Returns a path to where the packages files are located.

Return Value

string $path

Package install()

Installs the package info row and installs the database. Packages installing additional content should override this method, call the parent method, and use the resulting package object for further installs.

Return Value

Package

uninstall()

No description

string getChangelogContents()

Gets the contents of the package's CHANGELOG file. If no changelog is available an empty string is returned.

Return Value

string

static getInstalledList() deprecated

deprecated

No description

static getInstalledHandles() deprecated

deprecated

No description

static getByHandle($pkgHandle) deprecated

deprecated

No description

Parameters

$pkgHandle

static getLocalUpgradeablePackages() deprecated

deprecated

No description

static getRemotelyUpgradeablePackages() deprecated

deprecated

No description

static getAvailablePackages($filterInstalled = true) deprecated

deprecated

No description

Parameters

$filterInstalled

static getByID($pkgID) deprecated

deprecated

No description

Parameters

$pkgID

static getClass($pkgHandle) deprecated

deprecated

No description

Parameters

$pkgHandle

array|bool testForInstall(bool $testForAlreadyInstalled = true)

This is the pre-test routine that packages run through before they are installed. Any errors that come here are to be returned in the form of an array so we can show the user. If it's all good we return true.

Parameters

bool $testForAlreadyInstalled

Return Value

array|bool

Returns an array of errors or true if the package can be installed

protected getErrorText($result)

No description

Parameters

$result

bool|int[] testForUninstall()

No description

Return Value

bool|int[]

true on success, array of error codes on failure

backup()

Moves the current package's directory to the trash directory renamed with the package handle and a date code.

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.

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's 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 a package's name, description, version and ID 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 $withLeadingBacksalsh = false)

Get the namespace of the package by the package handle.

Parameters

bool $withLeadingBacksalsh

Return Value

string

EntityManager getPackageEntityManager()

Create a entity manager used for the package installation, update and unistall process.

Return Value

EntityManager

protected destroyProxyClasses(EntityManagerInterface $em)

Destroys all proxies related to a package.

Parameters

EntityManagerInterface $em

getEntityManager() deprecated

deprecated

No description

getPackageID() deprecated

deprecated This should be handled by the Concrete\Core\Entity\Package object, not by this object

No description

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>