Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
InfoCommand Class Reference

Public Member Functions

 __construct (MagentoComposerApplication $magentoComposerApplication)
 
 run ($package, $installed=false)
 

Data Fields

const CURRENT_VERSION = 'current_version'
 
const VERSIONS = 'versions'
 
const AVAILABLE_VERSIONS = 'available_versions'
 
const NAME = 'name'
 
const NEW_VERSIONS = 'new_versions'
 

Protected Attributes

 $magentoComposerApplication
 

Detailed Description

Class InfoCommand calls composer info command

Definition at line 12 of file InfoCommand.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( MagentoComposerApplication  $magentoComposerApplication)

Constructor

Parameters
MagentoComposerApplication$magentoComposerApplication

Definition at line 47 of file InfoCommand.php.

48  {
49  $this->magentoComposerApplication = $magentoComposerApplication;
50  }

Member Function Documentation

◆ run()

run (   $package,
  $installed = false 
)

Runs composer info command

Parameters
string$package
bool$installed
Returns
array|bool

Definition at line 59 of file InfoCommand.php.

60  {
61  $showAllPackages = !$installed;
62  $commandParameters = [
63  'command' => 'info',
64  'package' => $package,
65  '-i' => $installed,
66  '--all' => $showAllPackages,
67  ];
68 
69  try {
70  $output = $this->magentoComposerApplication->runComposerCommand($commandParameters);
71  } catch (\RuntimeException $e) {
72  return false;
73  }
74 
75  $rawLines = explode("\n", str_replace("\r\n", "\n", $output));
76  $result = [];
77 
78  foreach ($rawLines as $line) {
79  $chunk = explode(':', $line);
80  if (count($chunk) === 2) {
81  $result[trim($chunk[0])] = trim($chunk[1]);
82  }
83  }
84 
85  $result = $this->extractVersions($result);
86 
87  if (!isset($result[self::NAME]) && isset($result[self::CURRENT_VERSION])) {
88  $result[self::NAME] = $package;
89  }
90 
91  return $result;
92  }

Field Documentation

◆ $magentoComposerApplication

$magentoComposerApplication
protected

Definition at line 40 of file InfoCommand.php.

◆ AVAILABLE_VERSIONS

const AVAILABLE_VERSIONS = 'available_versions'

Available versions

Definition at line 24 of file InfoCommand.php.

◆ CURRENT_VERSION

const CURRENT_VERSION = 'current_version'

Current version

Definition at line 17 of file InfoCommand.php.

◆ NAME

const NAME = 'name'

Package name

Definition at line 29 of file InfoCommand.php.

◆ NEW_VERSIONS

const NEW_VERSIONS = 'new_versions'

New versions

Definition at line 34 of file InfoCommand.php.

◆ VERSIONS

const VERSIONS = 'versions'

Definition at line 19 of file InfoCommand.php.


The documentation for this class was generated from the following file: