sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function createPackageFolder($packagePath)
{
$this->info('Create package folder.');
if (File::exists($packagePath)) {
$this->info('Package folder already exists. Skipping.');
return;
}
if (! File::makeDirectory($packagePath, 0755, true)) {
... | Create package folder.
@param string $packagePath
@throws RuntimeException | entailment |
protected function removePackageFolder($packagePath)
{
$this->info('Remove package folder.');
if (File::exists($packagePath)) {
if (! File::deleteDirectory($packagePath)) {
throw new RuntimeException('Cannot remove package folder');
}
$this->info... | Remove package folder.
@param $packagePath
@throws RuntimeException | entailment |
public function handle()
{
$vendor = $this->getVendor();
$package = $this->getPackage();
$vendorFolderName = $this->getVendorFolderName($vendor);
$packageFolderName = $this->getPackageFolderName($package);
$relPackagePath = "packages/$vendorFolderName/$packageFolderName";
... | Execute the console command.
@return mixed | entailment |
public function levenshtein($first, $second)
{
$l = new \Atomescrochus\StringSimilarities\Levenshtein();
return $l->compare($first, $second);
} | Run a basic levenshtein comparison using PHP's built-in function
@param string $first First string to compare
@param string $second Second string to compare
@return string Returns the phrase passed in | entailment |
protected function askUser($question, $defaultValue = '')
{
if ($this->option('interactive')) {
return $this->ask($question, $defaultValue);
}
return $defaultValue;
} | Ask user.
@param $question
@param $defaultValue
@return string | entailment |
public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
if ($row['CType'] === 'pagelist_selected' || $row['CType'] === 'pagelist_sub' || $row['CType'] === 'pagelist_category') {
if ($row['CType'] === 'pagelist_selected') {
$itemContent = $parentObjec... | Preprocesses the preview rendering of a content element of type "textmedia"
@param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
@param bool $drawItem Whether to draw the item using the default functionality
@param string $headerContent Header content
@param string $itemContent Item conten... | entailment |
public function run()
{
if(empty($this->options['id'])) {
$this->options['id'] = $this->id;
}
if($this->encodeLabel) {
$this->label = Html::encode($this->label);
}
$perPage = !empty($_GET[$this->pageSizeParam]) ? $_GET[$this->pageSizeParam] : $this->defaultPageSize;
$listHtml = H... | Runs the widget and render the output | entailment |
protected function registerPackage($vendor, $package, $relPackagePath)
{
$this->info('Register package in composer.json.');
$composerJson = $this->loadComposerJson();
if (! isset($composerJson['repositories'])) {
Arr::set($composerJson, 'repositories', []);
}
$... | Register package in composer.json.
@param $vendor
@param $package
@param $relPackagePath
@throws RuntimeException | entailment |
protected function unregisterPackage($vendor, $package, $relPackagePath)
{
$this->info('Unregister package from composer.json.');
$composerJson = $this->loadComposerJson();
unset($composerJson['require']["$vendor\\$package\\"]);
$repositories = array_filter($composerJson['reposito... | Unregister package from composer.json.
@param $vendor
@param $package
@throws FileNotFoundException
@throws RuntimeException | entailment |
protected function loadComposerJson()
{
$composerJsonPath = $this->getComposerJsonPath();
if (! File::exists($composerJsonPath)) {
throw new FileNotFoundException('composer.json does not exist');
}
$composerJsonContent = File::get($composerJsonPath);
$composerJs... | Load and parse content of composer.json.
@return array
@throws FileNotFoundException
@throws RuntimeException | entailment |
protected function saveComposerJson($composerJson)
{
$newComposerJson = json_encode(
$composerJson,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
$composerJsonPath = $this->getComposerJsonPath();
if (File::put($composerJsonPath, $newComposerJson) === false) {... | @param array $composerJson
@throws RuntimeException | entailment |
public function handle()
{
$url = $this->argument('url');
try {
list($vendorFolderName, $packageFolderName) = $this->getVendorAndFolderName($url);
} catch (Exception $e) {
$this->error($e->getMessage());
return -1;
}
$vendor = $this->get... | Execute the console command.
@return mixed | entailment |
protected function getVendorAndFolderName($url)
{
if (Str::contains($url, '@')) {
$vendorAndPackage = explode(':', $url);
$vendorAndPackage = explode('/', $vendorAndPackage[1]);
return [
$vendorAndPackage[0],
Str::replaceLast('.git', '', ... | Get vendor and package folder name.
@param $url
@return array | entailment |
public function hasMultilingualAttribute($name)
{
return in_array($name, $this->attributes) || array_key_exists($name, $this->_multilingualAttributes);
} | Whether an attribute exists
@param string $name the name of the attribute
@return boolean | entailment |
public function getMultilingualAttributeLabel($attribute)
{
$attributeLabels = $this->getMultilingualAttributeLabels();
return isset($attributeLabels[$attribute]) ? $attributeLabels[$attribute] : $attribute;
} | Return multilingual attribute label.
@param string $attribute
@return string | entailment |
public function beforeAction($event)
{
if (!Yii::$app->errorHandler->exception && count($this->languages) > 1) {
// Set language by GET request, session or cookie
if ($language = Yii::$app->getRequest()->get('language')) {
Yii::$app->language = $this->getLanguageCod... | Tracks language parameter for multilingual controllers.
@param ActionEvent $event
@return bool
@throws MethodNotAllowedHttpException|InvalidConfigException when the request method is not allowed. | entailment |
protected function getLanguageCode($redirectLanguageCode)
{
$sourceLanguage = MultilingualHelper::getRedirectedLanguageCode($redirectLanguageCode, $this->languageRedirects);
if (!isset($this->languages[$sourceLanguage])) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')... | Returns code of language by its redirect language code.
@param string $redirectLanguageCode
@return string
@throws NotFoundHttpException | entailment |
public function getStatus($id = null)
{
if ($this->isSuccess()) {
if (!$id) {
$result = $this->getResult();
return $result[0]['status'];
}
foreach ($this->getResult() as $row) {
if ($row['id'] == $id) {
... | Get the status of a lead. If no lead ID is given, it returns the status of the first lead returned.
@param $id
@return bool | entailment |
public function register()
{
$this->app->singleton('orchestra.imagine', function (Application $app) {
$manager = new ImagineManager($app);
$namespace = $this->hasPackageRepository() ? 'orchestra/imagine::' : 'orchestra.imagine';
$manager->setConfig($app->make('config')->... | Register the service provider.
@return void | entailment |
protected function registerCoreContainerAliases(): void
{
$this->app->alias('orchestra.imagine', ImagineManager::class);
$this->app->bind(ImagineInterface::class, function (Application $app) {
return $app->make('orchestra.imagine')->driver();
});
} | Register the core class aliases in the container.
@return void | entailment |
public function handle(ImagineInterface $imagine)
{
$data = $this->getFilteredOptions($this->options);
$path = \rtrim($data['path'], '/');
$source = Str::replace('{filename}.{extension}', $data);
$destination = Str::replace($data['format'], $data);
$this->handleImageManipul... | Execute the job.
@param \Imagine\Image\ImagineInterface $imagine
@return void | entailment |
protected function getFilteredOptions(array $options)
{
$default = $this->getDefaultOptions();
$options = \array_merge($default, $options);
$uses = \array_unique(\array_merge([
'path', 'filename', 'extension', 'format',
], \array_keys($default)));
$data = Arr::o... | Get filtered options.
@param array $options
@return array | entailment |
public function generateTableName($ownerTableName, $tableNameSuffix)
{
if (preg_match('/{{%(\w+)}}$/', $ownerTableName, $matches)) {
$ownerTableName = $matches[1];
}
return '{{%' . $ownerTableName . $tableNameSuffix . '}}';
} | Generate translation table name.
@param ActiveRecord $ownerTableName
@param string $tableNameSuffix
@return string | entailment |
public function getTranslations()
{
return $this->owner->hasMany($this->translationClassName, [$this->languageForeignKey => $this->_ownerPrimaryKey]);
} | Relation to model translations
@return ActiveQuery | entailment |
public function getTranslation($language = null)
{
$language = $language ?: $this->_currentLanguage;
return $this->owner->hasOne($this->translationClassName, [$this->languageForeignKey => $this->_ownerPrimaryKey])
->where([$this->languageField => $language]);
} | Relation to model translation
@param $language
@return ActiveQuery | entailment |
public function beforeValidate()
{
foreach ($this->attributes as $attribute) {
$this->setMultilingualAttribute($this->getAttributeName($attribute, $this->_currentLanguage), $this->getMultilingualAttribute($attribute));
}
} | Handle 'beforeValidate' event of the owner. | entailment |
public function afterFind()
{
/** @var ActiveRecord $owner */
$owner = $this->owner;
if ($owner->isRelationPopulated('translations') && $related = $owner->getRelatedRecords()['translations']) {
$translations = $this->indexByLanguage($related);
foreach ($this->_langua... | Handle 'afterFind' event of the owner. | entailment |
public function afterUpdate()
{
/** @var ActiveRecord $owner */
$owner = $this->owner;
if ($owner->isRelationPopulated('translations')) {
$translations = $this->indexByLanguage($owner->getRelatedRecords()['translations']);
$this->saveTranslations($translations);
... | Handle 'afterUpdate' event of the owner. | entailment |
protected function initTranslationClass()
{
if (!class_exists($this->translationClassName)) {
$namespace = substr($this->translationClassName, 0, strrpos($this->translationClassName, '\\'));
$translationClassName = $this->getShortClassName($this->translationClassName);
e... | Create dynamic translation model. | entailment |
public static function factory($config = array())
{
$default = array(
'url' => false,
'munchkin_id' => false,
'version' => 1,
'bulk' => false
);
$required = array('client_id', 'client_secret', 'version');
$config = Collection::fromConf... | {@inheritdoc} | entailment |
public function importLeadsCsv($args)
{
if (!is_readable($args['file'])) {
throw new \Exception('Cannot read file: ' . $args['file']);
}
if (empty($args['format'])) {
$args['format'] = 'csv';
}
return $this->getResult('importLeadsCsv', $args);
} | Import Leads via file upload
@param array $args - Must contain 'format' and 'file' keys
e.g. array( 'format' => 'csv', 'file' => '/full/path/to/filename.csv'
@link http://developers.marketo.com/documentation/rest/import-lead/
@return array
@throws \Exception | entailment |
public function getBulkUploadStatus($batchId)
{
if (empty($batchId) || !is_int($batchId)) {
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
}
return $this->getResult('getBulkUploadStatus', array('batchId' => $batchId));
} | Get status of an async Import Lead file upload
@param int $batchId
@link http://developers.marketo.com/documentation/rest/get-import-lead-status/
@return array | entailment |
public function getBulkUploadFailures($batchId)
{
if( empty($batchId) || !is_int($batchId) ) {
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
}
return $this->getResult('getBulkUploadFailures', array('batchId' => $batchId));
} | Get failed lead results from an Import Lead file upload
@param int $batchId
@link http://developers.marketo.com/documentation/rest/get-import-failure-file/
@return Guzzle\Http\Message\Response | entailment |
public function getBulkUploadWarnings($batchId)
{
if( empty($batchId) || !is_int($batchId) ) {
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
}
return $this->getResult('getBulkUploadWarnings', array('batchId' => $batchId));
} | Get warnings from Import Lead file upload
@param int $batchId
@link http://developers.marketo.com/documentation/rest/get-import-warning-file/
@return Guzzle\Http\Message\Response | entailment |
private function createOrUpdateLeadsCommand($action, $leads, $lookupField, $args, $returnRaw = false)
{
$args['input'] = $leads;
$args['action'] = $action;
if (isset($lookupField)) {
$args['lookupField'] = $lookupField;
}
return $this->getResult('createOrUpdateL... | Calls the CreateOrUpdateLeads command with the given action.
@param string $action
@param array $leads
@param string $lookupField
@param array $args
@see Client::createLeads()
@see Client::createOrUpdateLeads()
@see Client::updateLeads()
@see Client::createDuplicateLeads()
@link http://developers.marketo.com/docum... | entailment |
public function createLeads($leads, $lookupField = null, $args = array())
{
return $this->createOrUpdateLeadsCommand('createOnly', $leads, $lookupField, $args);
} | Create the given leads.
@param array $leads
@param string $lookupField
@param array $args
@see Client::createOrUpdateLeadsCommand()
@link http://developers.marketo.com/documentation/rest/createupdate-leads/
@return CreateOrUpdateLeadsResponse | entailment |
public function createOrUpdateLeads($leads, $lookupField = null, $args = array())
{
return $this->createOrUpdateLeadsCommand('createOrUpdate', $leads, $lookupField, $args);
} | Update the given leads, or create them if they do not exist.
@param array $leads
@param string $lookupField
@param array $args
@see Client::createOrUpdateLeadsCommand()
@link http://developers.marketo.com/documentation/rest/createupdate-leads/
@return CreateOrUpdateLeadsResponse | entailment |
public function updateLeads($leads, $lookupField = null, $args = array())
{
return $this->createOrUpdateLeadsCommand('updateOnly', $leads, $lookupField, $args);
} | Update the given leads.
@param array $leads
@param string $lookupField
@param array $args
@see Client::createOrUpdateLeadsCommand()
@link http://developers.marketo.com/documentation/rest/createupdate-leads/
@return CreateOrUpdateLeadsResponse | entailment |
public function createDuplicateLeads($leads, $lookupField = null, $args = array())
{
return $this->createOrUpdateLeadsCommand('createDuplicate', $leads, $lookupField, $args);
} | Create duplicates of the given leads.
@param array $leads
@param string $lookupField
@param array $args
@see Client::createOrUpdateLeadsCommand()
@link http://developers.marketo.com/documentation/rest/createupdate-leads/
@return CreateOrUpdateLeadsResponse | entailment |
public function getLists($ids = null, $args = array(), $returnRaw = false)
{
if ($ids) {
$args['id'] = $ids;
}
return $this->getResult('getLists', $args, is_array($ids), $returnRaw);
} | Get multiple lists.
@param int|array $ids Filter by one or more IDs
@param array $args
@link http://developers.marketo.com/documentation/rest/get-multiple-lists/
@return GetListsResponse | entailment |
public function getList($id, $args = array(), $returnRaw = false)
{
$args['id'] = $id;
return $this->getResult('getList', $args, false, $returnRaw);
} | Get a list by ID.
@param int $id
@param array $args
@link http://developers.marketo.com/documentation/rest/get-list-by-id/
@return GetListResponse | entailment |
public function getLeadsByFilterType($filterType, $filterValues, $fields = array(), $nextPageToken = null, $returnRaw = false)
{
$args['filterType'] = $filterType;
$args['filterValues'] = $filterValues;
if ($nextPageToken) {
$args['nextPageToken'] = $nextPageToken;
}
... | Get multiple leads by filter type.
@param string $filterType One of the supported filter types, e.g. id, cookie or email. See Marketo's documentation for all types.
@param string $filterValues Comma separated list of filter values
@param array $fields Array of field names to be returned in the response
@param... | entailment |
public function getLeadByFilterType($filterType, $filterValue, $fields = array(), $returnRaw = false)
{
$args['filterType'] = $filterType;
$args['filterValues'] = $filterValue;
if (count($fields)) {
$args['fields'] = implode(',', $fields);
}
return $this->getRes... | Get a lead by filter type.
Convenient method which uses {@link http://developers.marketo.com/documentation/rest/get-multiple-leads-by-filter-type/}
internally and just returns the first lead if there is one.
@param string $filterType One of the supported filter types, e.g. id, cookie or email. See Marketo's document... | entailment |
public function getLeadsByList($listId, $args = array(), $returnRaw = false)
{
$args['listId'] = $listId;
return $this->getResult('getLeadsByList', $args, false, $returnRaw);
} | Get multiple leads by list ID.
@param int $listId
@param array $args
@link http://developers.marketo.com/documentation/rest/get-multiple-leads-by-list-id/
@return GetLeadsResponse | entailment |
public function getLead($id, $fields = null, $args = array(), $returnRaw = false)
{
$args['id'] = $id;
if (is_array($fields)) {
$args['fields'] = implode(',', $fields);
}
return $this->getResult('getLead', $args, false, $returnRaw);
} | Get a lead by ID.
@param int $id
@param array $fields
@param array $args
@link http://developers.marketo.com/documentation/rest/get-lead-by-id/
@return GetLeadResponse | entailment |
public function isMemberOfList($listId, $id, $args = array(), $returnRaw = false)
{
$args['listId'] = $listId;
$args['id'] = $id;
return $this->getResult('isMemberOfList', $args, is_array($id), $returnRaw);
} | Check if a lead is a member of a list.
@param int $listId List ID
@param int|array $id Lead ID or an array of Lead IDs
@param array $args
@link http://developers.marketo.com/documentation/rest/member-of-list/
@return IsMemberOfListResponse | entailment |
public function getCampaign($id, $args = array(), $returnRaw = false)
{
$args['id'] = $id;
return $this->getResult('getCampaign', $args, false, $returnRaw);
} | Get a campaign by ID.
@param int $id
@param array $args
@link http://developers.marketo.com/documentation/rest/get-campaign-by-id/
@return GetCampaignResponse | entailment |
public function addLeadsToList($listId, $leads, $args = array(), $returnRaw = false)
{
$args['listId'] = $listId;
$args['id'] = (array) $leads;
return $this->getResult('addLeadsToList', $args, true, $returnRaw);
} | Add one or more leads to the specified list.
@param int $listId List ID
@param int|array $leads Either a single lead ID or an array of lead IDs
@param array $args
@link http://developers.marketo.com/documentation/rest/add-leads-to-list/
@return AddOrRemoveLeadsToListResponse | entailment |
public function deleteLead($leads, $args = array(), $returnRaw = false)
{
$args['id'] = (array) $leads;
return $this->getResult('deleteLead', $args, true, $returnRaw);
} | Delete one or more leads
@param int|array $leads Either a single lead ID or an array of lead IDs
@param array $args
@link http://developers.marketo.com/documentation/rest/delete-lead/
@return DeleteLeadResponse | entailment |
public function requestCampaign($id, $leads, $tokens = array(), $args = array(), $returnRaw = false)
{
$args['id'] = $id;
$args['input'] = array('leads' => array_map(function ($id) {
return array('id' => $id);
}, (array) $leads));
if (!empty($tokens)) {
$arg... | Trigger a campaign for one or more leads.
@param int $id Campaign ID
@param int|array $leads Either a single lead ID or an array of lead IDs
@param array $tokens Key value array of tokens to send new values for.
@param array $args
@link http://developers.marketo.com/documentation/rest/request-campa... | entailment |
public function scheduleCampaign($id, \DateTime $runAt = NULL, $tokens = array(), $args = array(), $returnRaw = false)
{
$args['id'] = $id;
if (!empty($runAt)) {
$args['input']['runAt'] = $runAt->format('c');
}
if (!empty($tokens)) {
$args['input']['tokens'] =... | Schedule a campaign
@param int $id Campaign ID
@param DateTime $runAt The time to run the campaign. If not provided, campaign will be run in 5 minutes.
@param array $tokens Key value array of tokens to send new values for.
@param array $args
@link http://developers.marketo.com/documenta... | entailment |
public function associateLead($id, $cookie = null, $args = array(), $returnRaw = false)
{
$args['id'] = $id;
if (!empty($cookie)) {
$args['cookie'] = $cookie;
}
return $this->getResult('associateLead', $args, false, $returnRaw);
} | Associate a lead
@param int $id
@param string $cookie
@param array $args
@link http://developers.marketo.com/documentation/rest/associate-lead/
@return AssociateLeadResponse | entailment |
public function getPagingToken($sinceDatetime, $args = array(), $returnRaw = false)
{
$args['sinceDatetime'] = $sinceDatetime;
return $this->getResult('getPagingToken', $args, false, $returnRaw);
} | Get the paging token required for lead activity and changes
@param string $sinceDatetime String containing a datetime
@param array $args
@param bool $returnRaw
@return GetPagingToken
@link http://developers.marketo.com/documentation/rest/get-paging-token/ | entailment |
public function getLeadChanges($nextPageToken, $fields, $args = array(), $returnRaw = false)
{
$args['nextPageToken'] = $nextPageToken;
$args['fields'] = (array) $fields;
if (count($fields)) {
$args['fields'] = implode(',', $fields);
}
return $this->getResult('g... | Get lead changes
@param string $nextPageToken Next page token
@param string|array $fields
@param array $args
@param bool $returnRaw
@return GetLeadChanges
@link http://developers.marketo.com/documentation/rest/get-lead-changes/
@see getPagingToken | entailment |
public function updateEmailContent($emailId, $args = array(), $returnRaw = false)
{
$args['id'] = $emailId;
return $this->getResult('updateEmailContent', $args, false, $returnRaw);
} | Update an editable section in an email
@param int $emailId
@param string $htmlId
@param array $args
@link http://developers.marketo.com/documentation/asset-api/update-email-content-by-id/
@return Response | entailment |
public function updateEmailContentInEditableSection($emailId, $htmlId, $args = array(), $returnRaw = false)
{
$args['id'] = $emailId;
$args['htmlId'] = $htmlId;
return $this->getResult('updateEmailContentInEditableSection', $args, false, $returnRaw);
} | Update an editable section in an email
@param int $emailId
@param string $htmlId
@param array $args
@link http://developers.marketo.com/documentation/asset-api/update-email-content-in-editable-section/
@return UpdateEmailContentInEditableSectionResponse | entailment |
public function approveEmail($emailId, $args = array(), $returnRaw = false)
{
$args['id'] = $emailId;
return $this->getResult('approveEmailbyId', $args, false, $returnRaw);
} | Approve an email
@param int $emailId
@param string $htmlId
@param array $args
@link http://developers.marketo.com/documentation/asset-api/approve-email-by-id/
@return approveEmail | entailment |
private function getResult($command, $args, $fixArgs = false, $returnRaw = false)
{
$cmd = $this->getCommand($command, $args);
// Marketo expects parameter arrays in the format id=1&id=2, Guzzle formats them as id[0]=1&id[1]=2.
// Use a quick regex to fix it where necessary.
if ($fi... | Internal helper method to actually perform command.
@param string $command
@param array $args
@param bool $fixArgs
@return Response | entailment |
public function getTokenData()
{
$client = new GuzzleClient($this->url);
$params = array(
'grant_type' => 'client_credentials',
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret
);
$request = $client->get('/identity/oauth/tok... | {@inheritdoc} | entailment |
public function localized($language = null)
{
if (!$language){
$language = Yii::$app->language;
}
if (!isset($this->with['translations'])) {
$this->with(['translation' => function ($query) use ($language) {
$query->where([$this->languageFi... | Scope for querying by languages.
@param $language
@param $abridge
@return $this | entailment |
public static function getLanguages($languages, $owner)
{
if (!$languages && isset(Yii::$app->params['languages'])) {
$languages = Yii::$app->params['languages'];
}
if (!is_array($languages) || empty($languages)) {
throw new InvalidConfigException('Please specify arr... | Validates and returns list of languages.
@param array $languages
@param \yii\base\Object $owner
@return array
@throws InvalidConfigException | entailment |
public static function getLanguageRedirects($languageRedirects)
{
if (!$languageRedirects && isset(Yii::$app->params['languageRedirects'])) {
$languageRedirects = Yii::$app->params['languageRedirects'];
}
return $languageRedirects;
} | Validates and returns list of language redirects.
@param array $languageRedirects
@return array | entailment |
public static function getRedirectedLanguageCode($redirectLanguageCode, $redirects = null)
{
if (!$redirects && isset(Yii::$app->params['languageRedirects'])) {
$redirects = Yii::$app->params['languageRedirects'];
}
if (!is_array($redirects) || empty($redirects)) {
r... | Returns code of language by its redirect language code.
@param string $redirectLanguageCode
@param array $redirects
@return string | entailment |
public static function getDisplayLanguages($languages, $languageRedirects)
{
foreach ($languages as $key => $value) {
$key = (isset($languageRedirects[$key])) ? $languageRedirects[$key] : $key;
$redirects[$key] = $value;
}
return $redirects;
} | Returns list of languages with applied language redirects.
@param array $languages
@param array $languageRedirects
@return array | entailment |
public function shouldPrerenderPage(Request $request)
{
//if it contains _escaped_fragment_, show prerendered page
if (null !== $request->query->get('_escaped_fragment_')) {
return true;
}
// First, return false if User Agent is not a bot
if (!$this->isCrawler($r... | Is this request should be a prerender request?
@param Request $request
@return bool | entailment |
public function isIgnoredExtension($uri)
{
foreach ($this->ignoredExtensions as $ignoredExtension) {
if (strpos($uri, $ignoredExtension) !== false) {
return true;
}
}
return false;
} | @param string $uri
@return bool | entailment |
public function isCrawler(Request $request)
{
$userAgent = strtolower($request->headers->get('User-Agent'));
foreach ($this->crawlerUserAgents as $crawlerUserAgent) {
if (strpos($userAgent, strtolower($crawlerUserAgent)) !== false) {
return true;
}
}
... | Check if the request is made from a crawler
@param Request $request
@return bool | entailment |
public function isWhitelisted($uri, array $whitelistUrls = null)
{
if (is_null($whitelistUrls)) {
$whitelistUrls = $this->whitelistedUrls;
}
foreach ($whitelistUrls as $whitelistUrl) {
$match = preg_match('`'.$whitelistUrl.'`i', $uri);
if ($match > 0) {
... | Check if the request is whitelisted
@param string $uri
@param array $whitelistUrls
@return bool | entailment |
public function isBlacklisted($uri, $referer, array $blacklistUrls = null)
{
if (is_null($blacklistUrls)) {
$blacklistUrls = $this->blacklistedUrls;
}
foreach ($blacklistUrls as $blacklistUrl) {
$pattern = '`'.$blacklistUrl.'`i';
$match = preg_match($patte... | Check if the request is blacklisted
@param string $uri
@param string $referer
@param array $blacklistUrls
@return bool | entailment |
public function languageSwitcher($model, $view = null)
{
$languages = ($model->getBehavior('multilingual')) ? $languages = $model->getBehavior('multilingual')->languages : [];
return FormLanguageSwitcher::widget(['languages' => $languages, 'view' => $view]);
} | Renders form language switcher.
@param \yii\base\Model $model
@param string $view
@return string | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('yucca_prerender');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on ... | {@inheritDoc} | entailment |
protected function handleImageManipulation(ImageInterface $image, array $data): ImageInterface
{
$width = $data['width'];
$height = $data['height'];
if (isset($data['dimension'])) {
$width = $height = $data['dimension'];
}
return $image->resize(new Box($width, $... | Handle image manipulation.
@param \Imagine\Image\ImageInterface $image
@param array $data
@return \Imagine\Image\ImageInterface | entailment |
protected function handleImageManipulation(ImageInterface $image, array $data): ImageInterface
{
$width = $height = $data['dimension'];
return $image->thumbnail(new Box($width, $height), $data['mode'], $data['filter']);
} | Handle image manipulation.
@param \Imagine\Image\ImageInterface $image
@param array $data
@return \Imagine\Image\ImageInterface | entailment |
protected function updateArguments($method, $arguments, $field)
{
if ($method == 'widget' && isset($arguments[1]['options']['id'])) {
$arguments[1]['options']['id'] = MultilingualHelper::getAttributeName($arguments[1]['options']['id'], $field->language);
}
if (in_array($method, ... | Updates id for multilingual inputs with custom id.
@param string $method
@param array $arguments
@param mixed $field
@return array | entailment |
public function getStatus($id)
{
if ($this->isSuccess()) {
foreach ($this->getResult() as $row) {
if ($row['id'] == $id) {
return $row['status'];
}
}
}
return false;
} | Get the status of a lead.
@param $id
@return bool | entailment |
public function send($url, $token = '')
{
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => ... | @param $url
@param string $token
@return mixed
@throws Exception | entailment |
public function toArray()
{
$array = array();
foreach ($this as $key => $value) {
if ($value instanceof Enumerable) {
$array[$key] = $value->toArray();
} else {
$array[$key] = $value;
}
}
return $array;
} | {@inheritdoc} | entailment |
function nusoap_server($wsdl=false){
parent::nusoap_base();
// turn on debugging?
global $debug;
global $HTTP_SERVER_VARS;
if (isset($_SERVER)) {
$this->debug("_SERVER is defined:");
$this->appendDebug($this->varDump($_SERVER));
} elseif (isset($HTTP_SERVER_VARS)) {
$this->debug("HTTP_SE... | constructor
the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
@param mixed $wsdl file path or URL (string), or wsdl instance (object)
@access public | entailment |
function parse_http_headers() {
global $HTTP_SERVER_VARS;
$this->request = '';
$this->SOAPAction = '';
if(function_exists('getallheaders')){
$this->debug("In parse_http_headers, use getallheaders");
$headers = getallheaders();
foreach($headers as $k=>$v){
$k = strtolower($k);
$this->... | parses HTTP request headers.
The following fields are set by this function (when successful)
headers
request
xml_encoding
SOAPAction
@access private | entailment |
function parse_request($data='') {
$this->debug('entering parse_request()');
$this->parse_http_headers();
$this->debug('got character encoding: '.$this->xml_encoding);
// uncompress if necessary
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
$this->debug(... | parses a request
The following fields are set by this function (when successful)
headers
request
xml_encoding
SOAPAction
request
requestSOAP
methodURI
methodname
methodparams
requestHeaders
document
This sets the fault field on error
@param string $data XML string
@access private | entailment |
function invoke_method() {
$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
//
// if you are debugging in this area of the code, your service uses a class to implement methods,
// you use SOAP RPC, and the client is ... | invokes a PHP function for the requested SOAP method
The following fields are set by this function (when successful)
methodreturn
Note that the PHP function that is called may also set the following
fields to affect the response sent to the client
responseHeaders
outgoing_headers
This sets the fault field on error... | entailment |
function serialize_return() {
$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
// if fault
if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == '... | serializes the return value from a PHP function into a full SOAP Envelope
The following fields are set by this function (when successful)
responseSOAP
This sets the fault field on error
@access private | entailment |
function send_response() {
$this->debug('Enter send_response');
if ($this->fault) {
$payload = $this->fault->serialize();
$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
$this->outgoing_headers[] = "Status: 500 Internal Server Error";
} else {
$payload = $this->responseSOAP;
... | sends an HTTP response
The following fields are set by this function (when successful)
outgoing_headers
response
@access private | entailment |
function verify_method($operation,$request){
if(isset($this->wsdl) && is_object($this->wsdl)){
if($this->wsdl->getOperationData($operation)){
return true;
}
} elseif(isset($this->operations[$operation])){
return true;
}
return false;
} | takes the value that was created by parsing the request
and compares to the method's signature, if available.
@param string $operation The operation to be invoked
@param array $request The array of parameter values
@return boolean Whether the operation was found
@access private | entailment |
function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
if ($faultdetail == '' && $this->debug_flag) {
$faultdetail = $this->getDebug();
}
$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
$this->fault->soap_defencoding = $this->soap_defencoding;
} | Specify a fault to be returned to the client.
This also acts as a flag to the server that a fault has occured.
@param string $faultcode
@param string $faultstring
@param string $faultactor
@param string $faultdetail
@access public | entailment |
function getHTTPBody($soapmsg) {
if (count($this->responseAttachments) > 0) {
$params['content_type'] = 'multipart/related; type="text/xml"';
$mimeMessage = new Mail_mimePart('', $params);
unset($params);
$params['content_type'] = 'text/xml';
$params['encoding'] = '8bit';
$params['chars... | gets the HTTP body for the current response.
@param string $soapmsg The SOAP payload
@return string The HTTP body, which includes the SOAP payload
@access private | entailment |
function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
parent::nusoap_base();
$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
$this->appendDebug($this->varDump($curl_options));
$this->setURL($url);
if (is_array($curl_options)) {
$this->ch_options = $curl_options;... | constructor
@param string $url The URL to which to connect
@param array $curl_options User-specified cURL options
@param boolean $use_curl Whether to try to force cURL use
@access public | entailment |
function io_method() {
if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
return 'curl';
if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->auth... | gets the I/O method to use
@return string I/O method to use (socket|curl|unknown)
@access private | entailment |
function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
$this->debug('entered send() with data of length: '.strlen($data));
$this->tryagain = true;
$tries = 0;
while ($this->tryagain) {
$this->tryagain = false;
if ($tries++ < 2) {
// make connnection
if (!$this->conne... | sends the SOAP request and gets the SOAP response via HTTP[S]
@param string $data message data
@param integer $timeout set connection timeout in seconds
@param integer $response_timeout set response timeout in seconds
@param array $cookies cookies to send
@return string data
@access public | entailment |
function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
if ($proxyhost) {
$this->proxy = array(
'host' => $proxyhost,
'port' => $proxyport,
'username' => $proxyusername,
'password' => $proxypassword,
'authtype' => $proxyauthtype
... | set proxy info here
@param string $proxyhost use an empty string to remove proxy
@param string $proxyport
@param string $proxyusername
@param string $proxypassword
@param string $proxyauthtype (basic|ntlm)
@access public | entailment |
function isSkippableCurlHeader(&$data) {
$skipHeaders = array( 'HTTP/1.1 100',
'HTTP/1.0 301',
'HTTP/1.1 301',
'HTTP/1.0 302',
'HTTP/1.1 302',
'HTTP/1.0 401',
'HTTP/1.1 401',
'HTTP/1.0 200 Connection established');
foreach ($skipHeaders as $hd) {
... | Test if the given string starts with a header that is to be skipped.
Skippable headers result from chunked transfer and proxy requests.
@param string $data The string to check.
@returns boolean Whether a skippable header was found.
@access private | entailment |
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
$data = preg_split('/;/', $cookie_str);
$value_str = $data[0];
$cookie_param = 'domain=';
$start = strpos($cookie_str, $cookie_param);
if ($start > 0) {
$domain = substr($cookie_str, $start + strlen($coo... | /*
TODO: allow a Set-Cookie string to be parsed into multiple cookies | entailment |
function getCookiesForRequest($cookies, $secure=false) {
$cookie_str = '';
if ((! is_null($cookies)) && (is_array($cookies))) {
foreach ($cookies as $cookie) {
if (! is_array($cookie)) {
continue;
}
$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
... | sort out cookies for the current request
@param array $cookies array with all cookies
@param boolean $secure is the send-content secure or not?
@return string for Cookie-HTTP-Header
@access private | entailment |
public function generate()
{
$returnVar = $this->executeCommand($output);
if ($returnVar == 0)
{
$this->contents = $this->getPDFContents();
}
else
{
throw new PDFException($output);
}
$this->removeTmpFiles();
return $this;
} | Generates the PDF and save the PDF content for the further use
@return string
@throws PDFException | entailment |
public function save($fileName, AdapterInterface $adapter, $overwrite = false)
{
$fs = new Filesystem($adapter);
if ($overwrite == true)
{
$fs->put($fileName, $this->get());
}
else
{
$fs->write($fileName, $this->get());
}
return $this;
} | Saves the pdf content to the specified location
@param $fileName
@param AdapterInterface $adapter
@param bool $overwrite
@return $this | entailment |
public function removeTmpFiles()
{
if (file_exists($this->getHTMLPath()))
{
@unlink($this->getHTMLPath());
}
if (file_exists($this->getPDFPath()))
{
@unlink($this->getPDFPath());
}
} | Remove temporary HTML and PDF files | entailment |
public function executeCommand(&$output)
{
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = ... | Execute wkhtmltopdf command
@param array &$output
@return integer | entailment |
protected function getParams()
{
$result = "";
foreach ($this->params as $key => $value)
{
if (is_numeric($key))
{
$result .= '--' . $value;
}
else
{
$result .= '--' . $key . ' ' . '"' . $value . '"';
}
$result .= ' ';
}
return $result;
} | Gets the parameters defined by user
@return string | entailment |
protected function addParam($key, $value = null)
{
if (is_null($value))
{
$this->params[] = $key;
}
else
{
$this->params[$key] = $value;
}
} | Adds a wkhtmltopdf parameter
@param string $key
@param string $value | entailment |
protected function getInputSource()
{
if (!is_null($this->path))
{
return $this->path;
}
file_put_contents($this->getHTMLPath(), $this->htmlContent);
return $this->getHTMLPath();
} | Gets the Input source which can be an HTML file or a File path
@return string | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.