Liip\RMT\Context::get PHP Method

get() public static method

Shortcut to retried a service
public static get ( string $serviceName ) : mixed
$serviceName string
return mixed
    public static function get($serviceName)
    {
        return self::getInstance()->getService($serviceName);
    }

Usage Example

Example #1
0
 public function loadContext()
 {
     $configHandler = new Handler($this->getApplication()->getConfig(), $this->getApplication()->getProjectRootDir());
     $config = $configHandler->getBaseConfig();
     // Select a branch specific config if a VCS is in use
     if (isset($config['vcs'])) {
         Context::getInstance()->setService('vcs', $config['vcs']['class'], $config['vcs']['options']);
         /** @var VCSInterface $vcs */
         $vcs = Context::get('vcs');
         try {
             $branch = $vcs->getCurrentBranch();
         } catch (\Exception $e) {
             echo "Impossible to read the branch name";
         }
         if (isset($branch)) {
             $config = $configHandler->getConfigForBranch($branch);
         }
     }
     // Store the config for latter usage
     Context::getInstance()->setParameter('config', $config);
     // Populate the context
     foreach (array('version-generator', 'version-persister') as $service) {
         Context::getInstance()->setService($service, $config[$service]['class'], $config[$service]['options']);
     }
     foreach (array('prerequisites', 'pre-release-actions', 'post-release-actions') as $listName) {
         Context::getInstance()->createEmptyList($listName);
         foreach ($config[$listName] as $service) {
             Context::getInstance()->addToList($listName, $service['class'], $service['options']);
         }
     }
     // Provide the root dir as a context parameter
     Context::getInstance()->setParameter('project-root', $this->getApplication()->getProjectRootDir());
 }
All Usage Examples Of Liip\RMT\Context::get