Compose snapshot item.

@param int $customerId
@param int $parentId
@param string $dsChanged
@param ESnap[] $snap
@return ESnap
333633
private function composeSnapItem($customerId, $parentId, $dsChanged, $snap)
    {
        $result = new ESnap();
        $result->setCustomerRef($customerId);
        $result->setParentRef($parentId);
        $result->setDate($dsChanged);
        if ($customerId == $parentId) {
            /* this is root node customer */
            $newDepth = Cfg::INIT_DEPTH;
            $newPath = Cfg::DTPS;
        } else {
            /* this is NOT root node customer */
            if (!isset($snap[$parentId])) {
                $breakPoint = 'inconsistency detected'; // this is code for debug only
            }
            /** @var ESnap $parent */
            $parent = $snap[$parentId];
            $newDepth = $parent->getDepth() + 1;
            $newPath = $parent->getPath() . $parentId . Cfg::DTPS;
        }
        $result->setDepth($newDepth);
        $result->setPath($newPath);
        return $result;
    }
666284
public function upcomingInvoice($customerId, $subscriptionId = null, array $parameters = [])
    {
        $parameters = array_merge($parameters, [
            'customer'     => $customerId,
            'subscription' => $subscriptionId,
        ]);

        return $this->_get('invoices/upcoming', $parameters);
    }
1101874
public function getParentNode($dsId)
    {
        $parentDsId = $this->getParentDsId($dsId);

        if (null === $parentDsId) {
            return null;
        }

        return $this->dsIdMap[$parentDsId];
    }
487902
private function replaceIdxContentContentsByUids(array $parentUids)
    {
        if (0 < count($parentUids)) {
            $command = 'REPLACE';
            if (!$this->replaceSupported) {
                // REPLACE command not supported, remove first then insert
                $this->_removeIdxContentContents(array_keys($parentUids));
                $command = 'INSERT';
            }

            $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');
            $insertChildren = array();
            foreach ($parentUids as $parentUid => $subContentUids) {
                foreach ($subContentUids as $subContentUid) {
                    $insertChildren[] = sprintf('SELECT "%s", "%s"', $parentUid, $subContentUid);
                    $insertChildren[] = sprintf('SELECT %s, "%s"
                        FROM %s
                        WHERE %s = "%s"', $meta->getColumnName('content_uid'), $subContentUid, $meta->getTableName(), $meta->getColumnName('subcontent_uid'), $parentUid
                    );
                }
            }

            if (0 < count($insertChildren)) {
                $unionAll = implode(' UNION ALL ', $insertChildren);
                $query = sprintf('%s INTO %s (%s, %s) %s',
                    $command,
                    $meta->getTableName(),
                    $meta->getColumnName('content_uid'),
                    $meta->getColumnName('subcontent_uid'),
                    $unionAll
                );
                $this->_em->getConnection()->executeUpdate($query);
            }
        }

        return $this;
    }
1012898
public function triggerSubscriptionChanged(GatewayInterface $gateway, SubscriptionInterface $subscription, ChangeInterface $change)
    {
        $this->trigger(self::ON_SUBSCRIPTION_CHANGED, $gateway, $subscription, $change);
    }
699796
public function create($customerId, array $parameters = [])
    {
        $parameters = array_merge($parameters, [
            'customer' => $customerId,
        ]);

        return $this->_post('invoices', $parameters);
    }
883739
public function reactivate($customerId, $subscriptionId, array $attributes = [])
    {
        if (! isset($attributes['plan'])) {
            $subscription = $this->find($customerId, $subscriptionId);

            $attributes['plan'] = $subscription['plan']['id'];
        }

        return $this->update($customerId, $subscriptionId, $attributes);
    }
714320
protected function createPdoConnection($dsn, $username, $password, $options)
    {
        return new SwoolePDO($dsn, $username, $password, $options);
    }
617005
public function cancelFor(Customer $customer, $subscriptionId, array $data = [])
    {
        $this->parentId = $customer->id;

        return parent::rest_delete($subscriptionId, $data);
    }
