PHP Class Puli\Manager\Api\Container

Use this class to access the managers provided by this module: php $puli = new Puli(getcwd()); $puli->start(); $moduleManager = $puli->getModuleManager(); The Puli class either operates in the global or a project context: * The "global context" is not tied to a specific root module. A global context only loads the settings of the "config.json" file in the home directory. The Puli class operates in the global context if no project root directory is passed to the constructor. In the global context, only the global config file manager is available. * The "project context" is tied to a specific Puli project. You need to pass the path to the project's root directory to the constructor or to {@link setRootDirectory()}. The configuration of the "puli.json" file in the root directory is used to configure the managers. The Puli class creates four kinds of managers: * The "config file manager" allows you to modify entries of the "config.json" file in the home directory. * The "module file manager" manages modifications to the "puli.json" file of a Puli project. * The "module manager" manages the module repository of a Puli project. * The "repository manager" manages the resource repository of a Puli project. * The "discovery manager" manages the resource discovery of a Puli project. The home directory is read from the context variable "PULI_HOME". If this variable is not set, the home directory defaults to: * $HOME/.puli on Linux, where $HOME is the context variable "HOME". * $APPDATA/Puli on Windows, where $APPDATA is the context variable "APPDATA". If none of these variables can be found, an exception is thrown. A .htaccess file is put into the home directory to protect it from web access.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Show file Open project: puli/manager Class Usage Examples

Public Methods

Method Description
__construct ( string | null $rootDir = null, string $env = Environment::DEV ) Creates a new instance for the given Puli project.
arePluginsEnabled ( ) : boolean Returns whether Puli plugins are enabled.
disablePlugins ( ) Disables all Puli plugins.
enablePlugins ( ) Enables all Puli plugins.
getAssetManager ( ) : Puli\Manager\Api\Asset\AssetManager Returns the asset manager.
getConfigFileConverter ( ) : Puli\Manager\Config\ConfigFileConverter Returns the configuration file serializer.
getConfigFileManager ( ) : Puli\Manager\Api\Config\ConfigFileManager Returns the configuration file manager.
getContext ( ) : Puli\Manager\Api\Context\Context | Puli\Manager\Api\Context\ProjectContext Returns the context.
getDiscovery ( ) : Puli\Discovery\Api\EditableDiscovery Returns the resource discovery of the project.
getDiscoveryManager ( ) : Puli\Manager\Api\Discovery\DiscoveryManager Returns the resource discovery manager.
getEnvironment ( ) : string Retturns the environment of the managed Puli project.
getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface | null Returns the used event dispatcher.
getFactory ( ) : object
getFactoryManager ( ) : Puli\Manager\Api\Factory\FactoryManager
getInstallationManager ( ) : Puli\Manager\Api\Installation\InstallationManager Returns the installation manager.
getInstallerManager ( ) : Puli\Manager\Api\Installer\InstallerManager Returns the installer manager.
getJsonDecoder ( ) : JsonDecoder Returns the JSON decoder.
getJsonEncoder ( ) : JsonEncoder Returns the JSON encoder.
getJsonValidator ( ) : JsonValidator Returns the JSON validator.
getLegacyModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter Returns the module file serializer with support for legacy versions.
getLegacyRootModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter Returns the module file serializer with support for legacy versions.
getLogger ( ) : Psr\Log\LoggerInterface Returns the logger.
getModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter Returns the module file converter.
getModuleManager ( ) : Puli\Manager\Api\Module\ModuleManager Returns the module manager.
getRepository ( ) : Puli\Repository\Api\EditableRepository Returns the resource repository of the project.
getRepositoryManager ( ) : Puli\Manager\Api\Repository\RepositoryManager Returns the resource repository manager.
getRootDirectory ( ) : string | null Returns the root directory of the managed Puli project.
getRootModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter Returns the module file converter.
getRootModuleFileManager ( ) : Puli\Manager\Api\Module\RootModuleFileManager Returns the root module file manager.
getServerManager ( ) : Puli\Manager\Api\Server\ServerManager Returns the server manager.
getStorage ( ) : Puli\Manager\Api\Storage\Storage Returns the file storage.
getUrlGenerator ( ) : Puli\UrlGenerator\Api\UrlGenerator Returns the resource URL generator.
isStarted ( ) : boolean Returns whether the service container is started.
setEnvironment ( string $env ) Sets the environment of the managed Puli project.
setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher ) Sets the event dispatcher to use.
setLogger ( Psr\Log\LoggerInterface $logger ) Sets the logger to use.
setRootDirectory ( string | null $rootDir ) Sets the root directory of the managed Puli project.
start ( ) Starts the service container.

