/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Controller
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Controller/Component.php (6870B)
*/
protected $_defaultConfig = [];
/**
* A component lookup table used to lazy load component objects.
*
* @var array
*/
protected $_componentMap = [];
/**
* Constructor
*
* @param \Cake\Controller\ComponentRegistry $registry A component registry
* this component can use to lazy load its components.
* @param array $config Array of configuration settings.
*/
public function __construct(ComponentRegistry $registry, array $config = [])
{
$this->_registry = $registry;
$this->setConfig($config);
if ($this->components) {
$this->_componentMap = $registry->normalizeArray($this->components);
}
$this->initialize($config);
}
/**
* Get the controller this component is bound to.
*
* @return \Cake\Controller\Controller The bound controller.
*/
public function getController(): Controller
{
return $this->_registry->getController();
}
/**
* Constructor hook method.
*
* Implement this method to avoid having to overwrite
* the constructor and call parent.
*
* @param array $config The configuration settings provided to this component.
* @return void
*/
public function initialize(array $config): void
{
}
/**
* Magic method for lazy loading $components.
*
* @param string $name Name of component to get.
* @return \Cake\Controller\Component|null A Component object or null.
*/
public function __get(string $name)
{
if (isset($this->_componentMap[$name]) && !isset($this->{$name})) {
$config = (array)$this->_componentMap[$name]['config'] + ['enabled' => false];
$this->{$name} = $this->_registry->load($this->_componentMap[$name]['class'], $config);
}
return $this->{$name} ?? null;
}
/**
* Get the Controller callbacks this Component is interested in.
*
* Uses Conventions to map controller events to standard component
* callback method names. By defining one of the callback methods a
* component is assumed to be interested in the related event.
*
* Override this method if you need to add non-conventional event listeners.
* Or if you want components to listen to non-standard events.
*
* @return array
*/
public function implementedEvents(): array
{
$eventMap = [
'Controller.initialize' => 'beforeFilter',
'Controller.startup' => 'startup',
'Controller.beforeRender' => 'beforeRender',
'Controller.beforeRedirect' => 'beforeRedirect',
'Controller.shutdown' => 'afterFilter',
];
$events = [];
foreach ($eventMap as $event => $method) {
if (method_exists($this, $method)) {
$events[$event] = $method;
}
}
if (!isset($events['Controller.shutdown']) && method_exists($this, 'shutdown')) {
deprecationWarning(
'`Controller.shutdown` event callback is now `afterFilter()` instead of `shutdown()`.',
0
);
$events[$event] = 'shutdown';
}
return $events;
}
/**
* Returns an array that can be used to describe the internal state of this
* object.
*
* @return array
*/
public function __debugInfo(): array
{
return [
'components' => $this->components,
'implementedEvents' => $this->implementedEvents(),
'_config' => $this->getConfig(),
];
}
}