sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function all(array $params)
{
$endpoint = '/admin/inventory_levels.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(InventoryLevel::class, $response['inventory_levels']);
} | Retrieves a list of inventory levels.
You must include inventory_item_ids and/or location_ids as filter params.
@link https://help.shopify.com/api/reference/inventorylevel#index
@param array $params
@return InventoryLevel[] | entailment |
public function all(array $params = array())
{
$data = $this->request('/admin/application_credits.json', 'GET', $params);
return $this->createCollection(ApplicationCredit::class, $data['application_credits']);
} | Retrieve all application credits
@link https://help.shopify.com/api/reference/applicationcredit#index
@param array $params
@return ApplicationCredit[] | entailment |
public function get($applicationCreditId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/admin/application_credits/'.$applicationCreditId.'.json';
$data = $this->request($endpoint, 'GET', $params);
return $this->createObject(ApplicationCredit::class, $data['application_credit']);
} | Receive a single ApplicationCredit
@link https://help.shopify.com/api/reference/applicationcredit#show
@param integer $applicationCreditId
@param array $fields
@return ApplicationCredit | entailment |
public function create(ApplicationCredit &$applicationCredit)
{
$data = $applicationCredit->exportData();
$endpoint = '/admin/application_credits.json';
$response = $this->request(
$endpoint, 'POST', array(
'application_charge' => $data
)
);
$applicationCredit->setData($response['application_credit']);
} | Create an application credit
@link https://help.shopify.com/api/reference/applicationcredit#create
@param ApplicationCredit $applicationCredit
@return void | entailment |
public function setList(array $list)
{
foreach ($list as $item) {
$this->checkType(TypeDefinitionInterface::class, $item);
}
$this->list = $list;
} | Set a list of type definitions
@param TypeDefinitionInterface[] $list | entailment |
public function all($orderId, $fulfillmentId)
{
$endpoint = '/admin/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events.json';
$response = $this->request($endpoint, 'GET');
return $this->createCollection(FulfillmentEvent::class, $response['fulfillment_events']);
} | Receive a list of all fulfillmen events
@link https://help.shopify.com/api/reference/fulfillmentevent#index
@param integer $orderId
@param integer $fulfillmentId
@return FulfillmentEvent[] | entailment |
public function get($orderId, $fulfillmentId, $fulfillmentEventId)
{
$endpoint = '/admin/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events/'.$fulfillmentEventId.'.json';
$response = $this->request($endpoint);
return $this->createObject(FulfillmentEvent::class, $response['fulfillment_event']);
} | Get a specific fulfillment event
@link https://help.shopify.com/api/reference/fulfillmentevent#show
@param integer $orderId
@param integer $fulfillmentId
@param integer $fulfillmentEventId
@return FulfillmentEvent | entailment |
public function create($orderId, $fulfillmentId, FulfillmentEvent &$fulfillmentEvent)
{
$data = $fulfillmentEvent->exportData();
$endpoint = '/admin/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events.json';
$response = $this->request(
$endpoint, 'POST', array(
'fulfillment_event' => $data
)
);
$fulfillmentEvent->setData($response['fulfillment_event']);
} | Create a fulfillment event
@link https://help.shopify.com/api/reference/fulfillmentevent#create
@param integer $orderId
@param integer $fulfillmentId
@param FulfillmentEvent $fulfillmentEvent
@return void | entailment |
public function delete($orderId, $fulfillmentId, FulfillmentEvent $fulfillmentEvent)
{
$endpoint = '/admin/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events/'.$fulfillmentEvent->id.'.json';
$response = $this->request($endpoint, 'DELETE');
return;
} | Delete a fufillment events
@link https://help.shopify.com/api/reference/fulfillmentevent#destroy
@param integer $orderId
@param integer $fulfillmentId
@param FulfillmentEvent $fulfillmentEvent
@return void | entailment |
public function setValues(array $values)
{
foreach ($values as & $value) {
if (PHP_INT_SIZE == 4 && is_double($value)) {
//TODO: 32bit - handle this specially?
$value = $this->castValueToSimpleType('integer', $value);
}
$this->checkType('integer', $value, true);
}
parent::setValues($values);
} | {@inheritdoc}
@param integer[] $values | entailment |
public function getCacheKey()
{
$cacheKey = $this->isIncludeAcls() ? '1' : '0';
$cacheKey .= $this->isIncludeAllowableActions() ? '1' : '0';
$cacheKey .= $this->isIncludePolicies() ? '1' : '0';
$cacheKey .= $this->isIncludePathSegments() ? '1' : '0';
$cacheKey .= '|';
$cacheKey .= $this->getQueryFilterString();
$cacheKey .= '|';
$cacheKey .= (string) $this->getIncludeRelationships();
$cacheKey .= '|';
$cacheKey .= $this->getRenditionFilterString();
return $cacheKey;
} | {@inheritdoc} | entailment |
public function setFilter(array $propertyFilters)
{
$filters = [];
foreach ($propertyFilters as $filter) {
$filter = trim((string) $filter);
if ($filter === '') {
continue;
}
if (self::PROPERTIES_WILDCARD === $filter) {
$filters[] = self::PROPERTIES_WILDCARD;
break;
}
if (stripos($filter, ',') !== false) {
throw new \InvalidArgumentException('Filter must not contain a comma!');
}
$filters[] = $filter;
}
$this->filter = $filters;
return $this;
} | {@inheritdoc} | entailment |
public function setMaxItemsPerPage($maxItemsPerPage)
{
if ((int) $maxItemsPerPage < 1) {
throw new \InvalidArgumentException('itemsPerPage must be > 0!');
}
$this->maxItemsPerPage = (int) $maxItemsPerPage;
return $this;
} | {@inheritdoc} | entailment |
public function setRenditionFilter(array $renditionFilter)
{
$filters = [];
foreach ($renditionFilter as $filter) {
$filter = trim((string) $filter);
if ($filter === '') {
continue;
}
if (stripos($filter, ',') !== false) {
throw new \InvalidArgumentException('Rendition must not contain a comma!');
}
$filters[] = $filter;
}
if (count($filters) === 0) {
$filters[] = Constants::RENDITION_NONE;
}
$this->renditionFilter = $filters;
return $this;
} | {@inheritdoc} | entailment |
public function getQueryFilterString()
{
if (count($this->filter) === 0) {
return null;
}
if (array_search(self::PROPERTIES_WILDCARD, $this->filter)) {
return self::PROPERTIES_WILDCARD;
}
$filters = $this->filter;
$filters[] = PropertyIds::OBJECT_ID;
$filters[] = PropertyIds::BASE_TYPE_ID;
$filters[] = PropertyIds::OBJECT_TYPE_ID;
if ($this->loadSecondaryTypeProperties()) {
$filters[] = PropertyIds::SECONDARY_OBJECT_TYPE_IDS;
}
return implode(',', array_unique($filters));
} | {@inheritdoc} | entailment |
public function setFilterString($propertyFilter)
{
if (empty($propertyFilter)) {
$this->setFilter([]);
} else {
$this->setFilter(explode(',', $propertyFilter));
}
return $this;
} | {@inheritdoc} | entailment |
public function setRenditionFilterString($renditionFilter)
{
if (empty($renditionFilter)) {
$this->setRenditionFilter([]);
} else {
$this->setRenditionFilter(explode(',', $renditionFilter));
}
return $this;
} | {@inheritdoc} | entailment |
public function setValues(array $values)
{
$this->values = [];
if (is_array($values)) {
$this->values = array_values($values);
}
} | {@inheritdoc} | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/orders.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Order::class, $response['orders']);
} | Retrieve a list of Orders (OPEN Orders by default, use status=any for ALL orders)
@link https://help.shopify.com/api/reference/order#index
@param array $params
@return Order[] | entailment |
public function get($orderId, array $params = array())
{
$endpoint = '/admin/orders/'.$orderId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Order::class, $response['order']);
} | Receive a single Order
@link https://help.shopify.com/api/reference/order#count
@param integer $orderId
@param array $params
@return Order | entailment |
public function create(Order &$order)
{
$data = $order->exportData();
$endpoint = '/admin/orders.json';
$response = $this->request(
$endpoint, 'POST', array(
'order' => $data
)
);
$order->setData($response['order']);
} | Create a new order
@link https://help.shopify.com/api/reference/order#create
@param Order $order
@return void | entailment |
public function close(Order &$order)
{
$data = $order->exportData();
$endpoint= '/admin/orders/'.$order->id.'/close.json';
$response = $this->request($endpoint, 'POST');
$order->setData($response['order']);
} | Close an Order
@link https://help.shopify.com/api/reference/order#close
@param Order $order
@return void | entailment |
protected function generateStatementFromPropertiesAndTypesLists(
array $selectPropertyIds,
array $fromTypes,
$whereClause,
array $orderByPropertyIds
) {
$statementString = 'SELECT ' . $this->generateStatementPropertyList($selectPropertyIds, false);
$primaryTable = array_shift($fromTypes);
list ($primaryTableQueryName, $primaryAlias) = $this->getQueryNameAndAliasForType($primaryTable, 'primary');
$statementString .= ' FROM ' . $primaryTableQueryName . ' ' . $primaryAlias;
while (count($fromTypes) > 0) {
$secondaryTable = array_shift($fromTypes);
/*
* we build an automatic alias here, a simple one-byte ASCII value
* generated based on remaining tables. If 26 tables remain, a "z"
* is generated. If 1 table remains, an "a" is generated. The alias
* is, unfortunately, required for the JOIN to work correctly. It
* only gets used if the type string does not contain an alias.
*/
$alias = chr(97 + count($fromTypes));
list ($secondaryTableQueryName, $alias) = $this->getQueryNameAndAliasForType($secondaryTable, $alias);
$statementString .= ' JOIN ' . $secondaryTableQueryName . ' AS ' . $alias .
' ON ' . $primaryAlias . '.cmis:objectId = ' . $alias . '.cmis:objectId';
}
if (trim((string) $whereClause)) {
$statementString .= ' WHERE ' . trim($whereClause);
}
if (!empty($orderByPropertyIds)) {
$statementString .= ' ORDER BY ' . $this->generateStatementPropertyList($orderByPropertyIds, true);
}
return trim($statementString);
} | Generates a statement based on input criteria, with the necessary
JOINs in place for selecting attributes related to all provided types.
@param array $selectPropertyIds An array PropertyDefinitionInterface
or strings, can be mixed. When strings are provided those can be
either the actual ID of the property or the query name thereof.
@param array $fromTypes An array of TypeDefinitionInterface or strings,
can be mixed. When strings are provided those can be either the
actual ID of the type, or it can be the query name thereof. If
an array of arrays is provided, each array is expected to contain
a TypeDefinition or string as first member and an alias as second.
@param string|null $whereClause If searching by custom clause, provide here.
@param array $orderByPropertyIds List of property IDs by which to sort.
Each value can be either a PropertyDefinitionInterface instance,
a string (in which case, ID or queryName) or an array of a string
or PropertyDefinition as first member and ASC or DESC as second.
E.g. valid strings: "cm:title ASC", "cm:title", "P:cm:title".
Valid arrays: [PropertyDefinitionInterface, "ASC"], ["cm:title", "ASC"]
@return string | entailment |
protected function getQueryNameAndAliasForType($typeDefinitionMixed, $autoAlias)
{
$alias = null;
if (is_array($typeDefinitionMixed)) {
list ($typeDefinitionMixed, $alias) = $typeDefinitionMixed;
}
if ($typeDefinitionMixed instanceof TypeDefinitionInterface) {
$queryName = $typeDefinitionMixed->getQueryName();
} elseif (is_string($typeDefinitionMixed) && strpos($typeDefinitionMixed, ' ')) {
list ($typeDefinitionMixed, $alias) = explode(' ', $typeDefinitionMixed, 2);
}
try {
$queryName = $this->session->getTypeDefinition($typeDefinitionMixed)->getQueryName();
} catch (CmisObjectNotFoundException $error) {
$queryName = $typeDefinitionMixed;
}
return [$queryName, ($alias ? $alias : $autoAlias)];
} | Translates a TypeDefinition or string into a query name for
that TypeDefinition. Returns the input string as fallback if
the type could not be resolved. Input may contain an alias,
if so, we split and preserve the alias but attempt to translate
the type ID part.
@param mixed $typeDefinitionMixed Input describing the type
@param string $autoAlias If alias is not provided
@return array | entailment |
protected function generateStatementPropertyList(array $properties, $withOrdering)
{
$statement = [];
foreach ($properties as $property) {
$ordering = ($withOrdering ? 'ASC' : '');
if ($withOrdering) {
if (is_array($property)) {
list ($property, $ordering) = $property;
} elseif (is_string($property) && strpos($property, ' ')) {
list ($property, $ordering) = explode(' ', $property, 2);
}
}
if ($property instanceof PropertyDefinitionInterface) {
$propertyQueryName = $property->getQueryName();
} else {
$propertyQueryName = $property;
}
$statement[] = rtrim($propertyQueryName . ' ' . $ordering);
}
return implode(', ', $statement);
} | Renders a statement-compatible string of property selections,
with ordering support if $withOrdering is true. Input properties
can be an array of strings, an array of PropertyDefinition, or
when $withOrdering is true, an array of arrays each containing
a string or PropertyDefinition plus ASC or DESC as second value.
@param array $properties
@param boolean $withOrdering
@return string | entailment |
public function query($searchAllVersions, OperationContextInterface $context = null)
{
return $this->session->query($this->toQueryString(), $searchAllVersions, $context);
} | Executes the query.
@param boolean $searchAllVersions <code>true</code> if all document versions should be included in the search
results, <code>false</code> if only the latest document versions should be included in the search results
@param OperationContextInterface|null $context the operation context to use
@return QueryResultInterface[] | entailment |
public function setDateTime($parameterIndex, \DateTime $dateTime)
{
$this->setParameter($parameterIndex, $dateTime->format(Constants::QUERY_DATETIMEFORMAT));
} | Sets the designated parameter to the given DateTime value.
@param integer $parameterIndex the parameter index (one-based)
@param \DateTime $dateTime the DateTime value as DateTime object | entailment |
public function setId($parameterIndex, ObjectIdInterface $id)
{
$this->setParameter($parameterIndex, $this->escape($id->getId()));
} | Sets the designated parameter to the given object ID.
@param integer $parameterIndex the parameter index (one-based)
@param ObjectIdInterface $id the object ID | entailment |
public function setNumber($parameterIndex, $number)
{
if (!is_int($number)) {
throw new CmisInvalidArgumentException('Number must be of type integer!');
}
$this->setParameter($parameterIndex, $number);
} | Sets the designated parameter to the given number.
@param integer $parameterIndex the parameter index (one-based)
@param integer $number the value to be set as number
@throws CmisInvalidArgumentException If number not of type integer | entailment |
public function setProperty($parameterIndex, PropertyDefinitionInterface $propertyDefinition)
{
$queryName = $propertyDefinition->getQueryName();
if (empty($queryName)) {
throw new CmisInvalidArgumentException('Property has no query name!');
}
$this->setParameter($parameterIndex, $this->escape($queryName));
} | Sets the designated parameter to the query name of the given property.
@param integer $parameterIndex the parameter index (one-based)
@param PropertyDefinitionInterface $propertyDefinition
@throws CmisInvalidArgumentException If property has no query name | entailment |
public function setString($parameterIndex, $string)
{
if (!is_string($string)) {
throw new CmisInvalidArgumentException('Parameter string must be of type string!');
}
$this->setParameter($parameterIndex, $this->escape($string));
} | Sets the designated parameter to the given string.
@param integer $parameterIndex the parameter index (one-based)
@param string $string the string
@throws CmisInvalidArgumentException If given value is not a string | entailment |
public function setStringContains($parameterIndex, $string)
{
if (!is_string($string)) {
throw new CmisInvalidArgumentException('Parameter string must be of type string!');
}
$this->setParameter($parameterIndex, $this->escapeContains($string));
} | Sets the designated parameter to the given string in a CMIS contains statement.
Note that the CMIS specification requires two levels of escaping. The first level escapes ', ", \ characters
to \', \" and \\. The characters *, ? and - are interpreted as text search operators and are not escaped
on first level.
If *, ?, - shall be used as literals, they must be passed escaped with \*, \? and \- to this method.
For all statements in a CONTAINS() clause it is required to isolate those from a query statement.
Therefore a second level escaping is performed. On the second level grammar ", ', - and \ are escaped with a \.
See the spec for further details.
Summary (input --> first level escaping --> second level escaping and output):
* --> * --> *
? --> ? --> ?
- --> - --> -
\ --> \\ --> \\\\
(for any other character following other than * ? -)
\* --> \* --> \\*
\? --> \? --> \\?
\- --> \- --> \\-
' --> \' --> \\\'
" --> \" --> \\\"
@param integer $parameterIndex the parameter index (one-based)
@param string $string the CONTAINS string
@throws CmisInvalidArgumentException If given value is not a string | entailment |
public function setStringLike($parameterIndex, $string)
{
if (!is_string($string)) {
throw new CmisInvalidArgumentException('Parameter string must be of type string!');
}
$this->setParameter($parameterIndex, $this->escapeLike($string));
} | Sets the designated parameter to the given string.
It does not escape backslashes ('\') in front of '%' and '_'.
@param integer $parameterIndex the parameter index (one-based)
@param $string
@throws CmisInvalidArgumentException If given value is not a string | entailment |
public function setType($parameterIndex, ObjectTypeInterface $type)
{
$this->setParameter($parameterIndex, $this->escape($type->getQueryName()));
} | Sets the designated parameter to the query name of the given type.
@param integer $parameterIndex the parameter index (one-based)
@param ObjectTypeInterface $type the object type | entailment |
protected function setParameter($parameterIndex, $value)
{
if (!is_int($parameterIndex)) {
throw new CmisInvalidArgumentException('Parameter index must be of type integer!');
}
$this->parametersMap[$parameterIndex] = $value;
} | Sets the designated parameter to the given value
@param integer $parameterIndex
@param mixed $value
@throws CmisInvalidArgumentException If parameter index is not of type integer | entailment |
public function toQueryString()
{
$queryString = '';
$inString = false;
$parameterIndex = 0;
$length = strlen($this->statement);
for ($i=0; $i < $length; $i++) {
$char = $this->statement{$i};
if ($char === '\'') {
if ($inString && $this->statement{max(0, $i-1)} === '\\') {
$inString = true;
} else {
$inString = !$inString;
}
$queryString .= $char;
} elseif ($char === '?' && !$inString) {
$parameterIndex ++;
$queryString .= $this->parametersMap[$parameterIndex];
} else {
$queryString .= $char;
}
}
return $queryString;
} | Returns the query statement.
@return string the query statement, not null | entailment |
protected function escapeLike($string)
{
$escapedString = addcslashes($string, '\'\\');
$replace = [
'\\\\%' => '\\%',
'\\\\_' => '\\_',
];
$escapedString = str_replace(array_keys($replace), array_values($replace), $escapedString);
return "'" . $escapedString . "'";
} | Escapes string, but not escapes backslashes ('\') in front of '%' and '_'.
@param $string
@return string | entailment |
protected function escapeContains($string)
{
$escapedString = addcslashes($string, '"\'\\');
$replace = [
'\\\\*' => '\*',
'\\\\?' => '\?',
];
$escapedString = str_replace(array_keys($replace), array_values($replace), $escapedString);
return "'" . $escapedString . "'";
} | Escapes string, but not escapes backslashes ('\') in front of '*' and '?'.
@param $string
@return string | entailment |
public function isAllowed($entry)
{
foreach ($this->entries as $elmt) {
if ($elmt->check($entry)) {
return $this->matchingResponse;
}
}
return null;
} | Whether or not the Entry is allowed by this list
@param string $entry Entry
@return boolean|null TRUE = allowed, FALSE = rejected, NULL = not handled | entailment |
public function getMatchingEntries()
{
if ($this->matchingEntries === null) {
$this->matchingEntries = array();
foreach ($this->entries as $entry) {
$this->matchingEntries = array_merge($this->matchingEntries, $entry->getMatchingEntries());
}
}
return $this->matchingEntries;
} | Resolve all entries match the list
@return array | entailment |
public function initialize(
SessionInterface $session,
ObjectTypeInterface $objectType,
OperationContextInterface $context,
ObjectDataInterface $objectData = null
) {
if (count($this->getMissingBaseProperties($objectType->getPropertyDefinitions())) !== 0) {
throw new CmisInvalidArgumentException(
sprintf(
'Object type must have at least the base property definitions! '
. 'These property definitions are missing: %s',
implode(', ', PropertyIds::getBasePropertyKeys())
)
);
};
$this->session = $session;
$this->objectType = $objectType;
$this->secondaryTypes = null;
$this->creationContext = clone $context;
$this->refreshTimestamp = (integer) round(microtime(true) * 1000);
if ($objectData !== null) {
$this->initializeObjectData($objectData);
}
} | Initialize the CMIS Object
@param SessionInterface $session
@param ObjectTypeInterface $objectType
@param OperationContextInterface $context
@param ObjectDataInterface|null $objectData | entailment |
private function initializeObjectData(ObjectDataInterface $objectData)
{
// handle properties
if ($objectData->getProperties() !== null) {
$this->initializeObjectDataProperties($objectData->getProperties());
}
// handle allowable actions
if ($objectData->getAllowableActions() !== null) {
$this->allowableActions = $objectData->getAllowableActions();
$this->extensions[(string) ExtensionLevel::cast(
ExtensionLevel::ALLOWABLE_ACTIONS
)] = $objectData->getAllowableActions()->getExtensions();
}
// handle renditions
foreach ($objectData->getRenditions() as $rendition) {
$this->renditions[] = $this->getObjectFactory()->convertRendition($this->getId(), $rendition);
}
// handle ACL
if ($objectData->getAcl() !== null) {
$this->acl = $objectData->getAcl();
$this->extensions[(string) ExtensionLevel::cast(ExtensionLevel::ACL)] = $objectData->getAcl(
)->getExtensions();
}
// handle policies
if ($objectData->getPolicyIds() !== null) {
$this->initializeObjectDataPolicies($objectData->getPolicyIds());
}
// handle relationships
foreach ($objectData->getRelationships() as $relationshipData) {
$relationship = $this->getObjectFactory()->convertObject(
$relationshipData,
$this->getCreationContext()
);
if ($relationship instanceof RelationshipInterface) {
$this->relationships[] = $relationship;
}
}
$this->extensions[(string) ExtensionLevel::OBJECT] = $objectData->getExtensions();
} | Handle initialization for objectData
@param ObjectDataInterface $objectData | entailment |
private function initializeObjectDataProperties(PropertiesInterface $properties)
{
// get secondary types
$propertyList = $properties->getProperties();
if (isset($propertyList[PropertyIds::SECONDARY_OBJECT_TYPE_IDS])) {
$this->secondaryTypes = [];
foreach ($propertyList[PropertyIds::SECONDARY_OBJECT_TYPE_IDS]->getValues() as $secondaryTypeId) {
$type = $this->getSession()->getTypeDefinition($secondaryTypeId);
if ($type instanceof SecondaryTypeInterface) {
$this->secondaryTypes[] = $type;
}
}
}
$this->properties = $this->getObjectFactory()->convertPropertiesDataToPropertyList(
$this->getObjectType(),
(array) $this->getSecondaryTypes(),
$properties
);
$this->extensions[(string) ExtensionLevel::cast(
ExtensionLevel::PROPERTIES
)] = $properties->getExtensions();
} | Handle initialization of properties from the object data
@param PropertiesInterface $properties | entailment |
private function initializeObjectDataPolicies(PolicyIdListInterface $policies)
{
foreach ($policies->getPolicyIds() as $policyId) {
$policy = $this->getSession()->getObject($this->getSession()->createObjectId($policyId));
if ($policy instanceof PolicyInterface) {
$this->policies[] = $policy;
}
}
$this->extensions[(string) ExtensionLevel::POLICIES] = $policies->getExtensions();
} | Handle initialization of policies from the object data
@param PolicyIdListInterface $policies | entailment |
protected function getMissingBaseProperties(array $properties = null)
{
$basePropertyKeys = PropertyIds::getBasePropertyKeys();
if ($properties === null) {
return $basePropertyKeys;
}
foreach ($properties as $property) {
$propertyId = $property->getId();
$basePropertyKey = array_search($propertyId, $basePropertyKeys);
if ($basePropertyKey !== false) {
unset($basePropertyKeys[$basePropertyKey]);
}
}
return $basePropertyKeys;
} | Returns a list of missing property keys
@param PropertyDefinitionInterface[]|null $properties
@return array | entailment |
protected function getPropertyQueryName($propertyId)
{
$propertyDefinition = $this->getObjectType()->getPropertyDefinition($propertyId);
if ($propertyDefinition === null) {
return null;
}
return $propertyDefinition->getQueryName();
} | Returns the query name of a property.
@param string $propertyId
@return null|string | entailment |
public function updateProperties(array $properties, $refresh = true)
{
if (empty($properties)) {
throw new CmisInvalidArgumentException('Properties must not be empty!');
}
$objectId = $this->getId();
$changeToken = $this->getChangeToken();
$updatability = [];
$updatability[] = Updatability::cast(Updatability::READWRITE);
if ((boolean) $this->getPropertyValue(PropertyIds::IS_VERSION_SERIES_CHECKED_OUT) === true) {
$updatability[] = Updatability::cast(Updatability::WHENCHECKEDOUT);
}
$newObjectId = $objectId;
$this->getBinding()->getObjectService()->updateProperties(
$this->getRepositoryId(),
$newObjectId,
$this->getObjectFactory()->convertProperties(
$properties,
$this->getObjectType(),
(array) $this->getSecondaryTypes(),
$updatability
),
$changeToken
);
// remove the object from the cache, it has been changed
$this->getSession()->removeObjectFromCache($this->getSession()->createObjectId($objectId));
if ($refresh === true) {
$this->refresh();
}
if ($newObjectId === null) {
return null;
}
return $this->getSession()->getObject(
$this->getSession()->createObjectId($newObjectId),
$this->getCreationContext()
);
} | Updates the provided properties. If the repository created a new object, for example a new version,
the object ID of the new object is returned. Otherwise the object ID of the current object is returned.
@param mixed[] $properties the properties to update
@param boolean $refresh <code>true</code> if this object should be refresh after the update,
<code>false</code> if not
@return CmisObjectInterface|null the object ID of the updated object - can return <code>null</code> in case
of a repository failure | entailment |
public function rename($newName, $refresh = true)
{
if (empty($newName)) {
throw new CmisInvalidArgumentException('New name must not be empty!');
}
$properties = [
PropertyIds::NAME => $newName,
];
$object = $this->updateProperties($properties, $refresh);
return $object;
} | Renames this object (changes the value of cmis:name).
If the repository created a new object, for example a new version, the object id of the
new object is returned. Otherwise the object id of the current object is returned.
@param string $newName the new name, not <code>null</code> or empty
@param boolean $refresh <code>true</code> if this object should be refresh after the update,
<code>false</code> if not
@return CmisObjectInterface|null the object ID of the updated object - can return <code>null</code> in case of
a repository failure | entailment |
public function getBaseType()
{
$baseType = $this->getBaseTypeId();
if ($baseType === null) {
return null;
}
return $this->getSession()->getTypeDefinition((string) $baseType);
} | Returns the base type of this CMIS object (object type identified by cmis:baseTypeId).
@return ObjectTypeInterface the base type of the object or <code>null</code> if the property cmis:baseTypeId
hasn't been requested or hasn't been provided by the repository | entailment |
public function getBaseTypeId()
{
$baseTypeProperty = $this->getProperty(PropertyIds::BASE_TYPE_ID);
if ($baseTypeProperty === null) {
return null;
}
return BaseTypeId::cast($baseTypeProperty->getFirstValue());
} | Returns the base type of this CMIS object (object type identified by cmis:baseTypeId).
@return BaseTypeId|null the base type of the object or <code>null</code> if the property
cmis:baseTypeId hasn't been requested or hasn't been provided by the repository | entailment |
public function getProperty($id)
{
if (!isset($this->properties[$id])) {
return null;
}
return $this->properties[$id];
} | Returns a property.
@param string $id the ID of the property
@return PropertyInterface|null the property or <code>null</code> if the property hasn't been requested or
hasn't been provided by the repository | entailment |
public function getPropertyValue($id)
{
$property = $this->getProperty($id);
if ($property === null) {
return null;
}
return $property->isMultiValued() ? $property->getValues() : $property->getFirstValue();
} | Returns the value of a property.
@param string $id the ID of the property
@return mixed the property value or <code>null</code> if the property hasn't been requested,
hasn't been provided by the repository, or the property value isn't set | entailment |
public function findObjectType($id)
{
$result = [];
if ($this->getObjectType()->getPropertyDefinition($id) !== null) {
$result[] = $this->getObjectType();
}
$secondaryTypes = $this->getSecondaryTypes();
if ($secondaryTypes !== null) {
foreach ($secondaryTypes as $secondaryType) {
if ($secondaryType->getPropertyDefinition($id) !== null) {
$result[] = $secondaryType;
}
}
}
return empty($result) ? null : $result;
} | Returns a list of primary and secondary object types that define the given property.
@param string $id the ID of the property
@return ObjectTypeInterface[]|null a list of object types that define the given property or <code>null</code>
if the property could not be found in the object types that are attached to this object | entailment |
public function hasAllowableAction(Action $action)
{
$currentAllowableActions = $this->getAllowableActions();
if ($currentAllowableActions === null || count($currentAllowableActions->getAllowableActions()) === 0) {
throw new IllegalStateException('Allowable Actions are not available!');
}
return in_array($action, $currentAllowableActions->getAllowableActions(), false);
} | Checks if the given action is an allowed action for the object
@param Action $action
@return boolean | entailment |
public function applyAcl(array $addAces, array $removeAces, AclPropagation $aclPropagation)
{
$result = $this->getSession()->applyAcl($this, $addAces, $removeAces, $aclPropagation);
$this->refresh();
return $result;
} | Adds and removes ACEs to the object and refreshes this object afterwards.
@param AceInterface[] $addAces
@param AceInterface[] $removeAces
@param AclPropagation $aclPropagation
@return AclInterface the new ACL of this object | entailment |
public function setAcl(array $aces)
{
$result = $this->getSession()->setAcl($this, $aces);
$this->refresh();
return $result;
} | Removes the direct ACE of this object, sets the provided ACEs to the object and refreshes this object afterwards.
@param AceInterface[] $aces
@return AclInterface | entailment |
public function getPermissionsForPrincipal($principalId)
{
if (empty($principalId)) {
throw new IllegalStateException('Principal ID must be set!');
}
$currentAcl = $this->getAcl();
if ($currentAcl === null) {
throw new IllegalStateException('ACLs are not available');
}
$result = [];
foreach ($currentAcl->getAces() as $ace) {
if ($principalId === $ace->getPrincipalId() && count($ace->getPermissions()) > 0) {
$result = array_merge($result, $ace->getPermissions());
}
}
return $result;
} | Returns all permissions for the given principal from the ACL.
@param string $principalId the principal ID
@return string[] the set of permissions for this user, or an empty set if principal is not in the ACL
@throws IllegalStateException if the ACL hasn't been fetched or provided by the repository | entailment |
public function getExtensions(ExtensionLevel $level)
{
if (!isset($this->extensions[(string) $level])) {
return null;
}
return $this->extensions[(string) $level];
} | Returns the extensions for the given level.
@param ExtensionLevel $level the level
@return array[]|null A list of <code>CmisExtensionElementInterface</code> at the requested level or
<code>null</code> if there are no extensions for the requested level
@see CmisExtensionElementInterface | entailment |
public function refresh()
{
$operationContext = $this->getCreationContext();
$objectData = $this->getSession()->getBinding()->getObjectService()->getObject(
$this->getRepositoryId(),
$this->getId(),
$operationContext->getQueryFilterString(),
$operationContext->isIncludeAllowableActions(),
$operationContext->getIncludeRelationships(),
$operationContext->getRenditionFilterString(),
$operationContext->isIncludePolicies(),
$operationContext->isIncludeAcls(),
null
);
$this->initialize(
$this->getSession(),
$this->getSession()->getTypeDefinition($this->getObjectType()->getId()),
$this->creationContext,
$objectData
);
} | Reloads this object from the repository.
@throws CmisObjectNotFoundException - if the object doesn't exist anymore in the repository | entailment |
public function refreshIfOld($durationInMillis = 0)
{
if ($this->getRefreshTimestamp() < ((round(microtime(true) * 1000)) - (integer) $durationInMillis)) {
$this->refresh();
}
} | Reloads the data from the repository if the last refresh did not occur within durationInMillis.
@param integer $durationInMillis
@throws CmisObjectNotFoundException - if the object doesn't exist anymore in the repository | entailment |
public function cancelCheckOut($repositoryId, & $objectId, ExtensionDataInterface $extension = null)
{
$objectId = $this->getJsonConverter()->convertObject(
(array) $this->postJson(
$this->getObjectUrl($repositoryId, $objectId),
$this->createQueryArray(
Constants::CMISACTION_CANCEL_CHECK_OUT,
[],
$extension
)
)
);
} | Reverses the effect of a check-out.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the PWC
@param ExtensionDataInterface|null $extension | entailment |
public function checkIn(
$repositoryId,
& $objectId,
$major = true,
PropertiesInterface $properties = null,
StreamInterface $contentStream = null,
$checkinComment = null,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
$queryArray = $this->createQueryArray(
Constants::CMISACTION_CHECK_IN,
[
Constants::PARAM_MAJOR => $major ? 'true' : 'false',
],
$extension
);
if ($properties) {
$queryArray = array_replace(
$queryArray,
$this->convertPropertiesToQueryArray($properties)
);
}
if ($checkinComment) {
$queryArray[Constants::PARAM_CHECKIN_COMMENT] = $checkinComment;
}
if (!empty($policies)) {
$queryArray = array_replace(
$queryArray,
$this->convertPolicyIdArrayToQueryArray($policies)
);
}
if (!empty($removeAces)) {
$queryArray = array_replace($queryArray, $this->convertAclToQueryArray(
$removeAces,
Constants::CONTROL_REMOVE_ACE_PRINCIPAL,
Constants::CONTROL_REMOVE_ACE_PERMISSION
));
}
if (!empty($addAces)) {
$queryArray = array_replace($queryArray, $this->convertAclToQueryArray(
$addAces,
Constants::CONTROL_ADD_ACE_PRINCIPAL,
Constants::CONTROL_ADD_ACE_PERMISSION
));
}
if ($contentStream) {
$queryArray['content'] = $contentStream;
}
$objectId = $this->getJsonConverter()->convertObject(
(array) $this->postJson(
$this->getObjectUrl($repositoryId, $objectId),
$queryArray
)
)->getId();
} | Checks-in the private working copy (PWC) document.
@param string $repositoryId the identifier for the repository
@param string $objectId input: the identifier for the PWC,
output: the identifier for the newly created version document
@param boolean $major indicator if the new version should become a major (<code>true</code>) or minor
(<code>false</code>) version
@param PropertiesInterface|null $properties the property values that must be applied to the
newly created document object
@param StreamInterface|null $contentStream the content stream that must be stored
for the newly created document object
@param string|null $checkinComment a version comment
@param string[] $policies a list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object
@param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object
@param ExtensionDataInterface|null $extension | entailment |
public function checkOut(
$repositoryId,
& $objectId,
ExtensionDataInterface $extension = null,
$contentCopied = null
) {
$objectData = $this->getJsonConverter()->convertObject(
(array) $this->postJson(
$this->getObjectUrl($repositoryId, $objectId),
$this->createQueryArray(
Constants::CMISACTION_CHECK_OUT,
[],
$extension
)
)
);
$objectId = $objectData->getId();
} | Create a private working copy of the document.
@param string $repositoryId the identifier for the repository
@param string $objectId input: the identifier for the document that should be checked out,
output: the identifier for the newly created PWC
@param ExtensionDataInterface|null $extension
@param boolean|null $contentCopied output: indicator if the content of the original
document has been copied to the PWC | entailment |
public function getAllVersions(
$repositoryId,
$objectId,
$versionSeriesId,
$filter = null,
$includeAllowableActions = false,
ExtensionDataInterface $extension = null
) {
return $this->getJsonConverter()->convertObjectList(
[
'objects' => (array) $this->readJson(
$this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_VERSIONS)
)
]
)->getObjects();
} | Returns the list of all document objects in the specified version series,
sorted by the property "cmis:creationDate" descending.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param string $versionSeriesId the identifier for the object
@param string|null $filter a comma-separated list of query names that defines which properties must be
returned by the repository (default is repository specific)
@param boolean $includeAllowableActions if <code>true</code>, then the repository must return the allowable
actions for the objects (default is <code>false</code>)
@param ExtensionDataInterface|null $extension
@return ObjectDataInterface[] the complete version history of the version series | entailment |
public function all()
{
$endpoint = '/admin/users.json';
$response = $this->request($endpoint);
return $this->createCollection(User::class, $response['users']);
} | Receive a list of all Users
@link https://help.shopify.com/api/reference/user#index
@return User[] | entailment |
public function get($userId)
{
$endpoint = '/admin/users/'.$userId.'.json';
$response = $this->request($endpoint);
return $this->createObject(User::class, $response['user']);
} | Receive a single user
@link https://help.shopify.com/api/reference/user#show
@param integer $userId
@return User | entailment |
function start($id, $group = 'default', $doNotTestCacheValidity = false)
{
$this->nestedIds[] = $id;
$this->nestedGroups[] = $group;
$data = $this->get($id, $group, $doNotTestCacheValidity);
if ($data !== false) {
return $data;
}
ob_start();
ob_implicit_flush(false);
return false;
} | Start the cache
@param string $id cache id
@param string $group name of the cache group
@param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
@return boolean|string false if the cache is not hit else the data
@access public | entailment |
function end()
{
$data = ob_get_contents();
ob_end_clean();
$id = array_pop($this->nestedIds);
$group = array_pop($this->nestedGroups);
$this->save($data, $id, $group);
return $data;
} | Stop the cache
@param boolen
@return string return contents of cache | entailment |
public function appendContentStream(
$repositoryId,
& $objectId,
StreamInterface $contentStream,
$isLastChunk,
& $changeToken = null,
ExtensionDataInterface $extension = null
) {
// TODO: Implement appendContentStream() method.
} | Appends the content stream to the content of the document.
The stream in contentStream is consumed but not closed by this method.
@param string $repositoryId the identifier for the repository
@param string $objectId The identifier for the object. The repository might return a different/new object id
@param StreamInterface $contentStream The content stream to append
@param boolean $isLastChunk Indicates if this content stream is the last chunk
@param string|null $changeToken The last change token of this object that the client received.
The repository might return a new change token (default is <code>null</code>)
@param ExtensionDataInterface|null $extension | entailment |
public function bulkUpdateProperties(
$repositoryId,
array $objectIdsAndChangeTokens,
PropertiesInterface $properties,
array $addSecondaryTypeIds,
array $removeSecondaryTypeIds,
ExtensionDataInterface $extension = null
) {
// TODO: Implement bulkUpdateProperties() method.
} | Updates properties and secondary types of one or more objects.
@param string $repositoryId the identifier for the repository
@param BulkUpdateObjectIdAndChangeTokenInterface[] $objectIdsAndChangeTokens
@param PropertiesInterface $properties
@param string[] $addSecondaryTypeIds the secondary types to apply
@param string[] $removeSecondaryTypeIds the secondary types to remove
@param ExtensionDataInterface|null $extension
@return BulkUpdateObjectIdAndChangeTokenInterface[] | entailment |
public function createDocument(
$repositoryId,
PropertiesInterface $properties,
$folderId = null,
StreamInterface $contentStream = null,
VersioningState $versioningState = null,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
if ($folderId === null) {
$url = $this->getRepositoryUrl($repositoryId);
} else {
$url = $this->getObjectUrl($repositoryId, $folderId);
}
$queryArray = $this->createQueryArray(
Constants::CMISACTION_CREATE_DOCUMENT,
$properties,
$policies,
$addAces,
$removeAces,
$extension
);
if ($versioningState !== null) {
$queryArray[Constants::PARAM_VERSIONING_STATE] = (string) $versioningState;
}
if ($contentStream) {
$queryArray['content'] = $contentStream;
}
$newObject = $this->getJsonConverter()->convertObject(
(array) $this->postJson(
$url,
$queryArray
)
);
if ($newObject) {
$newObjectId = $newObject->getId();
return $newObjectId;
}
return null;
} | Creates a document object of the specified type (given by the cmis:objectTypeId property)
in the (optionally) specified location.
@param string $repositoryId the identifier for the repository
@param PropertiesInterface $properties the property values that must be applied to the newly
created document object
@param string|null $folderId if specified, the identifier for the folder that must be the parent
folder for the newly created document object
@param StreamInterface|null $contentStream the content stream that must be stored for the newly
created document object
@param VersioningState|null $versioningState specifies what the versioning state of the newly created object
must be (default is <code>VersioningState::MAJOR</code>)
@param string[] $policies a list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object,
either using the ACL from folderId if specified, or being applied if no folderId is specified
@param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object,
either using the ACL from folderId if specified, or being ignored if no folderId is specified
@param ExtensionDataInterface|null $extension
@return string|null Returns the new object id or <code>null</code> if the repository sent an empty
result (which should not happen) | entailment |
public function createDocumentFromSource(
$repositoryId,
$sourceId,
PropertiesInterface $properties,
$folderId = null,
VersioningState $versioningState = null,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
if ($folderId === null) {
$url = $this->getRepositoryUrl($repositoryId);
} else {
$url = $this->getObjectUrl($repositoryId, $folderId);
}
$queryArray = $this->createQueryArray(
Constants::CMISACTION_CREATE_DOCUMENT_FROM_SOURCE,
$properties,
$policies,
$addAces,
$removeAces,
$extension
);
$queryArray[Constants::PARAM_SOURCE_ID] = (string) $sourceId;
if ($versioningState !== null) {
$queryArray[Constants::PARAM_VERSIONING_STATE] = (string) $versioningState;
}
$newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray));
return ($newObject === null) ? null : $newObject->getId();
} | Creates a document object as a copy of the given source document in the (optionally) specified location.
@param string $repositoryId the identifier for the repository
@param string $sourceId the identifier for the source document
@param PropertiesInterface $properties the property values that must be applied to the newly
created document object
@param string|null $folderId if specified, the identifier for the folder that must be the parent folder for the
newly created document object
@param VersioningState|null $versioningState specifies what the versioning state of the newly created object
must be (default is <code>VersioningState::MAJOR</code>)
@param string[] $policies a list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object,
either using the ACL from folderId if specified, or being applied if no folderId is specified
@param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object,
either using the ACL from folderId if specified, or being ignored if no folderId is specified
@param ExtensionDataInterface|null $extension
@return string|null Returns the new object id or <code>null</code> if the repository sent an empty
result (which should not happen) | entailment |
public function createFolder(
$repositoryId,
PropertiesInterface $properties,
$folderId,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $folderId);
$queryArray = $this->createQueryArray(
Constants::CMISACTION_CREATE_FOLDER,
$properties,
$policies,
$addAces,
$removeAces,
$extension
);
$newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray));
return ($newObject === null) ? null : $newObject->getId();
} | Creates a folder object of the specified type (given by the cmis:objectTypeId property) in
the specified location.
@param string $repositoryId the identifier for the repository
@param PropertiesInterface $properties the property values that must be applied to the newly
created document object
@param string $folderId if specified, the identifier for the folder that must be the parent folder for the
newly created document object
@param string[] $policies a list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object,
either using the ACL from folderId if specified, or being applied if no folderId is specified
@param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object,
either using the ACL from folderId if specified, or being ignored if no folderId is specified
@param ExtensionDataInterface|null $extension
@return string|null Returns the new object id or <code>null</code> if the repository sent an empty
result (which should not happen) | entailment |
public function createPolicy(
$repositoryId,
PropertiesInterface $properties,
$folderId = null,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
// TODO: Implement createPolicy() method.
} | Creates a policy object of the specified type (given by the cmis:objectTypeId property).
@param string $repositoryId The identifier for the repository
@param PropertiesInterface $properties The property values that must be applied to the newly
created document object
@param string|null $folderId If specified, the identifier for the folder that must be the parent folder for the
newly created document object
@param string[] $policies A list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces A list of ACEs that must be added to the newly created document object,
either using the ACL from folderId if specified, or being applied if no folderId is specified
@param AclInterface|null $removeAces A list of ACEs that must be removed from the newly created document object,
either using the ACL from folderId if specified, or being ignored if no folderId is specified
@param ExtensionDataInterface|null $extension
@return string The id of the newly-created policy. | entailment |
public function createRelationship(
$repositoryId,
PropertiesInterface $properties,
array $policies = [],
AclInterface $addAces = null,
AclInterface $removeAces = null,
ExtensionDataInterface $extension = null
) {
$url = $this->getRepositoryUrl($repositoryId);
$queryArray = $this->createQueryArray(
Constants::CMISACTION_CREATE_RELATIONSHIP,
$properties,
$policies,
$addAces,
$removeAces,
$extension
);
$newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray));
return ($newObject === null) ? null : $newObject->getId();
} | Creates a relationship object of the specified type (given by the cmis:objectTypeId property).
@param string $repositoryId the identifier for the repository
@param PropertiesInterface $properties the property values that must be applied to the newly
created document object
@param string[] $policies a list of policy IDs that must be applied to the newly created document object
@param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object,
either using the ACL from folderId if specified, or being applied if no folderId is specified
@param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object,
either using the ACL from folderId if specified, or being ignored if no folderId is specified
@param ExtensionDataInterface|null $extension
@return string|null Returns the new item id of the relationship object or <code>null</code> if the repository
sent an empty result (which should not happen) | entailment |
public function deleteContentStream(
$repositoryId,
& $objectId,
& $changeToken = null,
ExtensionDataInterface $extension = null
) {
if (empty($objectId)) {
throw new CmisInvalidArgumentException('Object id must not be empty!');
}
$this->flushCached();
$url = $this->getObjectUrl($repositoryId, $objectId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE_CONTENT,
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false'
]
);
if ($changeToken !== null && !$this->getSession()->get(SessionParameter::OMIT_CHANGE_TOKENS, false)) {
$url->getQuery()->modify([Constants::PARAM_CHANGE_TOKEN => $changeToken]);
}
$newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url));
// $objectId was passed by reference. The value is changed here to new object id
$objectId = null;
if ($newObject !== null) {
$objectId = $newObject->getId();
$newObjectProperties = $newObject->getProperties()->getProperties();
if ($changeToken !== null && count($newObjectProperties) > 0) {
$newChangeToken = $newObjectProperties[PropertyIds::CHANGE_TOKEN];
// $changeToken was passed by reference. The value is changed here
$changeToken = $newChangeToken === null ? null : $newChangeToken->getFirstValue();
}
}
} | Deletes the content stream for the specified document object.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object. The repository might return a different/new object id
@param string|null $changeToken the last change token of this object that the client received.
The repository might return a new change token (default is <code>null</code>)
@param ExtensionDataInterface|null $extension
@throws CmisInvalidArgumentException If $objectId is empty | entailment |
public function deleteObject(
$repositoryId,
$objectId,
$allVersions = true,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $objectId);
$content = [
Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE,
Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false',
];
$this->post($url, $content);
$this->flushCached();
} | Deletes the specified object.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param boolean $allVersions If <code>true</code> then delete all versions of the document, otherwise delete only
the document object specified (default is <code>true</code>)
@param ExtensionDataInterface|null $extension | entailment |
public function deleteTree(
$repositoryId,
$folderId,
$allVersions = true,
UnfileObject $unfileObjects = null,
$continueOnFailure = false,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $folderId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE_TREE,
Constants::PARAM_FOLDER_ID => $folderId,
Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false',
Constants::PARAM_CONTINUE_ON_FAILURE => $continueOnFailure ? 'true' : 'false'
]
);
if ($unfileObjects !== null) {
$url->getQuery()->modify([Constants::PARAM_UNFILE_OBJECTS => (string) $unfileObjects]);
}
return $this->getJsonConverter()->convertFailedToDelete($this->postJson($url));
} | Deletes the specified folder object and all of its child- and descendant-objects.
@param string $repositoryId the identifier for the repository
@param string $folderId the identifier for the folder
@param boolean $allVersions If <code>true</code> then delete all versions of the document, otherwise delete only
the document object specified (default is <code>true</code>)
@param UnfileObject|null $unfileObjects defines how the repository must process file-able child- or
descendant-objects (default is <code>UnfileObject::DELETE</code>)
@param boolean $continueOnFailure If <code>true</code>, then the repository should continue attempting to
perform this operation even if deletion of a child- or descendant-object in the specified folder cannot
be deleted
@param ExtensionDataInterface|null $extension
@return FailedToDeleteDataInterface Returns a list of object ids that could not be deleted | entailment |
public function getContentStream(
$repositoryId,
$objectId,
$streamId = null,
$offset = null,
$length = null,
ExtensionDataInterface $extension = null
) {
if (empty($objectId)) {
throw new CmisInvalidArgumentException('Object id must not be empty!');
}
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_CONTENT);
if ($streamId !== null) {
$url->getQuery()->modify([Constants::PARAM_STREAM_ID => $streamId]);
}
/** @var Response $response */
$response = $this->getHttpInvoker()->get((string) $url);
$contentStream = $response->getBody();
if (!$contentStream) {
return null;
}
if ($offset !== null) {
$contentStream = new LimitStream($contentStream, $length !== null ? $length : - 1, $offset);
}
return $contentStream;
} | Gets the content stream for the specified document object, or gets a rendition stream for
a specified rendition of a document or folder object.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param string|null $streamId The identifier for the rendition stream, when used to get a rendition stream.
For documents, if not provided then this method returns the content stream. For folders,
it MUST be provided.
@param integer|null $offset
@param integer|null $length
@param ExtensionDataInterface|null $extension
@return StreamInterface|null
@throws CmisInvalidArgumentException If object id is empty | entailment |
public function getObject(
$repositoryId,
$objectId,
$filter = null,
$includeAllowableActions = false,
IncludeRelationships $includeRelationships = null,
$renditionFilter = Constants::RENDITION_NONE,
$includePolicyIds = false,
$includeAcl = false,
ExtensionDataInterface $extension = null
) {
$cacheKey = $this->createCacheKey(
$objectId,
[
$repositoryId,
$filter,
$includeAllowableActions,
$includeRelationships,
$renditionFilter,
$includePolicyIds,
$includeAcl,
$extension,
$this->getSuccinct()
]
);
if ($this->isCached($cacheKey)) {
return $this->getCached($cacheKey);
}
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_OBJECT);
$url->getQuery()->modify(
[
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_POLICY_IDS => $includePolicyIds ? 'true' : 'false',
Constants::PARAM_ACL => $includeAcl ? 'true' : 'false',
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
]
);
if (!empty($filter)) {
$url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
}
if ($includeRelationships !== null) {
$url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
}
$responseData = (array) $this->readJson($url);
return $this->cache(
$cacheKey,
$this->getJsonConverter()->convertObject($responseData)
);
} | Gets the specified information for the object specified by id.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param string|null $filter a comma-separated list of query names that defines which properties must be
returned by the repository (default is repository specific)
@param boolean $includeAllowableActions if <code>true</code>, then the repository must return the allowable
actions for the object (default is <code>false</code>)
@param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
participate must be returned (default is <code>IncludeRelationships::NONE</code>)
@param string $renditionFilter indicates what set of renditions the repository must return whose kind
matches this filter (default is "cmis:none")
@param boolean $includePolicyIds if <code>true</code>, then the repository must return the policy ids for
the object (default is <code>false</code>)
@param boolean $includeAcl if <code>true</code>, then the repository must return the ACL for the object
(default is <code>false</code>)
@param ExtensionDataInterface|null $extension
@return ObjectDataInterface|null Returns object of type ObjectDataInterface or <code>null</code>
if the repository response was empty | entailment |
public function getProperties(
$repositoryId,
$objectId,
$filter = null,
ExtensionDataInterface $extension = null
) {
$cacheKey = $this->createCacheKey(
$objectId,
[
$repositoryId,
$filter,
$extension,
$this->getSuccinct()
]
);
if ($this->isCached($cacheKey)) {
return $this->getCached($cacheKey);
}
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_PROPERTIES);
$url->getQuery()->modify(
[
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
]
);
if (!empty($filter)) {
$url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
}
$responseData = (array) $this->readJson($url);
if ($this->getSuccinct()) {
$objectData = $this->getJsonConverter()->convertSuccinctProperties($responseData);
} else {
$objectData = $this->getJsonConverter()->convertProperties($responseData);
}
return $this->cache(
$cacheKey,
$objectData
);
} | Gets the list of properties for an object.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param string|null $filter a comma-separated list of query names that defines which properties must be
returned by the repository (default is repository specific)
@param ExtensionDataInterface|null $extension
@return PropertiesInterface | entailment |
public function getRenditions(
$repositoryId,
$objectId,
$renditionFilter = Constants::RENDITION_NONE,
$maxItems = null,
$skipCount = 0,
ExtensionDataInterface $extension = null
) {
if (empty($objectId)) {
throw new CmisInvalidArgumentException('Object id must not be empty!');
}
if (!is_int($skipCount)) {
throw new CmisInvalidArgumentException('Skip count must be of type integer!');
}
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_RENDITIONS);
$url->getQuery()->modify(
[
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_SKIP_COUNT => (string) $skipCount,
]
);
if ($maxItems !== null) {
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
}
$responseData = (array) $this->readJson($url);
return $this->getJsonConverter()->convertRenditions($responseData);
} | Gets the list of associated renditions for the specified object.
Only rendition attributes are returned, not rendition stream.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object
@param string $renditionFilter indicates what set of renditions the repository must return whose kind
matches this filter (default is "cmis:none")
@param integer|null $maxItems the maximum number of items to return in a response
(default is repository specific)
@param integer $skipCount number of potential results that the repository MUST skip/page over before
returning any results (default is 0)
@param ExtensionDataInterface|null $extension
@return RenditionDataInterface[]
@throws CmisInvalidArgumentException If object id is empty or skip count not of type integer | entailment |
public function moveObject(
$repositoryId,
& $objectId,
$targetFolderId,
$sourceFolderId,
ExtensionDataInterface $extension = null
) {
$this->flushCached();
$url = $this->getObjectUrl($repositoryId, $objectId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_MOVE,
Constants::PARAM_TARGET_FOLDER_ID => $targetFolderId,
Constants::PARAM_SOURCE_FOLDER_ID => $sourceFolderId,
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false'
]
);
$newObject = $this->getJsonConverter()->convertObject($this->postJson($url));
// $objectId was passed by reference. The value is changed here to new object id
$objectId = ($newObject === null) ? null : $newObject->getId();
return $newObject;
} | Moves the specified file-able object from one folder to another.
@param string $repositoryId the identifier for the repository
@param string $objectId the identifier for the object. The repository might return a different/new object id
@param string $targetFolderId the identifier for the target folder
@param string $sourceFolderId the identifier for the source folder
@param ExtensionDataInterface|null $extension
@return ObjectDataInterface|null Returns object of type ObjectDataInterface or <code>null</code>
if the repository response was empty | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/collects.json';
$data = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Collect::class, $data['collects']);
} | Receive a list of all collects
@link https://help.shopify.com/api/reference/collect#index
@param array $params
@return Collect[] | entailment |
public function get($collectId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/admin/collects/'.$collectId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Collect::class, $response['collect']);
} | Receive a single collect
@link https://help.shopify.com/api/reference/collect#show
@param integer $collectId
@param array $fields
@return Collect | entailment |
public function create(Collect &$collect)
{
$data = $collect->exportData();
$endpoint = '/admin/collects.json';
$response = $this->request(
$endpoint, 'POST', array(
'collect' => $data
)
);
$collect->setData($response['collect']);
} | Create a new collect
@link https://help.shopify.com/api/reference/collect#create
@param Collect $collect
@return void | entailment |
public function all(array $params = array())
{
$data = $this->request('/admin/application_charges.json', 'GET', $params);
return $this->createCollection(ApplicationCharge::class, $data['application_charges']);
} | Retrieve all one-time application charges
@link https://help.shopify.com/api/reference/applicationcharge#index
@param array $params
@return ApplicationCharge[] | entailment |
public function get($applicationChargeId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$data = $this->request('/admin/application_charges/'.$applicationChargeId.'.json', 'GET', $params);
return $this->createObject(ApplicationCharge::class, $data['application_charge']);
} | Receive a single ApplicationCharge
@link https://help.shopify.com/api/reference/applicationcharge#show
@param integer $applicationChargeId
@param array $fields
@return ApplicationCharge | entailment |
public function create(ApplicationCharge &$applicationCharge)
{
$data = $applicationCharge->exportData();
$endpoint = '/admin/application_charges.json';
$response = $this->request(
'/admin/application_charges.json', 'POST', array(
'application_charge' => $data
)
);
$applicationCharge->setData($response['application_charge']);
} | Create a new one-time application charge
@link https://help.shopify.com/api/reference/applicationcharge#create
@param ApplicationCharge $applicationCharge
@return void | entailment |
public function activate(ApplicationCharge &$applicationCharge)
{
$response = $this->request('/admin/application_charges/'.$applicationCharge->id.'/activate.json', 'POST');
$applicationCharge->setData($response['application_charge']);
} | Activate a one-time application charge
@link https://help.shopify.com/api/reference/applicationcharge#activate
@param ApplicationCharge $applicationCharge
@return void | entailment |
public function load(array $configs, ContainerBuilder $container)
{
// retrieve each measure config from bundles
$measuresConfig = [];
foreach ($container->getParameter('kernel.bundles') as $bundle) {
$reflection = new \ReflectionClass($bundle);
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/measure.yml')) {
// merge measures configs
if (empty($measuresConfig)) {
$measuresConfig = Yaml::parse(file_get_contents(realpath($file)));
} else {
$entities = Yaml::parse(file_get_contents(realpath($file)));
foreach ($entities['measures_config'] as $family => $familyConfig) {
// merge result with already existing family config to add custom units
if (isset($measuresConfig['measures_config'][$family])) {
$measuresConfig['measures_config'][$family]['units'] =
array_merge(
$measuresConfig['measures_config'][$family]['units'],
$familyConfig['units']
);
} else {
$measuresConfig['measures_config'][$family] = $familyConfig;
}
}
}
}
}
$configs[] = $measuresConfig;
// process configurations to validate and merge
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
// load service
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
// set measures config
$container->setParameter('akeneo_measure.measures_config', $config);
$container
->getDefinition('akeneo_measure.manager')
->addMethodCall('setMeasureConfig', $config);
} | {@inheritDoc} | entailment |
public function getBaseTypeId()
{
$value = $this->getFirstValue(PropertyIds::BASE_TYPE_ID);
if (is_string($value)) {
try {
return BaseTypeId::cast($value);
} catch (InvalidEnumerationValueException $e) {
// invalid base type -> return null
}
}
return null;
} | Returns the base object type.
@return BaseTypeId|null the base object type or <code>null</code> if the base object type is unknown | entailment |
public function getId()
{
$value = $this->getFirstValue(PropertyIds::OBJECT_ID);
if (is_string($value)) {
return $value;
}
return null;
} | Returns the object ID.
@return string|null the object ID or <code>null</code> if the object ID is unknown | entailment |
private function getFirstValue($id)
{
if ($this->properties === null) {
return null;
}
$properties = $this->properties->getProperties();
if (isset($properties[$id])) {
return $properties[$id]->getFirstValue();
}
return null;
} | Returns the first value of a property or <code>null</code> if the
property is not set.
@param string $id
@return mixed | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/gift_cards.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(GiftCard::class, $response['gift_cards']);
} | Receive a list of Gift Cards
@link https://help.shopify.com/api/reference/gift_card#index
@param array $params
@return GiftCard[] | entailment |
public function get($giftCardId, array $params = array())
{
$endpoint = '/admin/gift_cards/'.$giftCardId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(GiftCard::class, $response['gift_card']);
} | Receive a single Gift Card
@link https://help.shopify.com/api/reference/gift_card#show
@param integer $giftCardId
@param array $params
@return GiftCard | entailment |
public function create(GiftCard &$giftCard)
{
$data = $giftCard->exportData();
$endpoint = '/admin/gift_cards.json';
$response = $this->request(
$endpoint, 'POST', array(
'gift_card' => $data
)
);
$giftCard->setData($response['gift_card']);
} | Create a gift card
@link https://help.shopify.com/api/reference/gift_card#create
@param GiftCard $giftCard
@return void | entailment |
public function update(GiftCard &$giftCard)
{
$data = $giftCard->exportData();
$endpoint = '/admin/gift_cards/'.$giftCard->id.'.json';
$response = $this->request(
$endpoint, 'POST', array(
'gift_card' => $data
)
);
$giftCard->setData($response['gift_card']);
} | Update a Gift Card
@link https://help.shopify.com/api/reference/gift_card#update
@param GiftCard $giftCard
@return void | entailment |
public function search(array $params = array())
{
$endpoint = '/admin/gift_cards/search.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(GiftCard::class, $response['gift_cards']);
} | Search for gift cards matching supplied query
@link https://help.shopify.com/api/reference/gift_card#search
@param array $params
@return GiftCard[] | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/custom_collections.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(CustomCollection::class, $response['custom_collections']);
} | Receive a list of all custom collections
@link https://help.shopify.com/api/reference/customcollection#index
@param array $params
@return CustomCollection[] | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.