Private Methods

Method Description
activatePlugins ( )
createGlobalContext ( )
createProjectContext ( string $rootDir, $env ) : Puli\Manager\Api\Context\ProjectContext Creates the context of a Puli project.
createValidatingConverter ( Webmozart\Json\Conversion\JsonConverter $innerConverter, string | callable | null $schema = null ) : ValidatingConverter Decorates a converter with a {@link ValidatingConverter}.
getJsonStorage ( ) : JsonStorage Returns the JSON file storage.
getJsonVersioner ( ) : Webmozart\Json\Versioning\JsonVersioner Returns the JSON versioner.
getModuleFileMigrationManager ( ) : MigrationManager Returns the migration manager for module files.
loadConfigFile ( $homeDir, Puli\Manager\Api\Config\Config $baseConfig )
parseHomeDirectory ( ) : null | string Parses the system context for a home directory.
validatePluginClass ( string $pluginClass ) Validates the given plugin class name.

Method Details

__construct() public method

Creates a new instance for the given Puli project.
public __construct ( string | null $rootDir = null, string $env = Environment::DEV )
$rootDir string | null The root directory of the Puli project. If none is passed, the object operates in the global context. You can set or switch the root directories later on by calling {@link setRootDirectory()}.
$env string One of the {@link Environment} constants.

arePluginsEnabled() public method

Returns whether Puli plugins are enabled.
public arePluginsEnabled ( ) : boolean
return boolean Returns `true` if Puli plugins will be loaded and `false` otherwise.

disablePlugins() public method

Disables all Puli plugins.
public disablePlugins ( )

enablePlugins() public method

Enables all Puli plugins.
public enablePlugins ( )

getAssetManager() public method

Returns the asset manager.
public getAssetManager ( ) : Puli\Manager\Api\Asset\AssetManager
return Puli\Manager\Api\Asset\AssetManager The asset manager.

getConfigFileConverter() public method

Returns the configuration file serializer.
public getConfigFileConverter ( ) : Puli\Manager\Config\ConfigFileConverter
return Puli\Manager\Config\ConfigFileConverter The configuration file serializer.

getConfigFileManager() public method

Returns the configuration file manager.
public getConfigFileManager ( ) : Puli\Manager\Api\Config\ConfigFileManager
return Puli\Manager\Api\Config\ConfigFileManager The configuration file manager.

getContext() public method

Returns the context.
public getContext ( ) : Puli\Manager\Api\Context\Context | Puli\Manager\Api\Context\ProjectContext
return Puli\Manager\Api\Context\Context | Puli\Manager\Api\Context\ProjectContext The context.

getDiscovery() public method

Returns the resource discovery of the project.
public getDiscovery ( ) : Puli\Discovery\Api\EditableDiscovery
return Puli\Discovery\Api\EditableDiscovery The resource discovery.

getDiscoveryManager() public method

Returns the resource discovery manager.
public getDiscoveryManager ( ) : Puli\Manager\Api\Discovery\DiscoveryManager
return Puli\Manager\Api\Discovery\DiscoveryManager The discovery manager.

getEnvironment() public method

Retturns the environment of the managed Puli project.
public getEnvironment ( ) : string
return string One of the {@link Environment} constants.

getEventDispatcher() public method

Returns the used event dispatcher.
public getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface | null
return Symfony\Component\EventDispatcher\EventDispatcherInterface | null The used logger.

getFactory() public method

public getFactory ( ) : object
return object

getFactoryManager() public method

public getFactoryManager ( ) : Puli\Manager\Api\Factory\FactoryManager
return Puli\Manager\Api\Factory\FactoryManager

getInstallationManager() public method

