Quellcode durchsuchen

fixed Ant Acl getInstanceList

Piotr Labudda vor 9 Jahren
Ursprung
Commit
1e2819317b
3 geänderte Dateien mit 30 neuen und 15 gelöschten Zeilen
  1. 14 0
      SE/se-lib/AntAclBase.php
  2. 15 15
      SE/se-lib/Api/WfsServerBase.php
  3. 1 0
      SE/se-lib/Schema/TestPermsStorageAcl.php

+ 14 - 0
SE/se-lib/AntAclBase.php

@@ -210,4 +210,18 @@ class AntAclBase extends Core_AclBase {
     return $_cache[$idZasob];
   }
 
+  public function getInstanceList() {
+    $rootTableName = $this->_rootTableName;
+    return array_map(function ($row) use ($rootTableName) {
+      return $row['name'];
+    }, SchemaFactory::loadDefaultObject('SystemObject')->getItems([
+        'propertyName' => 'name', // TODO: SystemObject fix propertyName
+        'f__rootTableName' => "={$rootTableName}",
+        'f__type' => "=AntAcl",
+        'f_isActive' => "=1",
+        'f_isStructInstalled' => "=1",
+      ])
+    );
+  }
+
 }

+ 15 - 15
SE/se-lib/Api/WfsServerBase.php

@@ -1319,13 +1319,12 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				] ]
 			] ]
 		]);
-		$instanceList = [];
-		$instanceList[] = [ 'xsd:enumeration', ['value'=>$acl->getName()], null ];
-		if (method_exists($acl, 'getInstanceList')) {
-			foreach ($acl->getInstanceList() as $instanceName) {
-				$instanceList[] = [ 'xsd:enumeration', ['value'=>$instanceName], null ];
-			}
-		}
+		$instanceList = (method_exists($acl, 'getInstanceList'))
+			? array_map(function ($instanceName) {
+				return [ 'xsd:enumeration', ['value'=>$instanceName], null ];
+			}, $acl->getInstanceList())
+			: [ 'xsd:enumeration', ['value'=>$acl->getName()], null ]
+		;
 		$xmlWriter->h('xsd:simpleType', ['name'=>$xsdInstanceType], [
 			[ 'xsd:restriction', ['base'=>"xsd:string"], $instanceList],
 		]);
@@ -1393,6 +1392,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 	public function _getDescribeFeatureTypes($typeNames, $simple = true) {
 		if (empty($typeNames)) throw new HttpException("Feature Type Names not defined", 400);
 		$this->DBG("types:" . json_encode($typeNames), __LINE__, __FUNCTION__, __CLASS__);
+		DBG::log($typeNames, 'array', "DescribeFeatureType \$typeNames");
 		// TODO: fix namespace BUG for multiple types:
 		//  - fetch namespace for first type
 		//  - if another object has another namespace then -> import tag
@@ -1446,6 +1446,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				$xmlWriter->writeComment("TODO: typeName '{$typeName}' by import namespace '{$aclNamespaceUri}'");// TODO: <xsd:import>; continue;
 			}
 
+			DBG::log($acl->hasSimpleSchema(), 'array', "\$acl({$typeName})->hasSimpleSchema()");
 			if ($acl->hasSimpleSchema()) {
 				$simpleSchema = $acl->getSimpleSchema();
 				$xmlWriter->writeComment("TODO: typeName '{$typeName}' hasSimpleSchema L." . __LINE__);
@@ -1601,19 +1602,18 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 					$xmlWriter->endElement(); // xsd:element
 				}
 				$xmlWriter->endElement(); // xsd:sequence
-				$xmlWriter->h('xsd:attribute', ['name' => "instance", 'type' => $acl->getSourceName() . ":instanceType"], null);
+				if (!$simple) $xmlWriter->h('xsd:attribute', ['name' => "instance", 'type' => $acl->getSourceName() . ":instanceType"], null);
 				$xmlWriter->endElement(); // xsd:extension
 				$xmlWriter->endElement(); // xsd:complexContent
 				$xmlWriter->endElement(); // xsd:complexType
 
 				if (!$simple) {
-					$xsdInstanceList = [];
-					$xsdInstanceList[] = ['xsd:enumeration', ['value'=>$acl->getName()], null];
-					if (method_exists($acl, 'getInstanceList')) {
-						foreach ($acl->getInstanceList() as $instanceName) {
-							$xsdInstanceList[] = ['xsd:enumeration', ['value'=>$instanceName], null];
-						}
-					}
+					$xsdInstanceList = (method_exists($acl, 'getInstanceList'))
+						? array_map(function ($instanceName) {
+							return [ 'xsd:enumeration', ['value'=>$instanceName], null ];
+						}, $acl->getInstanceList())
+						: [ 'xsd:enumeration', ['value'=>$acl->getName()], null ]
+					;
 					$xmlWriter->h('xsd:simpleType', ['name' => 'instanceType'], [
 						[ 'xsd:restriction', ['base' => 'xsd:string'], $xsdInstanceList ]
 					]);

+ 1 - 0
SE/se-lib/Schema/TestPermsStorageAcl.php

@@ -143,6 +143,7 @@ class Schema_TestPermsStorageAcl extends Core_AclBase {
 
   public function getInstanceList() {
     return [
+      'TestPerms',
       'TestPermsDoUzgodnienia',
       'TestPermsUzgodniony',
       'TestPermsOdrzucony',