getModules() 공개 메소드

Retrieve modules
public getModules ( ) : ModuleEntity[]
리턴 ModuleEntity[]
 /**
  * This function transform the old authentication system to the new one
  * based on APIs defined. It reads the old configuration and generates an
  * authentication mapping for each API and version.
  *
  * @return boolean|string Boolean false if nothing was performed; string
  *     adapter name otherwise.
  */
 public function transformAuthPerApis()
 {
     $oldAuth = $this->fetch();
     if (!$oldAuth) {
         return false;
     }
     $oldAuth = $oldAuth->getArrayCopy();
     switch ($oldAuth['type']) {
         case 'http_basic':
             $adapter = ['name' => 'http_basic', 'type' => AuthenticationEntity::TYPE_BASIC, 'realm' => $oldAuth['realm'], 'htpasswd' => $oldAuth['htpasswd']];
             break;
         case 'http_digest':
             $adapter = ['name' => 'http_digest', 'type' => AuthenticationEntity::TYPE_DIGEST, 'realm' => $oldAuth['realm'], 'htdigest' => $oldAuth['htdigest'], 'digest_domains' => $oldAuth['digest_domains'], 'nonce_timeout' => $oldAuth['nonce_timeout']];
             break;
         case AuthenticationEntity::TYPE_OAUTH2:
             $adapter = ['type' => AuthenticationEntity::TYPE_OAUTH2, 'oauth2_type' => $oldAuth['dsn_type'], 'oauth2_dsn' => $oldAuth['dsn'], 'oauth2_route' => $oldAuth['route_match']];
             switch ($oldAuth['dsn_type']) {
                 case AuthenticationEntity::DSN_PDO:
                     $adapter['name'] = 'oauth2_pdo';
                     $adapter['oauth2_username'] = $oldAuth['username'];
                     $adapter['oauth2_password'] = $oldAuth['password'];
                     break;
                 case AuthenticationEntity::DSN_MONGO:
                     $adapter['name'] = 'oauth2_mongo';
                     $adapter['oauth2_database'] = $oldAuth['database'];
                     break;
             }
             break;
     }
     // Save the authentication adapter
     $this->saveAuthenticationAdapter($adapter);
     // Create the authentication map for each API
     $modules = $this->modules->getModules();
     foreach ($modules as $module) {
         foreach ($module->getVersions() as $version) {
             $this->saveAuthenticationMap($adapter['name'], $module->getName(), $version);
         }
     }
     // Remove the old configuration
     $this->removeOldAuthentication();
     return $adapter['name'];
 }
 public function testDefaultApiVersionIsSetProperly()
 {
     $modules = array('Test\\Bar' => new Test\Bar\Module(), 'Test\\Foo' => new Test\Foo\Module());
     $moduleManager = $this->getMockBuilder('Zend\\ModuleManager\\ModuleManager')->disableOriginalConstructor()->getMock();
     $moduleManager->expects($this->any())->method('getLoadedModules')->will($this->returnValue($modules));
     $model = new ModuleModel($moduleManager, array(), array());
     $modules = $model->getModules();
     $this->assertSame(1, $modules[0]->getDefaultVersion(), 'Did not default to version 1 as the default version for unconfigured default version of Test\\Bar!');
     $this->assertSame(123, $modules[1]->getDefaultVersion(), 'Did not read configured default version 123 for Test\\Foo!');
 }
 /**
  * Fetch metadata for all API-First enabled modules
  *
  * @param  array $params
  * @return array
  */
 public function fetchAll($params = [])
 {
     return $this->modules->getModules();
 }