AppserverIo\Appserver\Core\InitialContext::setAttribute PHP Method

setAttribute() public method

Stores the passed key value pair in the initial context.
public setAttribute ( string $key, mixed $value ) : void
$key string The key to store the value under
$value mixed The value to add to the initial context
return void
    public function setAttribute($key, $value)
    {
        $this->storage->set($key, $value);
    }

Usage Example

 /**
  * Tests the if the attribute getter/setter works with a object.
  *
  * @return void
  */
 public function testGetSetAttributeWithObject()
 {
     $stdClass = new \stdClass();
     $stdClass->test = 'Testvalue';
     $this->initialContext->setAttribute('stdClass', $stdClass);
     $this->assertEquals($stdClass->test, $this->initialContext->getAttribute('stdClass')->test);
 }