|
|
@@ -341,6 +341,32 @@ class AclQueryFeatures {
|
|
|
|
|
|
DBG::log(['params' => $this->_params, 'sortBy' => $sortBy, 'limit' => $limit, 'offset' => $offset], 'array', '$this->_params');
|
|
|
|
|
|
+ $select = $this->prepareSelect();
|
|
|
+ DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
|
+
|
|
|
+ return $this->fetchRowsRefs(
|
|
|
+ $this->getQuery()
|
|
|
+ ->select($select)
|
|
|
+ ->limit($limit)
|
|
|
+ ->offset($offset)
|
|
|
+ ->orderBy($sortBy)
|
|
|
+ ->fetchAll()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getItem($primaryKey) {
|
|
|
+ if ($this->_legacyMode) return $this->_acl->getItem($primaryKey, $this->_params);
|
|
|
+ $select = $this->prepareSelect();
|
|
|
+ $pkField = $this->_acl->getPrimaryKeyField();
|
|
|
+ return $this->fetchRowRefs(
|
|
|
+ $this->getQuery()
|
|
|
+ ->select($select)
|
|
|
+ ->where([$pkField, '=', $primaryKey])
|
|
|
+ ->fetchFirst()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function prepareSelect() {
|
|
|
// TODO: select from params: 'cols' => [ fieldName, ... ]
|
|
|
// TODO: select from params: '@instances' => 1
|
|
|
// TODO: if no fields set, then '*'
|
|
|
@@ -357,16 +383,22 @@ class AclQueryFeatures {
|
|
|
$select[] = $fieldName;
|
|
|
}
|
|
|
}
|
|
|
- DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
|
+ return $select;
|
|
|
+ }
|
|
|
|
|
|
- return $this->getQuery()
|
|
|
- ->select($select)
|
|
|
- ->limit($limit)
|
|
|
- ->offset($offset)
|
|
|
- ->orderBy($sortBy)
|
|
|
- ->fetchAll();
|
|
|
+ public function fetchRowsRefs($rows) {
|
|
|
+ // if (!empty($rows) && !empty($rows[0])) {
|
|
|
+ // $rows[0]['default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK'] = [
|
|
|
+ // [ 'xlink' => 'default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK.999' ],
|
|
|
+ // [ 'xlink' => 'default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK.998' ],
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
+ return $rows;
|
|
|
}
|
|
|
|
|
|
- public function getItem($primaryKey) { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }
|
|
|
+ public function fetchRowRefs($row) {
|
|
|
+ if (!$row) return $row;
|
|
|
+ return $row;
|
|
|
+ }
|
|
|
|
|
|
}
|