Пример #1
0
 /**
  * @param null|AdapterOptions $adapterName
  * @param array $options
  * @throws Exception\RuntimeException
  * @return Acl
  */
 public static function getInstance($adapterName = null, $options = array())
 {
     if (static::$instance === null) {
         static::$logger = Logger::getLogger(__CLASS__);
         if ($adapterName instanceof AdapterInterface) {
             $adapter = $adapterName;
         } else {
             $adapter = static::getAdapterManager()->get($adapterName);
         }
         if ($options) {
             $adapter->setOptions($options);
         }
         static::$instance = new self($adapter);
     } elseif ($adapterName !== null && static::$instance->getOptions()->getThrowRuntimeExceptions()) {
         static::$logger->error("Acl cannot be initialized twice.");
         throw new RuntimeException("Acl cannot be initialized twice.");
     }
     return static::$instance;
 }