sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function getRepositoryUrlCache()
{
$repositoryUrlCache = $this->getSession()->get(SessionParameter::REPOSITORY_URL_CACHE);
if ($repositoryUrlCache === null) {
$repositoryUrlCache = new RepositoryUrlCache();
$this->getSession()->put(SessionParameter::REPOSITORY_URL_C... | Returns the repository URL cache or creates a new cache if it doesn't
exist.
@return RepositoryUrlCache | entailment |
protected function setSession(BindingSessionInterface $session)
{
$this->session = $session;
$succinct = $session->get(SessionParameter::BROWSER_SUCCINCT);
$this->succinct = $succinct ?? true;
$this->dateTimeFormat = DateTimeFormat::cast($session->get(SessionParameter::BROWSER_DATET... | Sets the current session.
@param BindingSessionInterface $session | entailment |
protected function getRepositoriesInternal($repositoryId = null)
{
$repositoryUrlCache = $this->getRepositoryUrlCache();
if ($repositoryId === null) {
// no repository id provided -> get all
$url = $repositoryUrlCache->buildUrl($this->getServiceUrl());
} else {
... | Retrieves the the repository info objects.
@param string|null $repositoryId
@throws CmisConnectionException
@return RepositoryInfo[] Returns ALL Repository Infos that are available and not just the one requested by id. | entailment |
protected function read(Url $url)
{
/** @var Response $response */
try {
$response = $this->getHttpInvoker()->get((string) $url);
} catch (RequestException $exception) {
$code = 0;
$message = null;
if ($exception->getResponse()) {
... | Do a get request for the given url
@param Url $url
@return Response
@throws CmisBaseException an more specific exception of this type could be thrown. For more details see
@see AbstractBrowserBindingService::convertStatusCode() | entailment |
protected function convertStatusCode($code, $message, \Exception $exception = null)
{
$messageData = json_decode($message, true);
if (is_array($messageData) && !empty($messageData[JSONConstants::ERROR_EXCEPTION])) {
$jsonError = $messageData[JSONConstants::ERROR_EXCEPTION];
... | Converts an error message or a HTTP status code into an Exception.
@see http://docs.oasis-open.org/cmis/CMIS/v1.1/os/CMIS-v1.1-os.html#x1-551021r549
@param integer $code
@param string $message
@param null|\Exception $exception
@return CmisBaseException | entailment |
protected function getPathUrl($repositoryId, $path, $selector = null)
{
$result = $this->getRepositoryUrlCache()->getPathUrl($repositoryId, $path, $selector);
if ($result === null) {
$this->getRepositoriesInternal($repositoryId);
$result = $this->getRepositoryUrlCache()->get... | Generate url for a given path of a given repository.
@param string $repositoryId
@param string $path
@param string|null $selector
@throws CmisConnectionException
@throws CmisObjectNotFoundException
@return Url | entailment |
protected function postJson(Url $url, $content = [], array $headers = [])
{
return \json_decode($this->post($url, $content, $headers)->getBody(), true);
} | Wrapper for calling post() and reading response as JSON, as is the general use case.
@param Url $url
@param array $content
@param array $headers
@return mixed | entailment |
protected function post(Url $url, $content = [], array $headers = [])
{
if (is_resource($content) || is_object($content)) {
$headers['body'] = $content;
} elseif (is_array($content)) {
$headers['multipart'] = $this->convertQueryArrayToMultiPart($content);
}
t... | Performs a POST on an URL, checks the response code and returns the
result.
@param Url $url Request url
@param resource|string|StreamInterface|array $content Entity body data or an array for POST fields and files
@param array $headers Additional header options
@return ResponseInterface
@throws CmisBaseException an mor... | entailment |
protected function getTypeDefinitionInternal($repositoryId, $typeId)
{
if (empty($repositoryId)) {
throw new CmisInvalidArgumentException('Repository id must not be empty!');
}
if (empty($typeId)) {
throw new CmisInvalidArgumentException('Type id must not be empty!')... | Retrieves a type definition.
@param string $repositoryId
@param string $typeId
@return TypeDefinitionInterface|null
@throws CmisInvalidArgumentException if repository id or type id is <code>null</code> | entailment |
protected function getRepositoryUrl($repositoryId, $selector = null)
{
$result = $this->getRepositoryUrlCache()->getRepositoryUrl($repositoryId, $selector);
if ($result === null) {
$this->getRepositoriesInternal($repositoryId);
$result = $this->getRepositoryUrlCache()->getRe... | Get url for a repository
@param string $repositoryId
@param string|null $selector
@throws CmisConnectionException
@throws CmisObjectNotFoundException
@return Url | entailment |
protected function convertPropertiesToQueryArray(PropertiesInterface $properties)
{
$propertiesArray = [];
$propertyCounter = 0;
$propertiesArray[Constants::CONTROL_PROP_ID] = [];
$propertiesArray[Constants::CONTROL_PROP_VALUE] = [];
foreach ($properties->getProperties() as ... | Converts a Properties list into an array that can be used for the CMIS request.
@param PropertiesInterface $properties
@return array Example <code>
array('propertyId' => array(0 => 'myId'), 'propertyValue' => array(0 => 'valueOfMyId'))
</code> | entailment |
protected function convertPropertyValueToSimpleType($value)
{
if ($value instanceof \DateTime) {
// CMIS expects a timestamp in milliseconds
$value = $value->getTimestamp() * 1000;
} elseif (is_bool($value)) {
// Booleans must be represented in string form since request wi... | Converts values to a format that can be used for the CMIS Browser binding request.
@param mixed $value
@return mixed | entailment |
protected function convertAclToQueryArray(AclInterface $acl, $principalControl, $permissionControl)
{
$acesArray = [];
$principalCounter = 0;
foreach ($acl->getAces() as $ace) {
$permissions = $ace->getPermissions();
if ($ace->getPrincipal() !== null && $ace->getPrin... | Converts a Access Control list into an array that can be used for the CMIS request
@param AclInterface $acl
@param string $principalControl one of principal ace constants
CONTROL_ADD_ACE_PRINCIPAL or CONTROL_REMOVE_ACE_PRINCIPAL
@param string $permissionControl one of permission ace constants
CONTROL_REMOVE_ACE_PRINCI... | entailment |
protected function convertPolicyIdArrayToQueryArray(array $policies)
{
$policiesArray = [];
$policyCounter = 0;
foreach ($policies as $policy) {
$policiesArray[Constants::CONTROL_POLICY][$policyCounter] = (string) $policy;
$policyCounter ++;
}
return... | Converts a policies array into an array that can be used for the CMIS request
@param string[] $policies A list of policy string representations
@return array | entailment |
protected function appendPoliciesToUrl(Url $url, array $policies)
{
if (!empty($policies)) {
$url->getQuery()->modify($this->convertPolicyIdArrayToQueryArray($policies));
}
} | Appends policies parameters to url
@param Url $url
@param string[] $policies A list of policy IDs that must be applied to the newly created document object | entailment |
protected function appendAddAcesToUrl(Url $url, AclInterface $addAces = null)
{
if ($addAces !== null) {
$url->getQuery()->modify(
$this->convertAclToQueryArray(
$addAces,
Constants::CONTROL_ADD_ACE_PRINCIPAL,
Constants:... | Appends addAces parameters to url
@param Url $url
@param AclInterface|null $addAces A list of ACEs | entailment |
protected function appendRemoveAcesToUrl(Url $url, AclInterface $removeAces = null)
{
if ($removeAces !== null) {
$url->getQuery()->modify(
$this->convertAclToQueryArray(
$removeAces,
Constants::CONTROL_REMOVE_ACE_PRINCIPAL,
... | Appends removeAces parameters to url
@param Url $url
@param AclInterface|null $removeAces A list of ACEs | entailment |
public function loadContentLink($repositoryId, $documentId)
{
$result = $this->getRepositoryUrlCache()->getObjectUrl($repositoryId, $documentId, Constants::SELECTOR_CONTENT);
return $result === null ? null : (string) $result;
} | Gets the content link from the cache if it is there or loads it into the
cache if it is not there.
@param string $repositoryId
@param string $documentId
@return string|null | entailment |
public function loadRenditionContentLink($repositoryId, $documentId, $streamId)
{
$result = $this->getRepositoryUrlCache()->getObjectUrl($repositoryId, $documentId, Constants::SELECTOR_CONTENT);
if ($result !== null) {
$result->getQuery()->modify([Constants::PARAM_STREAM_ID => $streamId]... | Gets a rendition content link from the cache if it is there or loads it
into the cache if it is not there.
@param string $repositoryId
@param string $documentId
@param string $streamId
@return string|null | entailment |
public function setExtensions(array $extensions)
{
foreach ($extensions as $extension) {
$this->checkType(CmisExtensionElementInterface::class, $extension);
}
$this->extensions = $extensions;
} | Sets the list of top-level extension elements.
@param CmisExtensionElementInterface[] $extensions | entailment |
public function create($recurringApplicationChargeId, UsageCharge $usageCharge)
{
$data = $usageCharge->exportData();
$endpoint = '/admin/recurring_application_charges/'.$recurringApplicationChargeId.'/usage_charges.json';
$response = $this->request(
$endpoint, 'POST', array(
... | Create a usage charges
@link https://help.shopify.com/api/reference/usagecharge#create
@param integer $recurringApplicationChargeId
@param UsageCharge $usageCharge
@return void | entailment |
public function get($recurringApplicationChargeId, $usageChargeId, array $params = array())
{
$endpoint = '/admin/recurring_application_charges/'.$recurringApplicationChargeId.'/usage_charges/'.$usageChargeId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->creat... | Receive a single usage charge
@link https://help.shopify.com/api/reference/usagecharge#show
@param integer $recurringApplicationChargeId
@param integer $usageChargeId
@param array $params
@return UsageCharge | entailment |
public function all($recurringApplicationChargeId, array $params = array())
{
$endpoint = '/admin/recurring_application_charges/'.$recurringApplicationChargeId.'/usage_charges.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(UsageCharge::class, $re... | Retrieve all usage charges
@link https://help.shopify.com/api/reference/usagecharge#index
@param integer $recurringApplicationChargeId
@param array $params
@return UsageCharge[] | entailment |
public function setObjects(array $objects)
{
foreach ($objects as $object) {
$this->checkType(ObjectInFolderDataInterface::class, $object);
}
$this->objects = $objects;
} | checks input array for ObjectInFolderDataInterface and sets objects
@param ObjectInFolderDataInterface[] $objects | entailment |
public function addList(array $list, $listName, $state)
{
if (!is_bool($state)) {
throw new \InvalidArgumentException("Wrong parameter 'state' is not boolean");
}
$entryList = $this->entryFactory->getEntryList($list, $state);
$this->listMerger->addList($entryList, $listN... | Add a list
@param array $list List
@param string $listName Identifier for the list
@param boolean|null $state Whether the list is trusted or not
@return $this | entailment |
public function handle(callable $callBack = null)
{
$ip = $this->getIpAddress();
$isAllowed = $this->listMerger->isAllowed($ip, $this->defaultState);
if ($callBack !== null) {
return call_user_func($callBack, array($this, $isAllowed));
} else {
return $isAll... | Handle the current request
@param callable $callBack Result handler
@return boolean | entailment |
public function getSpi(BindingSessionInterface $session)
{
$spi = $session->get(self::SPI_OBJECT);
if ($spi !== null) {
return $spi;
}
$spiClass = $session->get(SessionParameter::BINDING_CLASS);
if (empty($spiClass) || !class_exists($spiClass)) {
thr... | Gets the SPI object for the given session. If there is already a SPI
object in the session it will be returned. If there is no SPI object it
will be created and put into the session.
@param BindingSessionInterface $session
@return CmisInterface | entailment |
public function getTypeDefinitionCache(BindingSessionInterface $session)
{
$cache = $session->get(self::TYPE_DEFINITION_CACHE);
if ($cache !== null) {
return $cache;
}
$className = $session->get(SessionParameter::TYPE_DEFINITION_CACHE_CLASS);
try {
$c... | Returns the type definition cache from the session.
@param BindingSessionInterface $session
@return Cache
@throws CmisRuntimeException Exception is thrown if cache instance could not be initialized. | entailment |
public static function match($entry)
{
$entries = preg_split('/' . static::$separatorRegex .'/', $entry);
if (count($entries) == 2) {
$checkIp = static::matchIp($entries[0]);
if ($checkIp && ($entries[1] >= 0) && ($entries[1] <= static::NB_BITS)) {
... | {@inheritdoc} | entailment |
public function getParts()
{
$keys = array('ip', 'mask');
$parts = array_combine($keys, preg_split('/'. self::$separatorRegex .'/', $this->template));
$bin = str_pad(str_repeat('1', (int) $parts['mask']), self::NB_BITS, 0);
$parts['mask'] = $this->long2ip($this->IPLongBaseConvert($... | {@inheritdoc} | entailment |
function get($id, $group = 'default', $doNotTestCacheValidity = false)
{
if ($data = parent::get($id, $group, true)) {
if ($filemtime = $this->lastModified()) {
if ($filemtime > $this->_masterFile_mtime) {
return $data;
}
}
... | Test if a cache is available and (if yes) return it
@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 string data of the cache (else : false)
@access public | entailment |
public function setValues(array $values)
{
foreach ($values as $value) {
$this->checkType(\DateTime::class, $value, true);
}
parent::setValues($values);
} | {@inheritdoc}
@param \DateTime[] $values | entailment |
public function addRepository($repositoryId, $repositoryUrl, $rootUrl)
{
if (empty($repositoryId) || empty($repositoryUrl) || empty($rootUrl)) {
throw new CmisInvalidArgumentException(
'Repository Id or Repository URL or Root URL is not set!',
1408536098
... | Adds the URLs of a repository to the cache.
@param string $repositoryId
@param string $repositoryUrl
@param string $rootUrl | entailment |
public function getRepositoryUrl($repositoryId, $selector = null)
{
$baseUrl = $this->getRepositoryBaseUrl($repositoryId);
if ($baseUrl === null) {
return null;
}
$repositoryUrl = $this->buildUrl($baseUrl);
if ($selector !== null && $selector !== '') {
... | Returns the repository URL of a repository.
@param string $repositoryId
@param string|null $selector add optional cmis selector parameter
@return Url|null | entailment |
public function getObjectUrl($repositoryId, $objectId, $selector = null)
{
if ($this->getRootUrl($repositoryId) === null) {
return null;
}
$url = $this->buildUrl($this->getRootUrl($repositoryId));
$urlQuery = $url->getQuery();
$urlQuery->modify([Constants::PARAM_... | Get URL for an object request
@param string $repositoryId
@param string $objectId
@param string|null $selector
@return Url|null | entailment |
public function getPathUrl($repositoryId, $path, $selector = null)
{
if ($this->getRootUrl($repositoryId) === null) {
return null;
}
$url = $this->buildUrl($this->getRootUrl($repositoryId));
$url->getPath()->append($path);
if (!empty($selector)) {
$u... | Get Repository URL with given path
@param string $repositoryId
@param string $path
@param string|null $selector
@return Url | entailment |
public function getSource(OperationContextInterface $context = null)
{
$sourceId = $this->getSourceId();
if ($sourceId === null) {
return null;
}
$context = $this->ensureContext($context);
return $this->getSession()->getObject($sourceId, $context);
} | Gets the source object using the given OperationContext.
@param OperationContextInterface|null $context
@return CmisObjectInterface|null If the source object ID is invalid, <code>null</code> will be returned. | entailment |
public function getTarget(OperationContextInterface $context = null)
{
$context = $this->ensureContext($context);
$targetId = $this->getTargetId();
if ($targetId === null) {
return null;
}
return $this->getSession()->getObject($targetId, $context);
} | Gets the target object using the given OperationContext.
@param OperationContextInterface|null $context
@return CmisObjectInterface If the target object ID is invalid, <code>null</code> will be returned. | entailment |
public function getSourceId()
{
$sourceId = $this->getPropertyValue(PropertyIds::SOURCE_ID);
if (empty($sourceId)) {
return null;
}
return $this->getSession()->createObjectId($sourceId);
} | Returns the source ID of this CMIS relationship (CMIS property cmis:sourceId).
@return ObjectIdInterface|null the source ID 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 getTargetId()
{
$targetId = $this->getPropertyValue(PropertyIds::TARGET_ID);
if (empty($targetId)) {
return null;
}
return $this->getSession()->createObjectId($targetId);
} | Returns the target ID of this CMIS relationship (CMIS property cmis:targetId).
@return ObjectIdInterface the target ID 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 all($priceRuleId, array $params = array())
{
$endpoint = '/admin/price_rules/'.$priceRuleId.'/discount_codes.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(DiscountCode::class, $response['discount_codes']);
} | Receive a list of all discounts
@link https://help.shopify.com/api/reference/discount#index
@param integer $priceRuleId
@param array $params
@return DiscountCode[] | entailment |
public function get($priceRuleId, $discountCodeId)
{
$endpoint = '/admin/price_rules/'.$priceRuleId.'/discount_codes/'.$discountCodeId.'.json';
$response = $this->request($endpoint);
return $this->createObject(DiscountCode::class, $response['discount_code']);
} | Receive a single discount
@link https://help.shopify.com/api/reference/discount#show
@param integer $priceRuleId
@param integer $discountCodeId
@return DiscountCode | entailment |
public function create($priceRuleId, DiscountCode &$discountCode)
{
$data = $discountCode->exportData();
$endpoint = '/admin/price_rules/'.$priceRuleId.'/discount_codes.json';
$response = $this->request($endpoint, 'POST', array(
'discount_code' => $data
));
$disco... | Create a new discount
@link https://help.shopify.com/api/reference/discount#create
@param integer $priceRuleId
@param DiscountCode $discountCode
@return void | entailment |
public function delete($priceRuleId, DiscountCode $discountCode)
{
$endpoint = '/admin/price_rules/'.$priceRuleId.'/discount_codes/'.$discountCode->id.'.json';
$this->request($endpoint, 'DELETE');
return;
} | Delete a discount
@link https://help.shopify.com/api/reference/discount#destroy
@param integer $priceRuleId
@param DiscountCode $discountCode
@return void | entailment |
public function update($priceRuleId, DiscountCode &$discountCode)
{
$data = $discountCode->exportData();
$endpoint = '/admin/price_rules/'.$priceRuleId.'/discount_codes/'.$discountCode->id.'.json';
$response = $this->request($endpoint, 'PUT', array(
'discount_code' => $data
... | Update a Discount Code
@param integer $priceRuleId
@param DiscountCode $discountCode
@return void | entailment |
function call()
{
$arguments = func_get_args();
$id = $this->_makeId($arguments);
$data = $this->get($id, $this->_defaultGroup);
if ($data !== false) {
if ($this->_debugCacheLiteFunction) {
echo "Cache hit !\n";
}
$array = unseriali... | Calls a cacheable function or method (or not if there is already a cache for it)
Arguments of this method are read with func_get_args. So it doesn't appear
in the function definition. Synopsis :
call('functionName', $arg1, $arg2, ...)
(arg1, arg2... are arguments of 'functionName')
@return mixed result of the functio... | entailment |
function drop()
{
$id = $this->_makeId(func_get_args());
return $this->remove($id, $this->_defaultGroup);
} | Drop a cache file
Arguments of this method are read with func_get_args. So it doesn't appear
in the function definition. Synopsis :
remove('functionName', $arg1, $arg2, ...)
(arg1, arg2... are arguments of 'functionName')
@return boolean true if no problem
@access public | entailment |
function _makeId($arguments)
{
$id = serialize($arguments); // Generate a cache id
if (!$this->_fileNameProtection) {
$id = md5($id);
// if fileNameProtection is set to false, then the id has to be hashed
// because it's a very bad file name in most cases
... | Make an id for the cache
@var array result of func_get_args for the call() or the remove() method
@return string id
@access private | entailment |
function setOption($name, $value)
{
$availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'f... | Generic way to set a Cache_Lite option
see Cache_Lite constructor for available options
@var string $name name of the option
@var mixed $value value of the option
@access public | entailment |
function get($id, $group = 'default', $doNotTestCacheValidity = false)
{
$this->_id = $id;
$this->_group = $group;
$data = false;
if ($this->_caching) {
$this->_setRefreshTime();
$this->_setFileName($id, $group);
clearstatcache();
if ($... | Test if a cache is available and (if yes) return it
@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 string data of the cache (else : false)
@access public | entailment |
function save($data, $id = NULL, $group = 'default')
{
if ($this->_caching) {
if ($this->_automaticSerialization) {
$data = serialize($data);
}
if (isset($id)) {
$this->_setFileName($id, $group);
}
if ($this->_memory... | Save some data in a cache file
@param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
@param string $id cache id
@param string $group name of the cache group
@return boolean true if no problem (else : false or a PEAR_Error object)
@access public | entailment |
function remove($id, $group = 'default', $checkbeforeunlink = false)
{
$this->_setFileName($id, $group);
if ($this->_memoryCaching) {
if (isset($this->_memoryCachingArray[$this->_file])) {
unset($this->_memoryCachingArray[$this->_file]);
$this->_memoryCach... | Remove a cache file
@param string $id cache id
@param string $group name of the cache group
@param boolean $checkbeforeunlink check if file exists before removing it
@return boolean true if no problem
@access public | entailment |
function clean($group = false, $mode = 'ingroup')
{
return $this->_cleanDir($this->_cacheDir, $group, $mode);
} | Clean the cache
if no group is specified all cache files will be destroyed
else only cache files of the specified group will be destroyed
@param string $group name of the cache group
@param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
'callback_myFunction'
@return boolean true if no problem
@access... | entailment |
function saveMemoryCachingState($id, $group = 'default')
{
if ($this->_caching) {
$array = array(
'counter' => $this->_memoryCachingCounter,
'array' => $this->_memoryCachingArray
);
$data = serialize($array);
$this->save($data, ... | Save the state of the caching memory array into a cache file cache
@param string $id cache id
@param string $group name of the cache group
@access public | entailment |
function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
{
if ($this->_caching) {
if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
$array = unserialize($data);
$this->_memoryCachingCounter = $array['counter'];
... | Load the state of the caching memory array from a given cache file 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
@access public | entailment |
function _setRefreshTime()
{
if (is_null($this->_lifeTime)) {
$this->_refreshTime = null;
} else {
$this->_refreshTime = time() - $this->_lifeTime;
}
} | Compute & set the refresh time
@access private | entailment |
function _cleanDir($dir, $group = false, $mode = 'ingroup')
{
if ($this->_fileNameProtection) {
$motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
} else {
$motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
}
if ($this->_memoryCaching) {
forea... | Recursive function for cleaning cache file in the given directory
@param string $dir directory complete path (with a trailing slash)
@param string $group name of the cache group
@param string $mode flush cache mode : 'old', 'ingroup', 'notingroup',
'callback_myFunction'
@return boolean true if no problem
@access priva... | entailment |
function _memoryCacheAdd($data)
{
$this->_touchCacheFile();
$this->_memoryCachingArray[$this->_file] = $data;
if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
$key = key($this->_memoryCachingArray);
next($this->_memoryCachingArray);
unset(... | Add some date in the memory caching array
@param string $data data to cache
@access private | entailment |
function _setFileName($id, $group)
{
if ($this->_fileNameProtection) {
$suffix = 'cache_'.md5($group).'_'.md5($id);
} else {
$suffix = 'cache_'.$group.'_'.$id;
}
$root = $this->_cacheDir;
if ($this->_hashedDirectoryLevel>0) {
$hash... | Make a file name (with path)
@param string $id cache id
@param string $group name of the group
@access private | entailment |
function _read()
{
$fp = @fopen($this->_file, "rb");
if ($fp) {
if ($this->_fileLocking) @flock($fp, LOCK_SH);
clearstatcache();
$length = @filesize($this->_file);
$mqr = get_magic_quotes_runtime();
if ($mqr) {
set_magic_quotes_run... | Read the cache file and return the content
@return string content of the cache file (else : false or a PEAR_Error object)
@access private | entailment |
function _write($data)
{
if ($this->_hashedDirectoryLevel > 0) {
$hash = md5($this->_fileName);
$root = $this->_cacheDir;
for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
if (!... | Write the given data in the cache file
@param string $data data to put in cache
@return boolean true if ok (a PEAR_Error object else)
@access private | entailment |
function _writeAndControl($data)
{
$result = $this->_write($data);
if (is_object($result)) {
return $result; # We return the PEAR_Error object
}
$dataRead = $this->_read();
if (is_object($dataRead)) {
return $dataRead; # We return the PEAR_Error object... | Write the given data in the cache file and control it just after to avoir corrupted cache entries
@param string $data data to put in cache
@return boolean true if the test is ok (else : false or a PEAR_Error object)
@access private | entailment |
function _hash($data, $controlType)
{
switch ($controlType) {
case 'md5':
return md5($data);
case 'crc32':
return sprintf('% 32d', crc32($data));
case 'strlen':
return sprintf('% 32d', strlen($data));
default:
return $this->rais... | Make a control key with the string containing datas
@param string $data data
@param string $controlType type of control 'md5', 'crc32' or 'strlen'
@return string control key
@access private | entailment |
public function all(array $params = array())
{
$endpoint = '/admin/redirects.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(Redirect::class, $response['redirects']);
} | Receive a list of all redirects
@link https://help.shopify.com/api/reference/redirect#index
@param ListOptions $options
@return Redirect[] | entailment |
public function get($redirectId, array $params = array())
{
$endpoint = '/admin/redirects/'.$redirectId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(Redirect::class, $response['redirect']);
} | Receive a singel redirect
@link https://help.shopify.com/api/reference/redirect#show
@param integer $redirectId
@param array $params
@return Redirect | entailment |
public function create(Redirect &$redirect)
{
$endpoint = '/admin/redirects.json';
$data = $redirect->exportData();
$response = $this->request(
$endpoint, "POST", array(
'redirect' => $data
)
);
$redirect->setData($response['redirect']);
... | Create a new redirect
@link https://help.shopify.com/api/reference/redirect#create
@param Redirect $redirect
@return void | entailment |
public function update(Redirect &$redirect)
{
$endpoint = '/admin/redirects/'.$redirect->id.'.json';
$data = $redirect->exportData();
$response = $this->request(
$endpoint, "POST", array(
'redirect' => $data
)
);
$redirect->setData($respons... | Modify an existing redirect
@link https://help.shopify.com/api/reference/redirect#update
@param Redirect $redirect
@return void | entailment |
public function delete(Redirect $redirect)
{
$endpoint = '/admin/redirect/'.$redirect->id.'.json';
$response = $this->request($endpoint, 'DELETE');
return;
} | Remove a redirect
@link https://help.shopify.com/api/reference/redirect#destroy
@param Redirect $redirect
@return void | entailment |
public function getObjectRelationships(
$repositoryId,
$objectId,
$includeSubRelationshipTypes = false,
RelationshipDirection $relationshipDirection = null,
$typeId = null,
$filter = null,
$includeAllowableActions = false,
$maxItems = null,
$skipCo... | Gets all or a subset of relationships associated with an independent object.
@param string $repositoryId The identifier for the repository.
@param string $objectId The identifier of the object.
@param boolean $includeSubRelationshipTypes If <code>true</code>, then the repository MUST return all
relationships whose obj... | entailment |
public function convertObject(ObjectDataInterface $objectData, OperationContextInterface $context)
{
$type = $this->getTypeFromObjectData($objectData);
if ($type === null) {
throw new CmisRuntimeException('Could not get type from object data.');
}
$baseTypeId = $objectDat... | Convert given ObjectData to a high level API object
@param ObjectDataInterface $objectData
@param OperationContextInterface $context
@return CmisObjectInterface
@throws CmisRuntimeException | entailment |
public function convertPolicies(array $policies)
{
$result = [];
foreach ($policies as $policy) {
if ($policy->getId() !== null) {
$result[] = $policy->getId();
}
}
return $result;
} | Converts a list of Policy objects into a list of there string representations
@param PolicyInterface[] $policies
@return string[] | entailment |
public function convertPropertiesDataToPropertyList(
ObjectTypeInterface $objectType,
array $secondaryTypes,
PropertiesInterface $properties
) {
if (count($objectType->getPropertyDefinitions()) === 0) {
throw new CmisInvalidArgumentException('Object type has no property d... | Convert Properties in Properties instance to a list of PropertyInterface objects
@param ObjectTypeInterface $objectType
@param SecondaryTypeInterface[] $secondaryTypes
@param PropertiesInterface $properties
@return PropertyInterface[]
@throws CmisInvalidArgumentException | entailment |
protected function convertProperty(
ObjectTypeInterface $objectType,
array $secondaryTypes,
PropertyDataInterface $propertyData
) {
$definition = $objectType->getPropertyDefinition($propertyData->getId());
// search secondary types
if ($definition === null && !empty(... | Convert PropertyData into a property API object
@param ObjectTypeInterface $objectType
@param SecondaryTypeInterface[] $secondaryTypes
@param PropertyDataInterface $propertyData
@return PropertyInterface
@throws CmisRuntimeException | entailment |
public function convertProperties(
array $properties,
ObjectTypeInterface $type = null,
array $secondaryTypes = [],
array $updatabilityFilter = []
) {
if (empty($properties)) {
return null;
}
if ($type === null) {
$type = $this->getTyp... | Convert properties to their property data objects and put them into a Properties object
@param mixed[] $properties
@param ObjectTypeInterface|null $type
@param SecondaryTypeInterface[] $secondaryTypes
@param Updatability[] $updatabilityFilter
@return PropertiesInterface
@throws CmisInvalidArgumentException | entailment |
private function getTypeDefinition($objectTypeId)
{
if (empty($objectTypeId) || !is_string($objectTypeId)) {
throw new CmisInvalidArgumentException(
'Type property must be set and must be of type string but is empty or not a string.'
);
}
return $this... | Get a type definition for the given object type id. If an empty id is given throw an exception.
@param string $objectTypeId
@return ObjectTypeInterface
@throws CmisInvalidArgumentException | entailment |
private function getValueFromArray($needle, $haystack)
{
if (!is_array($haystack) || !isset($haystack[$needle])) {
return null;
}
return $haystack[$needle];
} | Get a value from an array. Return <code>null</code> if the key does not exist in the array.
@param integer|string $needle
@param mixed $haystack
@return mixed | entailment |
public function convertRendition($objectId, RenditionDataInterface $renditionData)
{
$rendition = new Rendition($this->session, $objectId);
$rendition->populate($renditionData);
return $rendition;
} | Converts RenditionData to Rendition
@param string $objectId
@param RenditionDataInterface $renditionData
@return RenditionInterface | entailment |
public function convertTypeDefinition(TypeDefinitionInterface $typeDefinition)
{
if ($typeDefinition instanceof DocumentTypeDefinitionInterface) {
return new DocumentType($this->session, $typeDefinition);
} elseif ($typeDefinition instanceof FolderTypeDefinitionInterface) {
r... | Convert a type definition to a type
@param TypeDefinitionInterface $typeDefinition
@return ObjectTypeInterface
@throws CmisRuntimeException | entailment |
public function getTypeFromObjectData(ObjectDataInterface $objectData)
{
if ($objectData->getProperties() === null || count($objectData->getProperties()->getProperties()) === 0) {
return null;
}
$typeProperty = $objectData->getProperties()->getProperties()[PropertyIds::OBJECT_TY... | Try to determined what object type the given objectData belongs to and return that type.
@param ObjectDataInterface $objectData
@return ObjectTypeInterface|null The object type or <code>null</code> if type could not be determined | entailment |
public function createTypeDefinition(
$id,
$localName,
$baseTypeIdString,
$parentId,
$creatable,
$fileable,
$queryable,
$controllablePolicy,
$controllableACL,
$fulltextIndexed,
$includedInSupertypeQuery,
$localNamespace = ''... | Create a type definition with all required properties.
@param string $id This opaque attribute identifies this object-type in the repository.
@param string $localName This attribute represents the underlying repository’s name for the object-type.
This field is opaque and has no uniqueness constraint imposed by this sp... | entailment |
public function getTypeDefinitionByBaseTypeId($baseTypeIdString, $typeId)
{
$baseTypeId = BaseTypeId::cast($baseTypeIdString);
if ($baseTypeId->equals(BaseTypeId::cast(BaseTypeId::CMIS_FOLDER))) {
$baseType = new FolderTypeDefinition($typeId);
} elseif ($baseTypeId->equals(BaseT... | Get a type definition object by its base type id
@param string $baseTypeIdString
@param string $typeId
@return FolderTypeDefinition|DocumentTypeDefinition|RelationshipTypeDefinition|PolicyTypeDefinition|ItemTypeDefinition|SecondaryTypeDefinition
@throws CmisInvalidArgumentException Exception is thrown if the base type... | entailment |
public function createCmisBrowserBinding(array $sessionParameters, Cache $typeDefinitionCache = null)
{
$this->validateCmisBrowserBindingParameters($sessionParameters);
return new CmisBinding(new Session(), $sessionParameters, $typeDefinitionCache);
} | Create a browser binding
@param array $sessionParameters
@param Cache|null $typeDefinitionCache
@return CmisBinding | entailment |
protected function addDefaultSessionParameters(array &$sessionParameters)
{
$sessionParameters[SessionParameter::CACHE_SIZE_REPOSITORIES] = $sessionParameters[SessionParameter::CACHE_SIZE_REPOSITORIES] ?? 10;
$sessionParameters[SessionParameter::CACHE_SIZE_TYPES] = $sessionParameters[SessionParamete... | Sets some parameters to a default value if they are not already set
@param array $sessionParameters | entailment |
protected function check(array $sessionParameters, $parameter)
{
if (empty($sessionParameters[$parameter])) {
throw new CmisInvalidArgumentException(sprintf('Parameter "%s" is missing!', $parameter));
}
return true;
} | Checks if the given parameter is present. If not, throw an
<code>IllegalArgumentException</code>.
@param array $sessionParameters
@param string $parameter
@throws CmisInvalidArgumentException
@return boolean | entailment |
public function all(array $params = array())
{
$response = $this->request('/admin/webhooks.json', 'GET', $params);
return $this->createCollection(Webhook::class, $response['webhooks']);
} | Receive a list of all webhooks
@link https://help.shopify.com/api/reference/webhook#index
@param array $params
@return Webhook[] | entailment |
public function get($webhookId, array $fields = array())
{
$params = array();
if (!empty($fields)) {
$params['fields'] = implode(',', $fields);
}
$response = $this->request('/admin/webhooks/'.$webhookId.'.json', 'GET', $params);
return $this->createObject(Webhook:... | Receive a single webhook
@link https://help.shopify.com/api/reference/webhook#show
@param integer $webhookId
@param array $fields
@return Webhook | entailment |
public function create(Webhook &$webhook)
{
$data = $webhook->exportData();
$response = $this->request(
'/admin/webhooks.json', 'POST', array(
'webhook' => $data
)
);
$webhook->setData($response['webhook']);
} | Create a new webhook
@link https://help.shopify.com/api/reference/webhook#create
@param Webhook $webhook
@return void | entailment |
public function update(Webhook $webhook)
{
$data = $webhook->exportData();
$response = $this->request(
'/admin/webhooks/'.$webhook->id.'.json', 'PUT', array(
'webhook' => $data
)
);
$webhook->setData($response['webhook']);
} | Modify an existing webhook
@link https://help.shopify.com/api/reference/webhook#update
@param Webhook $webhook
@return void | entailment |
public function createDocument(
array $properties,
StreamInterface $contentStream,
VersioningState $versioningState,
array $policies = [],
array $addAces = [],
array $removeAces = [],
OperationContextInterface $context = null
) {
$newObjectId = $this->... | Creates a new document in this folder.
@param array $properties The property values that MUST be applied to the object. The array key is the property
name the value is the property value.
@param StreamInterface $contentStream
@param VersioningState $versioningState An enumeration specifying what the versioning state o... | entailment |
public function createDocumentFromSource(
ObjectIdInterface $source,
array $properties,
VersioningState $versioningState,
array $policies = [],
array $addAces = [],
array $removeAces = [],
OperationContextInterface $context = null
) {
$newObjectId = $t... | Creates a new document from a source document in this folder.
@param ObjectIdInterface $source The ID of the source document.
@param array $properties The property values that MUST be applied to the object. The array key is the property
name the value is the property value.
@param VersioningState $versioningState An e... | entailment |
public function createFolder(
array $properties,
array $policies = [],
array $addAces = [],
array $removeAces = [],
OperationContextInterface $context = null
) {
$newObjectId = $this->getSession()->createFolder($properties, $this, $policies, $addAces, $removeAces);
... | Creates a new subfolder in this folder.
@param array $properties The property values that MUST be applied to the newly-created item object.
@param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created folder object.
@param AceInterface[] $addAces A list of ACEs that MUST be added t... | entailment |
public function createItem(
array $properties,
array $policies = [],
array $addAces = [],
array $removeAces = [],
OperationContextInterface $context = null
) {
$newObjectId = $this->getSession()->createItem($properties, $this, $policies, $addAces, $removeAces);
... | Creates a new item in this folder.
@param array $properties The property values that MUST be applied to the newly-created item object.
@param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created item object.
@param AceInterface[] $addAces A list of ACEs that MUST be added to the n... | entailment |
public function createPolicy(
array $properties,
array $policies = [],
array $addAces = [],
array $removeAces = [],
OperationContextInterface $context = null
) {
$newObjectId = $this->getSession()->createPolicy($properties, $this, $policies, $addAces, $removeAces);
... | Creates a new policy in this folder.
@param array $properties The property values that MUST be applied to the newly-created policy object.
@param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created policy object.
@param AceInterface[] $addAces A list of ACEs that MUST be added to... | entailment |
public function deleteTree($allVersions, UnfileObject $unfile, $continueOnFailure = true)
{
$failed = $this->getBinding()->getObjectService()->deleteTree(
$this->getRepositoryId(),
$this->getId(),
$allVersions,
$unfile,
$continueOnFailure
)... | Deletes this folder and all subfolders.
@param boolean $allVersions If <code>true</code>, then delete all versions of all documents. If
<code>false</code>, delete only the document versions referenced in the tree. The repository MUST ignore the
value of this parameter when this service is invoked on any non-document o... | entailment |
public function getCheckedOutDocs(OperationContextInterface $context = null)
{
$context = $this->ensureContext($context);
$checkedOutDocs = $this->getBinding()->getNavigationService()->getCheckedOutDocs(
$this->getRepositoryId(),
$this->getId(),
$context->getQuery... | Returns all checked out documents in this folder using the given OperationContext.
@param OperationContextInterface|null $context
@return DocumentInterface[] A list of checked out documents. | entailment |
public function getChildren(OperationContextInterface $context = null)
{
$context = $this->ensureContext($context);
$children = $this->getBinding()->getNavigationService()->getChildren(
$this->getRepositoryId(),
$this->getId(),
$context->getQueryFilterString(),
... | Returns the children of this folder using the given OperationContext.
@param OperationContextInterface|null $context
@return CmisObjectInterface[] A list of the child objects for the specified folder. | entailment |
public function getFolderParent()
{
if ($this->isRootFolder()) {
return null;
}
$parents = $this->getParents($this->getSession()->getDefaultContext());
// return the first element of the array
$parent = reset($parents);
if (!$parent instanceof FolderInt... | Gets the parent folder object.
@return FolderInterface|null the parent folder object or <code>null</code> if the folder is the root folder. | entailment |
public function getFolderTree($depth, OperationContextInterface $context = null)
{
$context = $this->ensureContext($context);
$containerList = $this->getBinding()->getNavigationService()->getFolderTree(
$this->getRepositoryId(),
$this->getId(),
(int) $depth,
... | Gets the folder tree starting with this folder using the given OperationContext.
@param integer $depth The number of levels of depth in the folder hierarchy from which to return results.
Valid values are:
1
Return only objects that are children of the folder. See also getChildren.
<Integer value greater than 1>
Return... | entailment |
public function getPath()
{
$path = $this->getPropertyValue(PropertyIds::PATH);
// if the path property isn't set, get it
if ($path === null) {
$objectData = $this->getBinding()->getObjectService()->getObject(
$this->getRepositoryId(),
$this->getI... | Returns the path of the folder.
@return string the absolute folder path | entailment |
public function getAllowedChildObjectTypes()
{
$result = [];
$objectTypeIds = $this->getPropertyValue(PropertyIds::ALLOWED_CHILD_OBJECT_TYPE_IDS);
if ($objectTypeIds === null) {
return $result;
}
foreach ($objectTypeIds as $objectTypeId) {
$result[] ... | Returns the list of the allowed object types in this folder (CMIS property cmis:allowedChildObjectTypeIds).
If the list is empty or <code>null</code> all object types are allowed.
@return ObjectTypeInterface[] the property value or <code>null</code> if the property hasn't been requested,
hasn't been provided by the re... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.