_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q8900
Bindings.replace
train
private function replace($bindings) { $search = array_keys($bindings); $replace = array_values($bindings); foreach ($search as $key => &$value) {
php
{ "resource": "" }
q8901
Worker.registerJob
train
public function registerJob(string $jobName, callable $callback) : bool { $this->callbacks[$jobName] = $callback; $this->jobSocket->subscribe($jobName); // register job at server: $this->replySocket->send(json_encode([ 'request' => 'register_job',
php
{ "resource": "" }
q8902
Worker.createJobSocket
train
protected function createJobSocket() { /** @var Context|\ZMQContext $jobContext */ $jobContext = new Context($this->loop); $this->jobSocket = $jobContext->getSocket(\ZMQ::SOCKET_SUB);
php
{ "resource": "" }
q8903
Worker.createReplySocket
train
protected function createReplySocket() { $replyContext = new \ZMQContext; $this->replySocket = $replyContext->getSocket(\ZMQ::SOCKET_REQ);
php
{ "resource": "" }
q8904
Worker.onJobMessage
train
public function onJobMessage(array $message) : bool { $jobName = $message[0]; $jobId = $message[1]; $workerId = $message[2]; $payload = $message[3]; // Skip if job is assigned to another worker: if ($workerId !== $this->workerId) { return false; } // Skip if worker can not handle the requested job if (!isset($this->callbacks[$jobName])) { throw new WorkerException('No callback found for requested job.'); } // Switch to busy state handle job and switch back to idle state:
php
{ "resource": "" }
q8905
Worker.setState
train
protected function setState(int $state) : bool { $this->workerState = $state; // report idle state to server: $this->replySocket->send(json_encode([ 'request' => 'change_state', 'worker_id' => $this->workerId,
php
{ "resource": "" }
q8906
Worker.onJobCompleted
train
protected function onJobCompleted(string $result) : bool { $this->replySocket->send(json_encode([ 'request' => 'job_completed', 'worker_id' => $this->workerId, 'job_id' => $this->jobId, 'result' =>
php
{ "resource": "" }
q8907
Worker.loadConfig
train
protected function loadConfig() { $options = getopt('c:'); if (!isset($options['c'])) { throw new WorkerException('No path to configuration provided.'); } $pathToConfig = $options['c']; if (!file_exists($pathToConfig)) {
php
{ "resource": "" }
q8908
Worker.run
train
public function run() { try { $this->loop->run(); } catch (WorkerException $e) {
php
{ "resource": "" }
q8909
UserSessionResource.handleGET
train
protected function handleGET() { $serviceName = $this->getOAuthServiceName(); if (!empty($serviceName)) { /** @type BaseOAuthService $service */ $service = ServiceManager::getService($serviceName); $serviceGroup = $service->getServiceTypeInfo()->getGroup(); if ($serviceGroup !== ServiceTypeGroups::OAUTH) {
php
{ "resource": "" }
q8910
UserSessionResource.handlePOST
train
protected function handlePOST() { $serviceName = $this->getOAuthServiceName(); if (empty($serviceName)) { $credentials = [ 'email' => $this->getPayloadData('email'), 'username' => $this->getPayloadData('username'), 'password' => $this->getPayloadData('password'), 'is_sys_admin' => false ]; return $this->handleLogin($credentials, boolval($this->getPayloadData('remember_me'))); } /** @type ADLdap $service */ $service = ServiceManager::getService($serviceName); $serviceGroup = $service->getServiceTypeInfo()->getGroup(); switch ($serviceGroup) { case ServiceTypeGroups::LDAP: if ( config('df.enable_windows_auth', false) === true &&
php
{ "resource": "" }
q8911
UserSessionResource.getOAuthServiceName
train
protected function getOAuthServiceName() { $serviceName = $this->getPayloadData('service', $this->request->getParameter('service')); if (empty($serviceName)) { $state = $this->getPayloadData('state', $this->request->getParameter('state')); if (empty($state)) { $state = $this->getPayloadData('oauth_token', $this->request->getParameter('oauth_token'));
php
{ "resource": "" }
q8912
UserSessionResource.handleLogin
train
protected function handleLogin(array $credentials = [], $remember = false) { $loginAttribute = strtolower(config('df.login_attribute', 'email')); if ($loginAttribute === 'username') { $username = array_get($credentials, 'username'); if (empty($username)) { throw new BadRequestException('Login request is missing required username.'); } unset($credentials['email']); } else { $email = array_get($credentials, 'email'); if (empty($email)) {
php
{ "resource": "" }
q8913
Module.prepareMiniTemplateConfig
train
public function prepareMiniTemplateConfig() { $pluginsFormat = array(); $userSites = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites'; if(file_exists($userSites) && is_dir($userSites)) { $sites = $this->getDir($userSites); if(!empty($sites)){ foreach($sites as $key => $val) { //public site folder $publicFolder = $userSites . DIRECTORY_SEPARATOR . $val . DIRECTORY_SEPARATOR . 'public'; //mini template image folder // $imgFolder = $publicFolder . DIRECTORY_SEPARATOR . 'images' .DIRECTORY_SEPARATOR . 'miniTemplate'; //get the mini template folder path $miniTplPath = $publicFolder . DIRECTORY_SEPARATOR . 'miniTemplatesTinyMce'; //check if directory is available if(file_exists($miniTplPath) && is_dir($miniTplPath)) { //get the plugin config format $pluginsConfig = include __DIR__ . '/../config/plugins/MiniTemplatePlugin.config.php'; if(!empty($pluginsConfig)) { //get all the mini template $tpls = array_diff(scandir($miniTplPath), array('..', '.')); if (!empty($tpls)) { //set the site name as sub category title $pluginsConfig['melis']['subcategory']['title'] = $val; //set the id of the plugin $pluginsConfig['melis']['subcategory']['id'] = $pluginsConfig['melis']['subcategory']['id'] . '_' . $val; //get the content of the mini template foreach ($tpls as $k => $v) {
php
{ "resource": "" }
q8914
PresetListener.extend
train
private function extend(array $backup) { $preset = $this->presetStore->getPreset($this->application,
php
{ "resource": "" }
q8915
Database.prepareWhere
train
public function prepareWhere($whereObject) { $where = null; $params = []; if (!empty($whereObject)) { $arr = []; /** @var \Dframe\Database\Chunk\ChunkInterface $chunk */ foreach ($whereObject as $chunk) { list($wSQL, $wParams) = $chunk->build(); $arr[] = $wSQL; foreach ($wParams as $k => $v) { $params[] = $v; } } $this->setWhere = ' WHERE '
php
{ "resource": "" }
q8916
Database.prepareHaving
train
public function prepareHaving($havingObject) { $where = null; $params = []; if (!empty($havingObject)) { $arr = []; /** @var \Dframe\Database\Chunk\ChunkInterface $chunk */ foreach ($havingObject as $chunk) { list($wSQL, $wParams) = $chunk->build(); $arr[] = $wSQL; foreach ($wParams as $k => $v) { $params[] = $v; } } $this->setHaving = ' HAVING
php
{ "resource": "" }
q8917
Database.prepareOrder
train
public function prepareOrder($order = null, $sort = null) { if ($order == null or $sort == null) { $this->setOrderBy = ''; return $this; } if (!in_array($sort, ['ASC',
php
{ "resource": "" }
q8918
Database.prepareQuery
train
public function prepareQuery($query, $params = false) { if (isset($params) and is_array($params)) { $this->prepareParms($params); } if (!isset($this->setQuery)) { $this->setQuery = $query
php
{ "resource": "" }
q8919
Database.prepareParms
train
public function prepareParms($params) { if (is_array($params)) { foreach ($params as $key => $value)
php
{ "resource": "" }
q8920
Database.getQuery
train
public function getQuery() { $sql = $this->setQuery; $sql .= $this->getWhere(); $sql .= $this->getGroupBy(); $sql .= $this->getOrderBy(); $sql .= $this->getHaving(); $sql .= $this->getLimit(); $this->setQuery = null; $this->setWhere = null;
php
{ "resource": "" }
q8921
Database.getWhere
train
public function getWhere() { if (!isset($this->setWhere) or empty($this->setWhere)) {
php
{ "resource": "" }
q8922
Database.getHaving
train
public function getHaving() { if (!isset($this->setHaving) or empty($this->setHaving)) {
php
{ "resource": "" }
q8923
Database.prepareLimit
train
public function prepareLimit($limit, $offset = null) { if ($offset) { $this->setLimit = ' LIMIT ' . $limit . ', ' . $offset . ''; } else {
php
{ "resource": "" }
q8924
ProductMediaGalleryRepository.findOneByAttributeIdAndValue
train
public function findOneByAttributeIdAndValue($attributeId, $value) { // initialize the params $params = array( MemberNames::ATTRIBUTE_ID => $attributeId, MemberNames::VALUE => $value );
php
{ "resource": "" }
q8925
WebformWithOverride.preRenderWebformElement
train
public static function preRenderWebformElement($element) { $webform = ($element['#webform'] instanceof WebformInterface) ? $element['#webform'] : WebformEntity::load($element['#webform']); if (!$webform) { return $element; } if ($webform->access('submission_create')) { $values = []; // Set data. $values['data'] = $element['#default_data']; // Set source entity type and id. if (!empty($element['#entity']) && $element['#entity'] instanceof EntityInterface) { $values['entity_type'] = $element['#entity']->getEntityTypeId(); $values['entity_id'] = $element['#entity']->id(); } elseif (!empty($element['#entity_type']) && !empty($element['#entity_id'])) { $values['entity_type'] = $element['#entity_type']; $values['entity_id'] = $element['#entity_id']; } if (!empty($element['#override'])) { $new_settings = $element['#override']; $webform->setSettingsOverride($new_settings); $values['strawberryfield:override'] = $new_settings; }
php
{ "resource": "" }
q8926
MinifyAssetsService.generateAllAssets
train
public function generateAllAssets ($files, $sitePath, $siteName, $isFromVendor) { $cssMinifier = new Minify\CSS(); $jsMinifier = new Minify\JS(); if($isFromVendor){ $bundleDir = $sitePath.'/public/'; /** * we need to remove the site name on the path * since the site name is already included * in the file name inside the assets.config */ $sitePath = dirname($sitePath); }else{ $bundleDir = $sitePath.'/'.$siteName.'/public/'; } $messages = array(); //check if the directory for the bundle is exist if($this->checkDir($bundleDir)) { //check if bundle is writable
php
{ "resource": "" }
q8927
MinifyAssetsService.createBundleFile
train
private function createBundleFile ($minifier, $fileName, $files, $sitePath, $bundleDir, $cleanCode = true) { $translator = $this->getServiceLocator()->get('translator'); $message = ''; $success = false; if (!empty($files)) { try { foreach ($files as $key => $file) { //remove comments if($cleanCode) { $codeToAdd = $this->removeComments($sitePath . $file); }else{ $codeToAdd = $sitePath . $file; } //add the file to minify later $minifier->add($codeToAdd); // $minifier = $this->getFileContentsViaCurl($minifier, $file); } //minify all the files $minifier->minify($bundleDir . $fileName); $message = $translator->translate('tr_front_minify_assets_compiled_successfully');
php
{ "resource": "" }
q8928
MinifyAssetsController.minifyAssetsAction
train
public function minifyAssetsAction () { $request = $this->getRequest(); $siteID = $request->getPost('siteId'); /** @var \MelisFront\Service\MinifyAssetsService $minifyAssets */ $minifyAssets = $this->getServiceLocator()->get('MinifyAssets'); $result = $minifyAssets->minifyAssets($siteID); $title = 'Compiling assets'; /** * modify a little the result */ $success = true; $message = ''; if(!empty($result['results'])){
php
{ "resource": "" }
q8929
EventManagerTrait.mergeEventListeners
train
public function mergeEventListeners($eventListeners) { if ($eventListeners instanceof EventManagerInterface) { $eventListeners = $eventListeners->getEventListeners(); } foreach (((array) $eventListeners) as $eventName => $listeners) { $queue = []; if (isset($this->eventListeners[$eventName])) { $innerListeners = clone $this->eventListeners[$eventName]; $innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA); foreach ($innerListeners as $callback) { $queue[] = $callback;
php
{ "resource": "" }
q8930
EventManagerTrait.attach
train
public function attach($event, $callback, $priority = 0) { if (!isset($this->eventListeners[$event])) {
php
{ "resource": "" }
q8931
EventManagerTrait.detach
train
public function detach($event, $callback) { if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) { return false; } $removed = false; $listeners = $this->eventListeners[$event]; $newListeners = new ListenerQueue(); $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH); foreach ($listeners as $item) { if ($item['data'] === $callback) { $removed = true;
php
{ "resource": "" }
q8932
Request.toXML
train
public function toXML() { $namespace = 'tns'; $writer = new XMLWriter(); $writer->openMemory(); $writer->setIndent(true); $writer->setIndentString(' '); $writer->startElementNs($namespace, $this->getRequestName(), 'http://www.apis-it.hr/fin/2012/types/f73'); $writer->writeAttribute('Id', uniqid()); $writer->startElementNs($namespace, 'Zaglavlje', null); $writer->writeElementNs($namespace, 'IdPoruke', null, $this->generateUUID());
php
{ "resource": "" }
q8933
EnumDescriptorProto.addValue
train
public function addValue(\google\protobuf\EnumValueDescriptorProto $value) { if ($this->value === null) { $this->value = new
php
{ "resource": "" }
q8934
Shortcode.register
train
public function register( $context = null ) { if ( null !== $context ) { $this->add_context( $context ); } if ( ! $this->is_needed( $this->context ) ) {
php
{ "resource": "" }
q8935
Shortcode.render
train
public function render( $atts, $content = null, $tag = null ) { $atts = $this->atts_parser->parse_atts( $atts, $this->get_tag() ); $this->enqueue_dependencies( $this->get_dependency_handles(), $atts );
php
{ "resource": "" }
q8936
Shortcode.enqueue_dependencies
train
protected function enqueue_dependencies( $handles, $context = null ) { if ( null !== $context ) { $this->add_context( $context ); } if ( ! $this->dependencies || count( $handles ) < 1 ) { return; } foreach ( $handles as $handle ) { $found = $this->dependencies->enqueue_handle( $handle, $this->context, true ); if ( ! $found )
php
{ "resource": "" }
q8937
Shortcode.do_this
train
public function do_this( array $atts = [ ], $content = null ) {
php
{ "resource": "" }
q8938
MediaGalleryObserver.prepareProductMediaGalleryAttributes
train
protected function prepareProductMediaGalleryAttributes() { // load the attribute ID of the media gallery EAV attribute $mediaGalleryAttribute = $this->getEavAttributeByAttributeCode(MediaGalleryObserver::ATTRIBUTE_CODE); $attributeId = $mediaGalleryAttribute[MemberNames::ATTRIBUTE_ID]; // initialize the gallery data $disabled = 0; $mediaType = 'image'; $image = $this->getValue(ColumnKeys::IMAGE_PATH_NEW); // initialize and return the entity return $this->initializeEntity(
php
{ "resource": "" }
q8939
MediaGalleryObserver.prepareProductMediaGalleryValueToEntityAttributes
train
protected function prepareProductMediaGalleryValueToEntityAttributes() { // initialize and return the entity return $this->initializeEntity(
php
{ "resource": "" }
q8940
ValidatorChain.getValidator
train
public function getValidator($alias) { if (array_key_exists($alias, $this->validators)) {
php
{ "resource": "" }
q8941
MaintenanceClient.Alarm
train
public function Alarm(AlarmRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/etcdserverpb.Maintenance/Alarm', $argument,
php
{ "resource": "" }
q8942
MaintenanceClient.Status
train
public function Status(StatusRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/etcdserverpb.Maintenance/Status', $argument,
php
{ "resource": "" }
q8943
MaintenanceClient.Defragment
train
public function Defragment(DefragmentRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/etcdserverpb.Maintenance/Defragment', $argument,
php
{ "resource": "" }
q8944
MaintenanceClient.Hash
train
public function Hash(HashRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/etcdserverpb.Maintenance/Hash', $argument,
php
{ "resource": "" }
q8945
MaintenanceClient.Snapshot
train
public function Snapshot(SnapshotRequest $argument, $metadata = [], $options = []) { return $this->_serverStreamRequest('/etcdserverpb.Maintenance/Snapshot',
php
{ "resource": "" }
q8946
InstallerServiceProvider.registerRedirection
train
protected function registerRedirection(): void { if (! empty($this->redirectAfterInstalled) &&
php
{ "resource": "" }
q8947
InstallerServiceProvider.addDefaultSpecifications
train
protected function addDefaultSpecifications(RequirementContract $requirement) { return $requirement->add(new Specifications\WritableStorage($this->app)) ->add(new Specifications\WritableBootstrapCache($this->app)) ->add(new
php
{ "resource": "" }
q8948
Authentication.retrieveResetToken
train
public function retrieveResetToken($token) { return $this->queryBuilder->from($this->getTokenTable())
php
{ "resource": "" }
q8949
Authentication.deleteToken
train
public function deleteToken($token) { return $this->queryBuilder->from($this->getTokenTable())
php
{ "resource": "" }
q8950
Authentication.registerToken
train
public function registerToken(\Globalis\PuppetSkilled\Database\Magic\Model $user) { $this->queryBuilder->from($this->getTokenTable()) ->insert([ 'user_id' => $user->getKey(),
php
{ "resource": "" }
q8951
Connection.getConfig
train
public function getConfig($key = null, $default = null) { $name = $this->current ?: 'default'; $configs = $this->configs[$name]; if ($key === null) {
php
{ "resource": "" }
q8952
Connection.getOption
train
public function getOption($key = null, $default = null) { $name = $this->current ?: 'default'; $options = isset($this->configs[$name]['options']) ? $this->configs[$name]['options'] : []; if ($key === null) {
php
{ "resource": "" }
q8953
Connection.addConnection
train
public function addConnection($name, $dsn, $username = null, $password = null, $options = []) { //default driver options static $defaultOptions = array( \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, //PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ); if (isset($options['prefix'])) { $prefix = $options['prefix']; unset($options['prefix']); } else { $prefix = '';
php
{ "resource": "" }
q8954
Connection.quoteIdentifier
train
public function quoteIdentifier($name) { $quote = null; switch ($this->getAttribute(\PDO::ATTR_DRIVER_NAME)) { case 'pgsql': case 'sqlsrv': case 'dblib': case 'mssql': case 'sybase': $quote = '"'; break; case 'mysql': case 'sqlite': case 'sqlite2':
php
{ "resource": "" }
q8955
Client.writeClientInit
train
public function writeClientInit($compression = false, $ssl = false) { // MMM dd yyyy HH:mm:ss $date = date('M d Y H:i:s'); $data = array( 'MsgType' => 'ClientInit', 'ClientDate' => $date,
php
{ "resource": "" }
q8956
Client.writeCoreSetupData
train
public function writeCoreSetupData($user, $password, $backend = 'SQLite', $properties = array()) { return $this->write(array( 'MsgType' => 'CoreSetupData', 'SetupData' => array( 'AdminUser' => (string)$user,
php
{ "resource": "" }
q8957
Client.writeHeartBeatRequest
train
public function writeHeartBeatRequest(\DateTime $dt = null) { if ($dt === null) { $dt = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))); }
php
{ "resource": "" }
q8958
Client.writeBufferRequestBacklogAll
train
public function writeBufferRequestBacklogAll($messageIdFirst, $messageIdLast, $maxAmount, $additional) { return $this->write(array( Protocol::REQUEST_SYNC, "BacklogManager", "",
php
{ "resource": "" }
q8959
Client.write
train
public function write($data) { return $this->stream->write( $this->splitter->writePacket(
php
{ "resource": "" }
q8960
Pipeline.execute
train
public function execute() { $groups = array(); $results = array(); $currentOperation = null; $currentGroup = array(); foreach ($this->commands as $command) { if ($currentOperation !== $command[0]) { $groups[] = array($currentOperation, $currentGroup); $currentOperation = $command[0]; $currentGroup = array(); } if ($currentOperation === 'get') {
php
{ "resource": "" }
q8961
ReconfigureCommand.rebuild
train
protected function rebuild(InputInterface $input, OutputInterface $output) { $puli = new Puli(Path::join([getcwd(), NANBANDO_DIR])); $puli->start(); /** @var EmbeddedComposerInterface $embeddedComposer */ $embeddedComposer = $this->getApplication()->getEmbeddedComposer(); $packageManager = $puli->getPackageManager(); $io = new ConsoleIO($input, $output, $this->getApplication()->getHelperSet()); $composer = $embeddedComposer->createComposer($io); $installationManager = $composer->getInstallationManager(); $rootPackage = $composer->getPackage(); $repository = $composer->getRepositoryManager()->getLocalRepository(); $packages = []; foreach ($repository->getPackages() as $package) { $packages[$package->getName()] = $package; } foreach ($rootPackage->getRequires() as $require) { if (!array_key_exists($require->getTarget(), $packages)) { continue; } $packageManager->installPackage( Path::normalize($installationManager->getInstallPath($packages[$require->getTarget()])), $require->getTarget(),
php
{ "resource": "" }
q8962
ExtLipsum._getParagraph
train
private function _getParagraph($first = false) { $words = $this->_dictionary; shuffle($words); if ($first) { $pre = array('lorem', 'ipsum'); $words = array_merge($pre, $words); } $nbrWordsPerParagraph = $this->_nbrWordsPerParagraph + mt_rand(-20, 20); $nbrWordsPerSentence = $this->_nbrWordsPerSentence + mt_rand(-8, 8); $words = array_slice($words, 0, $nbrWordsPerParagraph);
php
{ "resource": "" }
q8963
ExtLipsum._numberOfCommas
train
private function _numberOfCommas($len) { $avg = (float)log($len, 6); $stdDev = (float)($avg / 6.000);
php
{ "resource": "" }
q8964
HtmlMaker.get
train
public function get($name) { if(isset($this->global_vars[$name]))
php
{ "resource": "" }
q8965
Frontmatter.parseLines
train
public function parseLines() { $text = []; while (($line = $this->nextLine()) !== false) { $line = rtrim($line); // Skip empty lines if ($line == "") { $text[] = null; continue; } // Look at start of line to detect valid blocktypes $blockTypes = []; $marker = $line[0]; if (isset($this->blockTypes[$marker])) { foreach ($this->blockTypes[$marker] as $blockType) { $blockTypes[] = $blockType;
php
{ "resource": "" }
q8966
Frontmatter.currentLine
train
public function currentLine() { return isset($this->lines[$this->lineNumber -
php
{ "resource": "" }
q8967
Frontmatter.blockInclude
train
protected function blockInclude($line) { if ($this->config["include"] && preg_match("/^#include[ \t]([\w.]+)$/", $line, $matches) ) { $file = $this->config["include_base"]."/".$matches[1]; if (!is_readable($file)) { throw new Exception("Could not find include file:
php
{ "resource": "" }
q8968
Frontmatter.blockYamlFrontmatter
train
protected function blockYamlFrontmatter($line) { if ($this->config["frontmatter_yaml"] && strlen($line) === 3 && $line[2] === "-" && $line[1] === "-" ) { $startLineNumber = $this->lineNumber; // Detect end of block and move it to frontmatter while (($line = $this->nextLine()) !== false) { $line = rtrim($line); // Block ends with --- or ... if (strlen($line) === 3 && ( ($line[2] === "-" && $line[1] === "-" && $line[0] === "-") || ($line[2] === "." && $line[1] === "." && $line[0] === ".") ) ) { $linesRemoved = $this->lineNumber + 1 - $startLineNumber; $this->linesRemoved += $linesRemoved; $frontmatter = array_splice(
php
{ "resource": "" }
q8969
Frontmatter.addYamlFrontmatter
train
protected function addYamlFrontmatter($lines) { $text = implode("\n", $lines); $parsed = $this->parseYaml($text); if (!is_array($parsed)) {
php
{ "resource": "" }
q8970
Frontmatter.parseYaml
train
protected function parseYaml($text) { if ($this->config["yaml_parser_pecl"] && function_exists("yaml_parse") ) { // PECL php5-yaml extension $parsed = yaml_parse($text); if ($parsed === false) { throw new Exception("Failed parsing YAML frontmatter using PECL."); } return $parsed; } if ($this->config["yaml_parser_symfony"] && method_exists("Symfony\Component\Yaml\Yaml", "parse") ) { // symfony/yaml
php
{ "resource": "" }
q8971
Frontmatter.addJsonFrontmatter
train
protected function addJsonFrontmatter($lines) { if (!function_exists("json_decode")) { throw new Exception("Missing JSON support, perhaps install JSON module with PHP."); } $text = implode("\n", $lines); $parsed = json_decode($text."\n", true); if (is_null($parsed)) {
php
{ "resource": "" }
q8972
DescriptorProto.addField
train
public function addField(\google\protobuf\FieldDescriptorProto $value) { if ($this->field === null) { $this->field = new
php
{ "resource": "" }
q8973
DescriptorProto.addNestedType
train
public function addNestedType(\google\protobuf\DescriptorProto $value) { if ($this->nested_type === null) { $this->nested_type = new
php
{ "resource": "" }
q8974
DescriptorProto.addExtensionRange
train
public function addExtensionRange(\google\protobuf\DescriptorProto\ExtensionRange $value) { if ($this->extension_range === null) { $this->extension_range = new
php
{ "resource": "" }
q8975
DescriptorProto.addOneofDecl
train
public function addOneofDecl(\google\protobuf\OneofDescriptorProto $value) { if ($this->oneof_decl === null) { $this->oneof_decl = new
php
{ "resource": "" }
q8976
DescriptorProto.addReservedRange
train
public function addReservedRange(\google\protobuf\DescriptorProto\ReservedRange $value) { if ($this->reserved_range === null) { $this->reserved_range = new
php
{ "resource": "" }
q8977
DescriptorProto.addReservedName
train
public function addReservedName($value) { if ($this->reserved_name === null) {
php
{ "resource": "" }
q8978
CropController.filterAction
train
public function filterAction(Request $request, $endpoint) { $form = $this->createForm(CropType::class); $form->handleRequest($request); // Form invalid. Exit. if (!$form->isValid()) { return $this->createErrorResponse( $this->get('translator')->trans('Invalid crop parameters') ); } // Else process crop try {
php
{ "resource": "" }
q8979
LocalStorage.parseDateFromFilename
train
protected function parseDateFromFilename($filename) { if ($date = \DateTime::createFromFormat(self::FILE_NAME_PATTERN, explode('_', $filename)[0])) { return $date; } /**
php
{ "resource": "" }
q8980
QueryBuilder.prepare
train
public function prepare() { if (null === $this->statement) {
php
{ "resource": "" }
q8981
QueryBuilder.groupBy
train
public function groupBy($fields) { if (!is_array($fields)) { $fields = $this->splitParts($fields); } foreach ($fields as $k => $field) {
php
{ "resource": "" }
q8982
QueryBuilder.buildQuery
train
public function buildQuery($query = null) { if (null === $query) { $query = $this->query; } $sql = "SELECT "; if (isset($query['distinct']) && $query['distinct']) { $sql .= 'DISTINCT '; } $sql .= isset($query['select']) ? $query['select'] : '*'; if (!isset($query['from'])) { return false; } $sql .= "\nFROM " . $query['from']; if (isset($query['join'])) { $sql .= "\n" . (is_array($query['join']) ? implode("\n", $query['join']) : $query['join']); } if (isset($query['where']) && $query['where'] !== '') { $sql .= "\nWHERE " . $query['where']; } if (isset($query['group'])) { $sql .= "\nGROUP BY " . $query['group']; if (isset($query['having'])) { $sql .= "\nHAVING " . $query['having']; } }
php
{ "resource": "" }
q8983
QueryBuilder.setSql
train
public function setSql($sql) { if ('' !== $prefix = $this->db->getPrefix()) {
php
{ "resource": "" }
q8984
QueryBuilder.getSql
train
public function getSql() { if (null === $this->sql) { if (!empty($this->query)) { $this->setSql($this->buildQuery()); } else {
php
{ "resource": "" }
q8985
QueryBuilder.beginQuery
train
protected function beginQuery() { $autoSlave = $this->db->isAutoSlave(); if ($autoSlave) { $this->db->switchConnection('slave'); } $reconnect = $this->db->getOption('reconnect'); $reconnectRetries = $this->db->getOption('reconnect_retries', 3); $reconnectDelayMS = $this->db->getOption('reconnect_delay_ms', 1000); while (true) { $e = null; $errorCode = null; $errorInfo = null; $result = null; $isReconnectError = false; try { $this->prepare(); $result = $this->statement->execute($this->params ? $this->params : $this->positionParams); } catch (\Exception $e) { } if ($result === false || !$e) { $errorCode = $this->statement->errorCode(); $errorInfo = $this->statement->errorInfo(); } $isReconnectError = Util::checkReconnectError($errorCode, $errorInfo, $e); // reconnect if ($reconnect && $isReconnectError && $reconnectRetries > 0) {
php
{ "resource": "" }
q8986
QueryBuilder.queryAll
train
public function queryAll($params = array()) { $this->mergeParams($params); $this->beginQuery(); $rst
php
{ "resource": "" }
q8987
QueryBuilder.queryRow
train
public function queryRow($params = array()) { $this->mergeParams($params); $this->beginQuery(); $rst
php
{ "resource": "" }
q8988
QueryBuilder.queryColumn
train
public function queryColumn($params = array()) { $this->mergeParams($params); $this->beginQuery(); $rst
php
{ "resource": "" }
q8989
QueryBuilder.queryValue
train
public function queryValue($params = array()) { $this->mergeParams($params); $this->beginQuery();
php
{ "resource": "" }
q8990
QueryBuilder.execute
train
public function execute($params = array()) { $this->mergeParams($params); $reconnect = $this->db->getOption('reconnect'); $reconnectRetries = $this->db->getOption('reconnect_retries', 3); $reconnectDelayMS = $this->db->getOption('reconnect_delay_ms', 1000); while (true) { $e = null; $errorCode = null; $errorInfo = null; $result = null; $isReconnectError = false; try { $this->prepare(); foreach ($this->positionParams as $index => $value) { $this->statement->bindValue($index + 1, $value); } $result = $this->statement->execute($this->params?:null); } catch (\Exception $e) { } if ($result === false || !$e) { $errorCode = $this->statement->errorCode(); $errorInfo = $this->statement->errorInfo(); } $isReconnectError = Util::checkReconnectError($errorCode, $errorInfo, $e); // reconnect
php
{ "resource": "" }
q8991
Cache.computeTTL
train
public function computeTTL($ttl = null) { $ttl = $ttl ?: $this->defaultTTL;
php
{ "resource": "" }
q8992
Cache.capturePage
train
public function capturePage($id = null, $ttl = null, $exit = true) { if ($id === null) { $id = md5(serialize($_SERVER['REQUEST_URI']) . serialize($_REQUEST)); } if ($this->start($id)) { if ($exit) { exit; }
php
{ "resource": "" }
q8993
Cache.pipeline
train
public function pipeline($callback = null) { $pipe = $this->createPipeline(); if ($callback === null) { return $pipe; }
php
{ "resource": "" }
q8994
Field.unIndexed
train
public static function unIndexed($name, $value, $encoding = 'UTF-8')
php
{ "resource": "" }
q8995
AbstractImageValidator.validateConfig
train
protected function validateConfig($key, array $configuration, $isFloat = false) { if (!$isFloat && !ctype_digit((string) $configuration[$key])) { throw new ValidationException(sprintf('"%s" is not
php
{ "resource": "" }
q8996
GdaemonFiles.metadata
train
public function metadata($path) { $writeBinn= new BinnList; $writeBinn->addUint8(self::FSERV_FILEINFO); $writeBinn->addStr($path); $read = $this->writeAndReadSocket($writeBinn->serialize()); $readBinn = new BinnList; $readBinn->binnOpen($read); $results = $readBinn->unserialize(); if ($results[0] != self::FSERV_STATUS_OK) { throw new RuntimeException('GDaemon metadata error:' . isset($results[1]) ? $results[1] : 'Unknown'); } $fileInfo = $results[2]; return [ 'name' => basename($fileInfo[0]),
php
{ "resource": "" }
q8997
GdaemonFiles.chmod
train
public function chmod($mode, $path) { $writeBinn = new BinnList; $writeBinn->addUint8(self::FSERV_CHMOD); $writeBinn->addStr($path); $writeBinn->addUint16($mode); $read = $this->writeAndReadSocket($writeBinn->serialize()); $readBinn = new BinnList; $readBinn->binnOpen($read); $results = $readBinn->unserialize();
php
{ "resource": "" }
q8998
Zipper.zip
train
public function zip($directory, $fileName) { $path = sprintf('%s/%s/%s.zip', $this->localDirectory, $this->name, $fileName); $this->filesystem->mkdir(dirname($path)); // FIXME find better place for this message $this->output->writeln(PHP_EOL . 'Creating zip file (it may take a few minutes) ...'); $zip = $this->openZip($path); $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)); foreach ($files
php
{ "resource": "" }
q8999
Zipper.openZip
train
private function openZip($path) { $zip = new \ZipArchive(); if (!$zip->open($path, \ZipArchive::CREATE))
php
{ "resource": "" }