_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q9700
S3ClientFactory.getClient
train
public function getClient() { return new S3Client([ 'version' => $this->apiVersion, 'region' => $this->region, 'credentials' => [ 'key' => $this->key, 'secret' => $this->secret, ] ]); }
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']); ...
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); } $this->loadString($content); } else { $this->load_fi...
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( "The Asset advertised as being of type %s is actually of type %s", $...
php
{ "resource": "" }
q9705
Asset.is
train
public function is($type = null) { if ($type === null) { return $this->is; } else { return $type == $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 ($obj === null) { $obj = $this->validate($closure($asset, $assetManager)); ...
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 +...
php
{ "resource": "" }
q9708
Pager.createSimplePages
train
private function createSimplePages() { $pager = []; for ($i = 1; $i <= $this->maxPage; $i++) { $pager[$i - 1] = $this->buildAnchor($i); } return $pager; }
php
{ "resource": "" }
q9709
Pager.displayPager
train
private function displayPager() { $pager = ($this->maxPage > 9) ? $this->createFullPages() : $this->createSimplePages(); echo '<div class="pager">'; $this->displayLeftSide(); for ($i = 0; $i < count($pager); $i++) { echo $pager[$i]; } $this->displayRightSi...
php
{ "resource": "" }
q9710
SaveService.save
train
public function save(SaveEntityInterface $entity) { $entity = $this->persist($entity); $this->flush(); return $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) { $index += count($this->chain); } return isset($this->chain[$index]) ...
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( ...
php
{ "resource": "" }
q9713
ModelCloning.clone
train
public function clone($modelitemId) { event(new BeforeClone($this)); $this->beforeClone(); $this->doClone(); $this->afterClone(); event(new AfterClone($this)); }
php
{ "resource": "" }
q9714
ModelCloning.excludeOnClone
train
public function excludeOnClone() { return [ $this->model->getKeyName(), $this->model->getCreatedAtColumn(), $this->model->getUpdatedAtColumn(), ]; }
php
{ "resource": "" }
q9715
AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontIcon
train
protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon) { $attributes = []; $attributes["class"][] = "zmdi"; $attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon); $attributes["class"][] = MaterialDesignIconicFontIconRende...
php
{ "resource": "" }
q9716
AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontList
train
protected function materialDesignIconicFontList($items) { $innerHTML = true === is_array($items) ? implode("\n", $items) : $items; return static::coreHTMLElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]); }
php
{ "resource": "" }
q9717
AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontListIcon
train
protected function materialDesignIconicFontListIcon($icon, $content) { $glyphicon = null !== $icon ? StringHelper::replace($icon, ["class=\"zmdi"], ["class=\"zmdi-hc-li zmdi"]) : ""; $innerHTML = null !== $content ? $content : ""; return static::coreHTMLElement("li", $glyphicon . $innerHTML); ...
php
{ "resource": "" }
q9718
S3Service.uploadFileWithFolderAndName
train
public function uploadFileWithFolderAndName(UploadedFile $file, $folderPath, $fileName) { $folderPath = !empty($folderPath) ? $folderPath . '/' : ''; $path = $this->env . '/' . $folderPath . $fileName . '.'. $file->guessClientExtension(); /** @var Result $result */ $result = $t...
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->bucketNam...
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 ]; $function = (!$this->urlEncodedValue) ? 'setrawcookie' : '...
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); $this->extends =...
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...
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->ge...
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 Tran...
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["tr...
php
{ "resource": "" }
q9727
CronController.listAction
train
public function listAction(): Response { $this->permissionAccess('uicron', 'list'); $crons = $this->cronService->getCrons(); return $this->render('@EdgarEzUICron/cron/list.html.twig', [ 'crons' => $crons, ]); }
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 : '') .DS.$this->attributes['name'].'.'.$this->attributes['extension']; }
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...
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['c...
php
{ "resource": "" }
q9732
Sonarr.getCommand
train
public function getCommand($id = null) { $uri = ($id) ? 'command/' . $id : 'command'; $response = [ 'uri' => $uri, 'type' => 'get', 'data' => [] ]; return $this->processRequest($response); }
php
{ "resource": "" }
q9733
Sonarr.postCommand
train
public function postCommand($name, array $params = null) { $uri = 'command'; $uriData = [ 'name' => $name ]; if (is_array($params)) { foreach($params as $key=>$value) { $uriData[$key] = $value; } } $response = [ ...
php
{ "resource": "" }
q9734
Sonarr.getRelease
train
public function getRelease($episodeId) { $uri = 'release'; $uriData = [ 'episodeId' => $episodeId ]; $response = [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ]; return $this->processRequest($respon...
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...
php
{ "resource": "" }
q9737
Sonarr.deleteSeries
train
public function deleteSeries($id, $deleteFiles = true) { $uri = 'series'; $uriData = []; $uriData['deleteFiles'] = ($deleteFiles) ? 'true' : 'false'; $response = [ 'uri' => $uri . '/' . $id, 'type' => 'delete', 'data' => $uriData ...
php
{ "resource": "" }
q9738
Sonarr.processRequest
train
protected function processRequest(array $request) { try { $response = $this->_request( [ 'uri' => $request['uri'], 'type' => $request['type'], 'data' => $request['data'] ] ); ...
php
{ "resource": "" }
q9739
AttributeCollection.add
train
public function add($items = []) { if (!is_array($items) || func_num_args() > 1) { $items = func_get_args(); } $this->push($this->formatInnerField(null, $items)); }
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)]); } return $this->fields->create($type, $name, $this->getValue($name), $inner); }
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"); } return sprintf("<fg=yellow;options=bold>%s</>", OSHelper::isWindows() ? "KO" : "!"); }
php
{ "resource": "" }
q9742
Redirect.setRedirectUrl
train
public function setRedirectUrl($redirectUrl) { if (!$this->getUrlValidator()->isValid($redirectUrl)) { throw new InvalidArgumentException('URL provided is invalid'); } $this->redirectUrl = $redirectUrl; }
php
{ "resource": "" }
q9743
Redirect.setRequestUrl
train
public function setRequestUrl($requestUrl) { if (!$this->getUrlValidator()->isValid($requestUrl)) { throw new InvalidArgumentException('URL provided is invalid'); } $this->requestUrl = $requestUrl; }
php
{ "resource": "" }
q9744
Redirect.setSite
train
public function setSite($site) { if ($site === null) { $this->siteId = null; $this->site = null; return; } $this->siteId = $site->getSiteId(); $this->site = $site; }
php
{ "resource": "" }
q9745
Form.removeMemorizedValue
train
public static function removeMemorizedValue($fieldId = null) { if (isset($_SESSION['_FIELDS'])) { if (is_null($fieldId)) { $_SESSION['_FIELDS'] = null; unset($_SESSION['_FIELDS']); } else { unset($_SESSION['_FIELDS'][$fieldId]); ...
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 (is_callable([$instance, $method])) { $inst...
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->get...
php
{ "resource": "" }
q9748
MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteBackgroundFunction
train
public function materialDesignColorPaletteBackgroundFunction(array $args = []) { return $this->materialDesignColorPalette("bg", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value")); }
php
{ "resource": "" }
q9749
MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteTextFunction
train
public function materialDesignColorPaletteTextFunction(array $args = []) { return $this->materialDesignColorPalette("text", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value")); }
php
{ "resource": "" }
q9750
SessionGuard.silentLogin
train
public function silentLogin(Authenticatable $user) { $this->updateSession($user->getAuthIdentifier()); $this->setUser($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(...
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->resourceConf...
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...
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->h...
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: ' . $b...
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,' ...
php
{ "resource": "" }
q9757
EntityManagerTrait.getFilters
train
protected function getFilters(Request $request) { $type = $this->getFilterType($request); if (!$type) { return $request->query->get('search')['value']; } $filter = new $type(); $param = $filter->getBlockPrefix(); return $request->query->get($param); ...
php
{ "resource": "" }
q9758
EntityManagerTrait.getLimit
train
protected function getLimit(Request $request) { return min( $this->getMaxLimit($request), $request->query->get( 'length', $this->getDefaultLimit($request) ) ); }
php
{ "resource": "" }
q9759
EntityManagerTrait.getOffset
train
protected function getOffset(Request $request) { return max( $request->query->get('start', 0), $this->getDefaultOffset($request) ); }
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)) { ...
php
{ "resource": "" }
q9761
EntityManagerTrait.sort
train
protected function sort(ModelCriteria $query, Request $request) { $order = $this->getSortOrder($request); foreach ($order as $setting) { $column = $setting[0]; $direction = $setting[1]; $query->orderBy($column, $direction); } return $query; }
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, $colu...
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 { uasort($values, $callback); ...
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)) { $value = self::stringifyKey($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)) { return spl_object_hash($key); } return static::stringifyArrayKey($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, "$title<center><img class=\"img-responsive\" src=\"$image\" alt=\"$title\"></center>") ) ); ...
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) { $expires = time() + $this->options['default_age']; } ...
php
{ "resource": "" }
q9768
ViewRenderer.getDispatcher
train
protected function getDispatcher(): IDispatcher { if ($this->dispatcher === null) { $this->dispatcher = new Dispatcher(); } return $this->dispatcher; }
php
{ "resource": "" }
q9769
ViewRenderer.handle
train
public function handle(string $pattern, callable $resolver, int $priority = 0): Route { $this->cache = []; return $this->collection->createRoute($pattern, $resolver)->set('priority', $priority); }
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)) { $view = null; } $this-...
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) { throw new FilesystemException(\sprintf('Failed to scan directory: "%s"', $pat...
php
{ "resource": "" }
q9772
PoolFilesystem.scandirJob
train
protected static function scandirJob(string $path): ?array { if (!\is_dir($path)) { return null; } $entries = @\glob($path . \DIRECTORY_SEPARATOR . '*', \GLOB_NOSORT); return ($entries === false) ? null : $entries; }
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 (!...
php
{ "resource": "" }
q9774
PoolFilesystem.checkFileReadableJob
train
protected static function checkFileReadableJob(string $path): bool { if (!\is_file($path) || !\is_readable($path)) { return false; } return true; }
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...
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; } if ($truncate && \is_file($path)) { @\ftruncate(@\fopen($path, 'wb'), 0); ...
php
{ "resource": "" }
q9777
Thumbnail.url
train
public function url($file, array $params) { $cacheFileSrc = $this->make($file, $params); return $cacheFileSrc ? $cacheFileSrc : null; }
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('...
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) { $src .= $src . '&random=yes'; } ...
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; $height = (isset($params['height']) && is_numeric($params['height'])) ? $par...
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_dashlet...
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... // Admi...
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 && $dashbo...
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 ...
php
{ "resource": "" }
q9786
TableUtilitiesTrait.updateField
train
public function updateField($primaryKey, $field, $value = null): bool { $query = $this->query() ->update() ->set([ $field => $value, ]) ->where([ $this->primaryKey() => $primaryKey, ]); $statement = $query->...
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, ...
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'] = []; } $optParams['cloud']['id'] = $p...
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...
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'] = []; } $optParams['cloud']['id'] = $params; return $this->sendRequest([], [ ...
php
{ "resource": "" }
q9792
Views.render
train
public static function render($view, array $context = [], $type = null) { $viewBuilder = static::getViewBuilder(); $viewObject = $viewBuilder->create($view, $type); return $viewObject->render($context); }
php
{ "resource": "" }
q9793
CssProperties.flat
train
public function flat(array $properties): string { Assert::isMap($properties); return $this->arrayImploder->byGlue($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->getHeader...
php
{ "resource": "" }
q9795
Client.sendTo
train
public function sendTo($data, $topic = '/topics/global', array $options = []) { $options['to'] = $topic; return $this->send($data, [], $options); }
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, $methodName)) { $this->$methodName($value); } } }
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 ...
php
{ "resource": "" }
q9798
AbstractField.resolveProperty
train
protected function resolveProperty($name) { $value = $this->$name; if (is_callable($value)) { return call_user_func($value, $this); } return $this->resolveValue($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.'); } $value = $this->dataSet->resolvePath($value); } if (is_...
php
{ "resource": "" }