/** * Add a named stream belongs to this resource type instance * * @param ResourceStreamInfo $namedStream ResourceStreamInfo instance describing the named stream to add. * * @return void * * @throws InvalidOperationException */ public function addNamedStream(ResourceStreamInfo $namedStream) { if ($this->_resourceTypeKind != ResourceTypeKind::ENTITY) { throw new InvalidOperationException(Messages::resourceTypeNamedStreamsOnlyApplyToEntityType()); } $name = $namedStream->getName(); foreach (array_keys($this->_namedStreamsDeclaredOnThisType) as $namedStreamName) { if (strcasecmp($namedStreamName, $name) == 0) { throw new InvalidOperationException(Messages::resourceTypeNamedStreamWithSameNameAlreadyExists($name, $this->_name)); } } $this->_namedStreamsDeclaredOnThisType[$name] = $namedStream; // Set $this->_allNamedStreams to null, the first call to getAllNamedStreams // will initialize $this->_allNamedStreams, further call to // getAllNamedStreams will not reinitialize _allNamedStreams // so if addNamedStream is called after calling getAllNamedStreams then the // property just added will not be reflected in $this->_allNamedStreams unset($this->_allNamedStreams); $this->_allNamedStreams = array(); }