sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function getBaseDatagrid(AdminInterface $admin, array $values = [])
{
// Check if we use smart or original datagrid builder
$smartDatagrid = $this->smartDatagridBuilder->isSmart($admin, $values);
return $this->getAdminDatagridBuilder($admin, $smartDatagrid)->getBaseDatagrid($admin, $... | {@inheritdoc} | entailment |
public function filter(ProxyQueryInterface $query, $alias, $field, $data)
{
if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) {
return;
}
$data['type'] = !isset($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type'];
... | {@inheritdoc} | entailment |
private function getOperators($type)
{
$choices = [
ChoiceType::TYPE_CONTAINS => ['must', 'terms'],
ChoiceType::TYPE_NOT_CONTAINS => ['must_not', 'terms'],
];
return $choices[$type] ?? false;
} | @param string $type
@return bool | entailment |
public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
$token = $token->toJSON();
if(isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])){
$_SESSION[$this->sessionVar][$service] = $token;
}
else{
$_SESSION[$this->sessionVar] = [$service => $... | @param string $service
@param \chillerlan\OAuth\Core\AccessToken $token
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function getAccessToken(string $service):AccessToken{
if($this->hasAccessToken($service)){
return (new AccessToken)->fromJSON($_SESSION[$this->sessionVar][$service]);
}
throw new OAuthStorageException('token not found');
} | @param string $service
@return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface
@throws \chillerlan\OAuth\Storage\OAuthStorageException | entailment |
public function hasAccessToken(string $service):bool{
return isset($_SESSION[$this->sessionVar], $_SESSION[$this->sessionVar][$service]);
} | @param string $service
@return bool | entailment |
public function clearAccessToken(string $service):OAuthStorageInterface{
if(array_key_exists($service, $_SESSION[$this->sessionVar])){
unset($_SESSION[$this->sessionVar][$service]);
}
return $this;
} | @param string $service
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
if(isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])){
$_SESSION[$this->stateVar][$service] = $state;
}
else{
$_SESSION[$this->stateVar] = [$service => $state];
}
return $this;
} | @param string $service
@param string $state
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function getCSRFState(string $service):string{
if($this->hasCSRFState($service)){
return $_SESSION[$this->stateVar][$service];
}
throw new OAuthStorageException('state not found');
} | @param string $service
@return string
@throws \chillerlan\OAuth\Storage\OAuthStorageException | entailment |
public function hasCSRFState(string $service):bool{
return isset($_SESSION[$this->stateVar], $_SESSION[$this->stateVar][$service]);
} | @param string $service
@return bool | entailment |
public function clearCSRFState(string $service):OAuthStorageInterface{
if(array_key_exists($service, $_SESSION[$this->stateVar])){
unset($_SESSION[$this->stateVar][$service]);
}
return $this;
} | @param string $service
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function guessType($class, $property, ModelManagerInterface $modelManager)
{
if (!$ret = $modelManager->getParentMetadataForProperty($class, $property, $modelManager)) {
return false;
}
$options = [
'field_type' => null,
'field_options' => [],
... | {@inheritdoc} | entailment |
public function refreshAccessToken(AccessToken $token = null):AccessToken{
if($token === null){
$token = $this->storage->getAccessToken($this->serviceName);
}
$refreshToken = $token->refreshToken;
if(empty($refreshToken)){
if(!$this instanceof AccessTokenForRefresh){
throw new ProviderException(sp... | @param \chillerlan\OAuth\Core\AccessToken $token
@return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface
@throws \chillerlan\OAuth\Core\ProviderException | entailment |
public function prepareRequest($method, array $params = [])
{
$request = [
'jsonrpc' => '2.0',
'method' => $method,
'id' => mt_rand()
];
$request['params'] = $params ? $params : [];
/*$request['params'] = array_merge($request['params'], $th... | prepare a json rpc request array
@param $method
@param array $params
@return array | entailment |
public function makeRequest($request)
{
$optionsSet = curl_setopt_array($this->ch, [
CURLOPT_URL => $this->url,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => $this->timeout,
CURLOPT_USERAGENT => 'JSON-RPC Random... | make the request to the server and get response
@param $request
@return mixed
@throws RuntimeException
@throws \Exception | entailment |
public function getResponse(array $response)
{
if (isset($response['error']['code'])) {
$this->handleRpcErrors($response['error']);
}
return isset($response['result']) ? $response['result'] : null;
} | Get the response from the server
if there are API error pass them to error handler function
@param array $response
@return null
@throws BadFunctionCallException
@throws InvalidArgumentException
@throws RuntimeException | entailment |
public function handleRpcErrors($error)
{
switch ($error['code']) {
case -32600:
throw new \InvalidArgumentException('Invalid Request: '. $error['message']);
case -32601:
throw new \BadFunctionCallException('Procedure not found: '. $error['message']);
... | Process JSON-RPC errors
@param $error
@throws BadFunctionCallException
@throws InvalidArgumentException
@throws RuntimeException | entailment |
public function getResults()
{
return $this->getPaginator()->getResults(
$this->getQuery()->getFirstResult(),
$this->getQuery()->getMaxResults()
)->toArray();
} | {@inheritdoc} | entailment |
private function parse_ftp_rawlist($line) {
$output = array();
$split = preg_split('[ ]', $line, 9, PREG_SPLIT_NO_EMPTY);
if ($split[0] != 'total') {
$output['isdir'] = ($split[0] {0} === 'd');
$output['perms'] = $split[0];
$output['number'] = $split[1];
$output['owner'] = $split[2];
$output['grou... | function inspired by http://andreas.glaser.me/2009/03/12/php-ftp_rawlist-parser-windows-unixlinux/ | entailment |
public static function country2locale($code) {
# http://wiki.openstreetmap.org/wiki/Nominatim/Country_Codes
$arr = array(
'ad' => 'ca',
'ae' => 'ar',
'af' => 'fa,ps',
'ag' => 'en',
'ai' => 'en',
'al' => 'sq',
'am' => 'hy',
'an' => 'nl,en',
'ao' => 'pt',
... | #=================================================================== | entailment |
public function setHost(/* string */ $host) {
// Close connection before changing host.
if ($this->host !== $host) {
$this->close();
$this->host = $host;
}
} | Changing FTP host name or IP
@param string $host New hostname | entailment |
public function setPort(/* integer */ $port) {
// Close connection before changing port.
if ($this->port !== $port) {
$this->close();
$this->port = $port;
}
} | Changing FTP port.
@param integer $port New hostname | entailment |
public function setUser(/* string */ $user) {
// Close connection before changing username.
if ($this->user !== $user) {
$this->close();
$this->user = $user;
}
} | Changing FTP connecting username.
@param string $user New username | entailment |
public function setPass(/* string */ $pass) {
// Close connection before changing password.
if ($this->pass !== $pass) {
$this->close();
$this->pass = $pass;
}
} | Changing FTP password.
@param string $pass New password | entailment |
public function setPassive(/* boolean */ $passive) {
// Close connection before changing password.
if ($this->passive !== $passive) {
$this->passive = $passive;
if (isset($this->handle) && $this->handle != null) {
$this->pasv($this->passive);
}
}
} | Changing FTP passive mode.
@param boolean $passive Set passive mode
@throws FtpException if passive mode could not be set. | entailment |
public function systype() {
$this->connectIfNeeded();
$res = @ftp_systype($this->handle);
return $res == null || $res == false ? 'UNIX' : $res;
} | Returns the remote system type.
@return string The remote system type | entailment |
public function pasv($pasv) {
$this->connectIfNeeded();
$this->param = $pasv;
if (!ftp_pasv($this->handle, $pasv === true)) {
throw new FtpException(
Yii::t('gftp', 'Could not {set} passive mode on server "{host}": {message}', [
'host' => $this->host, 'set' => $pasv ? "set" : "unset"
])
);
... | Turns on or off passive mode.
@param bool $pasv If <strong>TRUE</strong>, the passive mode is turned on, else it's turned off. | entailment |
public function execute($command, $raw = false) {
$this->connectIfNeeded();
$this->param = $command;
if (!$raw && $this->stringStarts($command, "SITE EXEC")) {
$this->exec(substr($command, strlen("SITE EXEC")));
return true;
} else if (!$raw && $this->stringStarts($command, "SITE")) {
$this->site(subs... | Execute any command on FTP server.
@param string $command FTP command.
@param bool $raw Do not parse command to determine if it is a <i>SITE</i> or <i>SITE EXEC</i> command.
@returns bool|string[] Depending on command : SITE and SITE EXEC command will returns <strong>TRUE</strong>; other comma... | entailment |
public function exec($command) {
$this->connectIfNeeded();
$this->param = "SITE EXEC " . $command;
$exec = true;
if (!ftp_exec($this->handle, substr($command, strlen("SITE EXEC")))) {
throw new FtpException(
Yii::t('gftp', 'Could not execute command "{command}" on "{host}"', [
'host' => $this->host... | Sends a SITE EXEC command request to the FTP server.
@param string $command FTP command (does not include <i>SITE EXEC</i> words).
@throws FtpException If command execution fails. | entailment |
public function site($command) {
$this->connectIfNeeded();
$this->param = "SITE " . $command;
if (!ftp_site($this->handle, $command)) {
throw new FtpException(
Yii::t('gftp', 'Could not execute command "{command}" on "{host}"', [
'host' => $this->host, '{command}' => $this->param
])
);
}
} | Sends a SITE command request to the FTP server.
@param string $command FTP command (does not include <strong>SITE</strong> word).
@throws FtpException If command execution fails. | entailment |
public function raw($command) {
$this->connectIfNeeded();
$this->param = $command;
$res = ftp_raw($this->handle, $command);
return $res;
} | Sends an arbitrary command to the FTP server.
@param string $command FTP command to execute.
@return string[] The server's response as an array of strings. No parsing is performed on the response string and not determine if the command succeeded.
@throws FtpException If command execution fails. | entailment |
protected function connectIfNeeded($login = true) {
if (!isset($this->handle) || $this->handle == null) {
$this->connect();
if ($login && $this->user != null && $this->user != "") {
$this->login($this->user, $this->pass);
}
}
} | Connects and log in to FTP server if not already login.
Call to {link GFTp::connect} and {@link GTP::login} is not mandatory.
Must be called in each method, before executing FTP command.
@param bool $login Flag indicating if login will be done.
@see GFTp::connect
@see GFTp::login
@throws FtpException if... | entailment |
private function createException($function, $message) {
if ($function == 'ftp_connect()' || $function == 'ftp_ssl_connect()') {
$this->handle = false;
return new FtpException(
Yii::t('gftp', 'Could not connect to FTP server "{host}" on port "{port}": {message}', [
'host' => $this->host, 'port' => $this... | Handles FTP error (ftp_** functions sometimes use PHP error instead of methofr return).
It throws FtpException when ftp_** error is found.
@param string $function FTP function name
@param string $message Error message
@return FtpException if PHP error on ftp_*** method is found, null otherwise. | entailment |
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{
$request = $this->requestFactory
->createRequest($method ?? 'GET', Psr7\merge_query($this->apiURL.$path, $params ?? []));
foreach(array_merge($this->apiHeaders, $headers ??... | @param string $path
@param array $params
@param string $method
@param mixed $body
@param array $headers
@return \Psr\Http\Message\ResponseInterface | entailment |
public function sendRequest(RequestInterface $request):ResponseInterface{
// get authorization only if we request the provider API
if(strpos((string)$request->getUri(), $this->apiURL) === 0){
$token = $this->storage->getAccessToken($this->serviceName);
// attempt to refresh an expired token
if($this inst... | @param \Psr\Http\Message\RequestInterface $request
@return \Psr\Http\Message\ResponseInterface | entailment |
public function filter(ProxyQueryInterface $query, $alias, $field, $data)
{
if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || !is_numeric($data['value'])) {
return;
}
$type = $data['type'] ?? false;
$operator = $this->getOperator($type);
$... | {@inheritdoc} | entailment |
public function getBaseDatagrid(AdminInterface $admin, array $values = [])
{
$pager = new Pager();
$defaultOptions = [];
$defaultOptions['csrf_protection'] = false;
$formBuilder = $this->formFactory->createNamedBuilder(
'filter',
'form',
[],
... | {@inheritdoc} | entailment |
public function isSmart(AdminInterface $admin, array $values = [])
{
// first : validate if elastica is asked in the configuration for this action
$logicalControllerName = $admin->getRequest()->attributes->get('_controller');
$currentAction = explode(':', $logicalControllerName);
// ... | Returns true if this datagrid builder can process these values. | entailment |
public function filter(ProxyQueryInterface $query, $alias, $field, $data)
{
if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) {
return;
}
$data['value'] = trim($data['value']);
if (0 === \strlen($data['value'])) {
return;
}
... | {@inheritdoc} | entailment |
private function parse_ftp_rawlist($line) {
$output = array();
ereg('([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)', $Current, $split);
if (is_array($split)) {
if ($split[3] < 70) {
$split[3] += 2000;
} else {
$split[3] += 1900;
}
$output['isdir'] = ($split[7... | function inspired by http://andreas.glaser.me/2009/03/12/php-ftp_rawlist-parser-windows-unixlinux/ | entailment |
public function getFieldOptions()
{
return $this->getOption('choices', [
'required' => false,
'choice_list' => new ChoiceList(
array_values($this->getOption('sub_classes')),
array_keys($this->getOption('sub_classes'))
),
]);
} | {@inheritdoc} | entailment |
public function setConnectionString($connectionString) {
if (!isset($connectionString) || !is_string($connectionString) || trim($connectionString) === "") {
throw new FtpException(
Yii::t('gftp', '{connectString} is not a valid connection string', [
'connectString' => $connectionString
])
);
}
... | Sets a new connection string. If connection is already openned, try to close it before.
@param string $connectionString FTP connection string (like ftp://[<user>[:<pass>]@]<host>[:<port>])
@throws FtpException if <i>connectionString</i> is not valid or if could not close an already openned connection. | entailment |
protected function connectIfNeeded($login = true) {
if (!isset($this->handle) || $this->handle == null) {
$this->connect();
if ($login)
$this->login();
}
} | Connects and log in to FTP server if not already login.
Call to {link GFTp::connect} and {@link GTP::login} is not mandatory.
Must be called in each method, before executing FTP command.
@param bool $login Flag indicating if login will be done.
@see GFTp::connect
@see GFTp::login
@throws FtpException if... | entailment |
public function connect() {
if (isset($this->handle) && $this->handle != null) {
$this->close();
}
$this->parseConnectionString();
$this->handle = \Yii::createObject($this->driverOptions);
$this->handle->connect();
$this->onConnectionOpen(new Event(['sender' => $this]));
} | Connect to FTP server.
throws FtpException If connection failed. | entailment |
public function login () {
$this->connectIfNeeded(false);
$this->handle->login();
$this->onLogin(new Event(['sender' => $this, 'data' => $this->handle->user]));
} | Log into the FTP server. If connection is not openned, it will be openned before login.
@param string $user Username used for log on FTP server.
@param string $password Password used for log on FTP server.
@throws FtpException if connection failed. | entailment |
public function ls($dir = ".", $full = false, $recursive = false) {
$this->connectIfNeeded();
return $this->handle->ls($dir, $full, $recursive);
} | Returns list of files in the given directory.
@param string $dir The directory to be listed.
This parameter can also include arguments, eg. $ftp->ls("-la /your/dir");
Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters.
@param string ... | entailment |
public function close() {
if (isset($this->handle) && $this->handle != null) {
$this->handle->close();
$this->handle = false;
$this->onConnectionClose(new Event(['sender' => $this]));
}
} | Close FTP connection.
@throws FtpException Raised when error occured when closing FTP connection. | entailment |
public function mkdir($dir) {
$this->connectIfNeeded();
$this->handle->mkdir($dir);
$this->onFolderCreated(new Event(['sender' => $this, 'data' => $dir]));
} | Create a new folder on FTP server.
@param string $dir Folder to create on server (relative or absolute path).
@throws FtpException If folder creation failed. | entailment |
public function rmdir($dir) {
$this->connectIfNeeded();
$this->handle->rmdir($dir);
$this->onFolderDeleted(new Event(['sender' => $this, 'data' => $dir]));
} | Removes a folder on FTP server.
@param string $dir Folder to delete from server (relative or absolute path).
@throws FtpException If folder deletion failed. | entailment |
public function chdir($dir) {
$this->connectIfNeeded();
$this->handle->chdir($dir);
$this->onFolderChanged(new Event(['sender' => $this, 'data' => $dir]));
try {
$cwd = $this->pwd();
} catch (FtpException $ex) {
$cwd = $dir;
}
return $cwd;
} | Changes current folder.
@param string $dir Folder to move on (relative or absolute path).
@return string Current folder on FTP server.
@throws FtpException If folder deletion failed. | entailment |
public function get($remote_file, $local_file = null, $mode = FTP_ASCII, $asynchronous = false, callable $asyncFn = null) {
$this->connectIfNeeded();
$local_file = $this->handle->get($remote_file, $local_file,$mode, $asynchronous, $asyncFn);
$this->onFileDownloaded(new Event(['sender' => $this, 'data' => $local... | Download a file from FTP server.
@param string $remote_file The remote file path.
@param string|resource $local_file The local file path. If set to <strong>null</strong>, file will be downloaded inside current folder using remote file base name).
@param int $mode The transfer mode. Must be either <strong>FTP_ASCII</st... | entailment |
public function put($local_file, $remote_file = null, $mode = FTP_ASCII, $asynchronous = false, callable $asyncFn = null) {
$this->connectIfNeeded();
$full_remote_file = $this->handle->put($local_file, $remote_file, $mode, $asynchronous, $asyncFn);
$this->onFileUploaded(new Event(['sender' => $this, 'data' => $re... | Upload a file to the FTP server.
@param string|resource $local_file The local file path.
@param string $remote_file The remote file path. If set to <strong>null</strong>, file will be downloaded inside current folder using local file base name).
@param int $mode The transfer mode.... | entailment |
public function delete($path) {
$this->connectIfNeeded();
$this->handle->delete($path);
$this->onFileDeleted(new Event(['sender' => $this, 'data' => $path]));
} | Deletes specified files from FTP server.
@param string $path The file to delete.
@throws FtpException If file could not be deleted. | entailment |
public function rename($oldname, $newname) {
$this->connectIfNeeded();
$this->handle->rename($oldname, $newname);
$this->onFileRenamed(
new Event(['sender' => $this, 'data' => [
'oldname' => $oldname,
'newname' => $newname
]])
);
} | Renames a file or a directory on the FTP server.
@param string $oldname The old file/directory name.
@param string $newname The new name.
@throws FtpException If an error occured while renaming file or folder. | entailment |
public function chmod($mode, $file) {
$this->connectIfNeeded();
$this->handle->chmod($mode, $file);
$this->onFileModeChanged(
new Event(['sender' => $this, 'data' => [
'mode' => $mode, 'file' => $file
]])
);
} | Set permissions on a file via FTP.
@param string $mode The new permissions, given as an <strong>octal</strong> value.
@param string $file The remote file.
@throws FtpException If couldn't set file permission. | entailment |
public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
$this->tokens[$service] = $token;
return $this;
} | @param string $service
@param \chillerlan\OAuth\Core\AccessToken $token
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function getAccessToken(string $service):AccessToken{
if($this->hasAccessToken($service)){
return $this->tokens[$service];
}
throw new OAuthStorageException('token not found');
} | @param string $service
@return \chillerlan\OAuth\Core\AccessToken|\chillerlan\Settings\SettingsContainerInterface
@throws \chillerlan\OAuth\Storage\OAuthStorageException | entailment |
public function hasAccessToken(string $service):bool {
return isset($this->tokens[$service]) && $this->tokens[$service] instanceof AccessToken;
} | @param string $service
@return bool | entailment |
public function clearAccessToken(string $service):OAuthStorageInterface{
if(array_key_exists($service, $this->tokens)){
unset($this->tokens[$service]);
}
return $this;
} | @param string $service
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
$this->states[$service] = $state;
return $this;
} | @param string $service
@param string $state
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function getCSRFState(string $service):string{
if($this->hasCSRFState($service)){
return $this->states[$service];
}
throw new OAuthStorageException('state not found');
} | @param string $service
@return string
@throws \chillerlan\OAuth\Storage\OAuthStorageException | entailment |
public function hasCSRFState(string $service):bool {
return isset($this->states[$service]) && null !== $this->states[$service];
} | @param string $service
@return bool | entailment |
public function clearCSRFState(string $service):OAuthStorageInterface{
if(array_key_exists($service, $this->states)){
unset($this->states[$service]);
}
return $this;
} | @param string $service
@return \chillerlan\OAuth\Storage\OAuthStorageInterface | entailment |
public function filter(ProxyQueryInterface $query, $alias, $field, $data)
{
// check data sanity
if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) {
return;
}
$format = \array_key_exists('format', $this->getFieldOptions()) ? $this->getFieldOptions()[... | {@inheritdoc} | entailment |
public function decode($data, $format, array $context = [])
{
$decoded = parent::decode($data, $format, $context);
if (isset($decoded['$xmlns'])) {
$this->decodeCustomFields($decoded);
}
$this->cleanup($decoded);
return $decoded;
} | {@inheritdoc} | entailment |
protected function cleanup(array &$data)
{
foreach ($data as &$value) {
if (\is_array($value)) {
$this->cleanup($value);
}
}
$data = array_filter($data, function ($value) {
return null !== $value;
});
} | Recursively filter an array, removing null and empty string values.
@param array &$data The data to filter. | entailment |
protected function decodeCustomFields(&$decoded)
{
// @todo This is O(namespaces * entries) and can be optimized.
foreach ($decoded['$xmlns'] as $prefix => $namespace) {
if (!isset($decoded['entries'])) {
$this->decodeObject($prefix, $namespace, $decoded);
... | Decode custom fields into a format usable by a normalizer.
mpx returns custom fields as properties on the data object, prefixed with
a namespace identifier. Custom fields are described in a single class,
and not by manually extending core data classes. To be able to normalize
those fields, they must be moved into a si... | entailment |
protected function decodeObject($prefix, $namespace, &$object)
{
$customFields = ['namespace' => $namespace];
foreach ($object as $key => $value) {
if (false !== strpos($key, $prefix.'$')) {
$fieldName = substr($key, \strlen($prefix) + 1);
$customFields['d... | Decodes an object's custom fields.
@param string $prefix The prefix of the namespace in the response.
@param string $namespace The namespace identifier.
@param array $object The object data to decode. | entailment |
public function boot()
{
$this->package('maxxscho/laravel-tcpdf');
/* override the default TCPDF config file
------------------------------------- */
if (!defined('K_TCPDF_EXTERNAL_CONFIG'))
{
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
}
$this->set... | Bootstrap the application events.
@return void | entailment |
private function setTcpdfConstants()
{
foreach ($this->config_constant_map as $const => $configkey)
{
if (!defined($const))
{
if (is_string(\Config::get('laravel-tcpdf::' . $configkey)))
{
if (strlen(\Config::get('laravel-tc... | Set TCPDF constants based on configuration file.
!Notice! Some contants are never used by TCPDF. They are in the config file of TCPDF, but ...
This is a bug by TCPDF but we set it for completeness.
@author Markus Schober | entailment |
public static function create(
RequestInterface $request,
ResponseInterface $response,
\Exception $previous = null,
array $ctx = []
) {
$data = \GuzzleHttp\json_decode($response->getBody(), true);
MpxExceptionTrait::validateData($data);
$altered = $response->... | Create a new MPX API exception.
@param \Psr\Http\Message\RequestInterface $request
@param \Psr\Http\Message\ResponseInterface $response
@param \Exception|null $previous
@param array $ctx
@return \Lullabot\Mpx\Exception\ClientException|\Lullabot\Mpx\Exception\ServerEx... | entailment |
private static function createException(RequestInterface $request,
ResponseInterface $altered,
\Exception $previous = null,
array $ctx = []
) {
if ($altered->getStatusCode() >= 400 && $altered->getStatusCode() < 500) {
return new ClientException($request, $altered, $previ... | Create a client or server exception.
@param RequestInterface $request
@param ResponseInterface $altered
@param \Exception $previous
@param array $ctx
@return ClientException|ServerException | entailment |
public static function basicDiscovery(): self
{
// @todo Check Drupal core for other tags to ignore?
AnnotationReader::addGlobalIgnoredName('class');
AnnotationRegistry::registerFile(__DIR__.'/Annotation/CustomField.php');
$discovery = new CustomFieldDiscovery('\\Lullabot\\Mpx', 'src... | Register our annotations, relative to this file.
@return static | entailment |
public function getCustomField(string $name, string $objectType, string $namespace): DiscoveredCustomField
{
$services = $this->discovery->getCustomFields();
if (isset($services[$name][$objectType][$namespace])) {
return $services[$name][$objectType][$namespace];
}
throw... | Returns one custom field.
@param string $name
@param string $objectType
@param string $namespace
@return DiscoveredCustomField | entailment |
private function getClass(InputInterface $input, string $mpxNamespace): array
{
if (!isset($this->namespaceClasses[$mpxNamespace])) {
$nf = new \NumberFormatter('en', \NumberFormatter::SPELLOUT);
$className = 'CustomFieldClass'.ucfirst(
str_replace('-', '', $nf->f... | @param InputInterface $input
@param string $mpxNamespace
@return array | entailment |
private function addProperty(ClassType $class, Field $field)
{
$property = $class->addProperty($field->getFieldName());
$property->setVisibility('protected');
if (!empty($field->getDescription())) {
$property->setComment($field->getDescription());
$property->addCommen... | Add a property to a class.
@param ClassType $class
@param Field $field | entailment |
private function getPhpDataType(Field $field): string
{
$dataType = static::TYPE_MAP[$field->getDataType()];
if ('Single' != $field->getDataStructure()) {
$dataType .= '[]';
}
return $dataType;
} | Get the PHP data type for a field, including mapping to arrays.
@param Field $field
@return string | entailment |
public function getTargetAvailableDate(): \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface
{
if (!$this->targetAvailableDate) {
return new NullDateTime();
}
return $this->targetAvailableDate;
} | Returns the DateTime when this playback availability window begins.
@return \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface | entailment |
public function setTargetAvailableDate(\Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $targetAvailableDate)
{
$this->targetAvailableDate = $targetAvailableDate;
} | Set the DateTime when this playback availability window begins.
@param \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $targetAvailableDate | entailment |
public function getTargetExpirationDate(): \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface
{
if (!$this->targetExpirationDate) {
return new NullDateTime();
}
return $this->targetExpirationDate;
} | Returns the DateTime when this playback availability window ends.
@return \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface | entailment |
public function setTargetExpirationDate(\Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $targetExpirationDate)
{
$this->targetExpirationDate = $targetExpirationDate;
} | Set the DateTime when this playback availability window ends.
@param \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $targetExpirationDate | entailment |
private function getNewRequest(string $method, UriInterface $uri): RequestInterface
{
return $this->transport->createRequest($method, $uri);
} | To get a new PSR7 request from transport instance to be able to dialog with Sellsy API.
@param string $method
@param UriInterface $uri
@return RequestInterface | entailment |
private function encodeOAuthHeaders(&$oauth)
{
$values = [];
foreach ($oauth as $key => &$value) {
$values[] = $key.'="'.\rawurlencode($value).'"';
}
return 'OAuth '.\implode(', ', $values);
} | Transform an the OAuth array configuration to HTTP headers OAuth string.
@param array $oauth
@return string | entailment |
private function setOAuthHeaders(RequestInterface $request): RequestInterface
{
$now = new \DateTime();
if ($this->now instanceof \DateTime) {
$now = clone $this->now;
}
//Generate HTTP headers
$encodedKey = \rawurlencode($this->oauthConsumerSecret).'&'.\rawurlen... | Internal method to generate HTTP headers to use for the API authentication with OAuth protocol.
@param RequestInterface $request
@return RequestInterface | entailment |
private function getUri(): UriInterface
{
$uri = $this->getNewUri();
if (!empty($this->apiUrl['scheme'])) {
$uri = $uri->withScheme($this->apiUrl['scheme']);
}
if (!empty($this->apiUrl['host'])) {
$uri = $uri->withHost($this->apiUrl['host']);
}
... | To get the PSR7 Uri instance to configure the PSR7 request to be able to dialog with the Sellsy API.
@return UriInterface | entailment |
private function setBodyRequest(RequestInterface $request, array &$requestSettings): RequestInterface
{
$multipartBody = [];
foreach ($requestSettings as $key => &$value) {
$multipartBody[] = [
'name' => $key,
'contents' => $value
];
}
... | To register method's argument in the request for the Sellsy API.
@param RequestInterface $request
@param array $requestSettings
@return RequestInterface | entailment |
public function run(MethodInterface $method, array $params = []): ResultInterface
{
//Arguments for the Sellsy API
$this->lastResponse = null;
$encodedRequest = [
'request' => 1,
'io_mode' => 'json',
'do_in' => \json_encode([
'method' => (s... | {@inheritdoc} | entailment |
protected function getDataObjectFactory(InputInterface $input, OutputInterface $output): DataObjectFactory
{
$authenticatedClient = $this->getAuthenticatedClient($input, $output);
$manager = DataServiceManager::basicDiscovery();
$dataService = $manager->getDataService(
$input->ge... | @param InputInterface $input
@param OutputInterface $output
@return DataObjectFactory | entailment |
protected function getAuthenticatedClient(InputInterface $input, OutputInterface $output): \Lullabot\Mpx\AuthenticatedClient
{
$helper = $this->getHelper('question');
if (!$username = getenv('MPX_USERNAME')) {
$question = new Question('Enter the mpx user name, such as mpx/you@example.com... | @param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return \Lullabot\Mpx\AuthenticatedClient | entailment |
private function extractMethodsName(string $websiteUrl): array
{
$documentSource = \file_get_contents($websiteUrl);
$methods = [];
$pattern = '#<div class="page-header">.*?<h1><a name="[a-z0-9]+"></a>([a-z0-9]+\.[a-z0-9]+)</h1>#isS';
if (false === \preg_match_all($pattern, $document... | To extract from the documentation (downloaded from the Sellsy server) all methods declared into it.
@param string $websiteUrl
@return array | entailment |
private function getSellsyInstance(): Sellsy
{
$sellSy = new Sellsy('', '', '', '', '');
$transport = new class implements TransportInterface {
public function createUri(): UriInterface
{
}
public function createRequest(string $method, UriInterface $u... | To return a instance of sellsy to check if a collection and a method is defined and is available here.
TO prevent some issues with the inconsistency of the Sellsy Document, this method will preload some collections.
to avoid false positive.
@return Sellsy | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$websiteUrl = $input->getArgument('website');
$output->writeln(\sprintf('Check the documentation at "%s"', $websiteUrl));
try {
$methodsList = $this->extractMethodsName($websiteUrl);
} catch (\T... | {@inheritdoc} | entailment |
public function getTypes($class, $property, array $context = [])
{
// First, check to see if this object is a custom field.
if (isset($this->xmlns[$property])) {
return $this->customFieldInstance($property);
}
// Check if this is an array of custom field objects.
... | {@inheritdoc} | entailment |
private function customFieldInstance($prefix): array
{
$ns = $this->xmlns[$prefix];
if (!$discoveredCustomField = $this->customFields[$ns]) {
throw new LogicException(
sprintf(
'No custom field class was found for %s. setCustomFields() must be called ... | Return the type for a custom field class.
@param string $prefix The prefix of the namespace.
@return array | entailment |
private function customFieldsArrayType(): array
{
$collectionKeyType = new Type(Type::BUILTIN_TYPE_STRING);
$collectionValueType = new Type('object', false, CustomFieldInterface::class);
return [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, $collectionKeyType, $collectionValueType)]... | Return the type for an array of custom fields, indexed by a string.
@return array | entailment |
private function entriesType(): array
{
// This is an object list, so handle the 'entries' key.
if (!isset($this->class)) {
throw new \UnexpectedValueException('setClass() must be called before using this extractor.');
}
$collectionKeyType = new Type(Type::BUILTIN_TYPE_I... | Return the type of an array of entries used in an object list.
@return array | entailment |
public function getAdded(): \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface
{
if (!$this->added) {
return new NullDateTime();
}
return $this->added;
} | Returns the date and time that this object was created.
@return \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface | entailment |
public function setAdded(\Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $added)
{
$this->added = $added;
} | Set the date and time that this object was created.
@param \Lullabot\Mpx\DataService\DateTime\DateTimeFormatInterface $added | entailment |
public function getAddedByUserId(): \Psr\Http\Message\UriInterface
{
if (!$this->addedByUserId) {
return new Uri();
}
return $this->addedByUserId;
} | Returns the id of the user that created this object.
@return \Psr\Http\Message\UriInterface | entailment |
public function getId(): \Psr\Http\Message\UriInterface
{
if (!$this->id) {
return new Uri();
}
return $this->id;
} | Returns the globally unique URI of this object.
@return \Psr\Http\Message\UriInterface | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.