_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29800 | LibraryHelper.analytics | train | public function analytics($id)
{
return $this->getView()->getRequest()->is('localhost') ? null : $this->Html->scriptBlock(
sprintf('!function(e,a,t,n,c,o,s){e.GoogleAnalyticsObject=c,e[c]=e[c]||function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].l=1*new Date,o=a.createElement(t),s=a.getElements... | php | {
"resource": ""
} |
q29801 | LibraryHelper.ckeditor | train | public function ckeditor($jquery = false)
{
is_readable_or_fail(WWW_ROOT . 'ckeditor' . DS . 'ckeditor.js');
$scripts = ['/ckeditor/ckeditor'];
//Checks for the jQuery adapter
if ($jquery && is_readable(WWW_ROOT . 'ckeditor' . DS . 'adapters' . DS . 'jquery.js')) {
$scr... | php | {
"resource": ""
} |
q29802 | LibraryHelper.fancybox | train | public function fancybox()
{
$this->Html->css([
'/vendor/fancybox/jquery.fancybox',
'/vendor/fancybox/helpers/jquery.fancybox-buttons',
'/vendor/fancybox/helpers/jquery.fancybox-thumbs',
], ['block' => 'css_bottom']);
$scripts = [
'/vendor/fan... | php | {
"resource": ""
} |
q29803 | LibraryHelper.slugify | train | public function slugify($sourceField = 'form #title', $targetField = 'form #slug')
{
$this->Asset->script('MeTools.slugify', ['block' => 'script_bottom']);
$this->output[] = sprintf('$().slugify("%s", "%s");', $sourceField, $targetField);
} | php | {
"resource": ""
} |
q29804 | AbstractCompiler.setWarningLevel | train | public function setWarningLevel($level = self::WARNING_LEVEL_DEFAULT)
{
if (!in_array($level, $this->availableWarningLevels)) {
throw new Exception\InvalidArgumentException(sprintf(
'The warning level "%s" is not available.',
$level
));
... | php | {
"resource": ""
} |
q29805 | AbstractCompiler.addLocalFile | train | public function addLocalFile($file)
{
if (!file_exists($file)) {
throw new Exception\InvalidArgumentException(sprintf(
'The file "%s" does not exists.',
$file
));
}
$this->addScript(file_get_contents($file));
return... | php | {
"resource": ""
} |
q29806 | AbstractCompiler.addLocalDirectory | train | public function addLocalDirectory($directory, $recursive = false)
{
if (!file_exists($directory) || !is_dir($directory)) {
throw new Exception\InvalidArgumentException(sprintf(
'The directory "%s" does not exists.',
$directory
));
}
... | php | {
"resource": ""
} |
q29807 | AbstractCompiler.addRemoteFile | train | public function addRemoteFile($url)
{
if (!filter_var($url, FILTER_VALIDATE_URL)) {
throw new Exception\InvalidArgumentException(sprintf(
'The url "%s" is not valid.',
$url
));
}
$this->files[] = (string) $url;
retu... | php | {
"resource": ""
} |
q29808 | AbstractCompiler.getParams | train | public function getParams()
{
$params = array(
'compilation_level' => $this->getMode(),
'output_format' => 'xml',
'warning_level' => $this->getWarningLevel(),
'output_info_1' => 'compiled_code',
'output_info_2' => 'statistics... | php | {
"resource": ""
} |
q29809 | AbstractCompiler.getHash | train | public function getHash()
{
return md5(
implode('', $this->scripts)
. implode('', $this->files)
. $this->mode
. $this->warningLevel
. $this->getFormattingOptions()->getPrettyPrintEnabled()
. $this->getFormattingOptions()->getPri... | php | {
"resource": ""
} |
q29810 | AbstractOptions.setOption | train | public function setOption($name, $value)
{
$methodName = 'set' . ucfirst($name);
if (!method_exists($this, $methodName)) {
throw new RuntimeException('Method not exists: ' . $methodName);
}
return $this->$methodName($value);
} | php | {
"resource": ""
} |
q29811 | FormHelperMap.attachDefaultHelper | train | public function attachDefaultHelper()
{
$this->attachHelper('checkbox', new FormHelperChoiceCheckbox());
$this->attachHelper('radio', new FormHelperChoiceRadio());
$this->attachHelper('select', new FormHelperChoiceSelect());
$this->attachHelper('error', new FormHelperFieldErr... | php | {
"resource": ""
} |
q29812 | FormHelperMap.loadField | train | public function loadField(Property $property, $helperName, array $options=array())
{
if ($this->getHelper('field')->hasKey($helperName)) {
/**
* @var $formHelper FormHelperFieldInterface
*/
$formHelper = $this->getHelper('field')->get($helperName);
... | php | {
"resource": ""
} |
q29813 | FormHelperMap.loadChoice | train | public function loadChoice(Property $property, $helperName, $choiceValue, array $options=array())
{
if ($this->getHelper('choice')->hasKey($helperName)) {
/**
* @var $formHelper FormHelperChoiceInterface
*/
$formHelper = $this->getHelper('choice')->get($help... | php | {
"resource": ""
} |
q29814 | FormHelperMap.loadTag | train | public function loadTag(FormInterface $form, $helperName, $content=null, array $options=array())
{
if ($this->getHelper('tag')->hasKey($helperName)) {
/**
* @var $formHelper FormHelperTagInterface
*/
$formHelper = $this->getHelper('tag')->get($helperName);
... | php | {
"resource": ""
} |
q29815 | FormHelperMap.loadOption | train | public function loadOption(FormInterface $form, $helperName, $optionValue, array $options=array())
{
if (!$form instanceof FormCollectionInterface) {
throw new InvalidArgumentException(
sprintf('loadOption requires a instance of Type "%s", "%s" was given.',
Fo... | php | {
"resource": ""
} |
q29816 | FormHelperMap.getHelper | train | public function getHelper($helperType)
{
if ($this->isValidKey($helperType)) {
return $this->getHelperMap()->get($helperType);
} else {
throw new InvalidArgumentException('Invalid form helper type given');
}
} | php | {
"resource": ""
} |
q29817 | FormHelperMap.getHelperCount | train | public function getHelperCount($helperType)
{
if ($this->isValidKey($helperType)) {
if (!is_null($formHelperMap = $this->getHelperMap()->get($helperType))) {
return count($formHelperMap);
}
return 0;
} else {
throw new InvalidArgumentEx... | php | {
"resource": ""
} |
q29818 | FormHelperMap.hasHelper | train | public function hasHelper($helperType)
{
if ($this->isValidKey($helperType)) {
if (!is_null($formHelperMap = $this->getHelperMap()->get($helperType))
&& count($formHelperMap) > 0
) {
return true;
}
} else {
throw new Inv... | php | {
"resource": ""
} |
q29819 | FormHelperMap.attachHelper | train | public function attachHelper($helperName, FormHelperInterface $formHelper)
{
if ($this->isValidKey($helperName)) {
if (is_null($formHelperType = $this->resolveHelperType($formHelper))) {
throw new InvalidArgumentException('Unkown form helper instance given');
}
... | php | {
"resource": ""
} |
q29820 | FormHelperMap.detachHelper | train | public function detachHelper($helperName, FormHelperInterface $helper)
{
if ($this->isValidKey($helperName)) {
if (is_null($formHelperType = $this->resolveHelperType($helper))) {
throw new InvalidArgumentException('Unkown form helper instance given');
}
i... | php | {
"resource": ""
} |
q29821 | DatabaseHandler.clean | train | public function clean( $maxlifetime, $next ) {
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->prefix}sm_sessions WHERE session_expiry < %s LIMIT %d",
time(),
1000
)
);
return $next( $maxlifetime );
} | php | {
"resource": ""
} |
q29822 | GoogleGeocoder.geocode | train | public function geocode($address)
{
$query = $this->buildQuery('address', $address);
$response = $this->validateResponse(
$this->getResponse($query)
);
return $this->buildResults($response['results']);
} | php | {
"resource": ""
} |
q29823 | GoogleGeocoder.reverseByPlaceId | train | public function reverseByPlaceId($placeId)
{
$query = $this->buildQuery('place_id', $placeId);
$response = $this->validateResponse(
$this->getResponse($query)
);
return $this->buildResults($response['results']);
} | php | {
"resource": ""
} |
q29824 | GoogleGeocoder.reverseByCoordinates | train | public function reverseByCoordinates($latitude, $longitude)
{
$query = $this->buildQuery('address', "{$latitude},{$longitude}");
$response = $this->validateResponse(
$this->getResponse($query)
);
return $this->buildResults($response['results']);
} | php | {
"resource": ""
} |
q29825 | GoogleGeocoder.addOptionalQueryParameters | train | private function addOptionalQueryParameters($apiKey, $language, $region)
{
if ($apiKey) {
$this->endpoint = $this->buildQuery('key', $apiKey);
}
if ($language) {
$this->endpoint = $this->buildQuery('language', $language);
}
if ($region) {
... | php | {
"resource": ""
} |
q29826 | GoogleGeocoder.validateResponse | train | private function validateResponse($response)
{
if (!isset($response)) {
throw new NoResult(sprintf('Could not execute query'));
}
if ('REQUEST_DENIED' === $response['status'] && 'The provided API key is invalid.' === $response['error_message']) {
throw new InvalidKey... | php | {
"resource": ""
} |
q29827 | GoogleGeocoder.buildResults | train | private function buildResults($results)
{
return array_map(function ($result) {
$coordinates = $result['geometry']['location'];
$data = [
'address' => $result['formatted_address'],
'latitude' => $coordinates['lat'],
'longitude' => $coor... | php | {
"resource": ""
} |
q29828 | Object.setContent | train | public function setContent($content, $type = NULL) {
$this->content = $content;
if (!empty($type)) {
$this->contentType = $type;
}
return $this;
} | php | {
"resource": ""
} |
q29829 | MailTemplater.doRender | train | protected function doRender(FilterPreRenderEvent $preEvent, MailInterface $mail)
{
$variables = $preEvent->getVariables();
$variables['_mail_type'] = $mail->getType();
$variables['_layout'] = null !== $mail->getLayout() ? $mail->getLayout()->getName() : null;
$subject = $this->render... | php | {
"resource": ""
} |
q29830 | MailTemplater.getTranslatedMail | train | protected function getTranslatedMail($template, $type)
{
$mail = $this->loader->load($template, $type);
return TranslationUtil::translateMail($mail, $this->getLocale(), $this->translator);
} | php | {
"resource": ""
} |
q29831 | MailTemplater.getTranslatedLayout | train | protected function getTranslatedLayout(MailInterface $mail)
{
$layout = $mail->getLayout();
if (null !== $layout) {
$layout = TranslationUtil::translateLayout($layout, $this->getLocale(), $this->translator);
}
return $layout;
} | php | {
"resource": ""
} |
q29832 | Payload.generate | train | private function generate(
string $identifier,
string $method,
string $timestamp,
string $uri,
string $content
) : string {
$payload = [
'id' => $identifier,
'method' => strtoupper($method),
'timestamp' => $timestamp,
'u... | php | {
"resource": ""
} |
q29833 | Payload.generateFromPsr7Request | train | protected function generateFromPsr7Request(Psr7Request $request) : string
{
$id = isset($this->request->getHeader('X-SIGNED-ID')[0]) ?
$this->request->getHeader('X-SIGNED-ID')[0] : '';
$timestamp = isset($this->request->getHeader('X-SIGNED-TIMESTAMP')[0]) ?
$this->request->ge... | php | {
"resource": ""
} |
q29834 | Payload.generateFromIlluminateRequest | train | protected function generateFromIlluminateRequest(IlluminateRequest $request) : string
{
$id = $this->request->headers->get('X-SIGNED-ID', '');
$timestamp = $this->request->headers->get('X-SIGNED-TIMESTAMP', '');
return $this->generate(
(string) $id,
(string) $this->r... | php | {
"resource": ""
} |
q29835 | CustomerRepository.findOneByEmailAndWebsiteId | train | public function findOneByEmailAndWebsiteId($email, $websiteId)
{
// initialize the params
$params = array(
MemberNames::EMAIL => $email,
MemberNames::WEBSITE_ID => $websiteId
);
// if not, try to load the customer with the passed email and website ID
... | php | {
"resource": ""
} |
q29836 | aServiceAggregate.withServiceName | train | final function withServiceName($serviceName = null)
{
if (false == $this->canCreate($serviceName))
throw new \Exception(sprintf(
'Can`t Create (%s).'
, \Poirot\Std\flatten($serviceName)
));
$new = clone $this;
$new->currentService = $s... | php | {
"resource": ""
} |
q29837 | MelisModulesService.getCoreModules | train | public function getCoreModules($excludeModulesOnReturn = [])
{
$modules = [
'melisdbdeploy' => 'MelisDbDeploy',
'meliscomposerdeploy' => 'MelisComposerDeploy',
'meliscore' => 'MelisCore',
'melissites' => 'MelisSites',
'melisassetmanager' => ... | php | {
"resource": ""
} |
q29838 | MelisModulesService.activateModule | train | public function activateModule(
$module,
$defaultModules = ['MelisAssetManager', 'MelisComposerDeploy', 'MelisDbDeploy', 'MelisCore'],
$excludeModule = ['MelisModuleConfig'])
{
// Default melis modules
$activeModules = $this->getActiveModules($defaultModules);
... | php | {
"resource": ""
} |
q29839 | MelisModulesService.createModuleLoader | train | public function createModuleLoader($pathToStore, $modules = [],
$topModules = ['melisdbdeploy', 'meliscomposerdeploy', 'meliscore'],
$bottomModules = ['MelisModuleConfig'])
{
$tmpFileName = 'melis.module.load.php.tmp';
... | php | {
"resource": ""
} |
q29840 | ImageFile.getType | train | public static function getType($path, $outputFormat = null, array $imgInfo = null)
{
$imgInfo = $imgInfo ?: self::getSize($path);
if ($outputFormat) {
switch ($outputFormat) {
case 'png': $type = ImageFile::TYPE_PNG; break;
case 'gif': $type = ImageFile::... | php | {
"resource": ""
} |
q29841 | ImageFile.get | train | public static function get($path, array $info = null)
{
$info = $info ?: self::getSize($path);
switch ($info['mime']) {
case self::TYPE_JPG:
$srcImg = imagecreatefromjpeg($path);
break;
case self::TYPE_PNG:
$srcImg = imagecreat... | php | {
"resource": ""
} |
q29842 | ImageFile.save | train | public static function save($path, $img, $type = self::TYPE_JPG, $quality = null)
{
$dir = explode('/', $path);
unset($dir[count($dir) - 1]);
$dir = implode('/', $dir);
if (!file_exists($dir) || !is_dir($dir)) {
mkdir($dir, 0777, true);
}
switch ($type) {... | php | {
"resource": ""
} |
q29843 | CDN.newFromServiceCatalog | train | public static function newFromServiceCatalog($catalog, $token, $region = CDN::DEFAULT_REGION) {
$c = count($catalog);
for ($i = 0; $i < $c; ++$i) {
if ($catalog[$i]['type'] == self::SERVICE_TYPE) {
foreach ($catalog[$i]['endpoints'] as $endpoint) {
if (isset($endpoint['publicURL']) && $e... | php | {
"resource": ""
} |
q29844 | CDN.containers | train | public function containers($enabledOnly = NULL) {
$client = \HPCloud\Transport::instance();
$url = $this->url . '/?format=json';
if ($enabledOnly) {
$url .= '&enabled_only=true';
}
// DEVEX-1733 suggests that this should result in the
// server listing only DISABLED containers.
elseif... | php | {
"resource": ""
} |
q29845 | CDN.container | train | public function container($name) {
//$result = $this->modifyContainer($name, 'GET', array(), '?format=json');
$containers = $this->containers();
foreach ($containers as $container) {
if ($container['name'] == $name) {
return $container;
}
}
return FALSE;
} | php | {
"resource": ""
} |
q29846 | CDN.enable | train | public function enable($name, $ttl = NULL, &$created = FALSE) {
$headers = array();
if (!empty($ttl)) {
$headers['X-TTL'] = (int) $ttl;
}
$res = $this->modifyContainer($name, 'PUT', $headers);
$created = $res->status() == 201;
$url = $res->header('X-Cdn-Uri', 'UNKNOWN');
return $url;
... | php | {
"resource": ""
} |
q29847 | CDN.update | train | public function update($name, $attrs) {
$headers = array();
foreach ($attrs as $item => $val) {
switch ($item) {
case 'ttl':
$headers['X-TTL'] = (int) $val;
break;
case 'enabled':
case 'cdn_enabled':
if (isset($val) && $val == FALSE) {
$fl... | php | {
"resource": ""
} |
q29848 | CDN.modifyContainer | train | protected function modifyContainer($name, $method, $headers = array(), $qstring = '') {
$url = $this->url . '/' . rawurlencode($name) . $qstring;
$headers['X-Auth-Token'] = $this->token;
$client = \HPCloud\Transport::instance();
$response = $client->doRequest($url, $method, $headers);
return $resp... | php | {
"resource": ""
} |
q29849 | Util.array_merge_recursive_distinct | train | public static function array_merge_recursive_distinct (array $array1, array $array2)
{
$result = $array1;
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
$result[$key] = is_array($result[$key]) ? self::array_merge_recursive_distinct($result[$key], $arr... | php | {
"resource": ""
} |
q29850 | Util.time_ago | train | public static function time_ago($date, $granularity = 1) {
$periods = [
'decade' => 315360000,
'year' => 31536000,
'month' => 2628000,
'week' => 604800,
'day' => 86400,
'hour' => 3600,
'minute' => 60,
'seco... | php | {
"resource": ""
} |
q29851 | MissionGame.fulfillConditions | train | public function fulfillConditions($entry = null)
{
foreach ($this->getConditions() as $condition) {
if ($condition->getAttribute() == MissionGameCondition::NONE) {
continue;
}
// On passe au suivant si on a gagné
if ($condition->getAttribu... | php | {
"resource": ""
} |
q29852 | DoctrineDbalFactory.createCachedConditionGenerator | train | public function createCachedConditionGenerator(ConditionGenerator $conditionGenerator, $ttl = 0): ConditionGenerator
{
if (null === $this->cacheDriver) {
return $conditionGenerator;
}
return new CachedConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
} | php | {
"resource": ""
} |
q29853 | JwtTokenAuthenticator.getClaimOrNull | train | protected function getClaimOrNull( $claim )
{
$claim = $this->token->getPayload()->findClaimByName( $claim );
return $claim ? $claim->getValue() : null;
} | php | {
"resource": ""
} |
q29854 | JwtTokenAuthenticator.isExpired | train | protected function isExpired()
{
$exp = \DateTime::createFromFormat( 'U', $this->getClaimOrNull( self::EXPIRY ) );
return !$exp || $exp <= ( new DateTime );
} | php | {
"resource": ""
} |
q29855 | MailUtil.isValid | train | public static function isValid(MailInterface $mail, $type)
{
$validTypes = static::getValidTypes($type);
return $mail->isEnabled() && \in_array($mail->getType(), $validTypes, true);
} | php | {
"resource": ""
} |
q29856 | MailUtil.getValidTypes | train | public static function getValidTypes($type)
{
if (MailTypes::TYPE_PRINT === $type) {
return [MailTypes::TYPE_ALL, MailTypes::TYPE_PRINT];
}
if (MailTypes::TYPE_SCREEN === $type) {
return [MailTypes::TYPE_ALL, MailTypes::TYPE_SCREEN];
}
return [MailTyp... | php | {
"resource": ""
} |
q29857 | DynamoDbScheduler.startExecution | train | private function startExecution(int $timestamp, string $jobId): string
{
$start = new \DateTime('now', new \DateTimeZone('UTC'));
$sendAt = new \DateTime("@{$timestamp}");
$span = (int)$start->diff($sendAt)->format('%a');
$input = ['job_id' => $jobId];
/*
* AWS Ste... | php | {
"resource": ""
} |
q29858 | DynamoDbScheduler.stopExecution | train | private function stopExecution(string $jobId, string $executionArn): void
{
try {
$this->sfnClient->stopExecution([
'executionArn' => $executionArn,
'cause' => 'canceled',
]);
} catch (\Throwable $t) {
$this->logger->error(
... | php | {
"resource": ""
} |
q29859 | ConfigUtil.formatConfig | train | public static function formatConfig($config)
{
if (\is_string($config)) {
$config = ['file' => $config];
}
if (!\is_array($config)) {
throw new UnexpectedTypeException($config, 'array');
}
if (!isset($config['file'])) {
$msg = 'The "file"... | php | {
"resource": ""
} |
q29860 | ConfigUtil.formatTranslationConfig | train | public static function formatTranslationConfig($config, KernelInterface $kernel)
{
$config = static::formatConfig($config);
$config['file'] = $kernel->locateResource($config['file']);
if (isset($config['translations']) && \is_array($config['translations'])) {
/** @var array $tra... | php | {
"resource": ""
} |
q29861 | Strings.escape | train | public static function escape($string, $flag = ENT_COMPAT, $hardEscape = true)
{
return htmlspecialchars($string, $flag, static::ENCODING, (bool) $hardEscape);
} | php | {
"resource": ""
} |
q29862 | Strings.secureCompare | train | public static function secureCompare($userInput, $reference)
{
if (strlen($userInput) !== strlen($reference)) {
// use $reference as reference for actual constant time
$comparison = $reference ^ $reference;
// this make sure the result will be false
$result = ... | php | {
"resource": ""
} |
q29863 | PathUtils.resolveRelative | train | public static function resolveRelative($sourcePath, $targetPath)
{
if ('.' == dirname($sourcePath)) {
$path = str_repeat('../', substr_count($targetPath, '/'));
} elseif ('.' == $targetDir = dirname($targetPath)) {
$path = dirname($sourcePath).'/';
} else {
... | php | {
"resource": ""
} |
q29864 | PathUtils.resolveUrl | train | public static function resolveUrl(AssetInterface $asset, $url)
{
// given URL is absolute URL
if (false !== strpos($url, '://')) {
return $url;
}
// source directory of the asset
$root = dirname($asset->getSourceRoot().'/'.$asset->getTargetPath());
// pa... | php | {
"resource": ""
} |
q29865 | PathUtils.removeQueryString | train | public static function removeQueryString($path)
{
if (false === $pos = strpos($path, '?')) {
return $path;
}
$anchorPos = strpos($path, '#', $pos);
$end = false === $anchorPos ? strlen($path) : $anchorPos;
return substr($path, 0, $pos).substr($path, $end);
... | php | {
"resource": ""
} |
q29866 | ConfigLayoutLoader.createLayout | train | protected function createLayout(array $config)
{
$layout = $this->newLayoutInstance();
$layout->setName(ConfigUtil::getValue($config, 'name'));
$layout->setLabel(ConfigUtil::getValue($config, 'label'));
$layout->setDescription(ConfigUtil::getValue($config, 'description'));
$... | php | {
"resource": ""
} |
q29867 | ConfigLayoutLoader.createLayoutTranslation | train | protected function createLayoutTranslation(LayoutInterface $layout, array $config)
{
$translation = $this->newLayoutTranslationInstance($layout);
$translation->setLocale(ConfigUtil::getValue($config, 'locale'));
$translation->setLabel(ConfigUtil::getValue($config, 'label'));
$transla... | php | {
"resource": ""
} |
q29868 | XmlDeserializationVisitor.getDomDocumentType | train | private function getDomDocumentType(string $data): string
{
$startPos = $endPos = \stripos($data, '<!doctype');
$braces = 0;
do {
$char = $data[$endPos++];
if ('<' === $char) {
++$braces;
}
if ('>' === $char) {
-... | php | {
"resource": ""
} |
q29869 | RankBehavior.rankAdd | train | public function rankAdd()
{
if (!$this->owner->isNewRecord) {
return;
}
if (!is_numeric($this->owner->getAttribute($this->attribute))) {
$this->owner->setAttribute($this->attribute, $this->getSiblings()->count());
}
} | php | {
"resource": ""
} |
q29870 | RankBehavior.rankRemove | train | public function rankRemove()
{
$owner = $this->owner;
$query = $this->getSiblings()->andWhere(['>', $this->attribute, $this->owner->getAttribute($this->attribute)]);
$owner::updateAllCounters(
[$this->attribute => -1],
$query->where
);
} | php | {
"resource": ""
} |
q29871 | RankBehavior.rankSwitch | train | public function rankSwitch($to)
{
$owner = $this->owner;
$this->getSiblings()->andWhere([$this->attribute => $to])->one()->updateAttributes([
$this->attribute => $this->owner->getAttribute($this->attribute)
]);
$owner->updateAttributes([$this->attribute => $to]);
} | php | {
"resource": ""
} |
q29872 | Request.initialize | train | public function initialize(array $get = [], array $post = [], array $cookie = [], array $files = [], array $server = [], $rawBody = null, array $globals = [])
{
$cookie = $this->removeSlashes($cookie);
$get = $this->removeSlashes($get);
$post = $this->removeSlashes($post);
$this->co... | php | {
"resource": ""
} |
q29873 | Request.removeSlashes | train | protected function removeSlashes($array)
{
$fnc = function ($value) use (&$fnc) {
if (is_array($value)) {
return array_map($fnc, $value);
}
return stripslashes($value);
};
if (version_compare(phpversion(), '6.0.0-dev', '<') && get_magic_q... | php | {
"resource": ""
} |
q29874 | Request.resolveInvalidRedirect | train | protected function resolveInvalidRedirect()
{
if (empty($this->server['REDIRECT_URL'])) {
return false;
}
$nodes = substr($this->server['SCRIPT_FILENAME'], strlen($this->server['DOCUMENT_ROOT']));
$nodes = str_replace('\\', '/', $nodes);
$nodes = substr($nodes, 0... | php | {
"resource": ""
} |
q29875 | Request.resolveBaseName | train | protected function resolveBaseName()
{
$schema = $this->schema();
$host = str_replace('//', '/', $this->host() . $this->dir . '/');
return $schema . '://' . $host;
} | php | {
"resource": ""
} |
q29876 | Request.resolveParameters | train | protected function resolveParameters(array $get = [], array $globals = [])
{
if ($this->method() != 'CLI' || !isset($globals['argc'], $globals['argv']) || $globals['argc'] <= 1) {
return $get;
}
$cli = [];
for ($i = 1; $i < $globals['argc']; $i++) {
if (preg_... | php | {
"resource": ""
} |
q29877 | Request.isSecure | train | public function isSecure()
{
if ($proto = (string) $this->header->get('x_forwarded_proto')) {
return in_array(strtolower(current(explode(',', $proto))), ['https', 'on', 'ssl', '1']);
}
return strtolower($this->server->get('HTTPS')) == 'on' || $this->server->get('HTTPS') == 1;
... | php | {
"resource": ""
} |
q29878 | Request.path | train | public function path($query = false)
{
return $this->path . ($query && $this->query->has() ? '?' . http_build_query($this->query->all(), null, '&') : null);
} | php | {
"resource": ""
} |
q29879 | Request.uri | train | public function uri($query = false)
{
return rtrim($this->baseName(), '/') . '/' . ltrim($this->path($query), '/');
} | php | {
"resource": ""
} |
q29880 | Request.format | train | public function format($format = null)
{
if ($format !== null) {
$this->format = $format;
}
return $this->format;
} | php | {
"resource": ""
} |
q29881 | DkimSignerPlugin.getPrivateKey | train | protected function getPrivateKey()
{
try {
$privateKey = file_get_contents($this->privateKeyPath);
} catch (\Exception $e) {
$msg = 'Impossible to read the private key of the DKIM swiftmailer signer "%s"';
throw new RuntimeException(sprintf($msg, $this->privateKe... | php | {
"resource": ""
} |
q29882 | Bag.& | train | protected function & getArrayByReference(&$offset)
{
$offset = explode(self::SEPARATOR, $offset);
if (count($offset) > 1) {
$arr = &$this->getFromArray($this->storage, array_slice($offset, 0, -1), false);
} else {
$arr = &$this->storage;
}
$offset = ... | php | {
"resource": ""
} |
q29883 | Bag.& | train | protected function & getFromArray(&$array, $keys, $default = null)
{
$key = array_shift($keys);
if (!isset($array[$key])) {
return $default;
}
if (empty($keys)) {
return $array[$key];
}
return $this->getFromArray($array[$key], $keys, $default... | php | {
"resource": ""
} |
q29884 | Bag.setIntoArray | train | protected function setIntoArray(&$array, $keys, $value)
{
$k = array_shift($keys);
if (is_scalar($array)) {
$array = (array) $array;
}
if (!isset($array[$k])) {
$array[$k] = null;
}
if (empty($keys)) {
return $array[$k] = &$value... | php | {
"resource": ""
} |
q29885 | Stream.contextValueToString | train | private static function contextValueToString($val)
{
if (is_bool($val)) {
return var_export($val, true);
} elseif (is_scalar($val)) {
return (string)$val;
} elseif (is_null($val)) {
return 'NULL';
} elseif (is_object($val)) {
if (is... | php | {
"resource": ""
} |
q29886 | ConfigEditor.get | train | public function get($name, $default = null)
{
if ( substr($name, -1) == '.' ) {
$ret = array();
foreach ( $this->settings as $setting_name => $setting_value ) {
if ( preg_match('/^' . preg_quote($name, '/') . '/', $setting_name) ) {
$ret[$setting_name] = $setting_value;
}
}
return $ret;
... | php | {
"resource": ""
} |
q29887 | ConfigEditor.set | train | public function set($name, $value)
{
if ( $value === null ) {
unset($this->settings[$name]);
}
else {
$this->settings[$name] = $value;
}
$this->store();
} | php | {
"resource": ""
} |
q29888 | ConfigEditor.load | train | protected function load(array $defaults)
{
if ( file_exists($this->filename) ) {
$stored_settings = json_decode(file_get_contents($this->filename), true);
$new_defaults = array_diff_key($defaults, $stored_settings);
if ( $new_defaults ) {
$this->settings = array_merge($stored_settings, $new_defaults);
... | php | {
"resource": ""
} |
q29889 | ConfigEditor.store | train | protected function store()
{
$options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
file_put_contents($this->filename, json_encode($this->settings, $options));
} | php | {
"resource": ""
} |
q29890 | HeaderBag.asArray | train | public function asArray()
{
$headers = [];
foreach (array_filter($this->storage) as $header => $value) {
$headers[] = $header . ': ' . $value;
}
return $headers;
} | php | {
"resource": ""
} |
q29891 | Youtube.getId | train | public static function getId($url)
{
if (strpos($url, 'youtube.com') !== false) {
$url = parse_url($url);
if (empty($url['query'])) {
return false;
}
parse_str($url['query'], $url);
return empty($url['v']) ? false : $url['v'];
... | php | {
"resource": ""
} |
q29892 | BaseSymfonyWorker.clearLogs | train | private function clearLogs()
{
if (!$this->logger instanceof Logger) {
return;
}
/* @var $logger Logger */
$logger = $this->logger;
foreach ($logger->getHandlers() as $handler) {
if ($handler instanceof FingersCrossedHandler) {
$handle... | php | {
"resource": ""
} |
q29893 | EngineFolder.remove | train | public function remove(Folder $entity)
{
$this->em->remove($entity);
$this->em->flush();
} | php | {
"resource": ""
} |
q29894 | Scheduler.command | train | public function command($command, $args = [], $id = null)
{
$target = Router::getInstance()->getTarget($command);
$fn = function () use ($target) {
return $target->run();
};
return $this->call($fn, $args, $id);
} | php | {
"resource": ""
} |
q29895 | DefinitionParser.isAllowedKey | train | protected function isAllowedKey($key): bool
{
return empty($this->allowedKeys) || \in_array($key, $this->allowedKeys, true);
} | php | {
"resource": ""
} |
q29896 | Report.all | train | public function all() {
$query = new \Peyote\Select('report_types');
$query->columns('id, value')
->where('public', '=', 1);
return $this->db->fetch($query);
} | php | {
"resource": ""
} |
q29897 | Report.get | train | public function get($id=NULL) {
if (!isset($id)) return $this->all();
$query = new \Peyote\Select('report_types');
$query->columns('id, value')
->where('id', '=', $id);
return $this->db->fetch($query);
} | php | {
"resource": ""
} |
q29898 | AbstractDefinition.get | train | public function get(string $directive, $default = null)
{
return $this->has($directive) ? $this->definition[$directive] : $default;
} | php | {
"resource": ""
} |
q29899 | eZFlowAjaxContent.jsonEncode | train | public static function jsonEncode( $obj )
{
if ( self::$nativeJsonEncode === null )
self::$nativeJsonEncode = function_exists( 'json_encode' );
if ( self::$nativeJsonEncode === true )
return json_encode( $obj );
$inst = self::getInstance();
return $inst->php... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.