Esempio n. 1
0
 public function addRealm(Realm $realm)
 {
     $realmName = $realm->getRealmName();
     if (!static::validRealmName($realm->getRealmName())) {
         throw new InvalidRealmNameException();
     }
     if (array_key_exists($realm->getRealmName(), $this->realms)) {
         throw new \Exception("There is already a realm \"" . $realm->getRealmName() . "\"");
     }
     $this->manager->debug("Adding realm \"" . $realmName . "\"");
     if ($realm->getManager() instanceof ManagerDummy) {
         /** remind people that we don't setup the manager for them if they
          * are creating their own realms */
         $this->manager->warning("Realm \"" . $realmName . "\" is using ManagerDummy");
     }
     $this->realms[$realm->getRealmName()] = $realm;
 }
Esempio n. 2
0
 /**
  * Add new realm
  *
  * @param \Thruway\Realm $realm
  * @throws \Thruway\Exception\InvalidRealmNameException
  * @throws \Exception
  */
 public function addRealm(Realm $realm)
 {
     $realmName = $realm->getRealmName();
     if (!static::validRealmName($realm->getRealmName())) {
         throw new InvalidRealmNameException();
     }
     if (array_key_exists($realm->getRealmName(), $this->realms)) {
         throw new \Exception("There is already a realm \"" . $realm->getRealmName() . "\"");
     }
     Logger::debug($this, "Adding realm \"" . $realmName . "\"");
     if ($realm->getManager() instanceof ManagerDummy) {
         /** remind people that we don't setup the manager for them if they
          * are creating their own realms */
         Logger::info($this, "Realm \"" . $realmName . "\" is using ManagerDummy");
     }
     $this->realms[$realm->getRealmName()] = $realm;
     $this->router->getEventDispatcher()->dispatch('new_realm', new NewRealmEvent($realm));
 }