Returns the installation manager.
public getInstallationManager ( ) : Puli\Manager\Api\Installation\InstallationManager
return Puli\Manager\Api\Installation\InstallationManager The installation manager.

getInstallerManager() public method

Returns the installer manager.
public getInstallerManager ( ) : Puli\Manager\Api\Installer\InstallerManager
return Puli\Manager\Api\Installer\InstallerManager The installer manager.

getJsonDecoder() public method

Returns the JSON decoder.
public getJsonDecoder ( ) : JsonDecoder
return Webmozart\Json\JsonDecoder The JSON decoder.

getJsonEncoder() public method

Returns the JSON encoder.
public getJsonEncoder ( ) : JsonEncoder
return Webmozart\Json\JsonEncoder The JSON encoder.

getJsonValidator() public method

Returns the JSON validator.
public getJsonValidator ( ) : JsonValidator
return Webmozart\Json\JsonValidator The JSON validator.

getLegacyModuleFileConverter() public method

Returns the module file serializer with support for legacy versions.
public getLegacyModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter
return Webmozart\Json\Conversion\JsonConverter The module file converter.

getLegacyRootModuleFileConverter() public method

Returns the module file serializer with support for legacy versions.
public getLegacyRootModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter
return Webmozart\Json\Conversion\JsonConverter The module file converter.

getLogger() public method

Returns the logger.
public getLogger ( ) : Psr\Log\LoggerInterface
return Psr\Log\LoggerInterface The logger.

getModuleFileConverter() public method

Returns the module file converter.
public getModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter
return Webmozart\Json\Conversion\JsonConverter The module file converter.

getModuleManager() public method

Returns the module manager.
public getModuleManager ( ) : Puli\Manager\Api\Module\ModuleManager
return Puli\Manager\Api\Module\ModuleManager The module manager.

getRepository() public method

Returns the resource repository of the project.
public getRepository ( ) : Puli\Repository\Api\EditableRepository
return Puli\Repository\Api\EditableRepository The resource repository.

getRepositoryManager() public method

Returns the resource repository manager.
public getRepositoryManager ( ) : Puli\Manager\Api\Repository\RepositoryManager
return Puli\Manager\Api\Repository\RepositoryManager The repository manager.

getRootDirectory() public method

If no Puli project is managed at the moment, null is returned.
public getRootDirectory ( ) : string | null
return string | null The root directory of the managed Puli project or `null` if none is set.

getRootModuleFileConverter() public method

Returns the module file converter.
public getRootModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter
return Webmozart\Json\Conversion\JsonConverter The module file converter.

getRootModuleFileManager() public method

Returns the root module file manager.
public getRootModuleFileManager ( ) : Puli\Manager\Api\Module\RootModuleFileManager
return Puli\Manager\Api\Module\RootModuleFileManager The module file manager.

getServerManager() public method

Returns the server manager.
public getServerManager ( ) : Puli\Manager\Api\Server\ServerManager
return Puli\Manager\Api\Server\ServerManager The server manager.

getStorage() public method

Returns the file storage.
public getStorage ( ) : Puli\Manager\Api\Storage\Storage
return Puli\Manager\Api\Storage\Storage The storage.

getUrlGenerator() public method

Returns the resource URL generator.
public getUrlGenerator ( ) : Puli\UrlGenerator\Api\UrlGenerator
return Puli\UrlGenerator\Api\UrlGenerator The resource URL generator.

isStarted() public method

Returns whether the service container is started.
public isStarted ( ) : boolean
return boolean Returns `true` if the container is started and `false` otherwise.

setEnvironment() public method

Sets the environment of the managed Puli project.
public setEnvironment ( string $env )
$env string One of the {@link Environment} constants.

setEventDispatcher() public method

Sets the event dispatcher to use.
public setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface The event dispatcher to use.

setLogger() public method

Sets the logger to use.
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface The logger to use.

setRootDirectory() public method

Sets the root directory of the managed Puli project.
public setRootDirectory ( string | null $rootDir )
$rootDir string | null The root directory of the managed Puli project or `null` to start Puli outside of a specific project.

start() public method

Starts the service container.
public start ( )