add() публичный Метод

만약 해당 key에 지정된 value가 이미 있을 경우, 아무 행동도 하지 않는다.
public add ( array | string $key, mixed $value ) : void
$key array | string key
$value mixed value for adding
Результат void
Пример #1
0
 /**
  * type, target + type 두가지 모두 등록
  *
  * @param array              $parts     parts of id
  * @param ComponentInterface $component component class name
  *
  * @return void
  */
 protected function addByType(array $parts, $component)
 {
     $key = $parts['type'];
     switch ($key) {
         case 'module':
         case 'skin':
         case 'settignsSkin':
         case 'theme':
         case 'settingsTheme':
         case 'widget':
         case 'uiobject':
         case 'FieldType':
         case 'FieldSkin':
         default:
             if ($parts['target'] != '') {
                 $key = $target = $parts['target'] . self::KEY_DELIMITER . $parts['type'];
             }
             $this->register->add($key . '.' . $component::getId(), $component);
     }
 }
Пример #2
0
 public function testAll()
 {
     $container = new Container('\\Illuminate\\Support\\Arr');
     $container->add('a', 'b');
     $this->assertEquals(['a' => 'b'], $container->all());
 }