340264
def change_parent(sender, instance, **kwargs):
    
    if instance.id is None:
        return
    if len({'task', 'task_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['task'][0] if 'task' in diff else diff['task_id'][0]
        parent_id = parent.item_id if isinstance(parent, Task) else Task.objects.get(pk=parent).item_id
        child_id = instance.item_id
        ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.create(parent_id=instance.task.item_id, child_id=child_id, visible=True)
    if len({'context', 'context_id'} & set(instance.changed_fields)) != 0:
        diff = instance.diff
        parent = diff['context'][0] if 'context' in diff else diff['context_id'][0]
        parent_id = parent.item_id if isinstance(parent, Context) else Context.objects.get(pk=parent).item_id
        child_id = instance.item_id
        ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
        ItemRelation.objects.create(parent_id=instance.context.item_id, child_id=child_id, visible=False)
279998
public function addChildAt(ClientObject $clientObject, $index )
    {
        array_splice($this->data,$index,0,[$clientObject]);
        if (is_null($clientObject->parentCollection))
            $clientObject->parentCollection = $this;
    }
809904
protected function _onChangeUpdateStock($parentId)
    {
        if ($parentId) {
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $query = 'SELECT oxstock, oxvendorid, oxmanufacturerid FROM oxarticles WHERE oxid = ?';
            $rs = $database->select($query, [$parentId]);
            $oldStock = $rs->fields[0];
            $vendorId = $rs->fields[1];
            $manufacturerId = $rs->fields[2];

            $query = 'SELECT SUM(oxstock) FROM ' . $this->getViewName(true) . ' WHERE oxparentid = ? AND ' . $this->getSqlActiveSnippet(true) . ' AND oxstock > 0 ';
            $stock = (float) $database->getOne($query, [$parentId]);

            $query = 'UPDATE oxarticles SET oxvarstock = ? WHERE oxid = ?';
            $database->execute($query, [$stock, $parentId]);

            //now lets update category counts
            //first detect stock status change for this article (to or from 0)
            if ($stock < 0) {
                $stock = 0;
            }
            if ($oldStock < 0) {
                $oldStock = 0;
            }
            if ($this->oxarticles__oxstockflag->value == 2 && $oldStock xor $stock) {
                //means the stock status could be changed (oxstock turns from 0 to 1 or from 1 to 0)
                // so far we leave it like this but later we could move all count resets to one or two functions
                $this->_onChangeResetCounts($parentId, $vendorId, $manufacturerId);
            }
        }
    }
98584
public function send(OrderInterface $order, $customerId = null)
    {
        $request = new ApiRequest();
        if (!empty($customerId)) {
            $request->setPath(ApiRequest::PATH_ORDER_TAGGING);
            $replaceParams = array('{m}' => $this->account->getName(), '{cid}' => $customerId);
        } else {
            $request->setPath(ApiRequest::PATH_UNMATCHED_ORDER_TAGGING);
            $replaceParams = array('{m}' => $this->account->getName());
        }
        if (is_string($this->activeDomain)) {
            $request->setActiveDomainHeader($this->activeDomain);
        }
        if (is_string($this->account->getName())) {
            $request->setNostoAccountHeader($this->account->getName());
        }
        $request->setReplaceParams($replaceParams);
        $response = $request->post($order);
        return self::checkResponse($request, $response);
    }
1317590
public function insertItem( MShop_Catalog_Item_Interface $item, $parentId = null, $refId = null )
	{
		$siteid = $this->_getContext()->getLocale()->getSiteId();
		$node = $item->getNode();
		$this->begin();

		try
		{
			$this->_createTreeManager( $siteid )->insertNode( $node, $parentId, $refId );
			$this->_updateUsage( $node->getId(), $item, true );
			$this->commit();
		}
		catch( Exception $e )
		{
			$this->rollback();
			throw $e;
		}
	}
639567
public function void($transactionId, $clientTransactionId = null)
    {
        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsCreditVoid = $xml->createElement('hps:CreditVoid');
        $hpsCreditVoid->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
        $hpsTransaction->appendChild($hpsCreditVoid);

        return $this->_submitTransaction($hpsTransaction, 'CreditVoid', $clientTransactionId);
    }
1220089
public function update(string $customerId, array $data, array $headers = [])
    {
        $url = $this->url('customers/%s/credit_card', $customerId);

        return $this->post($url, $data, $headers);
    }
614976
public function addChildObject($alias, $parent_id, $model, $foreignKey) {
        $query = array(
            'alias' => $alias,
            'parent_id' => $parent_id,
            'model' => $model,
            'foreign_key' => $foreignKey
        );

        $result = $this->find('first', array(
            'conditions' => $query
        ));

        if ($result) {
            return $result;
        }

        $this->create();

        if ($this->save($query)) {
            $this->deleteCache(array('RequestObject::hasAlias', $alias));

            return $this->getByAlias($alias);
        }

        return null;
    }