Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields
ComponentRegistrar Class Reference
Inheritance diagram for ComponentRegistrar:
ComponentRegistrarInterface

Public Member Functions

 getPaths ($type)
 
 getPath ($type, $componentName)
 

Static Public Member Functions

static register ($type, $componentName, $path)
 

Data Fields

const MODULE = 'module'
 
const LIBRARY = 'library'
 
const THEME = 'theme'
 
const LANGUAGE = 'language'
 
const SETUP = 'setup'
 

Detailed Description

Provides ability to statically register components.

Author
Josh Di Fabio joshd.nosp@m.ifab.nosp@m.io@gm.nosp@m.ail..nosp@m.com

@api

Since
100.0.2

Definition at line 16 of file ComponentRegistrar.php.

Member Function Documentation

◆ getPath()

getPath (   $type,
  $componentName 
)

{Get path of a component if it is already registered

Parameters
string$type
string$componentName
Returns
null|string
}

Implements ComponentRegistrarInterface.

Definition at line 71 of file ComponentRegistrar.php.

72  {
73  self::validateType($type);
74  return self::$paths[$type][$componentName] ?? null;
75  }
$type
Definition: item.phtml:13
$paths
Definition: _bootstrap.php:83

◆ getPaths()

getPaths (   $type)

{Get list of registered Magento componentsReturns an array where key is fully-qualified component name and value is absolute path to component

Parameters
string$type
Returns
array
}

Implements ComponentRegistrarInterface.

Definition at line 62 of file ComponentRegistrar.php.

63  {
64  self::validateType($type);
65  return self::$paths[$type];
66  }
$type
Definition: item.phtml:13
$paths
Definition: _bootstrap.php:83

◆ register()

static register (   $type,
  $componentName,
  $path 
)
static

Sets the location of a component.

Parameters
string$typecomponent type
string$componentNameFully-qualified component name
string$pathAbsolute file path to the component
Exceptions

Definition at line 46 of file ComponentRegistrar.php.

47  {
48  self::validateType($type);
49  if (isset(self::$paths[$type][$componentName])) {
50  throw new \LogicException(
51  ucfirst($type) . ' \'' . $componentName . '\' from \'' . $path . '\' '
52  . 'has been already defined in \'' . self::$paths[$type][$componentName] . '\'.'
53  );
54  } else {
55  self::$paths[$type][$componentName] = str_replace('\\', '/', $path);
56  }
57  }
$type
Definition: item.phtml:13
$paths
Definition: _bootstrap.php:83

Field Documentation

◆ LANGUAGE

const LANGUAGE = 'language'

Definition at line 24 of file ComponentRegistrar.php.

◆ LIBRARY

const LIBRARY = 'library'

Definition at line 22 of file ComponentRegistrar.php.

◆ MODULE

const MODULE = 'module'

#+ Different types of components

Definition at line 21 of file ComponentRegistrar.php.

◆ SETUP

const SETUP = 'setup'

Definition at line 25 of file ComponentRegistrar.php.

◆ THEME

const THEME = 'theme'

Definition at line 23 of file ComponentRegistrar.php.


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