_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q259200
Form.getField
test
public function getField($key) { foreach ($this->fields as $field) { if ($field->getKey() == $key) {
php
{ "resource": "" }
q259201
Form.getFieldsNotInArray
test
public function getFieldsNotInArray($keys) { $fields = []; foreach ($this->fields as $field) {
php
{ "resource": "" }
q259202
Form.serializeForLocale
test
public function serializeForLocale($locale, Dynamic $dynamic = null) { $fields = []; foreach ($this->fields as $field) { $fieldTranslation = $field->getTranslation($locale, false, true); $value = null; if ($dynamic) { $value = $dynamic->{$field->...
php
{ "resource": "" }
q259203
FormWebsiteController.formAction
test
public function formAction(StructureInterface $structure, $preview = false, $partial = false) { /** @var Request $request */ $request = $this->get('request_stack')->getCurrentRequest(); // get attributes $attributes = $this->getAttributes([], $structure, $preview); $templat...
php
{ "resource": "" }
q259204
FormWebsiteController.onlyAction
test
public function onlyAction(Request $request, $key) { $ajaxTemplates = $this->container->getParameter('sulu_form.ajax_templates'); if (!$ajaxTemplates[$key]) { throw new NotFoundHttpException(); } $typeClass = $this->getTypeClass($key); /** @var AbstractType $typ...
php
{ "resource": "" }
q259205
FormWebsiteController.handleFormSubmit
test
private function handleFormSubmit(Request $request, $type, $attributes) { // handle form submit $configuration = $this->get('sulu_form.configuration.form_configuration_factory')->buildByType( $type, $this->form->getData(), $request->getLocale(), $attri...
php
{ "resource": "" }
q259206
FormWebsiteController.handleFormOnlySubmit
test
private function handleFormOnlySubmit(Request $request, $type) { // handle form submit $configuration = $this->get('sulu_form.configuration.form_configuration_factory')->buildByType(
php
{ "resource": "" }
q259207
FormWebsiteController.tokenAction
test
public function tokenAction(Request $request) { $formName = $request->get('form'); $csrfToken = $this->get('security.csrf.token_manager')->getToken( $request->get('form') )->getValue(); $content = $csrfToken; // this should be the default behaviour in future bec...
php
{ "resource": "" }
q259208
FormWebsiteController.getErrors
test
protected function getErrors() { $errors = []; $generalErrors = []; foreach ($this->form->getErrors() as $error) { $generalErrors[] = $error->getMessage(); } if (!empty($generalErrors)) { $errors['general'] = $generalErrors; } foreac...
php
{ "resource": "" }
q259209
Handler.handle
test
public function handle(FormInterface $form, FormConfigurationInterface $configuration) { if (!$form->isValid()) { return false; } $mediaIds = $this->uploadMedia($form, $configuration);
php
{ "resource": "" }
q259210
Handler.save
test
private function save(FormInterface $form, FormConfigurationInterface $configuration) { $this->eventDispatcher->dispatch( self::EVENT_FORM_SAVE, new FormEvent( $form, $configuration
php
{ "resource": "" }
q259211
Handler.uploadMedia
test
private function uploadMedia(FormInterface $form, FormConfigurationInterface $configuration) { $this->attachments = []; $mediaIds = []; foreach ($configuration->getFileFields() as $field => $collectionId) { if (!$form->has($field) || !count($form[$field]->getData())) { ...
php
{ "resource": "" }
q259212
Handler.mapMediaIds
test
private function mapMediaIds($entity, $mediaIds) { $accessor = new PropertyAccessor(); foreach ($mediaIds as $key => $value) {
php
{ "resource": "" }
q259213
Handler.getMediaData
test
protected function getMediaData( UploadedFile $file, FormInterface $form, FormConfigurationInterface $configuration, $collectionId ) { return [ 'collection'
php
{ "resource": "" }
q259214
MailchimpType.getMailChimpLists
test
private function getMailChimpLists() { $lists = []; // If Milchimp class doesn't exist or no key is set return empty list. if (!class_exists(\DrewM\MailChimp\MailChimp::class) || !$this->apiKey) { return $lists; } $mailChimp = new \DrewM\MailChimp\MailChimp($thi...
php
{ "resource": "" }
q259215
DynamicListFactory.getBuilder
test
protected function getBuilder($alias = null) { if (!$alias || 'default' === $alias) { $alias = $this->defaultBuilder;
php
{ "resource": "" }
q259216
AbstractType.getBlockPrefix
test
public function getBlockPrefix() { $fqcn = get_class($this); $name = $this->getName(); // For BC: Use the name as block prefix if
php
{ "resource": "" }
q259217
CollectionStrategyTree.createCollection
test
private function createCollection($title, $parentId, $collectionKey, $locale) { $parentCollection = $this->collectionManager->save([ 'title' => $title, 'type' => ['id' => 2], 'parent'
php
{ "resource": "" }
q259218
CollectionStrategyTree.loadCollectionId
test
private function loadCollectionId( $collectionKey, $locale ) { try { $collection = $this->collectionManager->getByKey($collectionKey, $locale); if (!$collection) { return;
php
{ "resource": "" }
q259219
DynamicFormType.getItemWidthNumber
test
private function getItemWidthNumber($width) { switch ($width) { case 'one-sixth': $itemWidth = 2; break; case 'five-sixths': $itemWidth = 10; break; case 'one-quarter': $itemWidth = 3; ...
php
{ "resource": "" }
q259220
DynamicFormType.getLastWidth
test
private function getLastWidth(&$currentWidthValue, $width, $nextWidth) { $widthNumber = $this->getItemWidthNumber($width); $nextWidthNumber = $this->getItemWidthNumber($nextWidth); $currentWidthValue += $widthNumber;
php
{ "resource": "" }
q259221
ErrorHandler.rethrow
test
public static function rethrow(PDOException $e) { // the 2-character class of the error (if any) has the highest priority $errorClass = null; // the 3-character subclass of the error (if any) has a medium priority $errorSubClass = null; // the full error code itself has the lowest priority $error = null; ...
php
{ "resource": "" }
q259222
PdoDataSource.setHostname
test
public function setHostname($hostname = null) { $this->hostname = $hostname !== null
php
{ "resource": "" }
q259223
PdoDataSource.setUnixSocket
test
public function setUnixSocket($unixSocket = null) { $this->unixSocket = $unixSocket !== null
php
{ "resource": "" }
q259224
PdoDataSource.setMemory
test
public function setMemory($memory = null) { $this->memory = $memory !== null
php
{ "resource": "" }
q259225
PdoDataSource.setFilePath
test
public function setFilePath($filePath = null) { $this->filePath = $filePath !== null
php
{ "resource": "" }
q259226
PdoDataSource.setDatabaseName
test
public function setDatabaseName($databaseName = null) { $this->databaseName = $databaseName !== null
php
{ "resource": "" }
q259227
PdoDataSource.setCharset
test
public function setCharset($charset = null) { $this->charset = $charset !== null
php
{ "resource": "" }
q259228
PdoDatabase.ensureConnected
test
private function ensureConnected() { if ($this->pdo === null) { try { $this->pdo = new PDO($this->dsn->getDsn(), $this->dsn->getUsername(), $this->dsn->getPassword()); } catch (PDOException $e) { ErrorHandler::rethrow($e); } // iterate over all listeners waiting for the connection to be establ...
php
{ "resource": "" }
q259229
PdoDatabase.configureConnection
test
private function configureConnection(array &$newAttributes = null, array &$oldAttributes = null) { // if a connection is available if (isset($this->pdo)) { // if there are attributes that need to be applied if (isset($newAttributes)) { // get the keys and values of the attributes to apply foreach ($ne...
php
{ "resource": "" }
q259230
PdoDatabase.selectInternal
test
private function selectInternal(callable $callback, $query, array $bindValues = null) { $this->normalizeConnection(); try { // create a prepared statement from the supplied SQL string $stmt = $this->pdo->prepare($query); } catch (PDOException $e) { ErrorHandler::rethrow($e); } // if a performance...
php
{ "resource": "" }
q259231
IronMQ.getQueues
test
public function getQueues($previous = null, $per_page = self::LIST_QUEUES_PER_PAGE) { $url = "projects/{$this->project_id}/queues"; $params = array(); if (!is_null($previous)) { $params['previous'] = $previous; } if ($per_page !==
php
{ "resource": "" }
q259232
IronMQ.getQueue
test
public function getQueue($queue_name) { $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue"; $this->setJsonHeaders();
php
{ "resource": "" }
q259233
IronMQ.postMessage
test
public function postMessage($queue_name, $message, $properties = array()) { $msg = new IronMQMessage($message, $properties); $req = array( "messages" => array($msg->asArray()), ); $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "project...
php
{ "resource": "" }
q259234
IronMQ.postMessages
test
public function postMessages($queue_name, $messages, $properties = array()) { $req = array( "messages" => array(), ); foreach ($messages as $message) { $msg = new IronMQMessage($message, $properties); array_push($req['messages'], $msg->asArray()); ...
php
{ "resource": "" }
q259235
IronMQ.getMessageById
test
public function getMessageById($queue_name, $message_id) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url
php
{ "resource": "" }
q259236
IronMQ.touchMessage
test
public function touchMessage($queue_name, $message_id, $reservation_id, $timeout) { $req = array( "reservation_id" => $reservation_id, ); if ($timeout !== 0) { $req['timeout'] = (int) $timeout; } $this->setJsonHeaders();
php
{ "resource": "" }
q259237
IronMQ.releaseMessage
test
public function releaseMessage($queue_name, $message_id, $reservation_id, $delay) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $params = array('reservation_id' => $reservation_id); if ($delay !== 0) { $params['delay'] = (int) $delay;
php
{ "resource": "" }
q259238
IronMQ.addAlerts
test
public function addAlerts($queue_name, $alerts_hash) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue"; $options = array( 'queue' => array(
php
{ "resource": "" }
q259239
IronMQ.deleteAlertById
test
public function deleteAlertById($queue_name, $alert_id) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url
php
{ "resource": "" }
q259240
IronMQ.deleteQueue
test
public function deleteQueue($queue_name) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url
php
{ "resource": "" }
q259241
IronMQ.updateQueue
test
public function updateQueue($queue_name, $options) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue";
php
{ "resource": "" }
q259242
IronMQ.createQueue
test
public function createQueue($queue_name, $options) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue";
php
{ "resource": "" }
q259243
IronMQ.replaceSubscribers
test
public function replaceSubscribers($queue_name, $subscribers_hash) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue/subscribers"; $options = array(
php
{ "resource": "" }
q259244
IronMQ.removeSubscribers
test
public function removeSubscribers($queue_name, $subscriber_hash) { $this->setJsonHeaders(); $queue = rawurlencode($queue_name); $url = "projects/{$this->project_id}/queues/$queue/subscribers"; $options = array(
php
{ "resource": "" }
q259245
GenerateCommand.outputJson
test
protected function outputJson(OutputInterface $output, $data) { $json = json_encode($data, JSON_UNESCAPED_SLASHES |
php
{ "resource": "" }
q259246
GenerateCommand.outputXml
test
protected function outputXml(OutputInterface $output, $data) { $doc = new \DOMDocument();
php
{ "resource": "" }
q259247
GenerateCommand.generateXml
test
protected function generateXml(\DOMDocument $doc, $data) { if (is_array($data) && range(0, count($data) - 1) == array_keys($data)) { // $data is a regular indexed array $array = $doc->createElement('array'); foreach ($data as $value) { $entry = $doc->createElement('item'); $entry->appendChild($this...
php
{ "resource": "" }
q259248
GenerateCommand.outputCsv
test
protected function outputCsv(InputInterface $input, OutputInterface $output, $data) { $delimiter = $input->getOption('delimiter'); $enclosure = $input->getOption('enclosure'); $stream = fopen('php://temp', 'w+'); foreach ($data as $row) { if ($enclosure === null) { fputcsv($stream, $this->flattenArray...
php
{ "resource": "" }
q259249
GenerateCommand.flattenArray
test
protected function flattenArray($data) { if (is_array($data) || is_object($data)) { $buffer = array();
php
{ "resource": "" }
q259250
CacheClientStatsCommand.execute
test
protected function execute(InputInterface $input, OutputInterface $output) { $debug = $input->getOption('debug'); $client = $this->getContainer()->get('beryllium_cache.client'); if (is_object($client) && method_exists($client, 'getStats')) {
php
{ "resource": "" }
q259251
CacheClientStatsCommand.formatStats
test
public function formatStats($stats, $debug = false) { if (!is_array($stats)) { return "No statistics returned.\n"; } if (count($stats) == 0) { return "No statistics returned.\n"; } $out = "Servers found: " . count($stats) . "\n\n"; foreach ($...
php
{ "resource": "" }
q259252
CacheClientStatsCommand.formatUsage
test
public function formatUsage($bytes, $maxbytes) { if (!is_numeric($maxbytes) || $maxbytes < 1) { return '(undefined)'; } $out = round($bytes / $maxbytes, 3) . "% ("; $out
php
{ "resource": "" }
q259253
CacheClientStatsCommand.formatUptime
test
public function formatUptime($uptime) { $days = floor($uptime / 24 / 60 / 60); $days_remainder = $uptime - ($days * 24 * 60 * 60); $hours = floor($days_remainder / 60 / 60); $hours_remainder = $days_remainder - ($hours * 60 * 60); $minutes = floor($hours_remainder / 60); ...
php
{ "resource": "" }
q259254
MemcacheClient.addServer
test
public function addServer($ip, $port = 11211) { if (is_object($this->mem)) {
php
{ "resource": "" }
q259255
MemcacheClient.addServers
test
public function addServers(array $servers) { if (count($servers) == 0) { return false; } foreach ($servers as $ip => $port) { if (intval($port) == 0) { $port = null;
php
{ "resource": "" }
q259256
MemcacheClient.probeServer
test
public function probeServer($ip, $port) { $errno = null; $errstr = null; $fp = @fsockopen($ip, $port, $errno, $errstr, $this->sockttl); if ($fp) {
php
{ "resource": "" }
q259257
MemcacheClient.get
test
public function get($key) { if ($this->isSafe()) { $key = $this->prefix . $key;
php
{ "resource": "" }
q259258
MemcacheClient.set
test
public function set($key, $value, $ttl) { if ($this->isSafe()) { $key = $this->prefix . $key; return $this->mem->set($key,
php
{ "resource": "" }
q259259
MemcacheClient.delete
test
public function delete($key) { if ($this->isSafe()) { $key = $this->prefix . $key; return
php
{ "resource": "" }
q259260
Cache.setClient
test
public function setClient(CacheClientInterface $client) { if (is_object($client) && ($client instanceof CacheClientInterface)) $this->client = $client;
php
{ "resource": "" }
q259261
Cache.get
test
public function get($key) { if ($this->isSafe() && !empty($key)) {
php
{ "resource": "" }
q259262
Cache.delete
test
public function delete($key) { if ($this->isSafe() && !empty($key)) {
php
{ "resource": "" }
q259263
FCMMessage.makeInvalidArgumentException
test
protected static function makeInvalidArgumentException($data, $method, $container, $builder) { $type = gettype($data); if (is_object($data)) { $type = get_class($data); } return new InvalidArgumentException( 'The argument for %s::%s
php
{ "resource": "" }
q259264
FCMMessage.populateBuilder
test
protected static function populateBuilder($builder, array $map, array $data) { foreach ($map as $key => $method) { $value
php
{ "resource": "" }
q259265
FCMMessage.options
test
public function options($options = null) { if (is_array($options)) { if ($this->options && $this->options instanceof Options) { $options = array_merge($this->options->toArray(), $options); } if (! Arr::has($options, 'priority')) { $options[...
php
{ "resource": "" }
q259266
FCMMessage.notification
test
public function notification($notification = null) { if (is_array($notification)) { if ($this->notification && $this->notification instanceof PayloadNotification) { $notification = array_merge($this->notification->toArray(), $notification); } $builder = ne...
php
{ "resource": "" }
q259267
FCMMessage.data
test
public function data($data = null) { if (is_array($data)) { if ($this->data && $this->data instanceof PayloadData) { $data = array_merge($this->data->toArray(), $data); } $data = (new PayloadDataBuilder())->setData($data); } if ($data inst...
php
{ "resource": "" }
q259268
LoggerLayoutXml.encodeCDATA
test
private function encodeCDATA($string) { $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
php
{ "resource": "" }
q259269
UrlBuilder.getNonAuthenticationUrl
test
public function getNonAuthenticationUrl( $action, \FACTFinder\Util\Parameters $parameters ) { $configuration = $this->configuration; $this->ensureChannelParameter($parameters);
php
{ "resource": "" }
q259270
UrlBuilder.getAuthenticationUrl
test
public function getAuthenticationUrl( $action, \FACTFinder\Util\Parameters $parameters ) { $this->ensureChannelParameter($parameters); $c = $this->configuration; if ($c->isAdvancedAuthenticationType()) return $this->getAdvancedAuthenticationUrl($action, $paramete...
php
{ "resource": "" }
q259271
UrlBuilder.getAdvancedAuthenticationUrl
test
protected function getAdvancedAuthenticationUrl( $action, \FACTFinder\Util\Parameters $parameters ) { $configuration = $this->configuration; $ts = time() . '000'; //milliseconds needed $prefix = $configuration->getAuthenticationPrefix(); $postfix = $co...
php
{ "resource": "" }
q259272
UrlBuilder.getSimpleAuthenticationUrl
test
protected function getSimpleAuthenticationUrl( $action, \FACTFinder\Util\Parameters $parameters ) { $configuration = $this->configuration; $ts = time() . '000'; //milliseconds needed but won't be considered $authenticationParameters = "timestamp=" . $ts
php
{ "resource": "" }
q259273
UrlBuilder.getHttpAuthenticationUrl
test
protected function getHttpAuthenticationUrl( $action, \FACTFinder\Util\Parameters $parameters ) { $configuration = $this->configuration; $authentication = sprintf( '%s:%s@', $configuration->getUserName(), $configuration->getPassword() ); ...
php
{ "resource": "" }
q259274
UrlBuilder.ensureChannelParameter
test
protected function ensureChannelParameter($parameters) { if ((!isset($parameters['channel']) || $parameters['channel'] == '') && $this->configuration->getChannel() != ''
php
{ "resource": "" }
q259275
SimilarRecords.setProductID
test
public function setProductID($productID) { $parameters = $this->request->getParameters();
php
{ "resource": "" }
q259276
SimilarRecords.getSimilarAttributes
test
public function getSimilarAttributes() { if (is_null($this->similarAttributes) || !$this->upToDate ) {
php
{ "resource": "" }
q259277
SimilarRecords.getSimilarRecords
test
public function getSimilarRecords() { if (is_null($this->similarRecords) || !$this->upToDate ) { $this->request->resetLoaded();
php
{ "resource": "" }
q259278
LoggerAppenderFile.write
test
protected function write($string) { // Lazy file open if(!isset($this->fp)) { if ($this->openFile() === false) { return; // Do not write if file open failed. }
php
{ "resource": "" }
q259279
LoggerAutoloader.autoload
test
public static function autoload($className) { if(isset(self::$classes[$className])) {
php
{ "resource": "" }
q259280
LoggerAppenderConsole.setTarget
test
public function setTarget($target) { $value = trim($target); if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') { $this->target = self::STDOUT; } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') { $this->target = self::STDERR;
php
{ "resource": "" }
q259281
Import.triggerDataImport
test
public function triggerDataImport($download = false) { //this function changes parameters, action, ... so reload of response is neccessary $this->request->resetLoaded();
php
{ "resource": "" }
q259282
Import.triggerSuggestImport
test
public function triggerSuggestImport($download = false) { //this function changes parameters, action, ... so reload of response is neccessary $this->request->resetLoaded(); $this->request->setAction('Import.ff'); $this->parameters['download'] = $download ? 'true' : 'false';...
php
{ "resource": "" }
q259283
ParametersConverter.applyParameterMappings
test
protected function applyParameterMappings($parameters, $mappingRules) { foreach ($mappingRules as $k => $v) { if ($k != $v && isset($parameters[$k])) {
php
{ "resource": "" }
q259284
ParametersConverter.ensureChannelParameter
test
protected function ensureChannelParameter($parameters) { if (!isset($parameters['channel']) ||
php
{ "resource": "" }
q259285
ParametersConverter.addRequiredParameters
test
protected function addRequiredParameters($parameters, $requireRules) { foreach ($requireRules as $k => $v)
php
{ "resource": "" }
q259286
LoggerAppenderPool.add
test
public static function add(LoggerAppender $appender) { $name = $appender->getName(); if(empty($name)) { trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING); return; } if (isset(self::$appenders[$name])) {
php
{ "resource": "" }
q259287
LoggerAppenderPool.get
test
public static function get($name) { return isset(self::$appenders[$name]) ?
php
{ "resource": "" }
q259288
Logger.trace
test
public function trace($message, $throwable = null)
php
{ "resource": "" }
q259289
Logger.debug
test
public function debug($message, $throwable = null)
php
{ "resource": "" }
q259290
Logger.warn
test
public function warn($message, $throwable = null)
php
{ "resource": "" }
q259291
Logger.log
test
public function log(LoggerLevel $level, $message, $throwable = null) { if($this->isEnabledFor($level)) { $event = new LoggerLoggingEvent($this->fqcn, $this, $level, $message, null, $throwable); $this->callAppenders($event);
php
{ "resource": "" }
q259292
Logger.logEvent
test
public function logEvent(LoggerLoggingEvent $event) { if($this->isEnabledFor($event->getLevel())) { $this->callAppenders($event); } // Forward the event upstream if additivity is turned on
php
{ "resource": "" }
q259293
Logger.forcedLog
test
public function forcedLog($fqcn, $throwable, LoggerLevel $level, $message) { $event = new LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable);
php
{ "resource": "" }
q259294
Logger.removeAppender
test
public function removeAppender($appender) { if($appender instanceof LoggerAppender) { $appender->close(); unset($this->appenders[$appender->getName()]);
php
{ "resource": "" }
q259295
Logger.getEffectiveLevel
test
public function getEffectiveLevel() { for($logger = $this; $logger !== null; $logger
php
{ "resource": "" }
q259296
Logger.getHierarchy
test
public static function getHierarchy() { if(!isset(self::$hierarchy))
php
{ "resource": "" }
q259297
Logger.getLogger
test
public static function getLogger($name) { if(!self::isInitialized()) { self::configure(); }
php
{ "resource": "" }
q259298
Logger.resetConfiguration
test
public static function resetConfiguration() { self::getHierarchy()->resetConfiguration();
php
{ "resource": "" }
q259299
Logger.configure
test
public static function configure($configuration = null, $configurator = null) { self::resetConfiguration();
php
{ "resource": "" }