_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q9400 | AbstractColorManager.registerProvider | train | public function registerProvider(ColorProviderInterface $colorProvider) {
$key = ColorHelper::getIdentifier($colorProvider);
if (true === array_key_exists($key, $this->index)) {
throw new AlreadyRegisteredProviderException($colorProvider);
}
$this->index[$key] = $this->size... | php | {
"resource": ""
} |
q9401 | Domain.setDomainName | train | public function setDomainName($domain)
{
$domain = strtolower($domain);
if (!$this->getDomainValidator()->isValid($domain)) {
throw new InvalidArgumentException(
'Domain name is invalid: ' . $domain
);
}
$this->domain = $domain;
} | php | {
"resource": ""
} |
q9402 | Domain.setPrimaryDomain | train | public function setPrimaryDomain($primaryDomain)
{
if (empty($primaryDomain)) {
$this->primaryDomain = null;
$this->primaryId = null;
return;
}
$this->primaryDomain = $primaryDomain;
$this->primaryId = $primaryDomain->getDomainId();
} | php | {
"resource": ""
} |
q9403 | MenuController.isSortable | train | public function isSortable()
{
$this->getSearchCriteria();
$sortable = new \stdClass;
if($this->searchModel->Menu_id > 0) {
$sortable->sortable = true;
$sortable->link = Url::toRoute(['sort', 'Menu_id' => $this->searchModel->Menu_id]);
} else {
$s... | php | {
"resource": ""
} |
q9404 | MenuController.actionSort | train | public function actionSort()
{
$this->layout = static::FORM_LAYOUT;
$modelName = $this->getCompatibilityId();
if(isset($_POST[$modelName]) && count($_POST[$modelName])) {
//If we are changing the main categories then use a different algorithm
if($_GET['Menu_id']==-1)... | php | {
"resource": ""
} |
q9405 | MenuController.actionStatus | train | public function actionStatus($id)
{
$model = $this->findModel($id);
if($model->status == "active") {
$model->status = "inactive";
} else {
$model->status = "active";
}
$model->save(false);
if(Yii::$app->request->getIsAjax()) {
Yii::... | php | {
"resource": ""
} |
q9406 | MenuController.actionCreate | train | public function actionCreate()
{
$this->layout = static::FORM_LAYOUT;
$model = new $this->MainModel;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if(empty($model->Menu_id)) {
Yii::info('Making the new node as root');
$mode... | php | {
"resource": ""
} |
q9407 | ImageUploader.validateImageMimeType | train | private function validateImageMimeType()
{
$imageType = exif_imagetype($this->uploadFile->getTemporaryFilename());
$mime = image_type_to_mime_type($imageType);
if (!$imageType || !in_array($mime, parent::getAllowedMimeTypes())) {
throw new \Exception("Uploaded image appears to be... | php | {
"resource": ""
} |
q9408 | ChainManager.attach | train | public function attach(ChainEventInterface $event, $priority = 0)
{
$this->queue->insert($event, $priority);
return $this;
} | php | {
"resource": ""
} |
q9409 | Parser.parsePathParts | train | private function parsePathParts(Request $request)
{
if (empty($this->apiUrlPath)) {
throw new \Exception(self::ERROR_NO_API_BASE_PATH);
}
// Resolving not knowing whether the base contains a domain.
$base = explode('/', $this->apiUrlPath);
$path = explode('/', $r... | php | {
"resource": ""
} |
q9410 | ArrayHelper.getItems | train | public static function getItems($array, $keys = null)
{
if (is_null($keys)) {
return $array;
} elseif (is_scalar($keys)) {
$keys = [$keys => $array[$keys]];
}
$res = [];
foreach ($keys as $k) {
if (array_key_exists($k, $array)) {
... | php | {
"resource": ""
} |
q9411 | ArrayHelper.prepareWhere | train | protected static function prepareWhere(array $array, $list)
{
if (!is_array($list)) {
$list = [$list];
}
foreach ($list as $v) {
if (array_key_exists($v, $array)) {
return $v;
}
}
return null;
} | php | {
"resource": ""
} |
q9412 | ArrayHelper.unique | train | public static function unique($array)
{
$suitable = true;
foreach ($array as $k => &$v) {
if (is_array($v)) {
$v = self::unique($v);
} elseif (!is_int($k)) {
$suitable = false;
}
}
return $suitable ? self::uniqueFla... | php | {
"resource": ""
} |
q9413 | ArrayHelper.uniqueFlat | train | public static function uniqueFlat($array)
{
$uniqs = [];
$res = [];
foreach ($array as $k => $v) {
$uv = var_export($v, true);
if (array_key_exists($uv, $uniqs)) {
continue;
}
$uniqs[$uv] = 1;
$res[$k] = $v;
... | php | {
"resource": ""
} |
q9414 | Module.onBootstrap | train | public function onBootstrap(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
// Don't break console routes
if ($e->getRequest() instanceof Request) {
return;
}
//Add Domain Checker
$onDispatchListener = $serviceManager->get(
... | php | {
"resource": ""
} |
q9415 | RouteManager.group | train | public function group(array $attributes, callable $callback)
{
$this->groupAttributes = $attributes;
$callback();
$this->groupAttributes = null;
return $this;
} | php | {
"resource": ""
} |
q9416 | EmailGuard.supports | train | public function supports(Request $request)
{
$post = json_decode($request->getContent(), true);
return !empty($post[self::EMAIL_FIELD]) && !empty($post[self::PASSWORD_FIELD]);
} | php | {
"resource": ""
} |
q9417 | EmailGuard.getCredentials | train | public function getCredentials(Request $request)
{
$post = json_decode($request->getContent(), true);
return new CredentialEmailModel($post[self::EMAIL_FIELD], $post[self::PASSWORD_FIELD]);
} | php | {
"resource": ""
} |
q9418 | EmailGuard.checkCredentials | train | public function checkCredentials($credentials, UserInterface $user)
{
return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword());
} | php | {
"resource": ""
} |
q9419 | NotificationEventListener.onNotify | train | public function onNotify(NotificationEvent $event) {
if (true === ($this->getSession() instanceof Session)) {
$this->getSession()->getFlashBag()->add($event->getNotification()->getType(), $event->getNotification()->getContent());
}
return $event;
} | php | {
"resource": ""
} |
q9420 | PluginInstance.setInstanceConfig | train | public function setInstanceConfig($instanceConfig)
{
$this->instanceConfig = json_encode($instanceConfig);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception(json_last_error_msg());
}
} | php | {
"resource": ""
} |
q9421 | CacheFile.created | train | public function created(string $key)
{
$path = $this->path($key);
return $this->files->exists($path)
? \Carbon\Carbon::createFromTimestamp(
$this->files->lastModified($path)
) : null;
} | php | {
"resource": ""
} |
q9422 | CacheFile.expired | train | public function expired(string $key)
{
$path = $this->path($key);
return $this->files->exists($path)
? \Carbon\Carbon::createFromTimestamp(
substr($this->files->get($path), 0, 10)
) : null;
} | php | {
"resource": ""
} |
q9423 | ConfigureMenuListener.onMenuConfigure | train | public function onMenuConfigure(ConfigureMenuEvent $event)
{
if (!$this->permissionResolver->hasAccess('uicron', 'list')) {
return;
}
$menu = $event->getMenu();
$cronsMenu = $menu->getChild(MainMenuBuilder::ITEM_ADMIN);
$cronsMenu->addChild(self::ITEM_CRONS, ['r... | php | {
"resource": ""
} |
q9424 | AuthResponseService.createJsonAuthResponse | train | public function createJsonAuthResponse(BaseUser $user)
{
$responseModel = $this->createResponseAuthModel($user);
$response = new JsonResponse($responseModel->getBody(), Response::HTTP_CREATED);
return $this->setCookieForResponse($response, $responseModel);
} | php | {
"resource": ""
} |
q9425 | AuthResponseService.authenticateResponse | train | public function authenticateResponse(BaseUser $user, Response $response)
{
return $this->setCookieForResponse($response, $this->createResponseAuthModel($user));
} | php | {
"resource": ""
} |
q9426 | AuthResponseService.setCookieForResponse | train | protected function setCookieForResponse(Response $response, ResponseAuthenticationModel $responseModel)
{
$response->headers->setCookie(
new Cookie(
self::AUTH_COOKIE,
$responseModel->getAuthToken(),
$responseModel->getTokenExpirationTimeStamp(),
... | php | {
"resource": ""
} |
q9427 | AuthResponseService.createResponseAuthModel | train | protected function createResponseAuthModel(BaseUser $user)
{
$user = $this->userService->updateUserRefreshToken($user);
$authTokenModel = $this->authTokenService->createAuthTokenModel($user);
return new ResponseAuthenticationModel($user, $authTokenModel, $user->getAuthRefreshModel());
} | php | {
"resource": ""
} |
q9428 | ModelSoftDeleting.doDelete | train | private function doDelete()
{
if (!$this->model->trashed()) {
$this->model->delete();
event(new ModelSoftDelete($this));
return;
}
$this->model->forceDelete();
event(new ModelDelete($this));
} | php | {
"resource": ""
} |
q9429 | ModelSoftDeleting.restore | train | public function restore($modelitemId)
{
event(new BeforeRestore($this));
$this->findOnlyTrashed($modelitemId);
$this->beforeRestore();
$this->doRestore();
$this->afterRestore();
event(new AfterRestore($this));
} | php | {
"resource": ""
} |
q9430 | CachingReflector.getClass | train | public function getClass($class)
{
$cacheKey = self::CACHE_KEY_CLASSES . strtolower($class);
if (! $reflectionClass = $this->cache->fetch($cacheKey)) {
$reflectionClass = new ReflectionClass($class);
$this->cache->store($cacheKey, $reflectionClass);
}
return... | php | {
"resource": ""
} |
q9431 | CachingReflector.getConstructorParams | train | public function getConstructorParams($class)
{
$cacheKey = self::CACHE_KEY_CTOR_PARAMS . strtolower($class);
$reflectedConstructorParams = $this->cache->fetch($cacheKey);
if (false !== $reflectedConstructorParams) {
return $reflectedConstructorParams;
} elseif ($reflect... | php | {
"resource": ""
} |
q9432 | CachingReflector.getFunction | train | public function getFunction($functionName)
{
$lowFunc = strtolower($functionName);
$cacheKey = self::CACHE_KEY_FUNCS . $lowFunc;
$reflectedFunc = $this->cache->fetch($cacheKey);
if (false === $reflectedFunc) {
$reflectedFunc = new ReflectionFunction($functionName);
... | php | {
"resource": ""
} |
q9433 | CachingReflector.getMethod | train | public function getMethod($classNameOrInstance, $methodName)
{
$className = is_string($classNameOrInstance)
? $classNameOrInstance
: get_class($classNameOrInstance);
$cacheKey = self::CACHE_KEY_METHODS . strtolower($className) . '.' . strtolower($methodName);
if (! ... | php | {
"resource": ""
} |
q9434 | ImplementServices.getServiceConfig | train | private function getServiceConfig(string $name)
{
$config = $this->services()[$name] ?? null;
if ($config === null) {
return null;
}
if (\is_string($config)) {
return [
'class' => $config,
];
}
if (\is_array($config... | php | {
"resource": ""
} |
q9435 | ApiAdminManageSitesController.create | train | public function create($data)
{
/* ACCESS CHECK */
if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
return $this->getResponse();
}
/* */
$inputFilter = new SiteInputFilter... | php | {
"resource": ""
} |
q9436 | PhantomJSHelper.getCommand | train | public function getCommand() {
// Initialize the command.
$command = $this->getBinaryPath();
$command .= true === OSHelper::isWindows() ? ".exe" : "";
// Return the command.
return realpath($command);
} | php | {
"resource": ""
} |
q9437 | ContentProvider.getContent | train | public function getContent(string $namespace, string $locale, string $name): string
{
$nKey = self::getNKey($namespace, $locale);
// L1 read
$content = $this->loadedData[$nKey][$name] ?? false;
if (is_string($content)) {
// L1 hit
return $content;
}
... | php | {
"resource": ""
} |
q9438 | ControllerReflector.getReflectionMethod | train | public function getReflectionMethod(string $controller)
{
$callable = $this->getClassAndMethod($controller);
if (null === $callable) {
return null;
}
list($class, $method) = $callable;
try {
return new \ReflectionMethod($class, $method);
} ca... | php | {
"resource": ""
} |
q9439 | AbstractDependencyHandler.maybe_enqueue | train | public function maybe_enqueue( $handle ) {
if ( $this->is_registered( $handle ) ) {
$enqueue = $this->get_enqueue_function();
$enqueue( $handle );
return true;
}
return false;
} | php | {
"resource": ""
} |
q9440 | ClassFactory.createWithConstructorParams | train | public function createWithConstructorParams(array $params, $config = []) {
$definition = $this->prepareObjectDefinitionFromConfig($config);
return $this->getContainer()->create($definition, $params);
} | php | {
"resource": ""
} |
q9441 | LayoutManager.getThemesConfig | train | public function getThemesConfig()
{
if (empty($this->config['Rcm'])
|| empty($this->config['Rcm']['themes'])
) {
throw new RuntimeException(
'No Themes found defined in configuration. Please report the issue
with the themes author.'
... | php | {
"resource": ""
} |
q9442 | LayoutManager.getThemeConfig | train | public function getThemeConfig($theme)
{
$themesConfig = $this->getThemesConfig();
if (!empty($themesConfig[$theme])) {
return $themesConfig[$theme];
} elseif (!empty($themesConfig['generic'])) {
return $themesConfig['generic'];
}
throw new RuntimeEx... | php | {
"resource": ""
} |
q9443 | LayoutManager.getSiteLayout | train | public function getSiteLayout(Site $site, $layout = null)
{
$themeLayoutConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (empty($layout)) {
$layout = $site->getSiteLayout();
}
if (!empty($themeLayoutConfig[$layout])
&& !empty($themeLayoutConf... | php | {
"resource": ""
} |
q9444 | LayoutManager.getSitePageTemplateConfig | train | public function getSitePageTemplateConfig(Site $site, $template = null)
{
$themePageConfig = $this->getSiteThemePagesTemplateConfig($site);
if (!empty($themePageConfig[$template])) {
return $themePageConfig[$template];
} elseif (!empty($themePageConfig['default'])) {
... | php | {
"resource": ""
} |
q9445 | LayoutManager.getSitePageTemplate | train | public function getSitePageTemplate(Site $site, $template = null)
{
$themePageConfig = $this->getSitePageTemplateConfig($site, $template);
if (empty($themePageConfig['file'])) {
throw new RuntimeException('No Page Template Found in config');
}
return $themePageConfig['f... | php | {
"resource": ""
} |
q9446 | LayoutManager.isLayoutValid | train | public function isLayoutValid(Site $site, $layoutKey)
{
$themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (!empty($themesConfig[$layoutKey])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q9447 | ResourceEntityCollection.canAdd | train | public function canAdd(ResourceEntityInterface $entity)
{
return empty($this->className)
|| get_class($entity) == $this->className;
} | php | {
"resource": ""
} |
q9448 | RendererTwigExtension.coreScriptFilter | train | public function coreScriptFilter($content) {
$attributes = [];
$attributes["type"] = "text/javascript";
$innerHTML = null !== $content ? implode("", ["\n", $content, "\n"]) : "";
return static::coreHTMLElement("script", $innerHTML, $attributes);
} | php | {
"resource": ""
} |
q9449 | FileUploader.setDestinationDirectory | train | final public function setDestinationDirectory(string $destinationDirectory)
{
if ($destinationDirectory[strlen($destinationDirectory) - 1] != DIRECTORY_SEPARATOR) {
$destinationDirectory .= DIRECTORY_SEPARATOR;
}
$this->destinationDirectory = $destinationDirectory;
} | php | {
"resource": ""
} |
q9450 | FileUploader.setDestinationFilename | train | final public function setDestinationFilename(string $filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (empty($extension) && !empty($this->uploadFile->getExtension())) {
$filename .= '.' . $this->uploadFile->getExtension();
}
$this->destinationFilename ... | php | {
"resource": ""
} |
q9451 | BinaryBuffer.receiveHeader | train | protected function receiveHeader()
{
if(strlen($this->bufferData) > 8)
{
$header = substr($this->bufferData,0,8);
$this->waitingFor = intval($header);
$this->bufferData = substr($this->bufferData,8);
$this->headerReceived = true;
re... | php | {
"resource": ""
} |
q9452 | BinaryBuffer.receiveBody | train | protected function receiveBody()
{
if(strlen($this->bufferData) >= $this->waitingFor)
{
$this->messages[] = substr($this->bufferData,0,$this->waitingFor);
$this->bufferData = substr($this->bufferData,$this->waitingFor);
$this->headerReceived = false;
... | php | {
"resource": ""
} |
q9453 | BinaryBuffer.encodeMessage | train | public static function encodeMessage($message)
{
$waitingData = strlen($message);
$header = str_pad((string)$waitingData,8,'0',STR_PAD_LEFT);
return $header.$message;
} | php | {
"resource": ""
} |
q9454 | FOSUserBreadcrumbNodes.getFontAwesomeBreadcrumbNodes | train | public static function getFontAwesomeBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "fa:user", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "fa:u... | php | {
"resource": ""
} |
q9455 | FOSUserBreadcrumbNodes.getMaterialDesignIconicFontBreadcrumbNodes | train | public static function getMaterialDesignIconicFontBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "zmdi:account", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.sh... | php | {
"resource": ""
} |
q9456 | PageInfo.scriptVariables | train | public function scriptVariables()
{
$data = json_encode([
'locale' => $this->get('locale'),
'app_name' => $this->get('app_name'),
'app_skin' => $this->get('app_skin'),
'app_theme' => $this->get('app_theme'),
'app_url' => $this->get('app_url'),
... | php | {
"resource": ""
} |
q9457 | AbstractTwigExtension.coreHTMLElement | train | public static function coreHTMLElement($element, $content, array $attrs = []) {
$template = "<%element%%attributes%>%innerHTML%</%element%>";
$attributes = trim(StringHelper::parseArray($attrs));
if (0 < strlen($attributes)) {
$attributes = " " . $attributes;
}
$in... | php | {
"resource": ""
} |
q9458 | TimerHelper.start | train | public static function start($alias)
{
if (isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has already been started.');
}
self::$timers[$alias] = microtime();
} | php | {
"resource": ""
} |
q9459 | TimerHelper.getDifference | train | public static function getDifference($alias)
{
if (!isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has not been started');
}
return microtime() - self::$timers[$alias];
} | php | {
"resource": ""
} |
q9460 | FileObserver.originalPath | train | protected function originalPath(File $file, string $thumbSize = null)
{
return $file->getOriginal('type')
.DS.$file->getOriginal('category')
.($thumbSize ? DS.$thumbSize : '')
.DS.$file->getOriginal('name').'.'.$file->getOriginal('extension');
} | php | {
"resource": ""
} |
q9461 | DateTimeRenderer.renderAge | train | public static function renderAge(DateTime $birthDate, DateTime $refDate = null) {
// Use the current date/time.
if (null === $refDate) {
$refDate = new DateTime();
}
$diff = $refDate->getTimestamp() - $birthDate->getTimestamp();
$years = new DateTime("@" . $diff);
... | php | {
"resource": ""
} |
q9462 | CacheForgetByKeys.cacheForgetByKeys | train | protected function cacheForgetByKeys($entity = null)
{
$keys = $this->keysToForgetCache;
if (is_array($keys) and array_diff_key($keys, array_keys(array_keys($keys)))) {
foreach ($keys as $key => $method) {
cache()->forget($key);
if (is_subclass_of($entity... | php | {
"resource": ""
} |
q9463 | Site.setDomain | train | public function setDomain(Domain $domain)
{
$this->domain = $domain;
$this->domainId = $domain->getDomainId();
} | php | {
"resource": ""
} |
q9464 | Site.setLanguage | train | public function setLanguage(Language $language)
{
$this->language = $language;
$this->languageId = $language->getLanguageId();
} | php | {
"resource": ""
} |
q9465 | Site.getContainer | train | public function getContainer($name)
{
$container = $this->containers->get($name);
if (empty($container)) {
return null;
}
return $container;
} | php | {
"resource": ""
} |
q9466 | PhpDocFullyQualifiedParamHintFixer.getMatches | train | private function getMatches($line, $matchCommentOnly = false)
{
if (preg_match($this->regex, $line, $matches)) {
if (!empty($matches['tag2'])) {
$matches['tag'] = $matches['tag2'];
$matches['hint'] = $matches['hint2'];
}
return $matches;
... | php | {
"resource": ""
} |
q9467 | Page.getPageByName | train | public function getPageByName(
SiteEntity $site,
$pageName,
$pageType = PageTypes::NORMAL
) {
$results = $this->getPagesByName(
$site,
$pageName,
$pageType
);
if (empty($results)) {
return null;
}
retur... | php | {
"resource": ""
} |
q9468 | Page.getPublishedRevisionId | train | public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('publishedRevision.revisionId')
->from(\Rcm\Entity\Page::class, 'page')... | php | {
"resource": ""
} |
q9469 | Page.getAllPageIdsAndNamesBySiteThenType | train | public function getAllPageIdsAndNamesBySiteThenType($siteId, $type)
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('page.name, page.pageId')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.site', 'site')
->where('page.pageType = :p... | php | {
"resource": ""
} |
q9470 | Page.setPageDeleted | train | public function setPageDeleted(
PageEntity $page,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
$pageType = $page->getPageType();
if (strpos($pageType, self::PAGE_TYPE_DELETED) !== false) {
return;//This page is already deleted s... | php | {
"resource": ""
} |
q9471 | Page.copyPage | train | public function copyPage(
SiteEntity $destinationSite,
PageEntity $pageToCopy,
$pageData,
$pageRevisionId = null,
$publishNewPage = false,
$doFlush = true
) {
if (empty($pageData['name'])) {
throw new InvalidArgumentException(
'Mis... | php | {
"resource": ""
} |
q9472 | Page.publishPageRevision | train | public function publishPageRevision(
$siteId,
$pageName,
$pageType,
$revisionId,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
//Query is needed to ensure revision belongs to the page in question
$pageQueryBuilder = $t... | php | {
"resource": ""
} |
q9473 | Page.getSitePage | train | public function getSitePage(
SiteEntity $site,
$pageId
) {
try {
/** @var \Rcm\Entity\Page $page */
$page = $this->findOneBy(
[
'site' => $site,
'pageId' => $pageId
]
);
} catc... | php | {
"resource": ""
} |
q9474 | Page.sitePageExists | train | public function sitePageExists(
SiteEntity $site,
$pageName,
$pageType
) {
try {
$page = $this->getPageByName(
$site,
$pageName,
$pageType
);
} catch (\Exception $e) {
$page = null;
}
... | php | {
"resource": ""
} |
q9475 | MainLayout.isValid | train | public function isValid($value)
{
$this->setValue($value);
if (!$this->layoutManager->isLayoutValid($this->currentSite, $value)) {
$this->error(self::MAIN_LAYOUT);
return false;
}
return true;
} | php | {
"resource": ""
} |
q9476 | PluginManager.getPluginViewData | train | public function getPluginViewData(
$pluginName,
$pluginInstanceId,
$forcedAlternativeInstanceConfig = null
) {
$request = ServerRequestFactory::fromGlobals();
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if ($pluginInstanceId < 0) {
... | php | {
"resource": ""
} |
q9477 | PluginManager.getDefaultInstanceConfig | train | public function getDefaultInstanceConfig($pluginName)
{
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if (empty($blockConfig)) {
throw new \Exception('Block config not found for ' . $pluginName); //@TODO throw custom exception class
}
return $block... | php | {
"resource": ""
} |
q9478 | PluginManager.listAvailablePluginsByType | train | public function listAvailablePluginsByType()
{
$list = [];
foreach ($this->config['rcmPlugin'] as $name => $data) {
$displayName = $name;
$type = 'Misc';
$icon = $this->config['Rcm']['defaultPluginIcon'];
if (isset($data['type'])) {
$ty... | php | {
"resource": ""
} |
q9479 | GoogleProvider.loadUserByUsername | train | public function loadUserByUsername($username)
{
try {
$payload = $this->googleClient->verifyIdToken($username);
$email = $payload['email'];
$googleUserId = $payload['sub'];
$user = $this->userService->findByGoogleUserId($googleUserId);
if (!empty... | php | {
"resource": ""
} |
q9480 | GoogleProvider.updateUserWithGoogleUserId | train | protected function updateUserWithGoogleUserId(BaseUser $user, $googleUserId)
{
$user->setGoogleUserId($googleUserId);
$this->userService->save($user);
} | php | {
"resource": ""
} |
q9481 | Journey.setUrl | train | public function setUrl($url): self
{
if (\is_string($url)) {
$this->options['url'] = $url;
return $this;
}
if ($url instanceof Leg) {
$this->setUrlFromLeg($url);
return $this;
}
if ($url instanceof BoardData) {
$... | php | {
"resource": ""
} |
q9482 | CommentsController.massUpdate | train | public function massUpdate(CommentsRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$comments = $this->model->whereIn('id', $request->comments);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $comments->update(... | php | {
"resource": ""
} |
q9483 | TimeMachine.find | train | public function find(string $id, array $headers = [])
{
$url = $this->url('time_machines/%s', $id);
return $this->get($url, [], $headers);
} | php | {
"resource": ""
} |
q9484 | TimeMachine.startAfresh | train | public function startAfresh(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/start_afresh', $id);
return $this->post($url, $data, $headers);
} | php | {
"resource": ""
} |
q9485 | TimeMachine.travelForward | train | public function travelForward(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/travel_forward', $id);
return $this->post($url, $data, $headers);
} | php | {
"resource": ""
} |
q9486 | ContentSecurityPolicy.send | train | public function send()
{
$header = $this->buildCompleteHeader();
$reportOnly = ($this->reportOnly) ? "-Report-Only" : "";
header("Content-Security-Policy$reportOnly: " . $header);
if ($this->compatible) {
header("X-Content-Security-Policy$reportOnly: " . $header);
... | php | {
"resource": ""
} |
q9487 | ContentSecurityPolicy.buildCompleteHeader | train | private function buildCompleteHeader(): string
{
$header = "";
foreach ($this->headers as $sourceType => $value) {
$header .= $this->buildHeaderLine($sourceType, $value);
}
if (!empty($this->reportUri)) {
$header .= 'report-uri ' . $this->reportUri . ';';
... | php | {
"resource": ""
} |
q9488 | ContentSecurityPolicy.buildHeaderLine | train | private function buildHeaderLine(string $name, array $sources): string
{
$header = '';
if (!empty($sources)) {
$value = "";
foreach ($sources as $source) {
if (!empty($value)) {
$value .= ' ';
}
$value .= $so... | php | {
"resource": ""
} |
q9489 | ApiAdminSitesCloneController.create | train | public function create($data)
{
/* ACCESS CHECK */
if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
return $this->getResponse();
}
/* */
$inputFilter = new SiteDuplicateInp... | php | {
"resource": ""
} |
q9490 | Route.compileRegex | train | protected function compileRegex($rule)
{
$regex = '^' . preg_replace_callback(
'@\{[\w]+\??\}@',
function ($matches) {
$optional = false;
$key = str_replace(['{', '}'], '', $matches[0]);
if (substr($key, -1) == '?') {
... | php | {
"resource": ""
} |
q9491 | Route.process | train | public function process(Request $request)
{
$results = [];
// Test hostname rule.
if (isset($this->options['hostname'])) {
$regex = $this->compileRegex($this->options['hostname']);
$tokens = $this->compileTokens($this->options['hostname']);
... | php | {
"resource": ""
} |
q9492 | SecuritySession.start | train | public function start(): bool
{
if (!is_null($this->expiration)) {
$this->expiration->start();
}
if (!is_null($this->fingerprint)) {
$this->fingerprint->start();
}
if (!isset($_SESSION['__HANDLER_INITIATED'])) {
return $this->initialSession... | php | {
"resource": ""
} |
q9493 | SecuritySession.laterSessionStart | train | private function laterSessionStart()
{
if (!is_null($this->fingerprint) && !$this->fingerprint->hasValidFingerprint()) {
throw new \Exception("Session fingerprint doesn't match"); // @codeCoverageIgnore
}
if (!is_null($this->expiration) && $this->expiration->isObsolete()) {
... | php | {
"resource": ""
} |
q9494 | StringHelper.hideEmail | train | public static function hideEmail($email) {
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
... | php | {
"resource": ""
} |
q9495 | StringHelper.summary | train | public static function summary($str, $limit=100, $strip = false) {
$str = ($strip == true) ? strip_tags($str) : $str;
return static::truncate($str, $limit - 3, '...');
} | php | {
"resource": ""
} |
q9496 | ModelQuerying.find | train | public function find($modelitemId)
{
$this->model = $this->model->findOrFail($modelitemId);
return $this->model;
} | php | {
"resource": ""
} |
q9497 | ModelQuerying.query | train | private function query($count)
{
$this->applyQueryFilters();
if ($this->hasTranslating()) {
$this->applyTranslationFilter();
}
if ($this->orderBy()) {
$this->query = $this->query->orderBy(
$this->orderBy(),
... | php | {
"resource": ""
} |
q9498 | ModelQuerying.totals | train | public function totals()
{
if ($this->hasSoftDeleting()) {
return [
'all' => $this->items($count = true),
'with_trashed' => $this->allItems($count = true),
'only_trashed' => $this->onlyTrashedItems($count = true),
... | php | {
"resource": ""
} |
q9499 | ModelQuerying.orderBy | train | public function orderBy()
{
if (Request::input('order')) {
return Request::input('order');
}
if ($this->orderBy) {
return $this->orderBy;
}
return $this->model->getKeyName();
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.