ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Slim\Container Class Reference
+ Inheritance diagram for Slim\Container:
+ Collaboration diagram for Slim\Container:

Public Member Functions

 __construct (array $values=[])
 Create new container. More...
 
 get ($id)
 Finds an entry of the container by its identifier and returns it. More...
 
 has ($id)
 Returns true if the container can return an entry for the given identifier. More...
 
 __get ($name)
 
 __isset ($name)
 
- Public Member Functions inherited from Pimple\Container
 __construct (array $values=array())
 Instantiate the container. More...
 
 offsetSet ($id, $value)
 Sets a parameter or an object. More...
 
 offsetGet ($id)
 Gets a parameter or an object. More...
 
 offsetExists ($id)
 Checks if a parameter or an object is set. More...
 
 offsetUnset ($id)
 Unsets a parameter or an object. More...
 
 factory ($callable)
 Marks a callable as being a factory service. More...
 
 protect ($callable)
 Protects a callable from being interpreted as a service. More...
 
 raw ($id)
 Gets a parameter or the closure defining an object. More...
 
 extend ($id, $callable)
 Extends an object definition. More...
 
 keys ()
 Returns all defined value names. More...
 
 register (ServiceProviderInterface $provider, array $values=array())
 Registers a service provider. More...
 

Private Member Functions

 registerDefaultServices ($userSettings)
 This function registers the default services that Slim needs to work. More...
 
 exceptionThrownByContainer (\InvalidArgumentException $exception)
 Tests whether an exception needs to be recast for compliance with Container-Interop. More...
 

Private Attributes

 $defaultSettings
 

Detailed Description

Definition at line 45 of file Container.php.

Constructor & Destructor Documentation

◆ __construct()

Slim\Container::__construct ( array  $values = [])

Create new container.

Parameters
array$valuesThe parameters or objects.

Definition at line 67 of file Container.php.

68  {
69  parent::__construct($values);
70 
71  $userSettings = isset($values['settings']) ? $values['settings'] : [];
72  $this->registerDefaultServices($userSettings);
73  }
registerDefaultServices($userSettings)
This function registers the default services that Slim needs to work.
Definition: Container.php:85

Member Function Documentation

◆ __get()

Slim\Container::__get (   $name)

Definition at line 170 of file Container.php.

References $name.

171  {
172  return $this->get($name);
173  }
if($format !==null) $name
Definition: metadata.php:146

◆ __isset()

Slim\Container::__isset (   $name)

Definition at line 175 of file Container.php.

References $name.

176  {
177  return $this->has($name);
178  }
has($id)
Returns true if the container can return an entry for the given identifier.
Definition: Container.php:160
if($format !==null) $name
Definition: metadata.php:146

◆ exceptionThrownByContainer()

Slim\Container::exceptionThrownByContainer ( \InvalidArgumentException  $exception)
private

Tests whether an exception needs to be recast for compliance with Container-Interop.

This will be if the exception was thrown by Pimple.

Parameters
\InvalidArgumentException$exception
Returns
bool

Definition at line 145 of file Container.php.

146  {
147  $trace = $exception->getTrace()[0];
148 
149  return $trace['class'] === PimpleContainer::class && $trace['function'] === 'offsetGet';
150  }

◆ get()

Slim\Container::get (   $id)

Finds an entry of the container by its identifier and returns it.

Parameters
string$idIdentifier of the entry to look for.
Exceptions
ContainerValueNotFoundExceptionNo entry was found for this identifier.
ContainerExceptionError while retrieving the entry.
Returns
mixed Entry.

Implements Psr\Container\ContainerInterface.

Definition at line 117 of file Container.php.

References $id.

118  {
119  if (!$this->offsetExists($id)) {
120  throw new ContainerValueNotFoundException(sprintf('Identifier "%s" is not defined.', $id));
121  }
122  try {
123  return $this->offsetGet($id);
124  } catch (\InvalidArgumentException $exception) {
125  if ($this->exceptionThrownByContainer($exception)) {
126  throw new SlimContainerException(
127  sprintf('Container error while retrieving "%s"', $id),
128  null,
129  $exception
130  );
131  } else {
132  throw $exception;
133  }
134  }
135  }
if(!array_key_exists('StateId', $_REQUEST)) $id
offsetGet($id)
Gets a parameter or an object.
Definition: Container.php:93
offsetExists($id)
Checks if a parameter or an object is set.
Definition: Container.php:128
exceptionThrownByContainer(\InvalidArgumentException $exception)
Tests whether an exception needs to be recast for compliance with Container-Interop.
Definition: Container.php:145

◆ has()

Slim\Container::has (   $id)

Returns true if the container can return an entry for the given identifier.

Returns false otherwise.

Parameters
string$idIdentifier of the entry to look for.
Returns
boolean

Implements Psr\Container\ContainerInterface.

Definition at line 160 of file Container.php.

References $id.

161  {
162  return $this->offsetExists($id);
163  }
if(!array_key_exists('StateId', $_REQUEST)) $id
offsetExists($id)
Checks if a parameter or an object is set.
Definition: Container.php:128

◆ registerDefaultServices()

Slim\Container::registerDefaultServices (   $userSettings)
private

This function registers the default services that Slim needs to work.

All services are shared - that is, they are registered such that the same instance is returned on subsequent calls.

Parameters
array$userSettingsAssociative array of application settings
Returns
void

This service MUST return an array or an instance of .

Returns
array|

Definition at line 85 of file Container.php.

86  {
88 
95  $this['settings'] = function () use ($userSettings, $defaultSettings) {
96  return new Collection(array_merge($defaultSettings, $userSettings));
97  };
98 
99  $defaultProvider = new DefaultServicesProvider();
100  $defaultProvider->register($this);
101  }

Field Documentation

◆ $defaultSettings

Slim\Container::$defaultSettings
private
Initial value:
= [
'httpVersion' => '1.1'

Definition at line 52 of file Container.php.


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