/** * Adds a profile * * @param FileProfile $profile * @return ProfileManager * @throws InvalidArgumentException */ public function addProfile(FileProfile $profile) { $identifier = $profile->getIdentifier(); if (isset($this->profiles[$identifier])) { throw new InvalidArgumentException("Profile '{$identifier}' already exists"); } $this->profiles[$identifier] = $profile; $this->eventDispatcher->addSubscriber($profile); $event = new FileProfileEvent($profile); $this->eventDispatcher->dispatch(Events::PROFILE_AFTER_ADD, $event); return $this; }