Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Static Public Member Functions
MagentoComponent Class Reference

Static Public Member Functions

static matchMagentoComponent ($key)
 

Detailed Description

Definition at line 8 of file MagentoComponent.php.

Member Function Documentation

◆ matchMagentoComponent()

static matchMagentoComponent (   $key)
static

Get matched Magento component or empty array, if it's not a Magento component

Parameters
string$key
Returns
string[] ['type' => '<type>', 'area' => '<area>', 'name' => '<name>'] Ex.: ['type' => 'module', 'name' => 'catalog'] ['type' => 'theme', 'area' => 'frontend', 'name' => 'blank']

Definition at line 18 of file MagentoComponent.php.

19  {
20  $typePattern = 'module|theme|language|framework';
21  $areaPattern = 'frontend|adminhtml';
22  $namePattern = '[a-z0-9_-]+';
23  $regex = '/^magento\/(?P<type>' . $typePattern . ')(?:-(?P<area>' . $areaPattern . '))?(?:-(?P<name>'
24  . $namePattern . '))?$/';
25  if (preg_match($regex, $key, $matches)) {
26  return $matches;
27  }
28  return [];
29  }

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