src/Model/Admin.php
public function getAdminData($key = null, $userId = null)
    {
        //  Get the user ID
        $userId = $this->adminDataGetUserId($userId);

        //  Check if data is already in the cache
        $cacheKey = 'admin-data-' . $userId;
        $cache    = $this->getCache($cacheKey);

        if ($cache) {

            $data = $cache;

        } else {


            $oRow = $this->oUserMetaService->get(NAILS_DB_PREFIX . 'user_meta_admin', $userId);

            if (!empty($oRow)) {

                foreach ($oRow as $sKey => &$mValue) {
                    //  Hat-tip: http://stackoverflow.com/a/6041773
                    if (in_array($sKey, $this->aJsonFields)) {
                        $mValue = json_decode($mValue);
                    }
                }
                $data = (array) $oRow;

            } else {

                $data = [];
            }

            $this->setCache($cacheKey, $data);
        }

        // --------------------------------------------------------------------------

        /**
         * If no key is returned, return the entire data array, alternatively return
         * the key if it exists.
         */

        if (is_null($key)) {

            return $data;

        } elseif (isset($data[$key])) {

            return $data[$key];

        } else {

            return null;
        }
    }
public function getAdminData($key = null, $userId = null)
    {
        //  Get the user ID
        $userId = $this->adminDataGetUserId($userId);

        //  Check if data is already in the cache
        $cacheKey = 'admin-data-' . $userId;
        $cache    = $this->getCache($cacheKey);

        if ($cache) {

            $data = $cache;

        } else {


            $oRow = $this->oUserMetaService->get(NAILS_DB_PREFIX . 'user_meta_admin', $userId);

            if (!empty($oRow)) {

                foreach ($oRow as $sKey => &$mValue) {
                    //  Hat-tip: http://stackoverflow.com/a/6041773
                    if (in_array($sKey, $this->aJsonFields)) {
                        $mValue = json_decode($mValue);
                    }
                }
                $data = (array) $oRow;

            } else {

                $data = [];
            }

            $this->setCache($cacheKey, $data);
        }

        // --------------------------------------------------------------------------

        /**
         * If no key is returned, return the entire data array, alternatively return
         * the key if it exists.
         */

        if (is_null($key)) {

            return $data;

        } elseif (isset($data[$key])) {

            return $data[$key];

        } else {

            return null;
        }
    }
Gets items from the admin data, or the entire array of $key is null

@param  string $key    The key to set
@param  mixed  $userId The user's ID, if null active user is used.

@return mixed