_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q259100
Worker.sendMessageToPool
test
function sendMessageToPool(\CharlotteDunois\Phoebe\Message $message) { if(static::$socket) { $data = \CharlotteDunois\Phoebe\Socket::encodeMessage($message); static::$socket->write($data); } else { $this->messagesOut[] = $message; } }
php
{ "resource": "" }
q259101
Worker.derefTask
test
function derefTask(\CharlotteDunois\Phoebe\AsyncTask $task) { if(isset($this->refBag[$task->id])) { unset($this->refBag[$task->id]); if(\count($this->refBag) === 0 && $this->stack->count() === 0) { $this->bag->lastEmptyStack = \time(); $this->...
php
{ "resource": "" }
q259102
Worker.bootstrap
test
protected function bootstrap() { \set_error_handler(function ($errno, $errstr, $errfile, $errline) { if(\error_reporting() === 0) { return true; } throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); \err...
php
{ "resource": "" }
q259103
Parallel.filter
test
static function filter(\CharlotteDunois\Phoebe\Pool $pool, array $array, ?callable $function = null) { if($function === null) { $function = function ($value) { return ((bool) $value); // @codeCoverageIgnore }; } $promises = array(); ...
php
{ "resource": "" }
q259104
Parallel.flatMap
test
static function flatMap(\CharlotteDunois\Phoebe\Pool $pool, array $array, callable $function) { $promises = array(); $howMany = (int) \ceil((\count($array) / $pool->getSize())); $chunks = \array_chunk($array, $howMany); $newFun = function ($value) use ($function) { ...
php
{ "resource": "" }
q259105
Parallel.map
test
static function map(\CharlotteDunois\Phoebe\Pool $pool, array $array, callable $function) { $promises = array(); foreach($array as $id => $arg) { $promises[$id] = static::parallelize($pool, $function, array($arg))->then(null, function (\Throwable $e) { return $e; ...
php
{ "resource": "" }
q259106
Parallel.parallelize
test
protected static function parallelize(\CharlotteDunois\Phoebe\Pool $pool, callable $function, array $args) { $task = new \CharlotteDunois\Phoebe\ParallelTask($function, $args); return $pool->submitTask($task); }
php
{ "resource": "" }
q259107
Parallel.convertResult
test
protected static function convertResult(array $result) { $errors = array(); foreach($result as $id => $value) { if($value instanceof \Throwable) { $errors[$id] = $value; } } if(!empty($errors)) { throw new \CharlotteDu...
php
{ "resource": "" }
q259108
NumArgsAwareTrait._setNumArgs
test
protected function _setNumArgs($numArgs) { $numArgs = $this->_normalizeInt($numArgs); if ($numArgs < 0) { throw $this->_createOutOfRangeException( $this->__('Number of arguments cannot be smaller than zero'), null, null, $numArgs ); } $this->...
php
{ "resource": "" }
q259109
RunWpHookCapableTrait._runWpHook
test
protected function _runWpHook($name, array $args = []) { $name = $this->_normalizeString($name); // Add the event name to the args array \array_unshift($args, $name); return \call_user_func_array('apply_filters', $args); }
php
{ "resource": "" }
q259110
WpHookReplacer.apply_filters
test
public function apply_filters($value, $args) { try { $value = $this->wpHook->apply_filters($value, $args); } catch (StoppedPropagationExceptionInterface $stoppedPropagationException) { $event = $stoppedPropagationException->getEvent(); $value = $event->getParam(0)...
php
{ "resource": "" }
q259111
AddWpHookCapableTrait._addWpHook
test
protected function _addWpHook($name, callable $handler, $priority = null, $numArgs = 1) { $name = $this->_normalizeString($name); $priority = ($priority === null) ? $this->_getWpHookDefaultPriority() : $this->_normalizeInt($priority); $numArgs = ($numArgs === null) ...
php
{ "resource": "" }
q259112
AsyncTask.wrap
test
final function wrap($functionResult) { try { if($functionResult instanceof \Closure) { $functionResult = $functionResult(); } if($functionResult instanceof \Throwable) { return $this->wrapUp(null, $functionResult); } el...
php
{ "resource": "" }
q259113
Messenger.resume
test
function resume() { if(!$this->sockets) { if(!$this->timer) { $this->timer = $this->loop->addPeriodicTimer($this->timerInterval, array($this->pool, 'timerTick')); } return; } if($this->streams->count() > 0) { f...
php
{ "resource": "" }
q259114
Messenger.stop
test
function stop() { if(!$this->sockets) { if($this->timer) { $this->loop->cancelTimer($this->timer); $this->timer = null; } return; } if($this->streams->count() > 0) { foreach($this->streams as $s...
php
{ "resource": "" }
q259115
Messenger.destroy
test
function destroy() { if(!$this->sockets) { if($this->timer) { $this->loop->cancelTimer($this->timer); $this->timer = null; } return; } if($this->streams->count() > 0) { foreach($this->streams as...
php
{ "resource": "" }
q259116
Messenger.getWorkerSocket
test
function getWorkerSocket(\CharlotteDunois\Phoebe\Worker $worker) { return $this->streams->get($worker->id); }
php
{ "resource": "" }
q259117
Messenger.removeWorkerSocket
test
function removeWorkerSocket(\CharlotteDunois\Phoebe\Worker $worker) { $stream = $this->streams->get($worker->id); if($stream !== null) { $this->streams->delete($worker->id); $stream->close(); $socket = $worker->getSocket(); if($socket !== null...
php
{ "resource": "" }
q259118
Messenger.prepareWorker
test
function prepareWorker(\CharlotteDunois\Phoebe\Worker $worker) { if($this->sockets) { $socket = new \CharlotteDunois\Phoebe\Socket($worker->id); $worker->setSocket($socket); $sock = $socket->getPoolSocket(); $stream = new \CharlotteDunois...
php
{ "resource": "" }
q259119
AttachMethodHandlerCapableTrait._attachMethodHandler
test
protected function _attachMethodHandler($eventName, $methodName, $priority = null, $numArgs = 1) { $methodName = $this->_normalizeString($methodName); $reflection = $this->_createReflectionMethod(get_class($this), $methodName); $handler = $reflection->getClosure($this); $this->_a...
php
{ "resource": "" }
q259120
HashCallableCapableTrait._hashCallable
test
protected function _hashCallable($callable) { $key = null; if (is_string($callable) || $callable instanceof Stringable) { $key = $this->_normalizeString($callable); } elseif (is_object($callable)) { $key = spl_object_hash($callable); } elseif (is_array($calla...
php
{ "resource": "" }
q259121
ResourceSocket.write
test
function write($data) { if(!$this->writable) { return false; } $this->data .= $data; $this->addWriteListener(); return (!isset($this->data[($this->softLimit - 1)])); }
php
{ "resource": "" }
q259122
ResourceSocket.pipe
test
function pipe(\React\Stream\WritableStreamInterface $dest, array $options = array()) { return \React\Stream\Util::pipe($this, $dest, $options); }
php
{ "resource": "" }
q259123
ResourceSocket.handleData
test
function handleData() { try { $this->setErrorHandler(); $data = ''; $bytes = \socket_recv($this->socket, $data, $this->bufferSize, (\defined('MSG_DONTWAIT') ? \MSG_DONTWAIT : 0)); if($bytes === false) { $this->checkSocketE...
php
{ "resource": "" }
q259124
ResourceSocket.handleWrite
test
function handleWrite() { try { if($this->data !== '') { $this->setErrorHandler(); if($this->writeChunkSize === -1) { $sent = \socket_send($this->socket, $this->data, \strlen($this->data), 0); } else { ...
php
{ "resource": "" }
q259125
ResourceSocket.checkSocketErrors
test
protected function checkSocketErrors() { $code = \socket_last_error($this->socket); \socket_clear_error($this->socket); if($code !== \SOCKET_EWOULDBLOCK) { throw new \DomainException(\socket_strerror($code)); } }
php
{ "resource": "" }
q259126
ResourceSocket.removeReadListener
test
protected function removeReadListener() { if($this->listeningRead) { $this->loop->removeReadStream($this->socket); $this->listeningRead = false; } }
php
{ "resource": "" }
q259127
ResourceSocket.removeWriteListener
test
protected function removeWriteListener() { if($this->listeningWrite) { $this->loop->removeWriteStream($this->socket); $this->listeningWrite = false; } }
php
{ "resource": "" }
q259128
Socket.decodeMessage
test
static function decodeMessage(string $data) { try { $message = \unserialize(\base64_decode(\rtrim($data, static::END_BUFFER))); if(!($message instanceof \CharlotteDunois\Phoebe\Message)) { throw new \Exception(''); } return $message; ...
php
{ "resource": "" }
q259129
Pool.attachTimer
test
function attachTimer() { $this->messenger->resume(); if($this->timer || !$this->messenger->usesSockets()) { return; } $this->timer = $this->loop->addPeriodicTimer(($this->options['internalTimerTick'] ?? 30), function () { $this->internalTimerTick...
php
{ "resource": "" }
q259130
Pool.cancelTimer
test
function cancelTimer() { $this->messenger->stop(); if($this->timer) { $this->loop->cancelTimer($this->timer); $this->timer = null; } }
php
{ "resource": "" }
q259131
Pool.submit
test
function submit(\Threaded $work) { if($this->timer === null) { $this->attachTimer(); } $worker = ($this->freeWorkers->count() > 0 ? $this->freeWorkers->dequeue() : null); if(!$worker) { if(\count($this->workers) >= $this->size) { $iwork = ...
php
{ "resource": "" }
q259132
Pool.submitTo
test
function submitTo(string $workerID, \Threaded $work) { if($this->timer === null) { $this->attachTimer(); } if(!isset($this->workers[$workerID])) { throw new \InvalidArgumentException('Worker does not exist'); } $worker = $this->checkAlive...
php
{ "resource": "" }
q259133
Pool.submitTask
test
function submitTask(\CharlotteDunois\Phoebe\AsyncTask $task) { if(!$task->id) { throw new \InvalidArgumentException('Async Task has no ID - did you call parent::__construct() in your constructor?'); } return $this->submit($task)->then(function (\CharlotteDunois\Phoebe\Worker...
php
{ "resource": "" }
q259134
Pool.submitTaskTo
test
function submitTaskTo(string $workerID, \CharlotteDunois\Phoebe\AsyncTask $task) { if(!$task->id) { throw new \InvalidArgumentException('Async Task has no ID - did you call parent::__construct() in your constructor?'); } $worker = $this->submitTo($workerID, $task); ...
php
{ "resource": "" }
q259135
Pool.stopWorker
test
function stopWorker(\CharlotteDunois\Phoebe\Worker $worker) { if($worker->isRunning()) { try { $message = new \CharlotteDunois\Phoebe\Message('internal-worker-exit', null); $this->sendMessageToWorker($worker, $message); } catch (\RuntimeException $e) { ...
php
{ "resource": "" }
q259136
Pool.removeWorker
test
protected function removeWorker(\CharlotteDunois\Phoebe\Worker $worker) { $msgs = $worker->getMessages(); while($message = $msgs->shift()) { $this->handleMessage($worker, $message); } unset($this->workers[$worker->id]); $this->busyWorkers->delete($worker); ...
php
{ "resource": "" }
q259137
Pool.sendMessageToWorker
test
function sendMessageToWorker(\CharlotteDunois\Phoebe\Worker $worker, \CharlotteDunois\Phoebe\Message $message) { if(!$worker->isRunning()) { throw new \RuntimeException('Tried to send a message to a non-running worker'); } if($this->messenger->usesSockets()) { $s...
php
{ "resource": "" }
q259138
Pool.broadcastMessage
test
function broadcastMessage(\CharlotteDunois\Phoebe\Message $message, ?\CharlotteDunois\Phoebe\Worker $skip = null) { foreach($this->workers as $worker) { if(!$worker->isRunning()) { $this->loop->futureTick(function () use ($worker) { $this->stopWorker($worker); ...
php
{ "resource": "" }
q259139
Pool.timerTick
test
function timerTick() { foreach($this->workers as $pos => $worker) { if(!$worker->isRunning()) { $this->loop->futureTick(function () use ($worker) { $this->stopWorker($worker); }); continue; } ...
php
{ "resource": "" }
q259140
Pool.internalTimerTick
test
protected function internalTimerTick() { if($this->messenger->usesSockets()) { foreach($this->workers as $worker) { if(!$worker->isRunning()) { $this->stopWorker($worker); } } } $this->handleResize(); $t...
php
{ "resource": "" }
q259141
Pool.spawnWorker
test
protected function spawnWorker() { $workerName = $this->worker; /** @var \CharlotteDunois\Phoebe\Worker $worker */ $worker = new $workerName(...$this->ctor); $this->messenger->prepareWorker($worker); $worker->start(static::WORKER_START_OPTIONS); $this->...
php
{ "resource": "" }
q259142
Pool.checkAlive
test
protected function checkAlive(\CharlotteDunois\Phoebe\Worker $worker) { if(!$worker->isRunning()) { $this->emit('debug', 'Picked worker '.$worker->id.' is not running, spawning new one...'); $this->removeWorker($worker); return $this->spawnWorker(); } ...
php
{ "resource": "" }
q259143
Pool.checkWorkerShutdown
test
protected function checkWorkerShutdown(\CharlotteDunois\Phoebe\Worker $worker) { $this->loop->futureTick(function () use ($worker) { if($worker->isRunning()) { return $this->checkWorkerShutdown($worker); } $this->messenger->removeWorkerSocket($wor...
php
{ "resource": "" }
q259144
Pool.handleMessage
test
function handleMessage(\CharlotteDunois\Phoebe\Worker $worker, \CharlotteDunois\Phoebe\Message $message) { $type = $message->getType(); switch($type) { case 'internal-error-handling': $error = \CharlotteDunois\Phoebe\Message::importException($message->getPayload()); ...
php
{ "resource": "" }
q259145
Pool.handleStreamClose
test
function handleStreamClose(\CharlotteDunois\Phoebe\Worker $worker) { $this->messenger->removeWorkerSocket($worker); $this->removeWorker($worker); $this->emit('exitWorker', $worker); }
php
{ "resource": "" }
q259146
StreamReader.readBytes
test
public function readBytes() { $binaryLength = $this->read(4); if ($binaryLength === "\xff\xff\xff\xff") return null; $length = unpack('N', $binaryLength)[1]; return $length === 0 ? '' : $this->read($length); }
php
{ "resource": "" }
q259147
StreamReader.readUuid
test
public function readUuid() { $data = unpack('n8', $this->read(16)); return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $data[8]); }
php
{ "resource": "" }
q259148
StreamReader.readList
test
public function readList(array $definition) { list($valueType) = $definition; $list = []; $count = $this->readInt(); for ($i = 0; $i < $count; ++$i) { $list[] = $this->readValue($valueType); } return $list; }
php
{ "resource": "" }
q259149
StreamReader.readMap
test
public function readMap(array $definition) { list($keyType, $valueType) = $definition; $map = []; $count = $this->readInt(); for ($i = 0; $i < $count; ++$i) { $map[$this->readValue($keyType)] = $this->readValue($valueType); } return $map; }
php
{ "resource": "" }
q259150
StreamReader.readVarint
test
public function readVarint() { list($higher, $lower) = array_values(unpack('N2', $this->data)); return $higher << 32 | $lower; }
php
{ "resource": "" }
q259151
StreamReader.readDecimal
test
public function readDecimal() { $scale = $this->readInt(); $value = $this->readVarint(); $len = strlen($value); return substr($value, 0, $len - $scale) . '.' . substr($value, $len - $scale); }
php
{ "resource": "" }
q259152
BulkSmsServiceProvider.register
test
public function register() { $l5 = $this->l5 = version_compare(Application::VERSION, '5.0', '>='); $factory = function ($app) use($l5) { $delim = $l5 ? '.' : '::'; $config = $app['config']; $username = $config->get("bulk-sms{$delim}username"); $passw...
php
{ "resource": "" }
q259153
BulkSmsServiceProvider.boot
test
public function boot() { $dir = dirname(dirname(__DIR__)).'/resources'; if ($this->l5) { $this->publishes([ $dir.'/config.php' => config_path('bulk-sms.php') ], 'config'); } else { $this->app['config']->package('bulk-sms', $dir, 'bulk-sms'...
php
{ "resource": "" }
q259154
BulkSmsService.sendMessage
test
public function sendMessage($recipient, $message, array $params = null) { $sender = $this->createMessageSender(); $msg = $this->createMessage($recipient, $message); $sender->setMessage($msg); if ($params) { $sender->setParams($params); } $response = $sen...
php
{ "resource": "" }
q259155
BulkSmsService.validateResponse
test
public function validateResponse($response) { if ($response->code !== '200 OK') { throw new BulkSmsException('BulkSMS API responded with HTTP status code ' . $response->code); } $parts = explode('|', $response->body); if (!is_numeric($parts[ 0 ])) { throw ne...
php
{ "resource": "" }
q259156
BulkSmsService.sendBulkMessages
test
public function sendBulkMessages(array $messages, array $params = null) { $sender = $this->createBulkSender(); v::notEmpty()->setName("BulkSms Array")->check($messages); foreach ($messages as $message) { // make sure messages are proper objects v::instance('anlutro\B...
php
{ "resource": "" }
q259157
BulkSmsService.getStatusForBatchId
test
public function getStatusForBatchId($bulksmsid) { $sender = $this->createBulkStatusSender(); $response = $sender->getStatusForBatchId($bulksmsid, $this->testMode); $this->validateResponse($response); return $sender->extractResponse($response); }
php
{ "resource": "" }
q259158
Bulk.send
test
public function send($testmode = false) { if (empty($this->messages)) { return false; } $data = array_replace($this->params, [ 'username' => $this->username, 'password' => $this->password, 'batch_data' => $this->generateCSV(), ]); ...
php
{ "resource": "" }
q259159
Bulk.generateCSV
test
protected function generateCSV() { $str = "msisdn,message"; foreach ($this->messages as $message) { $str .= "\n"; $recipient = $message->getRecipient(); $message = $message->getMessage(); $str .= '"' . $recipient . '","' . $message . '"'; } ...
php
{ "resource": "" }
q259160
Single.send
test
public function send($testmode = false) { $data = array_replace($this->params, [ 'username' => $this->username, 'password' => $this->password, 'message' => $this->message->getMessage(), 'msisdn' => $this->message->getRecipient(), ]); $conca...
php
{ "resource": "" }
q259161
Message.setMessage
test
protected function setMessage($message) { $this->message = $this->encodeMessage($message); if (strlen($this->message) > $this->concatLimit) { $this->concat = true; } return $this; }
php
{ "resource": "" }
q259162
Message.calculateConcat
test
protected function calculateConcat() { $len = strlen($this->message); $i = $this->concatLimit; $j = 1; while ($i < $len) { $i += $this->concatLimit; $j++; } return $j; }
php
{ "resource": "" }
q259163
Message.parseNumber
test
protected function parseNumber($number) { $number = (string) $number; // remove whitespaces $number = trim($number); $number = str_replace(' ', '', $number); // remove + in front if exists if (substr($number, 0, 1) == '+') { $number = substr($number, 1);...
php
{ "resource": "" }
q259164
Status.send
test
public function send($batchid) { if (empty($batchid)) { throw new \InvalidArgumentException("Batch Id must not be empty"); } $data = [ 'username' => $this->username, 'password' => $this->password, 'batch_id' => $batchid, ]; re...
php
{ "resource": "" }
q259165
DynamicRepository.findByFilters
test
public function findByFilters($filters, $sort = [], $limit = null, $offset = null) { $queryBuilder = $this->createQueryBuilder('dynamic'); // Add filter. $this->addFilter($queryBuilder, $filters); // Add sorting. if (!empty($sort)) { foreach ($sort as $key => $v...
php
{ "resource": "" }
q259166
DynamicRepository.countByFilters
test
public function countByFilters($filters) { $queryBuilder = $this->createQueryBuilder('dynamic'); $queryBuilder->select($queryBuilder->expr()->count('dynamic.id')); $this->addFilter($queryBuilder, $filters); return (int) $queryBuilder->getQuery()->getSingleScalarResult(); }
php
{ "resource": "" }
q259167
DynamicRepository.addFilter
test
protected function addFilter($queryBuilder, $filters) { $fromDate = null; $toDate = null; $search = null; $searchFields = null; if (isset($filters['fromDate'])) { $fromDate = $filters['fromDate']; unset($filters['fromDate']); } if (is...
php
{ "resource": "" }
q259168
DynamicRepository.addSearchFilter
test
protected function addSearchFilter($queryBuilder, $search, $searchFields) { if (empty($search) || empty($searchFields)) { return; } $terms = explode(' ', $search); // Search each term in each search field foreach ($terms as $counter => $term) { $expr...
php
{ "resource": "" }
q259169
DynamicRepository.addDateRangeFilter
test
protected function addDateRangeFilter($queryBuilder, $fromDate, $toDate) { if ($fromDate && $toDate) { $queryBuilder->andWhere($queryBuilder->expr()->between('dynamic.created', ':fromDate', ':toDate')); $queryBuilder->setParameter('fromDate', $fromDate); $queryBuilder->se...
php
{ "resource": "" }
q259170
Dynamic.getField
test
public function getField($key) { if (property_exists($this, $key)) { if (in_array($key, self::$ARRAY_TYPES)) { if (!is_string($this->$key)) { return; } return json_decode($this->$key, true); } return $t...
php
{ "resource": "" }
q259171
Dynamic.getFields
test
public function getFields($hideHidden = false) { $entry = []; if (!$this->form) { return []; } foreach ($this->form->getFields() as $field) { if ($hideHidden && in_array($field->getType(), self::$HIDDEN_TYPES)) { continue; } ...
php
{ "resource": "" }
q259172
FormConfigurationFactory.buildByDynamic
test
public function buildByDynamic(Dynamic $dynamic) { $config = $this->create($dynamic->getLocale()); $config->setFileFields($this->getFileFieldsByDynamic($dynamic)); $adminMailConfiguration = $this->buildAdminMailConfigurationByDynamic($dynamic); $websiteMailConfiguration = $this->bui...
php
{ "resource": "" }
q259173
FormConfigurationFactory.buildByType
test
public function buildByType(AbstractType $type, $formData, $locale, $attributes) { $config = $this->create($locale); $config->setFileFields(array_fill_keys($type->getFileFields(), $type->getCollectionId())); $attributes['form'] = [ 'data' => $formData, ]; $admin...
php
{ "resource": "" }
q259174
FormConfigurationFactory.buildAdminMailConfigurationByDynamic
test
private function buildAdminMailConfigurationByDynamic(Dynamic $dynamic) { $form = $dynamic->getForm(); $locale = $dynamic->getLocale(); $translation = $form->getTranslation($locale); if ($translation->getDeactivateNotifyMails()) { return null; } $adminMa...
php
{ "resource": "" }
q259175
FormConfigurationFactory.buildWebsiteMailConfigurationByDynamic
test
private function buildWebsiteMailConfigurationByDynamic(Dynamic $dynamic) { $form = $dynamic->getForm(); $locale = $dynamic->getLocale(); $translation = $form->getTranslation($locale); if ($translation->getDeactivateCustomerMails()) { return null; } $web...
php
{ "resource": "" }
q259176
FormConfigurationFactory.getFileFieldsByDynamic
test
private function getFileFieldsByDynamic(Dynamic $dynamic) { $form = $dynamic->getForm(); $fields = $form->getFieldsByType(Dynamic::TYPE_ATTACHMENT); if (0 === count($fields)) { return []; } $collectionId = $this->getCollectionIdByDynamic($dynamic); $fi...
php
{ "resource": "" }
q259177
FormConfigurationFactory.getCollectionIdByDynamic
test
private function getCollectionIdByDynamic(Dynamic $dynamic) { $form = $dynamic->getForm(); return $this->collectionStrategy->getCollectionId( $form->getId(), $form->getTranslation($dynamic->getLocale(), false, true)->getTitle(), $dynamic->getType(), $...
php
{ "resource": "" }
q259178
FormConfigurationFactory.getEmailFromDynamic
test
private function getEmailFromDynamic(Dynamic $dynamic) { $emails = $dynamic->getFieldsByType(Dynamic::TYPE_EMAIL); $email = reset($emails); return $this->getEmail($email); }
php
{ "resource": "" }
q259179
FormConfigurationFactory.getEmail
test
private function getEmail($email, $name = null) { if (!$email) { return null; } if (!$name) { $name = $email; } return [$email => $name]; }
php
{ "resource": "" }
q259180
Builder.buildForm
test
protected function buildForm($id, $type, $typeId, $locale, $name) { $request = $this->requestStack->getCurrentRequest(); // Load Form entity $formEntity = $this->loadFormEntity($id, $locale); if (!$formEntity) { return; } $webspaceKey = $this->getWebspa...
php
{ "resource": "" }
q259181
Builder.createForm
test
private function createForm($name, $type, $typeId, $locale, $formEntity, $webspaceKey) { $defaults = $this->getDefaults($formEntity, $locale); $typeName = $this->titleProviderPool->get($type)->getTitle($typeId); $recaptchaFields = $formEntity->getFieldsByType('recaptcha'); $csrfToke...
php
{ "resource": "" }
q259182
Builder.loadFormEntity
test
private function loadFormEntity($id, $locale) { $formEntity = $this->formRepository->loadById($id, $locale); if (!$formEntity) { return null; } $translation = $formEntity->getTranslation($locale); if (!$translation) { // No translation for this loca...
php
{ "resource": "" }
q259183
Builder.getDefaults
test
private function getDefaults(Form $formEntity, $locale) { // set Defaults $defaults = []; foreach ($formEntity->getFields() as $field) { $fieldTranslation = $field->getTranslation($locale); if ($fieldTranslation && $fieldTranslation->getDefaultValue()) { ...
php
{ "resource": "" }
q259184
Builder.getWebspaceKey
test
private function getWebspaceKey() { $request = $this->requestStack->getCurrentRequest(); $webspaceKey = null; if ($request->get('_sulu')) { if ($request->get('_sulu')->getAttribute('webspace')) { $webspaceKey = $request->get('_sulu')->getAttribute('webspace')->ge...
php
{ "resource": "" }
q259185
Checksum.check
test
public function check($checksum, $type, $typeId, $formId, $formName) { $checksumRaw = $this->createKey($type, $typeId, $formId, $formName); return $this->encoder->isPasswordValid($checksum, $checksumRaw, $this->secret); }
php
{ "resource": "" }
q259186
Checksum.get
test
public function get($type, $typeId, $formId, $formName) { $checksumRaw = $this->createKey($type, $typeId, $formId, $formName); return $this->encoder->encodePassword($checksumRaw, $this->secret); }
php
{ "resource": "" }
q259187
DynamicController.cgetAction
test
public function cgetAction(Request $request) { /** @var DynamicRepository $repository */ $repository = $this->get('sulu_form.repository.dynamic'); $filters = $this->getFilters($request); $page = $request->get('page', 1); $limit = $request->get('limit'); $offset = (($...
php
{ "resource": "" }
q259188
DynamicController.cgetFieldsAction
test
public function cgetFieldsAction(Request $request) { $form = $this->loadForm($request); $fieldDescriptors = []; if ($form) { $locale = $this->getLocale($request); $fieldDescriptors = $this->get('sulu_form.list_builder.dynamic_list_factory') ->getField...
php
{ "resource": "" }
q259189
DynamicController.deleteAction
test
public function deleteAction(Request $request, $id) { $mediaManager = $this->get('sulu_media.media_manager'); /** @var EntityManagerInterface $entityManager */ $entityManager = $this->get('doctrine.orm.entity_manager'); /** @var DynamicRepository $repository */ $repository ...
php
{ "resource": "" }
q259190
DynamicController.getFilters
test
protected function getFilters(Request $request) { $filters = [ 'type' => $request->get('type'), 'typeId' => $request->get('typeId'), 'webspaceKey' => $request->get('webspaceKey'), 'form' => $request->get('form'), 'fromDate' => $request->get('fromDa...
php
{ "resource": "" }
q259191
DynamicController.loadForm
test
protected function loadForm(Request $request) { $formId = (int) $request->get('form'); if (!$formId) { throw new BadRequestHttpException('"form" is required parameter'); } return $this->get('sulu_form.repository.form')->loadById($formId); }
php
{ "resource": "" }
q259192
DynamicListBuilder.toString
test
protected function toString($value) { if (is_string($value) || is_numeric($value)) { return $value; } if (is_bool($value)) { return $value ? 1 : 0; } if ($value instanceof \DateTime) { return $value->format('c'); } if (!$...
php
{ "resource": "" }
q259193
DynamicListBuilder.getMediaUrls
test
protected function getMediaUrls($value) { if (is_string($value)) { return $this->getMediaUrl($value); } if (is_array($value)) { foreach ($value as $key => $mediaId) { $value[$key] = $this->getMediaUrl($mediaId); } return implo...
php
{ "resource": "" }
q259194
DynamicListBuilder.getDownloadUrl
test
protected function getDownloadUrl() { if (null === $this->downloadUrl) { $this->downloadUrl = $this->router->generate( 'sulu_media.website.media.download', [ 'slug' => 'file', 'id' => '{id}', ], ...
php
{ "resource": "" }
q259195
ChoiceTrait.getChoices
test
protected function getChoices(FormFieldTranslation $translation) { $choices = preg_split('/\r\n|\r|\n/', $translation->getOption('choices'), -1, PREG_SPLIT_NO_EMPTY); return array_combine($choices, $choices); }
php
{ "resource": "" }
q259196
ChoiceTrait.getChoiceOptions
test
private function getChoiceOptions( FormFieldTranslation $translation, $options ) { if (isset($options['attr']['placeholder'])) { $options['placeholder'] = $options['attr']['placeholder']; unset($options['attr']['placeholder']); } // Choices. $...
php
{ "resource": "" }
q259197
FormTwigExtension.getFormById
test
public function getFormById($id, $type, $typeId, $locale = null, $name = 'form') { $form = $this->formBuilder->build((int) $id, $type, $typeId, $locale, $name); if (!$form) { return; } return $form->createView(); }
php
{ "resource": "" }
q259198
RequestListener.onKernelRequest
test
public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { // do nothing if it's not the master request return; } $request = $event->getRequest(); if (!$request->isMethod('post')) { // do nothing if it's not a po...
php
{ "resource": "" }
q259199
Form.getTranslation
test
public function getTranslation($locale, $create = false, $fallback = false) { foreach ($this->translations as $translation) { if ($translation->getLocale() == $locale) { return $translation; } } if ($create) { $translation = new FormTransl...
php
{ "resource": "" }