Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
TMap Class Reference
Inheritance diagram for TMap:

Public Member Functions

 __construct ( $type, ObjectManagerInterface $objectManager, ConfigInterface $configInterface, array $array=[], \Closure $objectCreationStrategy=null)
 
 getIterator ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ()
 

Detailed Description

Class TMap

Definition at line 14 of file TMap.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $type,
ObjectManagerInterface  $objectManager,
ConfigInterface  $configInterface,
array  $array = [],
\Closure  $objectCreationStrategy = null 
)
Parameters
string$type
ObjectManagerInterface$objectManager
ConfigInterface$configInterface
array$array
\Closure$objectCreationStrategy

Definition at line 58 of file TMap.php.

64  {
65  if (!class_exists($this->type) && !interface_exists($type)) {
66  throw new \InvalidArgumentException(sprintf('Unknown type %s', $type));
67  }
68 
69  $this->type = $type;
70 
71  $this->objectManager = $objectManager;
72  $this->configInterface = $configInterface;
73 
74  array_walk(
75  $array,
76  function ($item, $index) {
77  $this->assertValidTypeLazy($item, $index);
78  }
79  );
80 
81  $this->array = $array;
82  $this->counter = count($array);
83  $this->objectCreationStrategy = $objectCreationStrategy;
84  }
$index
Definition: list.phtml:44

Member Function Documentation

◆ count()

count ( )

{inheritdoc}

Definition at line 207 of file TMap.php.

208  {
209  return $this->counter;
210  }

◆ getIterator()

getIterator ( )

{inheritdoc}

Definition at line 147 of file TMap.php.

148  {
149  if (array_keys($this->array) != array_keys($this->objectsArray)) {
150  foreach (array_keys($this->array) as $index) {
151  $this->initObject($index);
152  }
153  }
154 
155  return new \ArrayIterator($this->objectsArray);
156  }
$index
Definition: list.phtml:44

◆ offsetExists()

offsetExists (   $offset)

{inheritdoc}

Definition at line 161 of file TMap.php.

162  {
163  return array_key_exists($offset, $this->array);
164  }

◆ offsetGet()

offsetGet (   $offset)

{inheritdoc}

Definition at line 169 of file TMap.php.

170  {
171  return isset($this->array[$offset]) ? $this->initObject($offset) : null;
172  }

◆ offsetSet()

offsetSet (   $offset,
  $value 
)

{inheritdoc}

Definition at line 177 of file TMap.php.

178  {
179  $this->assertValidTypeLazy($value, $offset);
180  if ($offset === null) {
181  $this->array[] = $value;
182  } else {
183  $this->array[$offset] = $value;
184  }
185 
186  $this->counter++;
187  }
$value
Definition: gender.phtml:16

◆ offsetUnset()

offsetUnset (   $offset)

{inheritdoc}

Definition at line 192 of file TMap.php.

193  {
194  if ($this->counter && isset($this->array[$offset])) {
195  $this->counter--;
196  unset($this->array[$offset]);
197 
198  if (isset($this->objectsArray[$offset])) {
199  unset($this->objectsArray[$offset]);
200  }
201  }
202  }

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