sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function dump_node($echo = true)
{
$string = $this->tag;
if (count($this->attr) > 0) {
$string .= '(';
foreach ($this->attr as $k => $v) {
$string .= "[$k]=>\"" . $this->$k . '", ';
}
$string .= ')';
}
if (count($this->_) > 0) {
$string .= ' $_ (';
foreach ($this->_ as $k => $v) {
if (is_array($v)) {
$string .= "[$k]=>(";
foreach ($v as $k2 => $v2) {
$string .= "[$k2]=>\"" . $v2 . '", ';
}
$string .= ')';
} else {
$string .= "[$k]=>\"" . $v . '", ';
}
}
$string .= ')';
}
if (isset($this->text)) {
$string .= ' text: (' . $this->text . ')';
}
$string .= " HDOM_INNER_INFO: '";
if (isset($node->_[HDOM_INFO_INNER])) {
$string .= $node->_[HDOM_INFO_INNER] . "'";
} else {
$string .= ' NULL ';
}
$string .= ' children: ' . count($this->children);
$string .= ' nodes: ' . count($this->nodes);
$string .= ' tag_start: ' . $this->tag_start;
$string .= "\n";
if ($echo) {
echo $string;
return;
} else {
return $string;
}
} | Debugging function to dump a single dom node with a bunch of information about it. | entailment |
public function next_sibling()
{
if ($this->parent === null) {
return null;
}
$idx = 0;
$count = count($this->parent->children);
while ($idx < $count && $this !== $this->parent->children[$idx]) {
++$idx;
}
if (++$idx >= $count) {
return null;
}
return $this->parent->children[$idx];
} | returns the next sibling of node | entailment |
public function get_display_size()
{
global $debugObject;
$width = -1;
$height = -1;
if ($this->tag !== 'img') {
return false;
}
// See if there is aheight or width attribute in the tag itself.
if (isset($this->attr['width'])) {
$width = $this->attr['width'];
}
if (isset($this->attr['height'])) {
$height = $this->attr['height'];
}
// Now look for an inline style.
if (isset($this->attr['style'])) {
// Thanks to user gnarf from stackoverflow for this regular expression.
$attributes = [];
preg_match_all("/([\w\-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$attributes[$match[1]] = $match[2];
}
// If there is a width in the style attributes:
if (isset($attributes['width']) && $width == -1) {
// check that the last two characters are px (pixels)
if (strtolower(substr($attributes['width'], -2)) == 'px') {
$proposed_width = substr($attributes['width'], 0, -2);
// Now make sure that it's an integer and not something stupid.
if (filter_var($proposed_width, FILTER_VALIDATE_INT)) {
$width = $proposed_width;
}
}
}
// If there is a width in the style attributes:
if (isset($attributes['height']) && $height == -1) {
// check that the last two characters are px (pixels)
if (strtolower(substr($attributes['height'], -2)) == 'px') {
$proposed_height = substr($attributes['height'], 0, -2);
// Now make sure that it's an integer and not something stupid.
if (filter_var($proposed_height, FILTER_VALIDATE_INT)) {
$height = $proposed_height;
}
}
}
}
// Future enhancement:
// Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
// Far future enhancement
// Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
// Note that in this case, the class or id will have the img subselector for it to apply to the image.
// ridiculously far future development
// If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
$result = ['height' => $height,
'width' => $width];
return $result;
} | Function to try a few tricks to determine the displayed size of an img on the page.
NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
@author John Schlick
@version April 19 2012
@return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out. | entailment |
protected function parse_charset()
{
global $debugObject;
$charset = null;
if (function_exists('get_last_retrieve_url_contents_content_type')) {
$contentTypeHeader = get_last_retrieve_url_contents_content_type();
$success = preg_match('/charset=(.+)/', $contentTypeHeader, $matches);
if ($success) {
$charset = $matches[1];
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'header content-type found charset of: ' . $charset);
}
}
}
if (empty($charset)) {
$el = $this->root->find('meta[http-equiv=Content-Type]', 0);
if (!empty($el)) {
$fullvalue = $el->content;
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'meta content-type tag found' . $fullvalue);
}
if (!empty($fullvalue)) {
$success = preg_match('/charset=(.+)/', $fullvalue, $matches);
if ($success) {
$charset = $matches[1];
} else {
// If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');
}
$charset = 'ISO-8859-1';
}
}
}
}
// If we couldn't find a charset above, then lets try to detect one based on the text we got...
if (empty($charset)) {
// Have php try to detect the encoding from the text given to us.
$charset = mb_detect_encoding($this->root->plaintext . 'ascii', $encoding_list = ['UTF-8', 'CP1252']);
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'mb_detect found: ' . $charset);
}
// and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
if ($charset === false) {
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'since mb_detect failed - using default of utf-8');
}
$charset = 'UTF-8';
}
}
// Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1'))) {
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'replacing ' . $charset . ' with CP1252 as its a superset');
}
$charset = 'CP1252';
}
if (is_object($debugObject)) {
$debugObject->debugLog(1, 'EXIT - ' . $charset);
}
return $this->_charset = $charset;
} | (or the content_type header from the last transfer), we will parse THAT, and if a charset is specified, we will use it over any other mechanism. | entailment |
protected function remove_noise($pattern, $remove_tag = false)
{
global $debugObject;
if (is_object($debugObject)) {
$debugObject->debugLogEntry(1);
}
$count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
for ($i = $count - 1; $i > -1; --$i) {
$key = '___noise___' . sprintf('% 5d', count($this->noise) + 1000);
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'key is: ' . $key);
}
$idx = ($remove_tag) ? 0 : 1;
$this->noise[$key] = $matches[$i][$idx][0];
$this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
}
// reset the length of content
$this->size = strlen($this->doc);
if ($this->size > 0) {
$this->char = $this->doc[0];
}
} | save the noise in the $this->noise array. | entailment |
public function restore_noise($text)
{
global $debugObject;
if (is_object($debugObject)) {
$debugObject->debugLogEntry(1);
}
while (($pos = strpos($text, '___noise___')) !== false) {
// Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
if (strlen($text) > $pos + 15) {
$key = '___noise___' . $text[$pos + 11] . $text[$pos + 12] . $text[$pos + 13] . $text[$pos + 14] . $text[$pos + 15];
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'located key of: ' . $key);
}
if (isset($this->noise[$key])) {
$text = substr($text, 0, $pos) . $this->noise[$key] . substr($text, $pos + 16);
} else {
// do this to prevent an infinite loop.
$text = substr($text, 0, $pos) . 'UNDEFINED NOISE FOR KEY: ' . $key . substr($text, $pos + 16);
}
} else {
// There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
$text = substr($text, 0, $pos) . 'NO NUMERIC NOISE KEY' . substr($text, $pos + 11);
}
}
return $text;
} | restore noise to html content | entailment |
public function setDefaultResponse()
{
$error = [[
'status' => $this->getStatusCode(),
'code' => $this->getCode(),
'source' => ['pointer' => $this->getDescription()],
'title' => strtolower(class_basename($this->exception)),
'detail' => $this->getMessage(),
]];
$this->jsonApiResponse->setStatus($this->getStatusCode());
$this->jsonApiResponse->setErrors($error);
} | Set the default response on $response attribute. Get default value from
methods. | entailment |
public function getDescription()
{
return class_basename($this->exception).
' line '.$this->exception->getLine().
' in '.$this->exception->getFile();
} | Mount the description with exception class, line and file.
@return string | entailment |
public function getStatusCode()
{
if (method_exists($this->exception, 'getStatusCode')) {
$httpCode = $this->exception->getStatusCode();
} else {
$httpCode = config($this->configFile.'.http_code');
}
return $httpCode;
} | Get default http code. Check if exception has getStatusCode() methods.
If not get from config file.
@return int | entailment |
public function getCode($type = 'default')
{
$code = $this->exception->getCode();
if (empty($this->exception->getCode())) {
$code = config($this->configFile.'.codes.'.$type);
}
return $code;
} | Get error code. If code is empty from config file based on type.
@param string $type Code type from config file
@return int | entailment |
public function jsonResponse(Exception $exception)
{
$this->exception = $exception;
$this->jsonApiResponse = new JsonApiResponse;
if ($this->exceptionIsTreated()) {
$this->callExceptionHandler();
} else {
$this->setDefaultResponse();
}
return response()->json(
$this->jsonApiResponse->toArray(),
$this->jsonApiResponse->getStatus()
);
} | Handle the json response. Check if exception is treated. If true call
the specific handler. If false set the default response to be returned.
@param Exception $exception
@return JsonResponse | entailment |
public function validationException(ValidationException $exception)
{
$this->jsonApiResponse->setStatus(422);
$this->jsonApiResponse->setErrors($this->jsonApiFormatErrorMessages($exception));
} | Assign to response attribute the value to ValidationException.
@param ValidationException $exception | entailment |
public function notFoundHttpException(NotFoundHttpException $exception)
{
$statuCode = $exception->getStatusCode();
$error = [[
'status' => $statuCode,
'code' => $this->getCode('not_found_http'),
'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()],
'title' => $this->getDescription($exception),
'detail' => $this->getNotFoundMessage($exception),
]];
$this->jsonApiResponse->setStatus($statuCode);
$this->jsonApiResponse->setErrors($error);
} | Set response parameters to NotFoundHttpException.
@param NotFoundHttpException $exception | entailment |
public function getNotFoundMessage(NotFoundHttpException $exception)
{
$message = ! empty($exception->getMessage()) ? $exception->getMessage() : class_basename($exception);
if (basename($exception->getFile()) === 'RouteCollection.php') {
$message = __('exception::exceptions.not_found_http.message');
}
return $message;
} | Get message based on file. If file is RouteCollection return specific
message.
@param NotFoundHttpException $exception
@return string | entailment |
public function addObjectToFolder(
$repositoryId,
$objectId,
$folderId,
$allVersions = true,
ExtensionDataInterface $extension = null
)
{
$url = $this->getObjectUrl($repositoryId, $objectId);
$queryArray = [
Constants::CONTROL_CMISACTION => Constants::CMISACTION_ADD_OBJECT_TO_FOLDER,
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
Constants::PARAM_FOLDER_ID => $folderId,
Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false',
];
$this->post($url, $queryArray);
} | Adds an existing fileable non-folder object to a folder.
@param string $repositoryId The identifier for the repository.
@param string $objectId The identifier for the object.
@param string $folderId The folder into which the object is to be filed.
@param boolean $allVersions Add all versions of the object to the folder if the repository
supports version-specific filing. Defaults to <code>true</code>.
@param ExtensionDataInterface|null $extension | entailment |
public function removeObjectFromFolder(
$repositoryId,
$objectId,
$folderId = null,
ExtensionDataInterface $extension = null
)
{
$url = $this->getObjectUrl($repositoryId, $objectId);
$queryArray = [
Constants::CONTROL_CMISACTION => Constants::CMISACTION_REMOVE_OBJECT_FROM_FOLDER,
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
Constants::PARAM_FOLDER_ID => $folderId,
];
$this->post($url, $queryArray);
} | Removes an existing fileable non-folder object from a folder.
@param string $repositoryId The identifier for the repository.
@param string $objectId The identifier for the object.
@param string|null $folderId The folder from which the object is to be removed.
If no value is specified, then the repository MUST remove the object from all folders in which it is
currently filed.
@param ExtensionDataInterface|null $extension | entailment |
function start($id, $group = 'default', $doNotTestCacheValidity = false)
{
$data = $this->get($id, $group, $doNotTestCacheValidity);
if ($data !== false) {
echo($data);
return true;
}
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 true if the cache is hit (false else)
@access public | entailment |
function end()
{
$data = ob_get_contents();
ob_end_clean();
$this->save($data, $this->_id, $this->_group);
echo($data);
} | Stop the cache
@access public | entailment |
public function decode($jwsString)
{
$components = explode('.', $jwsString);
if (count($components) !== 3) {
throw new MalformedSignatureException('JWS string must contain 3 dot separated component.');
}
try {
$headers = Json::decode(Base64Url::decode($components[0]));
$payload = Json::decode(Base64Url::decode($components[1]));
} catch (\InvalidArgumentException $e) {
throw new MalformedSignatureException("Cannot decode signature headers and/or payload");
}
return [
'headers' => $headers,
'payload' => $payload
];
} | Only decodes jws string and returns headers and payload. To verify signature use verify method.
@throws MalformedSignatureException
@param $jwsString
@return array(
'headers' => array(),
'payload' => payload data
) | entailment |
public function verify($jwsString, $key, $expectedAlgorithm = null)
{
$jws = $this->decode($jwsString);
$headers = $jws['headers'];
list($dataToSign, $signature) = $this->extractSignature($jwsString);
if (empty($headers['alg'])) {
throw new UnspecifiedAlgorithmException("No algorithm information found in headers. alg header parameter is required.");
}
if ($expectedAlgorithm !== null && strtolower($headers['alg']) !== strtolower($expectedAlgorithm)) {
throw new UnexpectedAlgorithmException(sprintf("Algorithm '%s' is not expected. Expected algorithm is '%s'",
$headers['alg'], $expectedAlgorithm));
}
$algorithm = $this->_getAlgorithm($headers['alg']);
if (!$algorithm->verify($key, $dataToSign, Base64Url::decode($signature))) {
throw new InvalidSignatureException("Invalid signature");
}
return $jws;
} | @param $jwsString
@param $key
@param $expectedAlgorithm
@throws UnspecifiedAlgorithmException
@throws MalformedSignatureException
@throws UnspecifiedAlgorithmException
@throws InvalidSignatureException
@throws UnexpectedAlgorithmException
@return array(
'headers' => array(),
'payload' => mixed payload data
) | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('akeneo_measure');
$rootNode->children()
->arrayNode('measures_config')
->prototype('array')
->children()
// standard unit (used as reference for conversion)
->scalarNode('standard')
->isRequired()
->end()
// units of this group
->arrayNode('units')
->prototype('array')
->children()
->append($this->addConvertNode())
->scalarNode('symbol')
->isRequired()
->end()
->end()
->end();
return $treeBuilder;
} | {@inheritDoc} | entailment |
protected function addConvertNode()
{
$treeBuilder = new TreeBuilder();
$node = $treeBuilder->root('convert');
$node->requiresAtLeastOneElement()
->prototype('array')
->children()
->scalarNode('add')
->cannotBeEmpty()
->end()
->scalarNode('sub')
->cannotBeEmpty()
->end()
->scalarNode('mul')
->cannotBeEmpty()
->end()
->scalarNode('div')
->cannotBeEmpty()
->end()
->end()
->end();
return $node;
} | Create a node definition for operations (could be extended to define new operations)
@return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|
\Symfony\Component\Config\Definition\Builder\NodeDefinition | entailment |
public function perform($targetDocument)
{
$pointer = new Pointer($targetDocument);
try {
$get = $pointer->get($this->getPath());
} catch (NonexistentValueReferencedException $e) {
return $targetDocument;
}
$targetDocument = json_decode($targetDocument);
$this->replace(
$targetDocument,
$this->getPointerParts(),
$this->getValue()
);
return json_encode($targetDocument, JSON_UNESCAPED_UNICODE);
} | @param string $targetDocument
@throws \Rs\Json\Patch\InvalidOperationException
@throws \Rs\Json\Pointer\InvalidJsonException
@throws \Rs\Json\Pointer\InvalidPointerException
@throws \Rs\Json\Pointer\NonWalkableJsonException
@throws \RuntimeException
@return string | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/products.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Product::class, $response['products']);
} | Receive a lists of all Products
@link https://help.shopify.com/api/reference/product#index
@param array $params
@return Product[] | entailment |
public function get($productId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = $fields;
}
$endpoint = '/admin/products/'.$productId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Product::class, $response['product']);
} | Receive a single product
@link https://help.shopify.com/api/reference/product#show
@param integer $productId
@param array $fields
@return Product | entailment |
public function create(Product &$product)
{
$data = $product->exportData();
$endpoint = '/admin/products.json';
$response = $this->request(
$endpoint, 'POST', array(
'product' => $data
)
);
$product->setData($response['product']);
} | Create a new Product
@link https://help.shopify.com/api/reference/product#create
@param Product $product
@return void | entailment |
public function update(Product &$product)
{
$data = $product->exportData();
$endpoint = '/admin/products/'.$product->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'product' => $data
)
);
$product->setData($response['product']);
} | Modify an existing product
@link https://help.shopify.com/api/reference/product#update
@param Product $product
@return void | entailment |
public function createType($repositoryId, TypeDefinitionInterface $type, ExtensionDataInterface $extension = null)
{
$url = $this->getRepositoryUrl($repositoryId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_CREATE_TYPE,
Constants::CONTROL_TYPE => $this->getJsonConverter()->convertFromTypeDefinition($type)
]
);
return $this->getJsonConverter()->convertTypeDefinition($this->postJson($url));
} | Creates a new type.
@param string $repositoryId The identifier for the repository.
@param TypeDefinitionInterface $type A fully populated type definition including all new property definitions.
@param ExtensionDataInterface|null $extension
@return TypeDefinitionInterface | entailment |
public function deleteType($repositoryId, $typeId, ExtensionDataInterface $extension = null)
{
$url = $this->getRepositoryUrl($repositoryId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE_TYPE,
Constants::CONTROL_TYPE_ID => $typeId
]
);
$this->post($url);
} | Deletes a type.
@param string $repositoryId The identifier for the repository.
@param string $typeId The typeId of an object-type specified in the repository.
@param ExtensionDataInterface|null $extension | entailment |
public function getRepositoryInfo($repositoryId, ExtensionDataInterface $extension = null)
{
foreach ($this->getRepositoriesInternal($repositoryId) as $repositoryInfo) {
if ($repositoryInfo->getId() === $repositoryId) {
return $repositoryInfo;
}
}
throw new CmisObjectNotFoundException(sprintf('Repository "%s" not found!', $repositoryId));
} | Returns information about the CMIS repository, the optional capabilities it
supports and its access control information if applicable.
@param string $repositoryId The identifier for the repository.
@param ExtensionDataInterface|null $extension
@throws CmisObjectNotFoundException
@return RepositoryInfoInterface | entailment |
public function getTypeChildren(
$repositoryId,
$typeId = null,
$includePropertyDefinitions = false,
$maxItems = null,
$skipCount = 0,
ExtensionDataInterface $extension = null
) {
$url = $this->getRepositoryUrl($repositoryId, Constants::SELECTOR_TYPE_CHILDREN);
$url->getQuery()->modify(
[
Constants::PARAM_PROPERTY_DEFINITIONS => $includePropertyDefinitions ? 'true' : 'false',
Constants::PARAM_SKIP_COUNT => $skipCount,
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
]
);
if ($typeId !== null) {
$url->getQuery()->modify([Constants::PARAM_TYPE_ID => $typeId]);
}
if ($maxItems !== null) {
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => $maxItems]);
}
$responseData = (array) $this->readJson($url);
return $this->getJsonConverter()->convertTypeChildren($responseData);
} | Returns the list of object types defined for the repository that are children of the specified type.
@param string $repositoryId the identifier for the repository
@param string|null $typeId the typeId of an object type specified in the repository
(if not specified the repository MUST return all base object types)
@param boolean $includePropertyDefinitions if <code>true</code> the repository MUST return the property
definitions for each object type returned (default is <code>false</code>)
@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 TypeDefinitionListInterface | entailment |
public function getTypeDefinition(
$repositoryId,
$typeId,
ExtensionDataInterface $extension = null,
$useCache = true
) {
$cache = null;
$cacheKey = $repositoryId . '-' . $typeId;
// if the cache should be used and the extension is not set, check the cache first
if ($useCache === true && empty($extension)) {
$cache = $this->cmisBindingsHelper->getTypeDefinitionCache($this->getSession());
if ($cache->contains($cacheKey)) {
return $cache->fetch($cacheKey);
}
}
$typeDefinition = $this->getTypeDefinitionInternal($repositoryId, $typeId);
if ($useCache === true && empty($extension)) {
$cache->save($cacheKey, $typeDefinition);
}
return $typeDefinition;
} | Gets the definition of the specified object type.
@param string $repositoryId the identifier for the repository
@param string $typeId he type definition
@param ExtensionDataInterface|null $extension
@param boolean $useCache
@return TypeDefinitionInterface|null the newly created type | entailment |
public function getTypeDescendants(
$repositoryId,
$typeId = null,
$depth = null,
$includePropertyDefinitions = false,
ExtensionDataInterface $extension = null
) {
$url = $this->getRepositoryUrl($repositoryId, Constants::SELECTOR_TYPE_DESCENDANTS);
$url->getQuery()->modify(
[
Constants::PARAM_PROPERTY_DEFINITIONS => $includePropertyDefinitions ? 'true' : 'false',
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
]
);
if ($typeId !== null) {
$url->getQuery()->modify([Constants::PARAM_TYPE_ID => $typeId]);
}
if ($depth !== null) {
$url->getQuery()->modify([Constants::PARAM_DEPTH => $depth]);
}
$responseData = (array) $this->readJson($url);
return $this->getJsonConverter()->convertTypeDescendants($responseData);
} | Returns the set of descendant object type defined for the repository under the specified type.
@param string $repositoryId repositoryId - the identifier for the repository
@param string|null $typeId the typeId of an object type specified in the repository
(if not specified the repository MUST return all types and MUST ignore the value of the depth parameter)
@param integer|null $depth the number of levels of depth in the type hierarchy from which
to return results (default is repository specific)
@param boolean $includePropertyDefinitions if <code>true</code> the repository MUST return the property
definitions for each object type returned (default is <code>false</code>)
@param ExtensionDataInterface|null $extension
@return TypeDefinitionContainerInterface[] | entailment |
public function updateType($repositoryId, TypeDefinitionInterface $type, ExtensionDataInterface $extension = null)
{
$url = $this->getRepositoryUrl($repositoryId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_UPDATE_TYPE,
Constants::CONTROL_TYPE => json_encode($this->getJsonConverter()->convertFromTypeDefinition($type))
]
);
return $this->getJsonConverter()->convertTypeDefinition($this->postJson($url));
} | Updates a type.
@param string $repositoryId the identifier for the repository
@param TypeDefinitionInterface $type the type definition
@param ExtensionDataInterface|null $extension
@return TypeDefinitionInterface the updated type | entailment |
public function getRenditionDocument(OperationContextInterface $context = null)
{
$renditionDocumentId = $this->getRenditionDocumentId();
if (empty($renditionDocumentId)) {
return null;
}
if ($context === null) {
$context = $this->session->getDefaultContext();
}
$document = $this->session->getObject($this->session->createObjectId($renditionDocumentId), $context);
return $document instanceof DocumentInterface ? $document : null;
} | Returns the rendition document using the provides OperationContext if the rendition is a stand-alone document.
@param OperationContextInterface|null $context
@return DocumentInterface|null the rendition document or <code>null</code> if there is no rendition document | entailment |
public function getContentStream()
{
if (!$this->objectId || !$this->getStreamId()) {
return null;
}
return $this->session->getBinding()->getObjectService()->getContentStream(
$this->session->getRepositoryInfo()->getId(),
$this->objectId,
$this->getStreamId()
);
} | Returns the content stream of the rendition.
@return StreamInterface|null the content stream of the rendition
or <code>null</code> if the rendition has no content | entailment |
public function getContentUrl()
{
$objectService = $this->session->getBinding()->getObjectService();
if ($objectService instanceof LinkAccessInterface) {
return $objectService->loadRenditionContentLink(
$this->session->getRepositoryInfo()->getId(),
$this->objectId,
$this->getStreamId()
);
}
return null;
} | Returns the content URL of the rendition if the binding supports content
URLs.
Depending on the repository and the binding, the server might not return
the content but an error message. Authentication data is not attached.
That is, a user may have to re-authenticate to get the content.
@return string|null the content URL of the rendition or <code>null</code> if the binding
does not support content URLs | entailment |
protected function createObjectFactory()
{
try {
if (isset($this->parameters[SessionParameter::OBJECT_FACTORY_CLASS])) {
$objectFactoryClass = new $this->parameters[SessionParameter::OBJECT_FACTORY_CLASS];
} else {
$objectFactoryClass = $this->createDefaultObjectFactoryInstance();
}
if (!($objectFactoryClass instanceof ObjectFactoryInterface)) {
throw new \RuntimeException('Class does not implement ObjectFactoryInterface!', 1408354119);
}
$objectFactoryClass->initialize($this, $this->parameters);
return $objectFactoryClass;
} catch (\Exception $exception) {
throw new \RuntimeException(
'Unable to create object factory: ' . $exception,
1408354120
);
}
} | Create an object factory based on the SessionParameter::OBJECT_FACTORY_CLASS. If not set it returns an instance
of ObjectFactory.
@return ObjectFactoryInterface
@throws \RuntimeException | entailment |
protected function createCache()
{
try {
if (isset($this->parameters[SessionParameter::CACHE_CLASS])) {
$cache = new $this->parameters[SessionParameter::CACHE_CLASS];
} else {
$cache = $this->createDefaultCacheInstance();
}
if (!($cache instanceof CacheProvider)) {
throw new \RuntimeException(
sprintf(
'Class %s does not subclass %s!',
get_class($cache),
CacheProvider::class
),
1408354124
);
}
return $cache;
} catch (\Exception $exception) {
throw new CmisInvalidArgumentException(
'Unable to create cache: ' . $exception,
1408354123
);
}
} | Create a cache instance based on the given session parameter SessionParameter::CACHE_CLASS.
If no session parameter SessionParameter::CACHE_CLASS is defined, the default Cache implementation will be used.
@return Cache
@throws \InvalidArgumentException | entailment |
public function createDocument(
array $properties,
ObjectIdInterface $folderId = null,
StreamInterface $contentStream = null,
VersioningState $versioningState = null,
array $policies = [],
array $addAces = [],
array $removeAces = []
) {
if (empty($properties)) {
throw new CmisInvalidArgumentException('Properties must not be empty!');
}
$objectId = $this->getBinding()->getObjectService()->createDocument(
$this->getRepositoryId(),
$this->getObjectFactory()->convertProperties(
$properties,
null,
[],
self::$createAndCheckoutUpdatability
),
$folderId === null ? null : $folderId->getId(),
$contentStream,
$versioningState,
$this->getObjectFactory()->convertPolicies($policies),
$this->getObjectFactory()->convertAces($addAces),
$this->getObjectFactory()->convertAces($removeAces),
null
);
if ($objectId === null) {
return null;
}
return $this->createObjectId($objectId);
} | Creates a new document. The stream in contentStream is consumed but not closed by this method.
@param string[] $properties The property values that MUST be applied to the newly-created document object.
@param ObjectIdInterface|null $folderId If specified, the identifier for the folder that MUST be the parent
folder for the newly-created document object. This parameter MUST be specified if the repository does NOT
support the optional "unfiling" capability.
@param StreamInterface|null $contentStream The content stream that MUST be stored for the newly-created document
object. The method of passing the contentStream to the server and the encoding mechanism will be specified
by each specific binding. MUST be required if the type requires it.
@param VersioningState|null $versioningState An enumeration specifying what the versioning state of the
newly-created object MUST be. Valid values are:
<code>none</code>
(default, if the object-type is not versionable) The document MUST be created as a non-versionable
document.
<code>checkedout</code>
The document MUST be created in the checked-out state. The checked-out document MAY be
visible to other users.
<code>major</code>
(default, if the object-type is versionable) The document MUST be created as a major version.
<code>minor</code>
The document MUST be created as a minor version.
@param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created
document object.
@param AceInterface[] $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 AceInterface[] $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.
@return ObjectIdInterface|null the object ID of the new document or <code>null</code> if the document could not
be created.
@throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty
property list is given | entailment |
public function createDocumentFromSource(
ObjectIdInterface $source,
array $properties = [],
ObjectIdInterface $folderId = null,
VersioningState $versioningState = null,
array $policies = [],
array $addAces = [],
array $removeAces = []
) {
if (!$source instanceof CmisObjectInterface) {
$sourceObject = $this->getObject($source);
} else {
$sourceObject = $source;
}
$type = $sourceObject->getType();
$secondaryTypes = $sourceObject->getSecondaryTypes();
if ($secondaryTypes === null) {
$secondaryTypes = [];
}
if (!BaseTypeId::cast($type->getBaseTypeId())->equals(BaseTypeId::CMIS_DOCUMENT)) {
throw new CmisInvalidArgumentException('Source object must be a document!');
}
$objectId = $this->getBinding()->getObjectService()->createDocumentFromSource(
$this->getRepositoryId(),
$source->getId(),
$this->getObjectFactory()->convertProperties(
$properties,
$type,
$secondaryTypes,
self::$createAndCheckoutUpdatability
),
$folderId === null ? null : $folderId->getId(),
$versioningState,
$this->getObjectFactory()->convertPolicies($policies),
$this->getObjectFactory()->convertAces($addAces),
$this->getObjectFactory()->convertAces($removeAces),
null
);
if ($objectId === null) {
return null;
}
return $this->createObjectId($objectId);
} | Creates a new document from a source document.
@param ObjectIdInterface $source The identifier for the source document.
@param string[] $properties The property values that MUST be applied to the object. This list of properties
SHOULD only contain properties whose values differ from the source document.
@param ObjectIdInterface|null $folderId If specified, the identifier for the folder that MUST be the parent
folder for the newly-created document object. This parameter MUST be specified if the repository does NOT
support the optional "unfiling" capability.
@param VersioningState|null $versioningState An enumeration specifying what the versioning state of the
newly-created object MUST be. Valid values are:
<code>none</code>
(default, if the object-type is not versionable) The document MUST be created as a non-versionable
document.
<code>checkedout</code>
The document MUST be created in the checked-out state. The checked-out document MAY be
visible to other users.
<code>major</code>
(default, if the object-type is versionable) The document MUST be created as a major version.
<code>minor</code>
The document MUST be created as a minor version.
@param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created
document object.
@param AceInterface[] $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 AceInterface[] $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.
@return ObjectIdInterface|null the object ID of the new document or <code>null</code> if the document could not
be created.
@throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty
property list is given | entailment |
public function createFolder(
array $properties,
ObjectIdInterface $folderId,
array $policies = [],
array $addAces = [],
array $removeAces = []
) {
if (empty($properties)) {
throw new CmisInvalidArgumentException('Properties must not be empty!');
}
$objectId = $this->getBinding()->getObjectService()->createFolder(
$this->getRepositoryId(),
$this->getObjectFactory()->convertProperties($properties),
$folderId->getId(),
$this->getObjectFactory()->convertPolicies($policies),
$this->getObjectFactory()->convertAces($addAces),
$this->getObjectFactory()->convertAces($removeAces),
null
);
return $this->createObjectId($objectId);
} | Creates a new folder.
@param string[] $properties
@param ObjectIdInterface $folderId
@param PolicyInterface[] $policies
@param AceInterface[] $addAces
@param AceInterface[] $removeAces
@return ObjectIdInterface the object ID of the new folder
@throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code> if empty
property list is given | entailment |
public function createOperationContext(
$filter = [],
$includeAcls = false,
$includeAllowableActions = true,
$includePolicies = false,
IncludeRelationships $includeRelationships = null,
array $renditionFilter = [],
$includePathSegments = true,
$orderBy = null,
$cacheEnabled = false,
$maxItemsPerPage = 100
) {
$operationContext = new OperationContext();
$operationContext->setFilter($filter);
$operationContext->setIncludeAcls($includeAcls);
$operationContext->setIncludeAllowableActions($includeAllowableActions);
$operationContext->setIncludePolicies($includePolicies);
if ($includeRelationships !== null) {
$operationContext->setIncludeRelationships($includeRelationships);
}
$operationContext->setRenditionFilter($renditionFilter);
$operationContext->setIncludePathSegments($includePathSegments);
if (!empty($orderBy)) {
$operationContext->setOrderBy($orderBy);
}
$operationContext->setCacheEnabled($cacheEnabled);
$operationContext->setMaxItemsPerPage($maxItemsPerPage);
return $operationContext;
} | Creates a new operation context object with the given properties.
@param string[] $filter the property filter, a comma separated string of query names or "*" for all
properties or <code>null</code> to let the repository determine a set of properties
@param boolean $includeAcls indicates whether ACLs should be included or not
@param boolean $includeAllowableActions indicates whether Allowable Actions should be included or not
@param boolean $includePolicies indicates whether policies should be included or not
@param IncludeRelationships|null $includeRelationships enum that indicates if and which
relationships should be includes
@param string[] $renditionFilter the rendition filter or <code>null</code> for no renditions
@param boolean $includePathSegments indicates whether path segment or the relative path segment should
be included or not
@param string|null $orderBy the object order, a comma-separated list of query names and the ascending
modifier "ASC" or the descending modifier "DESC" for each query name
@param boolean $cacheEnabled flag that indicates if the object cache should be used
@param integer $maxItemsPerPage the max items per page/batch
@return OperationContextInterface the newly created operation context object | entailment |
public function createQueryStatement(
array $selectPropertyIds,
array $fromTypes,
$whereClause = null,
array $orderByPropertyIds = []
) {
if (empty($selectPropertyIds)) {
throw new CmisInvalidArgumentException('Select property IDs must not be empty');
}
if (empty($fromTypes)) {
throw new CmisInvalidArgumentException('From types must not be empty');
}
return new QueryStatement($this, null, $selectPropertyIds, $fromTypes, $whereClause, $orderByPropertyIds);
} | Creates a query statement for a query of one primary type joined by zero or more secondary types.
Generates something like this:
`SELECT d.cmis:name,s.SecondaryStringProp FROM cmis:document AS d JOIN MySecondaryType AS s ON
d.cmis:objectId=s.cmis:objectId WHERE d.cmis:name LIKE ? ORDER BY d.cmis:name,s.SecondaryIntegerProp`
@param string[] $selectPropertyIds the property IDs in the SELECT statement,
if <code>null</code> all properties are selected
@param string[] $fromTypes a Map of type aliases (keys) and type IDs (values), the Map must contain
exactly one primary type and zero or more secondary types
@param string|null $whereClause an optional WHERE clause with placeholders ('?'), see QueryStatement for details
@param string[] $orderByPropertyIds an optional list of properties IDs for the ORDER BY clause
@return QueryStatementInterface a new query statement object
@throws CmisInvalidArgumentException | entailment |
public function createRelationship(
array $properties,
array $policies = [],
array $addAces = [],
array $removeAces = []
) {
if (empty($properties)) {
throw new CmisInvalidArgumentException('Properties must not be empty!');
}
$newObjectId = $this->getBinding()->getObjectService()->createRelationship(
$this->getRepositoryId(),
$this->getObjectFactory()->convertProperties($properties, null, [], self::$createUpdatability),
$this->getObjectFactory()->convertPolicies($policies),
$this->getObjectFactory()->convertAces($addAces),
$this->getObjectFactory()->convertAces($removeAces)
);
if ($newObjectId === null) {
return null;
}
return $this->createObjectId($newObjectId);
} | Creates a new relationship between 2 objects.
@param string[] $properties
@param PolicyInterface[] $policies
@param AceInterface[] $addAces
@param AceInterface[] $removeAces
@return ObjectIdInterface|null the object ID of the new relationship or <code>null</code> if the relationship
could not be created | entailment |
public function createType(TypeDefinitionInterface $type)
{
if ($this->getRepositoryInfo()->getCmisVersion() == CmisVersion::cast(CmisVersion::CMIS_1_0)) {
throw new CmisNotSupportedException('This method is not supported for CMIS 1.0 repositories.');
}
return $this->convertTypeDefinition(
$this->getBinding()->getRepositoryService()->createType($this->getRepositoryInfo()->getId(), $type)
);
} | Creates a new type.
@param TypeDefinitionInterface $type
@return ObjectTypeInterface the new type definition
@throws CmisNotSupportedException If repository version 1.0 | entailment |
public function delete(ObjectIdInterface $objectId, $allVersions = true)
{
$this->getBinding()->getObjectService()->deleteObject(
$this->getRepositoryId(),
$objectId->getId(),
$allVersions
);
$this->removeObjectFromCache($objectId);
} | Deletes an object and, if it is a document, all versions in the version series.
@param ObjectIdInterface $objectId the ID of the object
@param boolean $allVersions if this object is a document this parameter defines
if only this version or all versions should be deleted | entailment |
public function deleteType($typeId)
{
if ($this->getRepositoryInfo()->getCmisVersion() == CmisVersion::cast(CmisVersion::CMIS_1_0)) {
throw new CmisNotSupportedException('This method is not supported for CMIS 1.0 repositories.');
}
$this->getBinding()->getRepositoryService()->deleteType($this->getRepositoryId(), $typeId);
$this->removeObjectFromCache($this->createObjectId($typeId));
} | Deletes a type.
@param string $typeId the ID of the type to delete
@throws CmisNotSupportedException If repository version 1.0 | entailment |
public function getContentChanges(
$changeLogToken,
$includeProperties,
$maxNumItems = null,
OperationContextInterface $context = null
) {
if ($context === null) {
$context = $this->getDefaultContext();
}
$objectList = $this->getBinding()->getDiscoveryService()->getContentChanges(
$this->getRepositoryInfo()->getId(),
$changeLogToken,
$includeProperties,
$context->isIncludePolicies(),
$context->isIncludeAcls(),
$maxNumItems
);
return $this->getObjectFactory()->convertChangeEvents($changeLogToken, $objectList);
} | Returns the content changes.
@param string $changeLogToken the change log token to start from or <code>null</code> to start from
the first available event in the repository
@param boolean $includeProperties indicates whether changed properties should be included in the result or not
@param integer|null $maxNumItems maximum numbers of events
@param OperationContextInterface|null $context the OperationContext
@return ChangeEventsInterface the change events | entailment |
public function getContentStream(ObjectIdInterface $docId, $streamId = null, $offset = null, $length = null)
{
return $this->getBinding()->getObjectService()->getContentStream(
$this->getRepositoryId(),
$docId->getId(),
$streamId,
$offset,
$length
);
} | Retrieves the main content stream of a document.
@param ObjectIdInterface $docId the ID of the document
@param string|null $streamId the stream ID
@param integer|null $offset the offset of the stream or <code>null</code> to read the stream from the beginning
@param integer|null $length the maximum length of the stream or <code>null</code> to read to the end of the
stream
@return StreamInterface|null the content stream or <code>null</code> if the
document has no content stream | entailment |
public function getObjectByPath($path, OperationContextInterface $context = null)
{
if (empty($path)) {
throw new CmisInvalidArgumentException('Path must not be empty.');
}
if ($context === null) {
$context = $this->getDefaultContext();
}
$objectData = $this->getBinding()->getObjectService()->getObjectByPath(
$this->getRepositoryInfo()->getId(),
$path,
$context->getQueryFilterString(),
$context->isIncludeAllowableActions(),
$context->getIncludeRelationships(),
$context->getRenditionFilterString(),
$context->isIncludePolicies(),
$context->isIncludeAcls()
);
if (!$objectData instanceof ObjectDataInterface) {
throw new CmisObjectNotFoundException(sprintf('Could not find object for given path "%s".', $path));
}
// TODO: Implement cache!
return $this->getObjectFactory()->convertObject($objectData, $context);
} | Returns a CMIS object from the session cache. If the object is not in the cache or the given OperationContext
has caching turned off, it will load the object from the repository and puts it into the cache.
This method might return a stale object if the object has been found in the cache and has been changed in or
removed from the repository. Use CmisObject::refresh() and CmisObject::refreshIfOld() to update the object
if necessary.
@param string $path the object path
@param OperationContextInterface|null $context the OperationContext to use
@return CmisObjectInterface Returns a CMIS object from the session cache.
@throws CmisInvalidArgumentException Throws an <code>CmisInvalidArgumentException</code>
if path is empty.
@throws CmisObjectNotFoundException - if an object with the given path doesn't exist | entailment |
public function getRelationships(
ObjectIdInterface $objectId,
$includeSubRelationshipTypes,
RelationshipDirection $relationshipDirection,
ObjectTypeInterface $type,
OperationContextInterface $context = null
) {
if ($context === null) {
$context = $this->getDefaultContext();
}
// TODO: Implement cache!
return $this->getBinding()->getRelationshipService()->getObjectRelationships(
$this->getRepositoryId(),
$objectId->getId(),
$includeSubRelationshipTypes,
$relationshipDirection,
$type->getId()
);
} | Fetches the relationships from or to an object from the repository.
@param ObjectIdInterface $objectId
@param boolean $includeSubRelationshipTypes
@param RelationshipDirection $relationshipDirection
@param ObjectTypeInterface $type
@param OperationContextInterface|null $context
@return RelationshipInterface[] | entailment |
public function getRootFolder(OperationContextInterface $context = null)
{
$rootFolderId = $this->getRepositoryInfo()->getRootFolderId();
$rootFolder = $this->getObject(
$this->createObjectId($rootFolderId),
$context === null ? $this->getDefaultContext() : $context
);
if (!($rootFolder instanceof FolderInterface)) {
throw new CmisRuntimeException('Root folder object is not a folder!', 1423735889);
}
return $rootFolder;
} | Gets the root folder of the repository with the given OperationContext.
@param OperationContextInterface|null $context
@return FolderInterface the root folder object
@throws CmisRuntimeException | entailment |
public function getTypeChildren($typeId, $includePropertyDefinitions)
{
return $this->getBinding()->getRepositoryService()->getTypeChildren(
$this->getRepositoryId(),
$typeId,
$includePropertyDefinitions,
999, // set max items to 999 - TODO: Implement CollectionIterable() method to iterate over all objects.
0 // TODO: Implement CollectionIterable() method to iterate over all objects.
);
} | Gets the type children of a type.
@param string $typeId the type ID or <code>null</code> to request the base types
@param boolean $includePropertyDefinitions indicates whether the property definitions should be included or not
@return TypeDefinitionListInterface the type iterator
@throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist | entailment |
public function getTypeDefinition($typeId, $useCache = true)
{
// TODO: Implement cache!
$typeDefinition = $this->getBinding()->getRepositoryService()->getTypeDefinition(
$this->getRepositoryId(),
$typeId
);
return $this->convertTypeDefinition($typeDefinition);
} | Gets the definition of a type.
@param string $typeId the ID of the type
@param boolean $useCache specifies if the type definition should be first looked up in the type definition
cache, if it is set to <code>false</code> or the type definition is not in the cache, the type definition is
loaded from the repository
@return ObjectTypeInterface the type definition
@throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist | entailment |
public function getTypeDescendants($typeId, $depth, $includePropertyDefinitions)
{
return $this->getBinding()->getRepositoryService()->getTypeDescendants(
$this->getRepositoryId(),
$typeId,
(integer) $depth,
$includePropertyDefinitions
);
} | Gets the type descendants of a type.
@param string $typeId the type ID or <code>null</code> to request the base types
@param integer $depth indicates whether the property definitions should be included or not
@param boolean $includePropertyDefinitions the tree depth, must be greater than 0 or -1 for infinite depth
@return TypeDefinitionContainerInterface[] A tree that contains ObjectTypeInterface objects
@see ObjectTypeInterface ObjectTypeInterface contained in returned Tree
@throws CmisObjectNotFoundException - if a type with the given type ID doesn't exist | entailment |
public function query($statement, $searchAllVersions = false, OperationContextInterface $context = null)
{
if (empty($statement)) {
throw new CmisInvalidArgumentException('Statement must not be empty.');
}
if ($context === null) {
$context = $this->getDefaultContext();
}
$queryResults = [];
$skipCount = 0;
$objectList = $this->getBinding()->getDiscoveryService()->query(
$this->getRepositoryInfo()->getId(),
$statement,
$searchAllVersions,
$context->getIncludeRelationships(),
$context->getRenditionFilterString(),
$context->isIncludeAllowableActions(),
$context->getMaxItemsPerPage(),
$skipCount
);
foreach ($objectList->getObjects() as $objectData) {
$queryResult = $this->getObjectFactory()->convertQueryResult($objectData);
if ($queryResult instanceof QueryResultInterface) {
$queryResults[] = $queryResult;
}
}
// TODO: Implement pagination using skipCount
return $queryResults;
} | Sends a query to the repository using the given OperationContext. (See CMIS spec "2.1.10 Query".)
@param string $statement the query statement (CMIS query language)
@param boolean $searchAllVersions specifies whether non-latest document versions should be included or not,
<code>true</code> searches all document versions, <code>false</code> only searches latest document versions
@param OperationContextInterface|null $context the operation context to use
@return QueryResultInterface[]
@throws CmisInvalidArgumentException If statement is empty | entailment |
public function queryObjects(
$typeId,
$where = null,
$searchAllVersions = false,
OperationContextInterface $context = null
) {
if (empty($typeId)) {
throw new CmisInvalidArgumentException('Type id must not be empty.');
}
if ($context === null) {
$context = $this->getDefaultContext();
}
$queryFilterString = $context->getQueryFilterString();
if (!empty($queryFilterString)) {
$querySelect = $queryFilterString;
} else {
$querySelect = '*';
}
$whereClause = '';
if (!empty($where)) {
$whereClause = ' WHERE ' . $where;
}
$orderBy = $context->getOrderBy();
if (!empty($orderBy)) {
$orderBy = ' ORDER BY ' . $orderBy;
}
$typeDefinition = $this->getTypeDefinition($typeId);
$statement = 'SELECT ' . $querySelect . ' FROM ' . $typeDefinition->getQueryName() . $whereClause . $orderBy;
$queryStatement = new QueryStatement($this, $statement);
$resultObjects = [];
$skipCount = 0;
$objectList = $this->getBinding()->getDiscoveryService()->query(
$this->getRepositoryInfo()->getId(),
$queryStatement->toQueryString(),
$searchAllVersions,
$context->getIncludeRelationships(),
$context->getRenditionFilterString(),
$context->isIncludeAllowableActions(),
$context->getMaxItemsPerPage(),
$skipCount
);
foreach ($objectList->getObjects() as $objectData) {
$object = $this->getObjectFactory()->convertObject($objectData, $context);
if ($object instanceof CmisObjectInterface) {
$resultObjects[] = $object;
}
}
// TODO: Implement pagination using skipCount
return $resultObjects;
} | Builds a CMIS query and returns the query results as an iterator of CmisObject objects.
@param string $typeId the ID of the object type
@param string|null $where the WHERE part of the query
@param boolean $searchAllVersions specifies whether non-latest document versions should be included or not,
<code>true</code> searches all document versions, <code>false</code> only searches latest document versions
@param OperationContextInterface|null $context the operation context to use
@return CmisObjectInterface[]
@throws CmisInvalidArgumentException If type id is empty | entailment |
public function all($productId, array $params = array())
{
$endpoint = '/admin/products/'.$productId.'/variants.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(ProductVariant::class, $response['variants']);
} | Receive a list of Product Variants
@link https://help.shopify.com/api/reference/product_variant#index
@param integer $productId
@param array $params
@return ProductVariant[] | entailment |
public function get($productVariantId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = $fields;
}
$endpoint = '/admin/variants/'.$productVariantId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(ProductVariant::class, $response['variant']);
} | Receive a single product variant
@link https://help.shopify.com/api/reference/product_variant#show
@param integer $productVariantId
@param array $fields
@return ProductVariant | entailment |
public function create($productId, ProductVariant &$productVariant)
{
$data = $productVariant->exportData();
$endpoint = '/admin/products/'.$productId.'/variants.json';
$response = $this->request(
$endpoint, 'POST', array(
'variant' => $data
)
);
$productVariant->setData($response['variant']);
} | Create a new product variant
@link https://help.shopify.com/api/reference/product_variant#create
@param integer $productId
@param ProductVariant $productVariant
@return void | entailment |
public function update(ProductVariant &$productVariant)
{
$data = $productVariant->exportData();
$endpoint = '/admin/variants/'.$productVariant->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'variant' => $data
)
);
$productVariant->setData($response['variant']);
} | Modify an existing product variant
@link https://help.shopify.com/api/reference/product_variant#update
@param ProductVariant $productVariant
@return void | entailment |
public function delete($productId, ProductVariant &$productVariant)
{
$endpoint = '/admin/products/'.$productId.'/variants/'.$productVariant->id.'.json';
$response = $this->request($endpoint, 'DELETE');
} | Delete a product variant
@link https://help.shopify.com/api/reference/product_variant#destroy
@param integer $productId
@param ProductVariant $productVariant
@return void | entailment |
public function perform($targetDocument)
{
$pointer = new Pointer($targetDocument);
try {
$get = $pointer->get($this->getFrom());
} catch (NonexistentValueReferencedException $e) {
return $targetDocument;
}
if ($this->getFrom() === $this->getPath()) {
return $targetDocument;
}
$removeOperation = new \stdClass;
$removeOperation->path = $this->getFrom();
$remove = new Remove($removeOperation);
$targetDocument = $remove->perform($targetDocument);
$addOperation = new \stdClass;
$addOperation->path = $this->getPath();
$addOperation->value = $get;
$add = new Add($addOperation);
return $add->perform($targetDocument);
} | @param string $targetDocument
@throws \Rs\Json\Patch\InvalidOperationException
@throws \Rs\Json\Pointer\InvalidJsonException
@throws \Rs\Json\Pointer\InvalidPointerException
@throws \Rs\Json\Pointer\NonWalkableJsonException
@throws \RuntimeException
@return string | entailment |
public function getCheckedOutDocs(
$repositoryId,
$folderId,
$filter = null,
$orderBy = null,
$includeAllowableActions = false,
IncludeRelationships $includeRelationships = null,
$renditionFilter = Constants::RENDITION_NONE,
$maxItems = null,
$skipCount = 0,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_CHECKEDOUT);
$url->getQuery()->modify(
[
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_SKIP_COUNT => (string) $skipCount,
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 (!empty($orderBy)) {
$url->getQuery()->modify([Constants::PARAM_ORDER_BY => $orderBy]);
}
if ($maxItems > 0) {
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
}
if ($includeRelationships !== null) {
$url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
}
$responseData = (array) $this->readJson($url);
// TODO Implement Cache
return $this->getJsonConverter()->convertObjectList($responseData);
} | Gets the list of documents that are checked out that the user has access to.
@param string $repositoryId the identifier for the repository
@param string $folderId the identifier for the folder
@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 string|null $orderBy a comma-separated list of query names that define the order of the result set.
Each query name must be followed by the ascending modifier "ASC" or the descending modifier "DESC"
(default is repository specific)
@param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
actions for each object in the result set (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 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 ObjectListInterface | entailment |
public function getFolderParent(
$repositoryId,
$folderId,
$filter = null,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_PARENT);
$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);
// TODO Implement Cache
return $this->getJsonConverter()->convertObject($responseData);
} | Gets the parent folder object for the specified folder object.
@param string $repositoryId the identifier for the repository
@param string $folderId the identifier for the folder
@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 ObjectDataInterface | entailment |
public function getFolderTree(
$repositoryId,
$folderId,
$depth,
$filter = null,
$includeAllowableActions = false,
IncludeRelationships $includeRelationships = null,
$renditionFilter = Constants::RENDITION_NONE,
$includePathSegment = false,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_FOLDER_TREE);
$url->getQuery()->modify(
[
Constants::PARAM_DEPTH => (string) $depth,
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_PATH_SEGMENT => $includePathSegment ? '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);
// TODO Implement Cache
return $this->getJsonConverter()->convertDescendants($responseData);
} | Gets the set of descendant folder objects contained in the specified folder.
@param string $repositoryId the identifier for the repository
@param string $folderId the identifier for the folder
@param integer $depth the number of levels of depth in the folder hierarchy from which to return results
@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 available
actions for each object in the result set (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 $includePathSegment if <code>true</code>, returns a path segment for each child object for use in
constructing that object's path (default is <code>false</code>)
@param ExtensionDataInterface|null $extension
@return ObjectInFolderContainerInterface[] | entailment |
public function getObjectParents(
$repositoryId,
$objectId,
$filter = null,
$includeAllowableActions = false,
IncludeRelationships $includeRelationships = null,
$renditionFilter = Constants::RENDITION_NONE,
$includeRelativePathSegment = false,
ExtensionDataInterface $extension = null
) {
$url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_PARENTS);
$url->getQuery()->modify(
[
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_RELATIVE_PATH_SEGMENT => $includeRelativePathSegment ? '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);
// TODO Implement Cache
return $this->getJsonConverter()->convertObjectParents($responseData);
} | Gets the parent folder(s) for the specified non-folder, fileable 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 boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
actions for each object in the result set (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 $includeRelativePathSegment if <code>true</code>, returns a relative path segment for each parent
object for use in constructing that object's path (default is <code>false</code>)
@param ExtensionDataInterface|null $extension
@return ObjectParentDataInterface[] | entailment |
public static function convertToSimpleType($object)
{
if (!$object instanceof TypeMutabilityInterface) {
throw new CmisInvalidArgumentException('Given object must be of type TypeMutabilityInterface');
}
$result = [];
$result[JSONConstants::JSON_TYPE_TYPE_MUTABILITY_CREATE] = $object->canCreate();
$result[JSONConstants::JSON_TYPE_TYPE_MUTABILITY_UPDATE] = $object->canUpdate();
$result[JSONConstants::JSON_TYPE_TYPE_MUTABILITY_DELETE] = $object->canDelete();
return $result;
} | Convert given object to a scalar representation or an array of scalar values.
@param TypeMutabilityInterface $object
@return boolean[] Array representation of object
@throws CmisInvalidArgumentException thrown if given object does not implement expected TypeMutabilityInterface | entailment |
public static function match($entry)
{
$entries = preg_split('/' . static::$separatorRegex .'/', $entry);
if (count($entries) == 2) {
foreach ($entries as $ent) {
if (!static::matchIp(trim($ent))) {
return false;
}
}
} else {
return false;
}
return true;
} | {@inheritdoc} | entailment |
public function check($entry)
{
if (!self::matchIp($entry)) {
return false;
}
$entryLong = $this->ip2long($entry);
$range = $this->getRange();
return (bool) $this->IPLongCompare($range['begin'], $entryLong, '<=') && $this->IPLongCompare($range['end'], $entryLong, '>=');
} | {@inheritdoc} | entailment |
protected function getRange($long = true)
{
$parts = $this->getParts();
$keys = array('begin', 'end');
$parts['ip_start'] = $this->ip2long($parts['ip_start']);
$parts['ip_end'] = $this->ip2long($parts['ip_end']);
natsort($parts);
$parts = array_combine($keys, array_values($parts));
if (!$long) {
$parts['begin'] = $this->long2ip($parts['begin']);
$parts['end'] = $this->long2ip($parts['end']);
}
return $parts;
} | Récupérer la plage d'IP valide sous forme d'entier
@param boolean $long Retourner un entier plutot qu'une IP
@return array | entailment |
public function getMatchingEntries()
{
$limits = $this->getRange();
$current = $limits['begin'];
$entries[] = $this->long2ip($current);
$entries = array();
while ($current != $limits['end']) {
$current = $this->IpLongAdd($current, 1);
$entries[] = $this->long2ip($current);
}
return $entries;
} | Calcul et retourne toutes les valeurs possible du range
@return array | entailment |
public function all($countryId, array $params = array())
{
$endpoint = '/admin/countries/'.$countryId.'/provinces.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Province::class, $response['provinces']);
} | Receive a list of all Provinces
@link https://help.shopify.com/api/reference/province#index
@param array $params
@return Province[] | entailment |
public function get($countryId, $provinceId)
{
$endpoint = '/admin/countries/'.$countryId.'/provinces/'.$provinceId.'.json';
$response = $this->request($endpoint);
return $this->createObject(Province::class, $response['province']);
} | Receive a single province
@link https://help.shopify.com/api/reference/province#show
@param integer $countryId
@param integer $provinceId
@return Province | entailment |
public function update($countryId, Province &$province)
{
$data = $province->exportData();
$endpoint = '/admin/countries/'.$countryId.'/provinces/'.$province->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'province' => $data
)
);
$province->setData($response['province']);
} | Modify an existing province
@link https://help.shopify.com/api/reference/province#update
@param Province $province
@return void | entailment |
public function setObjects(array $objects)
{
foreach ($objects as $object) {
$this->checkType(ObjectDataInterface::class, $object);
}
$this->objects = $objects;
} | Sets given list of objects
@param ObjectDataInterface[] $objects | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/recurring_application_charges.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(RecurringApplicationCharge::class, $response['recurring_application_charges']);
} | Retrieve all Recurring Application Charges
@link https://help.shopify.com/api/reference/recurringapplicationcharge#index
@param array $params
@return RecurringApplicationCharge[] | entailment |
public function get($recurringApplicationChargeId, array $params = array())
{
$endpoint = '/admin/recurring_application_charges/'.$recurringApplicationChargeId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(RecurringApplicationCharge::class, $response['recurring_application_charge']);
} | Receive a single recurring application charge
@link https://help.shopify.com/api/reference/recurringapplicationcharge#show
@param integer $recurringApplicationChargeId
@param array $params
@return RecurringApplicationCharge | entailment |
public function create(RecurringApplicationCharge &$recurringApplicationCharge)
{
$data = $recurringApplicationCharge->exportData();
$endpoint = '/admin/recurring_application_charges.json';
$response = $this->request(
$endpoint, 'POST', array(
'recurring_application_charge' => $data
)
);
$recurringApplicationCharge->setData($response['recurring_application_charge']);
} | Create a new recurring application charge
@link https://help.shopify.com/api/reference/recurringapplicationcharge#create
@param RecurringApplicationCharge $recurringApplicationCharge
@return void | entailment |
public function delete(RecurringApplicationCharge $recurringApplicationCharge)
{
$endpoint= '/admin/recurring_application_charges/'.$recurringApplicationCharge->id.'.json';
$response = $this->request($endpoint, 'DELETE');
} | Remove an existing recurring application charge
@link https://help.shopify.com/api/reference/recurringapplicationcharge#destroy
@param RecurringApplicationCharge $recurringApplicationCharge
@return void | entailment |
public function activate(RecurringApplicationCharge $recurringApplicationCharge)
{
$endpoint = '/admin/recurring_application_charges/'.$recurringApplicationCharge->id.'/activate.json';
$response = $this->request($endpoint, 'POST');
$recurringApplicationCharge->setData($response['recurring_application_charge']);
} | Activate a recurring application charge
@link https://help.shopify.com/api/reference/recurringapplicationcharge#activate
@param RecurringApplicationCharge $recurringApplicationCharge
@return boolean | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/blogs.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Blog::class, $response['blogs']);
} | Receive a list of all blogs
@link https://help.shopify.com/api/reference/blog#index
@param array $params
@return Blog[] | entailment |
public function get($blogId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/admin/blogs/'.$blogId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Blog::class, $response['blog']);
} | Receive a single blog
@link https://help.shopify.com/api/reference/blog#show
@param integer $blogId
@param array $fields
@return Blog | entailment |
public function create(Blog &$blog)
{
$data = $blog->exportData();
$endpoint = '/admin/blogs.json';
$response = $this->request(
$endpoint, 'POST', array(
'blog' => $data
)
);
$blog->setData($response['blog']);
} | Create a new blog
@link https://help.shopify.com/api/reference/blog#create
@param Blog $blog
@return void | entailment |
public function setValues(array $values)
{
foreach ($values as $key => $value) {
if (is_integer($value)) {
// cast integer values silenty to a double value.
$values[$key] = $value = (double) $value;
}
$this->checkType('double', $value, true);
}
parent::setValues($values);
} | {@inheritdoc}
@param float[] $values | entailment |
public function getEntryList(array $list, $trusted)
{
$flatten = array();
$this->flattenArray($list, $flatten);
$entries = array();
foreach ($flatten as $elm) {
$entry = $this->getEntry($elm);
if ($entry) {
$entries[] = $entry;
}
}
return new EntryList($entries, $trusted);
} | Get an entry list
@param array $list List of entries
@param bool $trusted Is list trusted?
@return EntryList | entailment |
protected function flattenArray(array $source, array &$dest)
{
foreach ($source as $elm) {
if (is_array($elm)) {
$this->flattenArray($elm, $dest);
} else {
$dest[] = $elm;
}
}
} | Flatten the array
@param array $source
@param array &$dest | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/reports.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Report::class, $response['reports']);
} | Retrieve a list of all Reports
@link https://help.shopify.com/api/reference/report#index
@param array $params
@return Report[] | entailment |
public function get($reportId, array $params = array())
{
$endpoint = '/admin/reports/'.$reportId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Report::class, $response['report']);
} | Receive a single report
@link https://help.shopify.com/api/reference/report#show
@param integer $reportId
@param array $params
@return Report | entailment |
public function create(Report &$report)
{
$data = $report->exportData();
$endpoint = '/admin/reports.json';
$response = $this->request(
$endpoint, 'POST', array(
'report' => $data
)
);
$report->setData($response['report']);
} | Create a new Report
@link https://help.shopify.com/api/reference/report#create
@param Report $report
@return void | entailment |
public function update(Report &$report)
{
$data = $report->exportData();
$endpoint = '/admin/reports/'.$report->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'report' => $data
)
);
$report->setData($response['report']);
} | Modify an existing Report
@link https://help.shopify.com/api/reference/report#update
@param Report $report
@return void | entailment |
public function perform($targetDocument)
{
$pointer = new Pointer($targetDocument);
try {
$get = $pointer->get($this->getFrom());
} catch (NonexistentValueReferencedException $e) {
return $targetDocument;
}
if ($this->getFrom() === $this->getPath()) {
return $targetDocument;
}
$operation = new \stdClass;
$operation->path = $this->getPath();
$operation->value = $get;
$add = new Add($operation);
return $add->perform($targetDocument);
} | @param string $targetDocument
@throws \Rs\Json\Patch\InvalidOperationException
@throws \Rs\Json\Pointer\InvalidJsonException
@throws \Rs\Json\Pointer\InvalidPointerException
@throws \Rs\Json\Pointer\NonWalkableJsonException
@throws \RuntimeException
@return string | entailment |
public function getContentChanges(
$repositoryId,
&$changeLogToken = null,
$includeProperties = false,
$includePolicyIds = false,
$includeAcl = false,
$maxItems = null,
ExtensionDataInterface $extension = null
) {
$url = $this->getRepositoryUrl($repositoryId, Constants::SELECTOR_CONTENT_CHANGES);
$url->getQuery()->modify(
[
Constants::PARAM_PROPERTIES => $includeProperties ? 'true' : 'false',
Constants::PARAM_POLICY_IDS => $includePolicyIds ? 'true' : 'false',
Constants::PARAM_ACL => $includeAcl ? 'true' : 'false',
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
]
);
if ($changeLogToken !== null) {
$url->getQuery()->modify([Constants::PARAM_CHANGE_LOG_TOKEN => (string) $changeLogToken]);
}
if ($maxItems > 0) {
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
}
$responseData = (array) $this->readJson($url);
// $changeLogToken was passed by reference. The value is changed here
$changeLogToken = $responseData[JSONConstants::JSON_OBJECTLIST_CHANGE_LOG_TOKEN] ?? null;
// TODO Implement Cache
return $this->getJsonConverter()->convertObjectList($responseData);
} | Gets a list of content changes.
@param string $repositoryId The identifier for the repository.
@param string|null $changeLogToken If specified, then the repository MUST return the change event corresponding
to the value of the specified change log token as the first result in the output.
If not specified, then the repository MUST return the first change event recorded in the change log.
@param boolean $includeProperties If <code>true</code>, then the repository MUST include the updated property
values for "updated" change events if the repository supports returning property values as specified by
capbilityChanges.
If <code>false</code>, then the repository MUST NOT include the updated property values for
"updated" change events. The single exception to this is that the property cmis:objectId MUST always
be included.
@param boolean $includePolicyIds If <code>true</code>, then the repository MUST include the ids of the policies
applied to the object referenced in each change event, if the change event modified the set of policies
applied to the object.
If <code>false</code>, then the repository MUST not include policy information.
@param boolean $includeAcl If <code>true</code>, then the repository MUST return the ACLs for each object in the
result set. Defaults to <code>false</code>.
@param integer|null $maxItems the maximum number of items to return in a response
(default is repository specific)
@param ExtensionDataInterface|null $extension
@return ObjectListInterface | entailment |
public function query(
$repositoryId,
$statement,
$searchAllVersions = false,
IncludeRelationships $includeRelationships = null,
$renditionFilter = Constants::RENDITION_NONE,
$includeAllowableActions = false,
$maxItems = null,
$skipCount = 0,
ExtensionDataInterface $extension = null
) {
$url = $this->getRepositoryUrl($repositoryId);
$url->getQuery()->modify(
[
Constants::CONTROL_CMISACTION => Constants::CMISACTION_QUERY,
Constants::PARAM_STATEMENT => (string) $statement,
Constants::PARAM_SEARCH_ALL_VERSIONS => $searchAllVersions ? 'true' : 'false',
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
Constants::PARAM_RENDITION_FILTER => $renditionFilter,
Constants::PARAM_SKIP_COUNT => (string) $skipCount,
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
]
);
if ($includeRelationships !== null) {
$url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
}
if ($maxItems > 0) {
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
}
return $this->getJsonConverter()->convertQueryResultList((array) $this->postJson($url));
} | Executes a CMIS query statement against the contents of the repository.
@param string $repositoryId The identifier for the repository.
@param string $statement CMIS query to be executed
@param boolean $searchAllVersions If <code>true</code>, then the repository MUST include latest and non-latest
versions of document objects in the query search scope.
If <code>false</code>, then the repository MUST only include latest versions of documents in the
query search scope.
If the repository does not support the optional capabilityAllVersionsSearchable capability, then this
parameter value MUST be set to <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 The Repository MUST return the set of renditions whose kind matches this
filter. See section below for the filter grammar. Defaults to "cmis:none".
@param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
actions for each object in the result set (default is <code>false</code>)
@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 ObjectListInterface|null Returns object of type <code>ObjectListInterface</code>
or <code>null</code> if the repository response was empty | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/countries.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Country::class, $response['countries']);
} | Receive a list of countries
@link https://help.shopify.com/api/reference/country#index
@param array $params
@return Country[] | entailment |
public function get($countryId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$endpoint = '/admin/countrys/'.$countryId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Country::class, $response['country']);
} | Receive a single country
@link https://help.shopify.com/api/reference/country#show
@param integer $countryId
@param array $fields
@return Country | entailment |
public function create(Country &$country)
{
$data = $country->exportData();
$endpoint = '/admin/countries.json';
$response = $this->request(
$endpoint, 'POST', array(
'country' => $data
)
);
$country->setData($response['country']);
} | Create a country
@link https://help.shopify.com/api/reference/country#create
@param Country $country
@return void | entailment |
public function update(Country &$country)
{
$data = $country->exportData();
$endpoint = '/admin/countries/'.$country->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'country' => $data
)
);
$country->setData($response['country']);
} | Update a country
@link https://help.shopify.com/api/reference/country#update
@param Country $country
@return void | entailment |
protected function getObjectUrl($repositoryId, $objectId, $selector = null)
{
$result = $this->getRepositoryUrlCache()->getObjectUrl($repositoryId, $objectId, $selector);
if ($result === null) {
$this->getRepositoriesInternal($repositoryId);
$result = $this->getRepositoryUrlCache()->getObjectUrl($repositoryId, $objectId, $selector);
}
if ($result === null) {
throw new CmisObjectNotFoundException(
sprintf(
'Unknown Object! Repository: "%s" | Object: "%s" | Selector: "%s"',
$repositoryId,
$objectId,
$selector
)
);
}
return $result;
} | Get the url for an object
@param string $repositoryId
@param string $objectId
@param string|null $selector
@throws CmisConnectionException
@throws CmisObjectNotFoundException
@return Url | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.