_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q9700 | S3ClientFactory.getClient | train | public function getClient()
{
return new S3Client([
'version' => $this->apiVersion,
'region' => $this->region,
'credentials' => [
| php | {
"resource": ""
} |
q9701 | ImpersonatorServiceProvider.extendAuthDriver | train | private function extendAuthDriver()
{
/** @var \Illuminate\Auth\AuthManager $auth */
$auth = $this->app['auth'];
$this->app['auth']->extend('session', function (Application $app, $name, array $config) use ($auth) {
$provider = $auth->createUserProvider($config['provider']);
return tap(new Guard\SessionGuard($name, $provider, $app['session.store']), function | php | {
"resource": ""
} |
q9702 | HtmlDomParser.loadUrl | train | public function loadUrl($url, $curl = false) {
if ($curl) {
$content = self::loadContent($url);
if (empty($content)) {
throw new Exception("Can't get content from " . $url);
| php | {
"resource": ""
} |
q9703 | HtmlDomParser.loadContent | train | private static function loadContent($url) {
//TODO: implement URL content load functionality with CURL and proxy
$ch = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
| php | {
"resource": ""
} |
q9704 | Asset.validate | train | protected function validate($object)
{
$object = (object) $object;
if ($object instanceof $this->is) {
return $object;
}
throw new \DomainException(
sprintf(
| php | {
"resource": ""
} |
q9705 | Asset.is | train | public function is($type = null)
{
if ($type === null) {
return $this->is;
| php | {
"resource": ""
} |
q9706 | Asset.single | train | public function single(\Closure $closure)
{
if ($this->asset === null) {
$this->asset = function ($asset = null, $assetManager = null) use ($closure) {
static $obj;
if | php | {
"resource": ""
} |
q9707 | Pager.createFullPages | train | private function createFullPages()
{
$pageStart = 1;
$pageEnd = $this->maxPage;
$tmp = $this->currentPage;
$pager = [];
while (($pageEnd - $tmp) < 4) {
$tmp--; // @codeCoverageIgnore
}
if ($tmp != $this->currentPage) {
$pageStart = 1 + ($tmp - 5); // @codeCoverageIgnore
}
if ($this->currentPage > 5 && $this->currentPage == $tmp) {
$pageStart = 1 + ($this->currentPage - 5);
}
$page = 0;
| php | {
"resource": ""
} |
q9708 | Pager.createSimplePages | train | private function createSimplePages()
{
$pager = [];
for ($i = 1; $i <= $this->maxPage; $i++) {
$pager[$i | php | {
"resource": ""
} |
q9709 | Pager.displayPager | train | private function displayPager()
{
$pager = ($this->maxPage > 9) ? $this->createFullPages() : $this->createSimplePages();
echo '<div class="pager">';
$this->displayLeftSide();
| php | {
"resource": ""
} |
q9710 | SaveService.save | train | public function save(SaveEntityInterface $entity)
{
$entity = $this->persist($entity);
| php | {
"resource": ""
} |
q9711 | InjectionChain.getByIndex | train | public function getByIndex($index)
{
if (! is_numeric($index)) {
throw new RuntimeException('Index needs to be a numeric value.');
}
$index = (int)$index;
if ($index < 0) {
| php | {
"resource": ""
} |
q9712 | DispatchListener.getAdminPanel | train | public function getAdminPanel(MvcEvent $event)
{
$matchRoute = $event->getRouteMatch();
if (empty($matchRoute)) {
return null;
}
/** @var \RcmAdmin\Controller\AdminPanelController $adminPanelController */
$adminPanelController = $this->serviceLocator->get(
\RcmAdmin\Controller\AdminPanelController::class
);
$adminPanelController->setEvent($event);
| php | {
"resource": ""
} |
q9713 | ModelCloning.clone | train | public function clone($modelitemId)
{
event(new BeforeClone($this));
$this->beforeClone();
$this->doClone();
| php | {
"resource": ""
} |
q9714 | ModelCloning.excludeOnClone | train | public function excludeOnClone()
{
return [
$this->model->getKeyName(),
| php | {
"resource": ""
} |
q9715 | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontIcon | train | protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon) {
$attributes = [];
$attributes["class"][] = "zmdi";
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSize($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderBorder($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderPull($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSpin($icon);
| php | {
"resource": ""
} |
q9716 | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontList | train | protected function materialDesignIconicFontList($items) {
$innerHTML = true === is_array($items) ? | php | {
"resource": ""
} |
q9717 | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontListIcon | train | protected function materialDesignIconicFontListIcon($icon, $content) {
$glyphicon = null !== $icon ? StringHelper::replace($icon, ["class=\"zmdi"], | php | {
"resource": ""
} |
q9718 | S3Service.uploadFileWithFolderAndName | train | public function uploadFileWithFolderAndName(UploadedFile $file, $folderPath, $fileName)
{
$folderPath = !empty($folderPath) ? $folderPath . '/' : '';
$path = $this->env . '/' . $folderPath . $fileName . '.'. $file->guessClientExtension();
| php | {
"resource": ""
} |
q9719 | S3Service.uploadFile | train | public function uploadFile(UploadedFile $file)
{
$path = $this->env . '/' . md5(time() . random_int(1,100000)) . '.'. $file->guessClientExtension();
/** @var Result $result */
$result = $this->client->putObject([
'ACL' => 'public-read',
'Bucket' => $this->bucketName,
| php | {
"resource": ""
} |
q9720 | Cookie.send | train | public function send()
{
$args = [
$this->name,
$this->value,
time() + $this->lifetime,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
]; | php | {
"resource": ""
} |
q9721 | UserClass.extendClass | train | public function extendClass($className, $useAlias = true)
{
if ($className[0] === '\\' && $useAlias) {
$className = ltrim($className, '\\');
$this->useClass($className);
$_p = explode('\\', $className);
$shortClassName = end($_p);
| php | {
"resource": ""
} |
q9722 | UserClass.generatePsr0ClassUnder | train | public function generatePsr0ClassUnder($directory, array $args = array())
{
$code = "<?php\n" . $this->render($args);
$classPath = $this->getPsr0ClassPath();
$path = $directory . DIRECTORY_SEPARATOR . $classPath;
if ($dir = dirname($path)) {
if (!file_exists($dir)) {
| php | {
"resource": ""
} |
q9723 | EzCronService.getCron | train | public function getCron(string $alias): ?EdgarEzCron
{
if ($cron = $this->repository->getCron($alias)) {
return $cron;
}
$crons = $this->getCrons();
if (isset($crons[$alias])) {
$cron = new EdgarEzCron();
$cron->setAlias($alias);
$cron->setExpression($crons[$alias]['expression']);
| php | {
"resource": ""
} |
q9724 | EzCronService.getCrons | train | public function getCrons(): array
{
/** @var CronInterface[] $crons */
$crons = $this->cronService->getCrons();
/** @var EdgarEzCron[] $ezCrons */
$ezCrons = $this->repository->listCrons();
$return = [];
foreach ($ezCrons as $ezCron) {
$return[$ezCron->getAlias()] = [
'alias' => $ezCron->getAlias(),
'expression' => $ezCron->getExpression(),
'arguments' => $ezCron->getArguments(),
'priority' => (int)$ezCron->getPriority(),
'enabled' => (int)$ezCron->getEnabled() == 1,
];
}
| php | {
"resource": ""
} |
q9725 | FormRenderer.renderOption | train | public static function renderOption($option, TranslatorInterface $translator = null) {
if (null === $option) {
return null !== $translator ? $translator->trans("label.empty_selection") : "Empty selection";
}
// Check the implementation.
if (true === ($option instanceof TranslatedChoiceLabelInterface)) {
$output = $option->getTranslatedChoiceLabel($translator);
} else if (true === ($option instanceof ChoiceLabelInterface)) {
$output = $option->getChoiceLabel();
} else {
$output = "This option must implements [Translated]ChoiceLabelInterface";
}
if (true === ($option | php | {
"resource": ""
} |
q9726 | FormFactory.newEntityType | train | public static function newEntityType($class, array $choices = [], array $options = []) {
// Check the options.
if (false === array_key_exists("empty", $options)) {
$options["empty"] = false;
}
if (false === array_key_exists("translator", $options)) {
$options["translator"] = null;
}
// Initialize the output.
$output = [
"class" => $class,
"choices" => [],
"choice_label" => function($entity) use ($options) { | php | {
"resource": ""
} |
q9727 | CronController.listAction | train | public function listAction(): Response
{
$this->permissionAccess('uicron', 'list');
$crons = $this->cronService->getCrons();
| php | {
"resource": ""
} |
q9728 | CronController.permissionAccess | train | protected function permissionAccess(string $module, string $function): ?RedirectResponse
{
if (!$this->permissionResolver->hasAccess($module, $function)) {
$this->notificationHandler->error(
$this->translator->trans(
'edgar.ezuicron.permission.failed',
[],
| php | {
"resource": ""
} |
q9729 | File.path | train | public function path(string $thumbSize = null)
{
return $this->attributes['type']
.DS.$this->attributes['category']
.($thumbSize ? DS.$thumbSize : '')
| php | {
"resource": ""
} |
q9730 | File.storeAsZip | train | protected function storeAsZip(UploadedFile $file, array $data)
{
$disk = $this->storageDisk($data['disk']);
// Make zip archive name with full path.
$zipname = $disk->getDriver()->getAdapter()->getPathPrefix()
.$data['type'].DS.$data['category'].DS
.$data['name'].'.'.$data['extension'] . '.zip';
// Check if new file exists
if ($disk->exists($zipname)) {
throw new FileException(sprintf(
'File with name `%s` already exists!', $zipname
));
}
| php | {
"resource": ""
} |
q9731 | File.storeAsImage | train | protected function storeAsImage(UploadedFile $file, array $data)
{
// Store uploaded image, to work it.
$this->storeAsFile($file, $data);
// Prepare local variables.
$properties = [];
$disk = $this->storageDisk($data['disk']);
$path_prefix = $data['type'].DS.$data['category'].DS;
$path_suffix = DS.$data['name'].'.'.$data['extension'];
$quality = setting('files.images_quality', 75);
$is_convert = setting('files.images_is_convert', true);
// Resave original file.
$image = $this->imageResave(
$this->getAbsolutePathAttribute(),
$disk->path($path_prefix.trim($path_suffix, DS)),
setting('files.images_max_width', 3840),
setting('files.images_max_height', 2160),
$quality, $is_convert
);
if ($image) {
// If extension has changed, then delete original file.
if ($data['extension'] != $image['extension']) {
$disk->delete($this->path);
}
// Revision attributes.
$this->attributes['mime_type'] = $image['mime_type'];
$this->attributes['extension'] = $image['extension'];
$this->attributes['filesize'] = $image['filesize'];
$properties = [
'width' => $image['width'],
| php | {
"resource": ""
} |
q9732 | Sonarr.getCommand | train | public function getCommand($id = null)
{
$uri = ($id) ? 'command/' . $id : 'command';
$response = [
'uri' => $uri,
'type' => 'get',
| php | {
"resource": ""
} |
q9733 | Sonarr.postCommand | train | public function postCommand($name, array $params = null)
{
$uri = 'command';
$uriData = [
'name' => $name
];
if (is_array($params)) {
| php | {
"resource": ""
} |
q9734 | Sonarr.getRelease | train | public function getRelease($episodeId)
{
$uri = 'release';
$uriData = [
'episodeId' => $episodeId
];
$response = [
'uri' => $uri,
| php | {
"resource": ""
} |
q9735 | Sonarr.postReleasePush | train | public function postReleasePush($title, $downloadUrl, $downloadProtocol, $publishDate)
{
$uri = 'release';
$uriData = [
'title' => $title,
'downloadUrl' => $downloadUrl,
'downloadProtocol' => $downloadProtocol,
'publishDate' => $publishDate
| php | {
"resource": ""
} |
q9736 | Sonarr.postSeries | train | public function postSeries(array $data, $onlyFutureEpisodes = true)
{
$uri = 'series';
$uriData = [];
// Required
$uriData['tvdbId'] = $data['tvdbId'];
$uriData['title'] = $data['title'];
$uriData['qualityProfileId'] = $data['qualityProfileId'];
if ( array_key_exists('titleSlug', $data) ) { $uriData['titleSlug'] = $data['titleSlug']; }
if ( array_key_exists('seasons', $data) ) { $uriData['seasons'] = $data['seasons']; }
if ( array_key_exists('path', $data) ) { $uriData['path'] = $data['path']; }
| php | {
"resource": ""
} |
q9737 | Sonarr.deleteSeries | train | public function deleteSeries($id, $deleteFiles = true)
{
$uri = 'series';
$uriData = [];
$uriData['deleteFiles'] = ($deleteFiles) ? 'true' : 'false';
$response = [
'uri' => $uri . '/' . $id,
| php | {
"resource": ""
} |
q9738 | Sonarr.processRequest | train | protected function processRequest(array $request)
{
try {
$response = $this->_request(
[
'uri' => $request['uri'],
'type' => $request['type'],
'data' => $request['data']
]
);
} catch ( \Exception $e ) {
echo json_encode(array(
| php | {
"resource": ""
} |
q9739 | AttributeCollection.add | train | public function add($items = [])
{
if (!is_array($items) || func_num_args() > 1) | php | {
"resource": ""
} |
q9740 | AttributeCollection.createField | train | private function createField($type, $name, $value, $inner)
{
if ($this->hasOptionsMethod($name)) {
$inner = array_merge($inner, ['options' => $this->getOptions($name)]);
| php | {
"resource": ""
} |
q9741 | CommandHelper.getCheckbox | train | public static function getCheckbox($checked) {
if (true === $checked) {
return sprintf("<fg=green;options=bold>%s</>", OSHelper::isWindows() ? "OK" : "\xE2\x9C\x94");
}
| php | {
"resource": ""
} |
q9742 | Redirect.setRedirectUrl | train | public function setRedirectUrl($redirectUrl)
{
if (!$this->getUrlValidator()->isValid($redirectUrl)) { | php | {
"resource": ""
} |
q9743 | Redirect.setRequestUrl | train | public function setRequestUrl($requestUrl)
{
if (!$this->getUrlValidator()->isValid($requestUrl)) { | php | {
"resource": ""
} |
q9744 | Redirect.setSite | train | public function setSite($site)
{
if ($site === null) {
$this->siteId = null;
$this->site = null;
return;
| php | {
"resource": ""
} |
q9745 | Form.removeMemorizedValue | train | public static function removeMemorizedValue($fieldId = null)
{
if (isset($_SESSION['_FIELDS'])) {
if (is_null($fieldId)) {
$_SESSION['_FIELDS'] = null;
| php | {
"resource": ""
} |
q9746 | Form.buildObject | train | public function buildObject($instance = null)
{
if (is_null($instance)) {
return (object) $this->fields;
}
foreach ($this->fields as $property => $value) {
$method = 'set' . ucwords($property);
if | php | {
"resource": ""
} |
q9747 | SlackProvider.loadUserByUsername | train | public function loadUserByUsername($username)
{
$slackUser = $this->client->getSlackUserFromOAuthCode($username);
if (!$slackUser->isValid()) {
throw new UsernameNotFoundException('No access token found.');
}
$user = $this->userService->findBySlackUserId($slackUser->getUserId());
if (!empty($user)) {
return $user;
| php | {
"resource": ""
} |
q9748 | MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteBackgroundFunction | train | public function materialDesignColorPaletteBackgroundFunction(array $args = []) {
| php | {
"resource": ""
} |
q9749 | MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteTextFunction | train | public function materialDesignColorPaletteTextFunction(array $args = []) {
return $this->materialDesignColorPalette("text", | php | {
"resource": ""
} |
q9750 | SessionGuard.silentLogin | train | public function silentLogin(Authenticatable $user)
{
| php | {
"resource": ""
} |
q9751 | ArticlesController.massUpdate | train | public function massUpdate(ArticlesRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$articles = $this->model->whereIn('id', $request->articles);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $articles->update(['state' => 'published'])) {
$messages[] = 'unable to published';
}
break;
case 'unpublished':
if (! $articles->update(['state' => 'unpublished'])) {
$messages[] = 'unable to unpublished';
}
break;
case 'draft':
if (! $articles->update(['state' => 'draft'])) {
$messages[] = 'unable to draft';
}
break;
case 'on_mainpage':
if (! $articles->update(['on_mainpage' => 1])) {
$messages[] = 'unable to mainpage';
}
break;
case 'not_on_mainpage':
if (! $articles->update(['on_mainpage' => 0])) {
$messages[] = 'unable to not_on_mainpage';
}
break;
case 'allow_com':
if (! $articles->update(['allow_com' => 1])) {
$messages[] = 'unable to allow_com';
}
break;
case 'disallow_com':
if (! $articles->update(['allow_com' => 0])) {
$messages[] = 'unable to disallow_com';
}
| php | {
"resource": ""
} |
q9752 | RepositoryHelper.findByRequestParams | train | public function findByRequestParams(Request\Params $params)
{
if (empty($params->pagination) &&
isset($params->resourceConfig) &&
isset($params->resourceConfig->defaults) &&
isset($params->resourceConfig->defaults->pagination) &&
!$params->resourceConfig->defaults->pagination
| php | {
"resource": ""
} |
q9753 | RepositoryHelper.findPaginated | train | public function findPaginated(
$entityClass,
array $criteria,
$sorting = [],
$offset = Request\Params::DEFAULT_PAGE_OFFSET,
$limit = Request\Params::DEFAULT_PAGE_SIZE,
$translatable = false
)
{
$qb = $this->getQueryBuilder($entityClass, $criteria, $sorting, $translatable);
| php | {
"resource": ""
} |
q9754 | RendererBc.getPluginController | train | public function getPluginController($pluginName)
{
/*
* Deprecated. All controllers should come from the controller manager
* now and not the service manager.
*
* @todo Remove if statement once plugins have been converted.
*/
if ($this->serviceManager->has($pluginName)) {
$serviceManager = $this->serviceManager;
} else {
$serviceManager = $this->serviceManager->get('ControllerLoader');
}
if (!$serviceManager->has($pluginName)) {
throw new InvalidPluginException(
"Plugin $pluginName is not loaded or configured. Check
config/application.config.php" | php | {
"resource": ""
} |
q9755 | RendererBc.handleResponseFromPluginController | train | public function handleResponseFromPluginController(ResponseInterface $response, $blockInstanceName)
{
// trigger_error( //@TODO remove all this and throw exception
// 'Returning responses from plugin controllers is no longer supported.
// The following plugin attempted this: ' . $blockInstanceName .
// ' Post to your own route to avoid this problem.',
// E_USER_WARNING
// );
foreach ($response->getHeaders() as $header) {
header($header->toString());
}
// //Some plugins used to return responses | php | {
"resource": ""
} |
q9756 | Container.getRevisionDbInfo | train | public function getRevisionDbInfo($siteId, $name, $revisionId)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder()
->select(
'container,'
. 'publishedRevision.revisionId,'
. 'revision,'
. 'pluginWrappers,'
. 'pluginInstances'
)
->from(\Rcm\Entity\Container::class, 'container')
->leftJoin('container.publishedRevision', 'publishedRevision')
->leftJoin('container.site', 'site')
->leftJoin('container.revisions', 'revision')
->leftJoin('revision.pluginWrappers', 'pluginWrappers')
->leftJoin('pluginWrappers.instance', 'pluginInstances')
->where('site.siteId = :siteId')
->andWhere('container.name = :containerName')
->andWhere('revision.revisionId = | php | {
"resource": ""
} |
q9757 | EntityManagerTrait.getFilters | train | protected function getFilters(Request $request)
{
$type = $this->getFilterType($request);
if (!$type) {
| php | {
"resource": ""
} |
q9758 | EntityManagerTrait.getLimit | train | protected function getLimit(Request $request)
{
return min(
$this->getMaxLimit($request),
| php | {
"resource": ""
} |
q9759 | EntityManagerTrait.getOffset | train | protected function getOffset(Request $request)
{
return max(
$request->query->get('start', 0),
| php | {
"resource": ""
} |
q9760 | EntityManagerTrait.search | train | protected function search(ModelCriteria $query, Request $request)
{
$filters = $this->getFilters($request);
if (empty($filters)) {
return $query;
}
$conditions = array();
$columns = $this->getSearchColumns($request);
if (is_array($filters)) {
foreach ($columns as $name => $condition) {
$items = explode('.', $name);
$i = 0;
$values = $filters;
while (is_array($values) && array_key_exists($items[$i], $values)) {
$values = $values[$items[$i]];
$i++;
}
if (is_array($values)) {
| php | {
"resource": ""
} |
q9761 | EntityManagerTrait.sort | train | protected function sort(ModelCriteria $query, Request $request)
{
$order = $this->getSortOrder($request);
foreach ($order as | php | {
"resource": ""
} |
q9762 | EntityManagerTrait.getSortOrder | train | protected function getSortOrder(Request $request)
{
$sort = array();
$order = $request->query->get('order', array());
$columns = $this->getSortColumns($request);
foreach ($order as $setting) {
$index = $setting['column'];
if (array_key_exists($index, $columns)) {
$column = $columns[$index];
| php | {
"resource": ""
} |
q9763 | HashMap.sort | train | public function sort(callable $callback, bool $keySort = false): self
{
$keys = $this->keys;
$values = $this->values;
if ($keySort) {
uasort($keys, $callback);
$values = array_replace($keys, $values);
} else {
| php | {
"resource": ""
} |
q9764 | HashMap.stringifyArrayKey | train | private static function stringifyArrayKey(array $key): string
{
ksort($key);
foreach ($key as &$value) {
if (is_array($value)) {
$value = self::stringifyArrayKey($value);
} elseif (is_object($value)) { | php | {
"resource": ""
} |
q9765 | HashMap.stringifyKey | train | private static function stringifyKey($key): string
{
if ($key === null || is_scalar($key)) {
return (string) $key;
}
if (is_object($key)) {
| php | {
"resource": ""
} |
q9766 | MainPageMenu.addMenuItem | train | public function addMenuItem($image, $title, $url)
{
return $this->row->addItem(
new \Ease\Html\ATag(
$url,
new \Ease\TWB\Col(2,
| php | {
"resource": ""
} |
q9767 | ByteArkV2UrlSigner.sign | train | public function sign($url, $expires = null, $options = [])
{
if (parse_url($url, PHP_URL_QUERY)) {
throw new \InvalidArgumentException('This signer do not accept URL with query string');
}
if (!$expires) {
| php | {
"resource": ""
} |
q9768 | ViewRenderer.getDispatcher | train | protected function getDispatcher(): IDispatcher
{
if ($this->dispatcher === null) {
$this->dispatcher = new | php | {
"resource": ""
} |
q9769 | ViewRenderer.handle | train | public function handle(string $pattern, callable $resolver, int $priority = 0): Route
{
$this->cache = [];
| php | {
"resource": ""
} |
q9770 | ViewRenderer.resolveViewName | train | public function resolveViewName(string $name): ?string
{
if (!array_key_exists($name, $this->cache)) {
$this->collection->sort();
$view = $this->getRouter()->route(new Context($name));
if (!is_string($view)) {
| php | {
"resource": ""
} |
q9771 | PoolFilesystem.scandirTask | train | protected function scandirTask(Context $context, string $path): \Generator
{
$entries = yield $this->pool->submit($context, new MethodCall(static::class, 'scandirJob', $path));
if ($entries === null) {
| php | {
"resource": ""
} |
q9772 | PoolFilesystem.scandirJob | train | protected static function scandirJob(string $path): ?array
{
if (!\is_dir($path)) {
return null;
| php | {
"resource": ""
} |
q9773 | PoolFilesystem.readStreamTask | train | protected function readStreamTask(Context $context, string $path): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileReadableJob', $path))) {
throw new FilesystemException(\sprintf('File is not readable: "%s"', $path));
}
if (!$this->fileTransferSupported) {
return new ReadableFileStream($this->pool, $path);
}
| php | {
"resource": ""
} |
q9774 | PoolFilesystem.checkFileReadableJob | train | protected static function checkFileReadableJob(string $path): bool
{
if | php | {
"resource": ""
} |
q9775 | PoolFilesystem.writeStreamTask | train | protected function writeStreamTask(Context $context, string $path, bool $append = false): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileWritableJob', $path, !$append && !$this->fileTransferSupported))) {
throw new FilesystemException(\sprintf('File is not writable: "%s"', | php | {
"resource": ""
} |
q9776 | PoolFilesystem.checkFileWritableJob | train | protected static function checkFileWritableJob(string $path, bool $truncate = false): bool
{
if (\file_exists($path) && (!\is_file($path) || !\is_writable($path))) {
return false;
}
| php | {
"resource": ""
} |
q9777 | Thumbnail.url | train | public function url($file, array $params)
{
$cacheFileSrc = $this->make($file, $params);
| php | {
"resource": ""
} |
q9778 | Thumbnail.urlPlaceholder | train | private function urlPlaceholder($width, $height, $text, $backgroundColor, $textColor, $textSize, $random, array
$options)
{
if ($random) {
$backgroundColor = $this->getRandomColor();
}
$src = 'https://placeholdit.imgix.net/~text?txtsize=' . $textSize . '&bg=' . str_replace('#', '',
$backgroundColor) . '&txtclr=' . str_replace('#', '', $textColor) . '&txt=' . $text . '&w=' . $width . '&h=' . $height;
if (!$this->options['placeholder']['cache']) {
return Html::img($src, $options);
}
$cacheFileName = md5($width . $height . $text . $backgroundColor . $textColor . $textSize);
$cacheFileExt = '.jpg';
$cacheFileDir = '/' . substr($cacheFileName, 0, 2);
$cacheFilePath = Yii::getAlias($this->cachePath) . $cacheFileDir;
$cacheFile = $cacheFilePath . '/' . $cacheFileName . $cacheFileExt;
$cacheUrl = str_replace('\\', '/', preg_replace('/^@[a-z]+/', | php | {
"resource": ""
} |
q9779 | Thumbnail.jsPlaceholder | train | private function jsPlaceholder($width, $height, $text, $backgroundColor, $textColor, $random, array $options)
{
$src = 'holder.js/' . $width . 'x' . $height . '?bg=' . $backgroundColor . '&fg=' . $textColor . '&text=' . $text;
if ($random) {
| php | {
"resource": ""
} |
q9780 | Thumbnail.thumbnail | train | private function thumbnail(array $params)
{
$mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;
$width = (isset($params['width']) && is_numeric($params['width'])) ? $params['width'] : null; | php | {
"resource": ""
} |
q9781 | Dashlet.getDashletFields | train | public function getDashletFields()
{
/**
* if you want to use jQuery color picker instead of HTML5
* <input type='color' />, uncomment out the lined which add
* the extra class, and comment out the lines which are setting
* the attribute to type => color
*/
| php | {
"resource": ""
} |
q9782 | Dashlet.canCreate | train | public function canCreate($member=null)
{
if (!$member) {
$member = singleton('SecurityContext')->getMember();
}
if ($member) {
// check dashboard controller's allowed_dashlets
$allowed = Config::inst()->get('DashboardController', 'allowed_dashlets');
if (in_array(get_class($this), $allowed)) {
return true;
}
| php | {
"resource": ""
} |
q9783 | Dashlet_Controller.save | train | public function save()
{
if ($this->widget && $this->widget->OwnerID && $this->widget->OwnerID != Member::currentUserID()) {
// check ownership, not just write access
return;
}
//Note : Gridster uses weird names... size_x? Why just not width, Argh...
// Admittedly, col and row makes sense since it's essentially
// using cells to align up objects.
$obj | php | {
"resource": ""
} |
q9784 | DashboardController.updateDashboard | train | public function updateDashboard()
{
$dashboardId = (int) $this->request->postVar('dashboard');
$items = (array) $this->request->postVar('order');
if ($dashboardId) {
$dashboard = $this->dataService->memberDashboardById($dashboardId);
if ($dashboard && $dashboard->exists()) {
$dashboard->Widgets()->removeAll();
| php | {
"resource": ""
} |
q9785 | DashboardController.getRecord | train | protected function getRecord()
{
$id = (int) $this->request->param('ID');
if (!$id) {
$id = (int) $this->request->requestVar('ID');
}
if ($id) {
$type = $this->stat('model_class');
$action = $this->request->param('Action');
if ($action == 'dashlet' || $action == 'widget') {
$type = 'Dashlet';
}
| php | {
"resource": ""
} |
q9786 | TableUtilitiesTrait.updateField | train | public function updateField($primaryKey, $field, $value = null): bool
{
$query = $this->query()
->update()
->set([
$field => $value,
| php | {
"resource": ""
} |
q9787 | SuperBackupService.index | train | public function index($params = [], $optParams = [])
{
if ($optParams instanceof IndexParams) {
$optParams = $optParams->toArray(true);
}
return $this->sendRequest([], [
'restAction' => 'index',
'params' => $params,
'getParams' => $optParams,
], function ($response) {
$backups = [];
if (isset($response->data['items'])) {
foreach ($response->data['items'] as $superbackup) {
| php | {
"resource": ""
} |
q9788 | SuperBackupService.create | train | public function create($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
| php | {
"resource": ""
} |
q9789 | SuperBackupService.update | train | public function update($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
if ($params->task && is_string($params->task->type)) {
$params->task = $params->task->type;
}
$optParams['cloud']['id'] = $params->cloud->id;
return $this->sendRequest([], [
'restAction' => 'update',
| php | {
"resource": ""
} |
q9790 | SuperBackupService.delete | train | public function delete($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params;
return $this->sendRequest([], [
| php | {
"resource": ""
} |
q9791 | SuperBackupService.view | train | public function view($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
| php | {
"resource": ""
} |
q9792 | Views.render | train | public static function render($view, array $context = [], $type = null)
{
$viewBuilder = static::getViewBuilder();
| php | {
"resource": ""
} |
q9793 | CssProperties.flat | train | public function flat(array $properties): string
{
Assert::isMap($properties);
| php | {
"resource": ""
} |
q9794 | Client.send | train | public function send($data, array $registrationIds = [], array $options = [])
{
$this->responses = [];
$data = array_merge($options, [
'data' => $data,
]);
if (isset($options['to'])) {
$this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
} elseif (count($registrationIds) > 0) {
// Chunk number of registration ID's according to the maximum allowed by GCM
$chunks = array_chunk($registrationIds, $this->registrationIdMaxCount);
// Perform the calls (in parallel)
foreach ($chunks as $registrationIds) {
$data['registration_ids'] = $registrationIds;
| php | {
"resource": ""
} |
q9795 | Client.sendTo | train | public function sendTo($data, $topic = '/topics/global', array $options = [])
{
$options['to'] = $topic; | php | {
"resource": ""
} |
q9796 | AbstractField.configure | train | public function configure(array $properties)
{
foreach ($properties as $name => $value) {
$methodName = 'set' . ucfirst(strtolower($name));
if (method_exists($this, | php | {
"resource": ""
} |
q9797 | AbstractField.validate | train | public function validate($value)
{
$assert = $this->getAssert();
if ($assert !== null) {
if (is_callable($assert)) {
if (!call_user_func($assert, $value, $this)) {
throw new AssertException(
sprintf('Custom validation fail with value (%s) "%s"', gettype($value), print_r($value, true))
);
}
} else {
if ($value !== $assert) {
throw new AssertException(
sprintf(
'Failed asserting that actual value (%s) "%s" matches expected value (%s) "%s".', | php | {
"resource": ""
} |
q9798 | AbstractField.resolveProperty | train | protected function resolveProperty($name)
{
$value = $this->$name;
if (is_callable($value)) | php | {
"resource": ""
} |
q9799 | AbstractField.resolveValue | train | private function resolveValue($value)
{
if (DataSet::isPath($value)) {
if (empty($this->dataSet)) {
throw new ConfigurationException('DataSet is required to resole value by path.');
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.