_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q238100
Routing.startRoutingPlugin
train
protected function startRoutingPlugin($app) { $this->requiresPlugins(Paths::class, Resources::class); $this->onRegister('routing', function (Application $app) { if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) { $router = $app->make('router'); $ke...
php
{ "resource": "" }
q238101
Yuml.getUriForDiagrammType
train
public function getUriForDiagrammType($type) { switch ($type) { case Diagramm::TYPE_ACTIVITY: $uri = $this->getOptions()->getYumlActivityDiagrammUrl(); break; case Diagramm::TYPE_CLASS: $uri = $this->getOptions()->getYumlClassDiagrammUr...
php
{ "resource": "" }
q238102
Yuml.requestDiagramm
train
public function requestDiagramm($type, $dslText) { if ($this->getOptions()->getReturnDummyImage()) { return $this->getOptions()->getDummyImage(); } $httpClient = $this->getHttpClient(); $httpClient->setUri($this->getUriForDiagrammType($type)); $httpClient->setPar...
php
{ "resource": "" }
q238103
Service.getConfig
train
public static function getConfig(Loops $loops = NULL, ArrayObject $config = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } if(!$config) { $parts = explode("\\", get_called_class()); if(count($parts) > 2 && array_slice($parts, 0, 2) == [ "Loops", "...
php
{ "resource": "" }
q238104
Service.getService
train
public static function getService(ArrayObject $config, Loops $loops) { return Misc::reflectionInstance(static::getClassname($loops), static::getConfig($loops, $config)); }
php
{ "resource": "" }
q238105
Service.hasService
train
public static function hasService(Loops $loops) { foreach(static::getDependencies($loops) as $classname) { if(!class_exists($classname)) { return FALSE; } } return TRUE; }
php
{ "resource": "" }
q238106
EventConverter.convert
train
public function convert(EventInterface $event) { $connection = $event->getConnection(); $array = array( 'message' => $event->getMessage(), 'params' => $event->getParams(), 'command' => $event->getCommand(), 'connection' => array( 'serv...
php
{ "resource": "" }
q238107
Stream.attach
train
protected function attach($stream) { if (is_resource($stream) === false) { throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource'); } if (is_resource($this->stream) === true) { $this->detach(); } $this->stream = $str...
php
{ "resource": "" }
q238108
Stream.close
train
public function close() { if (is_resource($this->stream) === true) { fclose($this->stream); } $this->detach(); }
php
{ "resource": "" }
q238109
Stream.getSize
train
public function getSize() { if (is_resource($this->stream) === true) { $stats = fstat($this->stream); if (isset($stats['size'])) { return $stats['size']; } } return null; }
php
{ "resource": "" }
q238110
Stream.isWritable
train
public function isWritable() { if (is_resource($this->stream) === true) { $metadata = $this->getMetadata(); return Validator::isWritable($metadata); } return false; }
php
{ "resource": "" }
q238111
FieldMethods.&
train
public function & AddFields ($fields) { /** @var $this \MvcCore\Ext\Forms\IForm */ $fields = func_get_args(); if (count($fields) === 1 && is_array($fields[0])) $fields = $fields[0]; foreach ($fields as & $field) $this->AddField($field); return $this; }
php
{ "resource": "" }
q238112
FieldMethods.&
train
public function & AddField (\MvcCore\Ext\Forms\IField $field) { /** @var $this \MvcCore\Ext\Forms\IForm */ /** @var $field \MvcCore\Ext\Forms\Field */ if ($this->dispatchState < 1) $this->Init(); $fieldName = $field->GetName(); $field->SetForm($this); $this->fields[$fieldName] = & $field; if ($field insta...
php
{ "resource": "" }
q238113
FieldMethods.HasField
train
public function HasField ($fieldOrFieldName = NULL) { $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } return isset($this->fields[$fieldName]); }
php
{ "resource": "" }
q238114
FieldMethods.&
train
public function & RemoveField ($fieldOrFieldName = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ if ($this->dispatchState < 1) $this->Init(); $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldNa...
php
{ "resource": "" }
q238115
FieldMethods.&
train
public function & GetField ($fieldName = '') { $result = NULL; if (isset($this->fields[$fieldName])) $result = & $this->fields[$fieldName]; return $result; }
php
{ "resource": "" }
q238116
FieldMethods.&
train
public function & GetFirstFieldByType ($fieldType = '') { $result = NULL; foreach ($this->fields as & $field) { if ($field->GetType() == $fieldType) { $result = & $field; } } return $result; }
php
{ "resource": "" }
q238117
Date.friendly
train
public static function friendly($time) { $now = time(); $delta = abs($time - $now); if ($delta < self::MINUTE) { return $delta === self::SECOND ? 'one second age' : ['%num% second ago', $delta]; } if ($delta < 2 * self::MINUTE) { return 'a minute ago...
php
{ "resource": "" }
q238118
Mysql.genDsn
train
public function genDsn($config): string { // Parse config $dsn = ''; foreach ($config as $key => $value) { if (\in_array($key, self::AVAILABLE_OPTIONS, false)) { $dsn .= "$key=$value;"; } } // Get driver of connection $driver =...
php
{ "resource": "" }
q238119
ArrayFactory.buildStates
train
private function buildStates(): array { $states = []; foreach ($this->getOffsetFromArray($this->schema, 'states', []) as $state) { $states[] = new State( $this->getOffsetFromArray($state, 'name'), $this->buildEvents($state), $this->getAddit...
php
{ "resource": "" }
q238120
ArrayFactory.buildEvents
train
private function buildEvents(array $state): array { $events = []; foreach ($this->getOffsetFromArray($state, 'events', []) as $event) { $events[] = new Event( $this->getOffsetFromArray($event, 'name'), $this->getOffsetFromArray($event, 'targetState'), ...
php
{ "resource": "" }
q238121
ArrayFactory.getProcess
train
public function getProcess(): Process { if ($this->process === null) { $this->process = new Process( $this->getSchemaName(), $this->getInitialState(), $this->buildStates() ); } return $this->process; }
php
{ "resource": "" }
q238122
Base.load
train
public function load($refresh = false, array $options = array()) { if ($refresh || $this->_contents === null) { $this->_contents = @file_get_contents($this->_path); if ($this->_contents === false) { throw LoadException::create($this->_path); } ...
php
{ "resource": "" }
q238123
Logger.pushHandler
train
public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); if ($this->_startTime === null) { $this->_startTime = microtime(true); $this->_previousRecordTime = $this->_startTime; } }
php
{ "resource": "" }
q238124
Logger.isHandling
train
public function isHandling($level) { $record = array( 'message' => '', 'context' => array(), 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => new \DateTime(), 'extra' => ...
php
{ "resource": "" }
q238125
Cache.normalizeId
train
protected function normalizeId($id) { if (null !== $this->getSessionPrefix()) { return $this->getSessionPrefix() . self::ID_SEPARATOR . $id; } return $id; }
php
{ "resource": "" }
q238126
UnitOfWork.computeSingleDocumentChangeSet
train
private function computeSingleDocumentChangeSet($document) { $state = $this->getDocumentState($document); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Document has to be managed or scheduled for removal for single computati...
php
{ "resource": "" }
q238127
UnitOfWork.executeExtraUpdates
train
private function executeExtraUpdates(array $options) { foreach ($this->extraUpdates as $oid => $update) { list ($document, $changeset) = $update; $this->documentChangeSets[$oid] = $changeset; $this->getDocumentPersister(get_class($document))->update($document, $options); ...
php
{ "resource": "" }
q238128
UnitOfWork.getDocumentChangeSet
train
public function getDocumentChangeSet($document) { $oid = spl_object_hash($document); if (isset($this->documentChangeSets[$oid])) { return $this->documentChangeSets[$oid]; } return array(); }
php
{ "resource": "" }
q238129
UnitOfWork.scheduleForUpdate
train
public function scheduleForUpdate($document) { $oid = spl_object_hash($document); if ( ! isset($this->documentIdentifiers[$oid])) { throw new \InvalidArgumentException("Document has no identity."); } if (isset($this->documentDeletions[$oid])) { throw new \Inva...
php
{ "resource": "" }
q238130
UnitOfWork.cascadePreRemove
train
private function cascadePreRemove(ClassMetadata $class, $document) { $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]-...
php
{ "resource": "" }
q238131
UnitOfWork.cascadePreLoad
train
private function cascadePreLoad(ClassMetadata $class, $document, $data) { $hasPreLoadListeners = $this->evm->hasListeners(Events::preLoad); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]...
php
{ "resource": "" }
q238132
UnitOfWork.getOriginalDocumentData
train
public function getOriginalDocumentData($document) { $oid = spl_object_hash($document); if (isset($this->originalDocumentData[$oid])) { return $this->originalDocumentData[$oid]; } return array(); }
php
{ "resource": "" }
q238133
ConsoleErrorEvent.setExitCode
train
public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); }
php
{ "resource": "" }
q238134
PortfolioResourceController.index
train
public function index(PortfolioRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Portfolio\Repositories\Presenter\Por...
php
{ "resource": "" }
q238135
PortfolioResourceController.show
train
public function show(PortfolioRequest $request, Portfolio $portfolio) { if ($portfolio->exists) { $view = 'portfolio::portfolio.show'; } else { $view = 'portfolio::portfolio.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio::po...
php
{ "resource": "" }
q238136
PortfolioResourceController.edit
train
public function edit(PortfolioRequest $request, Portfolio $portfolio) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio::portfolio.name')) ->view('portfolio::portfolio.edit', true) ->data(compact('portfolio')) ->output(); }
php
{ "resource": "" }
q238137
PortfolioResourceController.update
train
public function update(PortfolioRequest $request, Portfolio $portfolio) { try { $attributes = $request->all(); $portfolio->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')])) ...
php
{ "resource": "" }
q238138
PortfolioResourceController.destroy
train
public function destroy(PortfolioRequest $request, Portfolio $portfolio) { try { $portfolio->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio::portfolio.name')])) ->code(202) ->status('success')...
php
{ "resource": "" }
q238139
PDOAdapter.connect
train
public function connect() { $dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};"; $dsnString .= "charset={$this->dbCharset}"; /* * Try to connect to database */ try { $this->dbConnection = new \PDO( $dsnString...
php
{ "resource": "" }
q238140
PDOAdapter.query
train
public function query($queryString, array $queryValues = []) { if (!is_string($queryString) || empty($queryString)) { throw new \InvalidArgumentException( __METHOD__.': The specified query is not valid.' ); } $this->connect(); $this->resourceH...
php
{ "resource": "" }
q238141
PDOAdapter.select
train
public function select( $table, $conditions = null, $fields = null, $order = null, $limit = null, $offset = null ) { if (is_null($fields)) { $fields = "*"; } $queryString = "SELECT {$fields} FROM {$table} "; if (!is_nu...
php
{ "resource": "" }
q238142
PDOAdapter.insert
train
public function insert($table, array $data) { $nameFields = join(',', array_keys($data)); $preparedValues = $this->prepareValues($data); $keyValues = join(",", array_keys($preparedValues)); $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});"; $this->...
php
{ "resource": "" }
q238143
PDOAdapter.prepareValues
train
private function prepareValues($arrayData) { $arrayData = array_values($arrayData); $preparedValues = []; $vNumber = 1; foreach ($arrayData as $value) { $preparedValues[":value{$vNumber}"] = "$value"; $vNumber++; } unset($arrayData); ...
php
{ "resource": "" }
q238144
PDOAdapter.update
train
public function update($table, array $data, $conditions) { $nameFields = array_keys($data); $preparedValues = $this->prepareValues($data); $queryString = "UPDATE {$table} SET "; $fNumber = 0; foreach ($preparedValues as $key => $value) { unset($value); ...
php
{ "resource": "" }
q238145
Plugin.specialChar
train
private function specialChar($char) { switch($char) { case "!": return $this->hexToChar('00A1'); case "_": return $this->hexToChar('203E'); case "&": return $this->hexToChar('214B'); case "?": ret...
php
{ "resource": "" }
q238146
CreateInvocationExceptionCapableTrait._createInvocationException
train
protected function _createInvocationException( $message = null, $code = null, RootException $previous = null, callable $callable = null, $args = null ) { return new InvocationException($message, $code, $previous, $callable, $args); }
php
{ "resource": "" }
q238147
ValidatorFactory.create
train
public static function create(string $locale = 'en'): ValidatorFactory { $translator = new Translator; $factory = new ValidatorFactory($translator); $factory = $factory->withBuiltInFactories(); $factory = $factory->withBuiltInTemplates($locale); return $factory; }
php
{ "resource": "" }
q238148
ValidatorFactory.withBuiltInFactories
train
private function withBuiltInFactories(): ValidatorFactory { $keys = array_keys(self::$defaults); return array_reduce($keys, function ($factory, $key) { $rule = self::$defaults[$key]; return $factory->withRuleFactory($key, function (array $parameters = []) use ($rule) { ...
php
{ "resource": "" }
q238149
ValidatorFactory.withBuiltInTemplates
train
private function withBuiltInTemplates(string $locale): ValidatorFactory { $templates = include(__DIR__ . '/../lang/' . $locale . '.php'); return $this->withDefaultTemplates($templates); }
php
{ "resource": "" }
q238150
ValidatorFactory.getValidator
train
public function getValidator(array $rules = []): Validator { $parser = new RulesParser($this->factories); return new Validator($rules, $parser, $this->translator); }
php
{ "resource": "" }
q238151
ValidatorFactory.withRuleFactory
train
public function withRuleFactory(string $name, callable $factory): ValidatorFactory { $factories = array_merge($this->factories, [$name => $factory]); return new ValidatorFactory($this->translator, $factories); }
php
{ "resource": "" }
q238152
ValidatorFactory.withDefaultLabels
train
public function withDefaultLabels(array $labels): ValidatorFactory { $translator = $this->translator->withLabels($labels); return new ValidatorFactory($translator, $this->factories); }
php
{ "resource": "" }
q238153
ValidatorFactory.withDefaultTemplates
train
public function withDefaultTemplates(array $templates): ValidatorFactory { $translator = $this->translator->withTemplates($templates); return new ValidatorFactory($translator, $this->factories); }
php
{ "resource": "" }
q238154
Cookie.clear
train
public static function clear() { $isClearAll = true; if ($_COOKIE) { foreach ($_COOKIE as $key => $value) { $result = self::delete($key); if (!$result) { $isClearAll = false; } } } return $isC...
php
{ "resource": "" }
q238155
NewsletterController.disableAction
train
public function disableAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('CoreExtraBundle:Actor')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Actor entity.'); } ...
php
{ "resource": "" }
q238156
NewsletterController.showAction
train
public function showAction(Newsletter $newsletter) { $deleteForm = $this->createDeleteForm($newsletter); return array( 'entity' => $newsletter, 'delete_form' => $deleteForm->createView(), ); }
php
{ "resource": "" }
q238157
NewsletterController.newShippingAction
train
public function newShippingAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new NewsletterShipping(); $data = $request->request->get('corebundle_newslettershippingtype'); $formConfig = array(); if(isset($data['type']) && $data['type'] == 'token'...
php
{ "resource": "" }
q238158
NewsletterController.showShippingAction
train
public function showShippingAction(NewsletterShipping $newsletterShipping) { $deleteForm = $this->createNShippingDeleteForm($newsletterShipping); return array( 'entity' => $newsletterShipping, 'delete_form' => $deleteForm->createView(), ); }
php
{ "resource": "" }
q238159
NewsletterController.deleteShippingAction
train
public function deleteShippingAction(Request $request, NewsletterShipping $newsletterShipping) { $em = $this->getDoctrine()->getManager(); $em->remove($newsletterShipping); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.deleted'); ...
php
{ "resource": "" }
q238160
Command.ask
train
public function ask($question, $default = null) { $que = new Question($question, $default); $helper = new SymfonyQuestionHelper(); return $helper->ask($this->input, $this->output, $que); }
php
{ "resource": "" }
q238161
Command.optionOrAsk
train
public function optionOrAsk($option, $question, $default = null) { $value = $this->input->getOption($option); if ($value === null || Str::likeEmpty($value)) { $value = $this->ask($question, $default); } return $value; }
php
{ "resource": "" }
q238162
Util.post
train
public static function post($url, $payload, $contentType = 'Content-Type: application/json') { // TODO move constants to global configuration file $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt ( $ch, CURLOPT_RETURNT...
php
{ "resource": "" }
q238163
Util.createField
train
public static function createField($title, $value, $short = true) { $field = new SlackResultAttachmentField (); $field->setTitle ( $title ); $field->setValue ( $value ); $field->setShort ( $short ); return $field; }
php
{ "resource": "" }
q238164
Framework.initContainer
train
private function initContainer() { $dicons = (array)$this->app->config('container.dicon'); $container = ContainerFactory::create(); foreach ($dicons as $dicon) { $file = $this->app->getLoader()->find($dicon)->first(); $container->import($file); } $con...
php
{ "resource": "" }
q238165
Video.setReference
train
public function setReference(ChildReference $v = null) { if ($v === null) { $this->setReferenceId(NULL); } else { $this->setReferenceId($v->getId()); } $this->aReference = $v; // Add binding for other direction of this n:n relationship. // If...
php
{ "resource": "" }
q238166
Video.getReference
train
public function getReference(ConnectionInterface $con = null) { if ($this->aReference === null && ($this->reference_id !== null)) { $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con); /* The following can be used additionally to guara...
php
{ "resource": "" }
q238167
Video.initFeaturedTutorialSkills
train
public function initFeaturedTutorialSkills($overrideExisting = true) { if (null !== $this->collFeaturedTutorialSkills && !$overrideExisting) { return; } $this->collFeaturedTutorialSkills = new ObjectCollection(); $this->collFeaturedTutorialSkills->setModel('\gossi\trixion...
php
{ "resource": "" }
q238168
Video.getFeaturedTutorialSkillsJoinSport
train
public function getFeaturedTutorialSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getFeaturedTutorialSkills($query, ...
php
{ "resource": "" }
q238169
Gravatar.createURL
train
public function createURL() { $url = "https://secure.gravatar.com/avatar/".$this->createHash(); $url = $url."?s=".$this->size."&d=".$this->default."&r=".$this->rating; if($this->forceDefault == true) { $url = $url.'&f=y'; } return $url; }
php
{ "resource": "" }
q238170
HtmlElement.css
train
public function css( $cssClasses ) { if ( ! $cssClasses ) { return $this; } $cssClasses = explode( ' ', $cssClasses ); foreach ( $cssClasses as $cssClass ) { if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) ) {...
php
{ "resource": "" }
q238171
HtmlElement.ghost
train
public function ghost( $ghostValue ) { if ( $this->isCheckbox() ) { $this->ghostCheckboxValue = $ghostValue; $this->avoidGhost = ( null === $ghostValue ); } return $this; }
php
{ "resource": "" }
q238172
HtmlElement.getGhost
train
protected function getGhost() { // A value is set for this checkbox, use it if ( null !== $this->ghostCheckboxValue ) { return $this->ghostCheckboxValue; } // No value is set, and it is not forced to null, so use default ghost (if any) if ( ! $this->avoidGhost ) { return config...
php
{ "resource": "" }
q238173
PdoRepository.createSchema
train
public function createSchema() { $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` T...
php
{ "resource": "" }
q238174
Hostname.get
train
public function get() { $exec = $this->getExecutor(); $exec->setCommand('hostname'); $exec->run(); $output = $exec->getOutput(); return $output['stdout']; }
php
{ "resource": "" }
q238175
Hostname.set
train
public function set($name) { $exec = $this->getExecutor(); $exec->setCommand('hostname ' . $name); $exec->run(); return $exec->hasErrors(); }
php
{ "resource": "" }
q238176
PublishFiles.publishFiles
train
protected function publishFiles(Filesystem $filesystem, array $paths, $force = false) { foreach ($paths as $from => $to) { if ($filesystem->isFile($from)) { $this->publishFile($filesystem, $from, $to, $force); } elseif ($filesystem->isDirectory($from)) { ...
php
{ "resource": "" }
q238177
ConfigCommand.paths
train
public function paths(): void { $paths = $this->getConfigPaths(); WP_CLI::success(count($paths) . ' config files found.'); WP_CLI::success('The later ones override any previous configurations.'); foreach ($paths as $path) { WP_CLI::log($path); } }
php
{ "resource": "" }
q238178
ConfigCommand.cat
train
public function cat(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Printing $path%n") ); // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown ...
php
{ "resource": "" }
q238179
ConfigCommand.validate
train
public function validate(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Validating $path%n") ); try { Toml::parseFile($path); WP_CLI::success("File '...
php
{ "resource": "" }
q238180
NativeArray._
train
public function _($translateKey, $defaultTranslation = "", $placeholders = null) { $translation = $translateKey; if (is_array($defaultTranslation) && $placeholders === null) { $placeholders = $defaultTranslation; } else { if ($defaultTranslation!="") { $translation = $defaultTranslation; } } ...
php
{ "resource": "" }
q238181
NativeArray.setTranslation
train
public function setTranslation($translation) { if (is_array($translation)) { $this->_translate = array_merge($this->_translate, $translation); } }
php
{ "resource": "" }
q238182
DistributedExpiration.distributeExpire
train
public function distributeExpire(EventInterface $event)/*# : bool */ { $dist = $this->distribution; $item = $event->getParam('item'); if ($item instanceof CacheItemExtendedInterface) { // expire ttl $ttl = $item->getExpiration()->getTimestamp() - time(); ...
php
{ "resource": "" }
q238183
MDir.count
train
public function count(): int { if ($this->count == null) { $this->count = 0; if ($handle = opendir($this->fileInfo->getAbsoluteFilePath())) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..'))) { ...
php
{ "resource": "" }
q238184
NoSuchInstallerException.forInstallerNameAndPackageName
train
public static function forInstallerNameAndPackageName($installerName, $packageName, Exception $cause = null) { return new static(sprintf( 'The installer "%s" does not exist in package "%s".', $installerName, $packageName ), 0, $cause); }
php
{ "resource": "" }
q238185
BaseModule.getModelsPathList
train
public function getModelsPathList() { if ($this->_modelsPath === null) { $this->_modelsPath = $this->getBasePath() . DIRECTORY_SEPARATOR . static::$modelsSubdir; // default $pathList = $this->getBasePathList(); foreach ($pathList as $path) { $resultPath = ...
php
{ "resource": "" }
q238186
BaseModule.addRoutes
train
public function addRoutes() { list($rulesBefore, $rulesAfter) = $this->collectRoutes(); Yii::$app->urlManager->addRules($rulesBefore, false); Yii::$app->urlManager->addRules($rulesAfter, true); //echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit; }
php
{ "resource": "" }
q238187
BaseModule.setStartLink
train
protected function setStartLink($routeConfig) { if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) { $routeConfig['startLink'] = [ 'label' => $routeConfig['startLinkLabel'], 'link' => '', // default ]; } if...
php
{ "resource": "" }
q238188
BaseModule.startLink
train
public static function startLink($moduleUid, $routesType) { if (!empty(static::$_startLinks[$moduleUid][$routesType])) { $linkData = static::$_startLinks[$moduleUid][$routesType]; $tcCat = $linkData['tcCat']; $tc = "{$tcCat}/module"; if (!empty(Yii::$app->i18...
php
{ "resource": "" }
q238189
CommentTagTransformer.transform
train
public function transform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } ...
php
{ "resource": "" }
q238190
CommentTagTransformer.reverseTransform
train
public function reverseTransform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } ...
php
{ "resource": "" }
q238191
IteratorTrait.current
train
public function current() { if ($this->valid()) { $key = $this->baseArrayMap[$this->iteratorIterationPosition]; $value = $this->baseConcreteData[$key]; return $this->internalFilterHooks($key, $value, 'output') ? $this->internalSanitizeHooks($key, $value, '...
php
{ "resource": "" }
q238192
SkillGroupTableMap.doInsert
train
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillGroupTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rena...
php
{ "resource": "" }
q238193
AbstractWidget.render
train
public function render( RendererInterface $renderer, $content, array $params ) { return $renderer->render( $this->getTemplate(), $this->getVariables( array_merge( $params, array( 'content' => $content, ) ) ) ); }
php
{ "resource": "" }
q238194
Cache.setModifiedSince
train
private function setModifiedSince(Request $request, Item $item) { if ($modifiedAt = $item->getCreation()) { $modifiedAt->setTimezone(new DateTimeZone('GMT')); $date = sprintf('%s GMT', $modifiedAt->format('l, d-M-y H:i:s')); $request->addHeader('If-Modified-Since', $dat...
php
{ "resource": "" }
q238195
Cache.setEtag
train
private function setEtag(Request $request, Response $cachedResponse) { if ($etag = $cachedResponse->getHeader('ETag')) { $request->addHeader('If-None-Match', $etag); } }
php
{ "resource": "" }
q238196
FileStorage.save
train
public function save($name, $source, $folder, $override = false) { $return = false; try { if (!$this->storage->exists($folder)) { $this->storage->createFolder($folder); } $path = $this->setFilename($name, $folder, $override); ...
php
{ "resource": "" }
q238197
FileStorage.setFilename
train
protected function setFilename(&$name, $folder, $override = false) { $folder = trim($folder, '/'); $extension = strrchr($name, '.'); $len = mb_strlen($name) - mb_strlen($extension); $nameOrig = substr($name,0,$len); $num = 0; do { if (!$override && $num > ...
php
{ "resource": "" }
q238198
Dictionary.addWord
train
public function addWord(string $capitalCase, string $lowerCase = null) { if ($lowerCase == null) { $lowerCase = strtolower($capitalCase); } $index = strtolower($lowerCase); $record = [$capitalCase, $lowerCase]; $this->words[$index] = $record; if ($index...
php
{ "resource": "" }
q238199
Dictionary.getWord
train
public function getWord(string $word) { if (isset($this->words[strtolower($word)])) { return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]); } return new Word($word); }
php
{ "resource": "" }