Save XML to cache

@param int $userid
@param string $apikey
@param string $scope
@param string $name
@param array $args
@param string $xml
@return bool|void
@throws PhealException if something happened during the Database operations
199613
public function save($userid, $apikey, $scope, $name, $args, $xml)
    {
        $this->prepareStatements();

        $argumentString = $this->serializeArguments($args);

        /* @var $deleteStatement \PDOStatement */
        $deleteStatement = $this->statements['delete'];

        if ($userid === null) {
            // Fix for null value userids
            // e. g. for global calls to /eve/
            $userid = 0;
        }

        try {
            $deleteStatement->execute(
                array(
                    ':userId' => $userid,
                    ':scope'  => $scope,
                    ':name'   => $name,
                    ':args'   => $argumentString,
                )
            );
        } catch (\PDOException $e) {
            throw new PhealException('Deleting old cache entries failed!', null, $e);
        }

        /* @var $statement \PDOStatement */
        $statement = $this->statements['save'];

        try {
            $xml = new \SimpleXMLElement($xml);

            $statement->execute(
                array(
                    ':userId' => $userid,
                    ':scope'  => $scope,
                    ':name'   => $name,
                    ':args'   => $argumentString,
                    ':cachedUntil' => $xml->cachedUntil,
                    ':xml'    => $xml->asXML(),
                )
            );
        } catch (\PDOException $e) {
            throw new PhealException('Saving to cache failed!', null, $e);
        }
    }
339899
protected function saving($name, $userId, $value = null, $isNew = true)
    {
        $meta = $this->getModel()->search($name, $userId)->first();

        if (is_null($value) || $value === ':to-be-deleted:') {
            !is_null($meta) && $meta->delete();
            return;
        }

        if (true === $isNew && is_null($meta)) {
            $meta = $this->getModel();

            $meta->name    = $name;
            $meta->user_id = $userId;
        }

        $meta->value = serialize($value);
        $meta->save();
    }
1316690
public function SaveAbout($UserID, $About) {
      $About = substr($About, 0, 1000);
      $this->SetField($UserID, 'About', $About);
   }
493586
public function cacheResponseByTypo3Cache(
        $requestUri,
        array $requestGetData,
        array $apiMethodInfoMetadata,
        $responseData,
        $responseFormatClass,
        array $responseHeaders
    ) {
        $identifier = $this->buildIdentifier($requestUri, $requestGetData);
        $frontendCacheExpires = (integer) $apiMethodInfoMetadata['expires'];
        $typo3CacheExpires = (integer) $apiMethodInfoMetadata[self::API_METHOD_TYPO3CACHE_EXPIRES];
        $typo3CacheTags = explode(',', $apiMethodInfoMetadata[self::API_METHOD_TYPO3CACHE_TAGS]);

        $cacheData = array();
        $cacheData['requestUri'] = $requestUri;
        $cacheData['requestGetData'] = $requestGetData;
        $cacheData['responseData'] = $responseData;
        $cacheData['responseFormatClass'] = $responseFormatClass;
        $cacheData['responseHeaders'] = $responseHeaders;
        $cacheData['frontendCacheExpires'] = $frontendCacheExpires;

        $this->cache->set($identifier, $cacheData, $typo3CacheTags, $typo3CacheExpires);
    }
760135
protected function pforget($key, $userId)
    {
        $keys = is_array($key) ? $key : [$key];

        foreach ($keys as $key) {
            $this->cache->forget($this->pkey($key, $userId));
        }

        $this->cache->forget($this->pkey('*', $userId));
    }
1320149
static function cachePath( $keyString, $nodeID = false )
    {
        $filename = md5( $keyString ) . ".cache";

        $phpDir = eZTemplateCacheBlock::templateBlockCacheDir();
        if ( is_numeric( $nodeID ) )
        {
            $phpDir .= eZTemplateCacheBlock::calculateSubtreeCacheDir( $nodeID, $filename );
        }
        else
        {
            $phpDir .= $filename[0] . '/' . $filename[1] . '/' . $filename[2];
        }

        $phpPath = $phpDir . '/' . $filename;
        return $phpPath;
    }
581944
public static void cache(XmlFileModel key, Document document)
    {
        String cacheKey = getKey(key);
        map.put(cacheKey, new CacheDocument(false, document));
    }
427085
public static function can_create_data_deletion_request_for_children(int $userid, int $requesterid = null): bool {
        global $USER;
        $requesterid = $requesterid ?: $USER->id;
        return has_capability('tool/dataprivacy:makedatadeletionrequestsforchildren', \context_user::instance($userid),
            $requesterid);
    }
420450
public function write($userdata, $splash, $session, $sessionId, $expiry)
    {

        $database = $this->database;

        $database->insert($session->table, array(
            "session_key" => $database->quote($sessionId),
            "session_ip" => $database->quote($splash['ip']),
            "session_host" => $database->quote($splash['domain']),
            "session_agent" => $database->quote($splash['agent']),
            "session_token" => $database->quote($splash['token']),
            "session_expires" => $expiry,
            "session_lastactive" => time(),
            "session_registry" => $database->quote($userdata)
        ));
    }
850433
public function archive($userId, $callId)
    {

        /** @var StateStorage $stateStorage */
        $stateStorage = $this->getServiceManager()->get(StateStorage::SERVICE_ID);

        $state = $stateStorage->get($userId, $callId);

        return (!is_null($state)) ? $this->getFileSystem()->write($this->generateSerial($userId, $callId), $state) : false;
    }
1260790
public function saveCache($cacheKey, $data, $cacheTags = [], $lifetime = self::DEFAULT_LIFETIME)
    {
        $this->localCache[$cacheKey] = $data;

        if (!is_string($data)) {
            $data = serialize($data);
        }

        $this->cache->save($data, $cacheKey, $cacheTags, $lifetime);
    }
