Explorar el Código

#4148 - Build-in API support (pass on authenticated user with page request)

Alex Trofimov hace 3 años
padre
commit
c5241aaa18
Se han modificado 1 ficheros con 14 adiciones y 1 borrados
  1. 14 1
      template/scripts/BxBasePage.php

+ 14 - 1
template/scripts/BxBasePage.php

@@ -400,7 +400,7 @@ class BxBasePage extends BxDolPage
      */
     public function getPage ()
     {
-        return array(
+        $a = array(
             'id' => $this->_aObject['id'],
             'title' => $this->_getPageTitle(),
             'uri' => $this->_aObject['uri'],
@@ -411,6 +411,19 @@ class BxBasePage extends BxDolPage
             'layout' => $this->_aObject['layout_id'],
             'elements' => $this->getPageBlocks (),
         );
+        if (isLogged()) {
+            $o = BxDolProfile::getInstance();
+            $a['user'] = [
+                'id' => $o->id(),
+                'display_name' => $o->getDisplayName(),
+                'url' => $o->getUrl(),
+                'avatar' => $o->getAvatar(),
+                'info' => $o->getInfo(),
+                'active' => $o->isActive(),
+                'status' => $o->getStatus(),
+            ];
+        }
+        return $a;
     }
 
     public function getPageBlocks ()