1059874
public function post(Provider $provider, $userId, $requestScope, $requestUri, array $postBody, array $requestHeaders = [])
    {
        return $this->send($provider, $userId, $requestScope, Request::post($requestUri, $postBody, $requestHeaders));
    }
45499
public static function create($params = null, $apiKey = null)
    {
        $class = get_class();
        return self::_scopedCreate($class, $params, $apiKey);
    }
269623
public function save(array $data, $locale, $userId = null, $item = null, $itemStatusId = null)
    {
        $itemEntity = $this->itemFactory->createEntity();
        $isNewItem = !$item;

        // check required data
        if ($isNewItem) {
            $this->checkRequiredData($data, true);
            $item = $this->itemFactory->createApiEntity($this->itemFactory->createEntity(), $locale);
        }

        if ($item instanceof ItemInterface) {
            $item = $this->itemFactory->createApiEntity($item, $locale);
        }

        // get user
        $user = $userId ? $this->userRepository->findUserById($userId) : null;

        $contact = null;
        $account = null;
        if ($user) {
            $contact = $user->getContact();
            $account = $contact->getMainAccount();
        }

        // set item data
        $item->setQuantity($this->getProperty($data, 'quantity', null));
        $item->setUseProductsPrice($this->getProperty($data, 'useProductsPrice', true));
        $this->setDate(
            $data,
            'deliveryDate',
            $item->getDeliveryDate(),
            array($item, 'setDeliveryDate')
        );

        // terms of delivery
        $product = null;
        if ($isNewItem) {
            $productData = $this->getProperty($data, 'product');
            if ($productData) {
                // get product and set Product's data to item
                $product = $this->setItemByProductData($productData, $item, $locale);
            }
        }

        // if product is not set, set data manually
        if (!$product) {
            if ($isNewItem) {
                $item->setUseProductsPrice(false);
            }
            $item->setName($this->getProperty($data, 'name', $item->getName()));
            // TODO: set supplier based on if its a string  or object (fetch account and set it to setSupplier)
            $item->setTax($this->getProperty($data, 'tax', $item->getTax()));
            $item->setNumber($this->getProperty($data, 'number', $item->getNumber()));
            $item->setDescription($this->getProperty($data, 'description', $item->getDescription()));
            $item->setQuantityUnit($this->getProperty($data, 'quantityUnit', $item->getQuantityUnit()));
        }

        if (method_exists($item, 'getSupplierName')) {
            $item->setSupplierName($this->getProperty($data, 'supplierName', $item->getSupplierName()));
        }

        // update prices
        $this->updatePrices($item, $data);

        $item->setDiscount($this->getProperty($data, 'discount', $item->getDiscount()));

        // set delivery-address for item
        if (isset($data['deliveryAddress'])) {
            $this->setItemDeliveryAddress($data['deliveryAddress'], $item, $contact, $account);
        }

        // create new item
        if ($item->getId() == null) {
            $item->setCreated(new DateTime());
            $item->setCreator($user);
            $this->em->persist($item->getEntity());

            if (!$itemStatusId = null) {
                $itemStatusId = $itemEntity::STATUS_CREATED;
            }
        }

        if ($itemStatusId) {
            $this->addStatus($item, $itemStatusId);
        }

        // handle attributes
        $this->processAttributes($data, $item, $locale);

        $item->setChanged(new DateTime());
        $item->setChanger($user);

        return $item;
    }
1276797
public function load($userid, $apikey, $scope, $name, $args)
    {
        $key = $this->getKey($userid, $apikey, $scope, $name, $args);

        return $this->redis->get($key);
    }
576484
public function saveApiEndpoint($apiEndpoint, $websiteId)
    {
        if ($websiteId > 0) {
            $scope = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE;
        } else {
            $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
        }
        $this->writer->save(
            \Dotdigitalgroup\Email\Helper\Config::PATH_FOR_API_ENDPOINT,
            $apiEndpoint,
            $scope,
            $websiteId
        );
    }
387521
public function save(Group $group, array $fields = null, $userId = null)
    {
        $eligible = [
            'title',
            'is_ghost',
            'is_meta',
            'ts_created',
            'ts_changed',
            'attributes',
        ];

        if (null === $fields) {
            $fields = $eligible;
        } else {
            $fields = array_intersect($eligible, $fields);
        }

        $values = [];
        foreach ($fields as $field) {
            switch ($field) {

                case 'attributes':
                    $attributes = $group->getAttributes();
                    if (empty($attributes)) {
                        $values[$field] = null;
                    } else {
                        $values[$field] = serialize($attributes);
                    }
                    break;

                case 'is_ghost':
                    $values['is_ghost'] = (int)$group->isGhost();
                    break;

                case 'is_meta':
                    $values['is_meta'] = (int)$group->isMeta();
                    break;

                default:
                    $values[$field] = $group->{$field}; // @todo uses __get() fixme
            }
        }

        $values['ts_changed'] = $group->touch()->format('Y-m-d H:i:s');

        if ($group->getId()) {
            $this->dispatch($group, 'preSave', [], $userId);

            $this
                ->database
                ->merge('ucms_group')
                ->key(['id' => $group->getId()])
                ->fields($values)
                ->execute()
            ;

            $this->dispatch($group, 'save', [], $userId);
        } else {
            $this->dispatch($group, 'preCreate', [], $userId);

            $values['ts_created'] = $values['ts_changed'];

            $id = $this
                ->database
                ->insert('ucms_group')
                ->fields($values)
                ->execute()
            ;

            $group->setId($id);

            $this->dispatch($group, 'create', [], $userId);
        }
    }