_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q9500
ModelQuerying.applyQueryFilters
train
private function applyQueryFilters() { if (is_array($this->queryFilter())) {
php
{ "resource": "" }
q9501
ModelQuerying.queryFilterRequest
train
private function queryFilterRequest() { if (!$safeFilter = Request::get('filter')) { return false; } if (!isset($this->safeFilters()[$safeFilter])) { return false;
php
{ "resource": "" }
q9502
ModelQuerying.createQueryFilter
train
private function createQueryFilter() { if (count($this->queryFilter()) > 0) { foreach ($this->queryFilter() as $filter => $parameters) { if (!is_array($parameters)) {
php
{ "resource": "" }
q9503
ModelQuerying.safeFilters
train
public function safeFilters() { $filters = []; foreach ($this->filters() as
php
{ "resource": "" }
q9504
SessionManagerFactory.getSessionConfig
train
protected function getSessionConfig( ServiceLocatorInterface $serviceLocator, $sessionConfig ) { if (empty($sessionConfig) || empty($sessionConfig['config']) ) { return new SessionConfig(); } $class = '\Zend\Session\Config\SessionConfig'; $options = []; if (isset($sessionConfig['config']['class']) ) { $class = $sessionConfig['config']['class']; } if (isset($sessionConfig['config']['options']) ) { $options = $sessionConfig['config']['options']; } /** @var \Zend\Session\Config\ConfigInterface $sessionConfigObject */ if ($serviceLocator->has($class)) { $sessionConfigObject =
php
{ "resource": "" }
q9505
SessionManagerFactory.getSessionSaveHandler
train
protected function getSessionSaveHandler( ServiceLocatorInterface $serviceLocator, $sessionConfig ) { if (!isset($sessionConfig['save_handler'])) { return null; } // Setting with invokable currently not implemented. No session // Save handler available in ZF2 that's currently invokable is available // for testing. /** @var SaveHandlerInterface $sessionSaveHandler */
php
{ "resource": "" }
q9506
SessionManagerFactory.setValidatorChain
train
protected function setValidatorChain( SessionManager $sessionManager, ServiceLocatorInterface $serviceLocator, $sessionConfig ) { if (!isset($sessionConfig['validators']) || !is_array($sessionConfig['validators']) ) { return; } $chain = $sessionManager->getValidatorChain(); foreach ($sessionConfig['validators'] as &$validator) { if ($serviceLocator->has($validator)) { $validator = $serviceLocator->get($validator); } else { $validator = new $validator();
php
{ "resource": "" }
q9507
EntityAwareParamConverterTrait.callRepositoryMethod
train
protected function callRepositoryMethod(string $method, ...$args) { $om = $this->getManager(); $repo = $om->getRepository($this->getEntity()); if (!method_exists($repo, $method) || !is_callable([$repo, $method])) { throw new \InvalidArgumentException( sprintf(
php
{ "resource": "" }
q9508
AccessTokenGuard.supports
train
public function supports(Request $request) { $post = json_decode($request->getContent(),
php
{ "resource": "" }
q9509
AccessTokenGuard.getCredentials
train
public function getCredentials(Request $request) { $post = json_decode($request->getContent(), true);
php
{ "resource": "" }
q9510
RouterEngine.run
train
final public function run(Request $request) { $this->request = $request; $path = $this->request->getUri()->getPath(); $this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/"; $this->requestedMethod = strtoupper($this->request->getMethod());
php
{ "resource": "" }
q9511
RouterEngine.addRoute
train
final protected function addRoute($method, $uri, $callback, $acceptedFormats) { $this->routes[$method][] = [
php
{ "resource": "" }
q9512
RouterEngine.createResponse
train
private function createResponse($route): ?Response { $controller = $this->getRouteControllerInstance($route); if (!is_null($controller)) { $responseBefore = $controller->before(); if ($responseBefore instanceof Response) { return $responseBefore; } } $values = $route['route']->getArguments($this->requestedUri); $this->loadRequestParameters($values); $callback = new Callback($route['callback']); $arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
php
{ "resource": "" }
q9513
RouterEngine.loadRequestParameters
train
private function loadRequestParameters($values) { foreach ($values as
php
{ "resource": "" }
q9514
RouteListener.checkDomain
train
public function checkDomain(MvcEvent $event) { if ($this->isConsoleRequest()) { return null; } $currentDomain = $this->siteService->getCurrentDomain(); $site = $this->siteService->getCurrentSite($currentDomain); $redirectUrl = $this->domainRedirectService->getSiteNotAvailableRedirectUrl($site); if (!$site->isSiteAvailable() && empty($redirectUrl)) { $response = new Response(); $response->setStatusCode(404);
php
{ "resource": "" }
q9515
RouteListener.checkRedirect
train
public function checkRedirect(MvcEvent $event) { if ($this->isConsoleRequest()) { return null; } // User defaults $redirectUrl = $this->redirectService->getRedirectUrl(); if (empty($redirectUrl)) { return null; } $queryParams = $event->getRequest()->getQuery()->toArray(); header( 'Location: ' . $redirectUrl . (count($queryParams) ? '?' . http_build_query($queryParams) : null), true, 302 ); exit;
php
{ "resource": "" }
q9516
RouteListener.addLocale
train
public function addLocale(MvcEvent $event) { $locale = $this->siteService->getCurrentSite()->getLocale();
php
{ "resource": "" }
q9517
SavantPHP.getConfigList
train
public function getConfigList($key = null) { if (is_null($key)) { return $this->configList; // no key requested, return the entire configuration
php
{ "resource": "" }
q9518
SavantPHP.setPath
train
public function setPath($path) { // clear out the prior search dirs $this->configList[self::TPL_PATH_LIST] = []; // always add the fallback directories as last
php
{ "resource": "" }
q9519
SavantPHP.fetch
train
public function fetch($tpl = null) { // make sure we have a template source to work with if (is_null($tpl)) { $tpl = $this->configList[self::TPL_FILE]; } $result = $this->getPathToTemplate($tpl); if (! $result || $this->isError($result)) { //if no path return $result; } else { $this->configList[self::FETCHED_TPL_FILE] = $result; unset($result); unset($tpl);
php
{ "resource": "" }
q9520
SavantPHP.error
train
public function error($code, $info = [], $level = E_USER_ERROR, $trace = true) { if ($this->configList[self::EXCEPTIONS]) { throw new SavantPHPexception($code);
php
{ "resource": "" }
q9521
SavantPHP.isError
train
public function isError($obj) { // is it even an object? if (! is_object($obj)) { // if not an object, can't even be a SavantPHPerror object return false; } else {
php
{ "resource": "" }
q9522
ResourceCollection.buildFromArray
train
public static function buildFromArray(array $resources) { $resource = @$resources[0]; if (!$resource instanceof
php
{ "resource": "" }
q9523
Commentable.getComments
train
public function getComments(bool $nested = false) { $comments = $this->comments()->get(); // If at least one comment is left by a registered user if ($comments->firstWhere('user_id', '>', 'null')) {
php
{ "resource": "" }
q9524
ResponseHandler.processResponse
train
public function processResponse(ResponseInterface $response) { if (!$response instanceof Response || !$this->getRequest() ) { return; }
php
{ "resource": "" }
q9525
ResponseHandler.handleResponse
train
protected function handleResponse(Response $response) { $statusCode = $response->getStatusCode(); switch ($statusCode) { case 401:
php
{ "resource": "" }
q9526
ResponseHandler.processNotAuthorized
train
protected function processNotAuthorized() { $loginPage = $this->currentSite->getLoginPage(); $notAuthorized = $this->currentSite->getNotAuthorizedPage(); $returnToUrl = urlencode($this->request->getServer('REQUEST_URI')); $newResponse = new Response(); $newResponse->setStatusCode('302');
php
{ "resource": "" }
q9527
ResponseHandler.renderResponse
train
protected function renderResponse(Response $response) { $sendEvent = new SendResponseEvent();
php
{ "resource": "" }
q9528
AbstractFontAwesomeTwigExtension.fontAwesomeIcon
train
protected function fontAwesomeIcon(FontAwesomeIconInterface $icon) { $attributes = []; $attributes["class"][] = FontAwesomeIconRenderer::renderFont($icon); $attributes["class"][] = FontAwesomeIconRenderer::renderName($icon); $attributes["class"][] = FontAwesomeIconRenderer::renderSize($icon);
php
{ "resource": "" }
q9529
AbstractFontAwesomeTwigExtension.fontAwesomeList
train
protected function fontAwesomeList($items) { $innerHTML = true === is_array($items) ?
php
{ "resource": "" }
q9530
AbstractFontAwesomeTwigExtension.fontAwesomeListIcon
train
protected function fontAwesomeListIcon($icon, $content) { $glyphicon = static::coreHTMLElement("span", $icon, ["class" => "fa-li"]); $innerHTML = null !== $content ?
php
{ "resource": "" }
q9531
UnzipAssetsCommand.displayFooter
train
protected function displayFooter(StyleInterface $io, $exitCode, $count) { if (0 < $exitCode) { $io->error("Some errors occurred while unzipping assets"); return; } if (0 === $count) {
php
{ "resource": "" }
q9532
UnzipAssetsCommand.displayResult
train
protected function displayResult(StyleInterface $io, array $results) { $exitCode = 0; $rows = []; $success = $this->getCheckbox(true); $warning = $this->getCheckbox(false); // Handle each result. foreach ($results as $bundle => $assets) { foreach ($assets as $asset => $result) { $rows[] = [ true === $result ? $success : $warning,
php
{ "resource": "" }
q9533
AbstractStateLessGuard.supports
train
public function supports(Request $request) { return !empty($request->headers->get(self::AUTHORIZATION_HEADER))
php
{ "resource": "" }
q9534
AbstractStateLessGuard.getCredentials
train
public function getCredentials(Request $request) { $token = !empty($request->headers->get(self::AUTHORIZATION_HEADER)) ?
php
{ "resource": "" }
q9535
AdminPanelController.getAdminWrapperAction
train
public function getAdminWrapperAction() { $allowed = $this->cmsPermissionChecks->siteAdminCheck($this->currentSite); if (!$allowed) { return null; } /** @var RouteMatch $routeMatch */ $routeMatch = $this->getEvent()->getRouteMatch(); $siteId = $this->currentSite->getSiteId(); $sourcePageName = $routeMatch->getParam('page', 'index'); if ($sourcePageName instanceof Page) { $sourcePageName = $sourcePageName->getName(); } $pageType = $routeMatch->getParam('pageType', 'n'); $view = new ViewModel();
php
{ "resource": "" }
q9536
Page.setName
train
public function setName($name) { $name = strtolower($name); //Check for everything except letters and dashes. Throw exception if any are found. if (preg_match("/[^a-z\-0-9\.]/", $name)) { throw new InvalidArgumentException( 'Page names can
php
{ "resource": "" }
q9537
Page.setParent
train
public function setParent(Page $parent) { $this->parent = $parent;
php
{ "resource": "" }
q9538
Rule.isValid
train
public function isValid($value, array $fields = []): bool { $callback = new Callback($this->validation); $arguments
php
{ "resource": "" }
q9539
AbstractServiceCall.getRequest
train
public function getRequest(): RequestInterface { if (!$this->request) { $this->resolveOptions();
php
{ "resource": "" }
q9540
AbstractServiceCall.doCall
train
protected function doCall() { $this->resolveOptions(); $this->request = $this->createRequest(); $this->response
php
{ "resource": "" }
q9541
AbstractServiceCall.resolveOptions
train
protected function resolveOptions(): void { $resolver = new OptionsResolver();
php
{ "resource": "" }
q9542
AbstractServiceCall.validateJson
train
protected function validateJson(ResponseInterface $response): array { try {
php
{ "resource": "" }
q9543
AbstractThemeManager.addGlobal
train
public function addGlobal() { foreach ($this->getIndex() as $k => $v) { if (null === $v) { continue; }
php
{ "resource": "" }
q9544
AbstractThemeManager.setProvider
train
protected function setProvider($name, ThemeProviderInterface $provider) { $k = ObjectHelper::getShortName($name); $v = $this->getIndex()[$k]; if (null !== $v) { $this->getProviders()[$v] = $provider;
php
{ "resource": "" }
q9545
UploadFile.getRealMimeType
train
private function getRealMimeType() { $info = finfo_open(FILEINFO_MIME_TYPE); $mime
php
{ "resource": "" }
q9546
Trip.setWalkingDistance
train
public function setWalkingDistance(int $originDistance = 2000, int $destinationDistance = 2000): self {
php
{ "resource": "" }
q9547
Trip.getUrl
train
protected function getUrl(array $options): string { $urlOptions = []; $this->setOriginAndDestinationOption($urlOptions, $options); $this->setViaOption($urlOptions, $options); $this->setDateOption($urlOptions, $options);
php
{ "resource": "" }
q9548
Callback.executeMethod
train
private function executeMethod(array $arguments) { if ($this->reflection->isStatic()) { return $this->reflection->invokeArgs(null, $arguments); } elseif (is_object($this->callback[0])) {
php
{ "resource": "" }
q9549
AdminManager.getAdminClasses
train
public function getAdminClasses() { $classCollection = []; if (!defined('static::ADMIN_KEY')) {
php
{ "resource": "" }
q9550
AdminManager.registerSubRoutes
train
public function registerSubRoutes(array $classes) { foreach ($classes as $key => $class) { if (is_array($class)) { if ($this->usableClass($key)) { $this->registerAdminRoutes($key);
php
{ "resource": "" }
q9551
Cryptography.randomHex
train
public static function randomHex(int $length = 128): string {
php
{ "resource": "" }
q9552
Cryptography.randomInt
train
public static function randomInt(int $min, int $max): int { if ($max <= $min) { throw new \Exception('Minimum equal or greater than maximum!'); } if ($max < 0 || $min < 0) { throw new \Exception('Only positive integers supported for
php
{ "resource": "" }
q9553
Cryptography.encrypt
train
public static function encrypt(string $data, string $key): string { $method = Configuration::getSecurityConfiguration('encryption_algorithm'); $initializationVector = self::randomBytes(openssl_cipher_iv_length($method));
php
{ "resource": "" }
q9554
JWSTokenService.createAuthTokenModel
train
public function createAuthTokenModel(BaseUser $user) { $privateKey = openssl_pkey_get_private( file_get_contents($this->projectDir . '/var/jwt/private.pem'), $this->passPhrase ); $jws = new SimpleJWS([ 'alg' => self::ALG ]); $expirationDate = new \DateTime(); $expirationDate->modify('+' . $this->authTokenTTL . ' seconds'); $expirationTimestamp = $expirationDate->getTimestamp(); $jws->setPayload(array_merge([
php
{ "resource": "" }
q9555
JWSTokenService.isValid
train
public function isValid($token) { try { $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem'));
php
{ "resource": "" }
q9556
JWSTokenService.getUser
train
public function getUser($token) { $payload = $this->getPayload($token); if (empty($payload[JWSTokenService::USER_ID_KEY])) { throw new ProgrammerException("No user_id in token payload", ProgrammerException::AUTH_TOKEN_NO_USER_ID); } $userId = $payload[JWSTokenService::USER_ID_KEY]; $user = $this->userService->findUserById($userId);
php
{ "resource": "" }
q9557
JWSTokenService.getPayload
train
public function getPayload($token) { try { $jws = SimpleJWS::load($token); return $jws->getPayload(); } catch (\InvalidArgumentException $ex) {
php
{ "resource": "" }
q9558
JWSTokenService.isTokenNotExpired
train
private function isTokenNotExpired($token) { $payload = $this->getPayload($token);
php
{ "resource": "" }
q9559
PriorityQueue.insert
train
public function insert($data, $priority = 0) { $this->data[] = [ 'data' => $data, 'priority' => $priority, ];
php
{ "resource": "" }
q9560
Migration.getController
train
public function getController() { if(!empty($this->controller)) { return $this->controller; } else {
php
{ "resource": "" }
q9561
Migration.createAuthItems
train
public function createAuthItems() { foreach($this->privileges as $privilege) { $this->insert('AuthItem', [ "name" => $privilege.'::'.$this->getController(), "type" => 0, "description" => $privilege.' '.$this->getController(), "bizrule" => null, "data" =>
php
{ "resource": "" }
q9562
Migration.deleteAuthItems
train
public function deleteAuthItems() { foreach($this->privileges as $privilege) { $this->delete(
php
{ "resource": "" }
q9563
Migration.createAdminMenu
train
public function createAdminMenu() { $connection = \Yii::$app->db; $query = new Query; if(!$this->singleMenu) { $menu_name = $this->friendly($this->getController()); $menu = $query->from('AdminMenu') ->where('internal=:internal', [':internal'=>$this->menu]) ->one(); if(!$menu) { $query = new Query; // compose the query $last_main_menu = $query->from('AdminMenu') ->where('AdminMenu_id IS NULL') ->orderby('order DESC') ->one(); $this->insert('AdminMenu', [ "name" => $this->menu, "internal" => $this->menu,
php
{ "resource": "" }
q9564
ModelCreating.create
train
public function create() { event(new BeforeCreate($this)); $this->beforeCreate(); $this->doCreate();
php
{ "resource": "" }
q9565
Module.onBootstrap
train
public function onBootstrap(MvcEvent $event) { $serviceManager = $event->getApplication()->getServiceManager(); $request = $serviceManager->get('request'); if ($request instanceof ConsoleRequest) { return; } //Add Domain Checker $eventWrapper = $serviceManager->get( \Rcm\EventListener\EventWrapper::class ); /** @var \Zend\EventManager\EventManager $eventManager */ $eventManager = $event->getApplication()->getEventManager(); // Check for redirects from the CMS $eventManager->attach( MvcEvent::EVENT_ROUTE, [$eventWrapper, 'routeEvent'], 10000 ); // Set the sites layout. $eventManager->attach( MvcEvent::EVENT_DISPATCH, [$eventWrapper, 'dispatchEvent'], 10000 ); // Set the custom http response checker $eventManager->attach( MvcEvent::EVENT_FINISH,
php
{ "resource": "" }
q9566
Controller.getCompatibilityId
train
public function getCompatibilityId() { $controller = $this->getUniqueId(); if (strpos($controller, "/")) { $controller = substr($controller, strpos($controller, "/")
php
{ "resource": "" }
q9567
Controller.actionIndex
train
public function actionIndex() { $this->getSearchCriteria(); $this->layout = static::TABLE_LAYOUT; return $this->render('index', [
php
{ "resource": "" }
q9568
Controller.getSearchCriteria
train
public function getSearchCriteria() { /* setting the default pagination for the page */ if (!Yii::$app->session->get($this->MainModel . 'Pagination')) { Yii::$app->session->set($this->MainModel . 'Pagination', Yii::$app->getModule('core')->recordsPerPage); } $savedQueryParams = Yii::$app->session->get($this->MainModel . 'QueryParams'); if (count($savedQueryParams)) { $queryParams = $savedQueryParams; } else { $queryParams = [substr($this->MainModelSearch, strrpos($this->MainModelSearch, "\\") + 1) => $this->defaultQueryParams]; } /* use the same filters as before */ if (count(Yii::$app->request->queryParams)) { $queryParams = array_merge($queryParams, Yii::$app->request->queryParams);
php
{ "resource": "" }
q9569
Controller.actionPdf
train
public function actionPdf() { $this->getSearchCriteria(); $this->layout = static::BLANK_LAYOUT; $this->dataProvider->pagination = false; $content = $this->render('pdf', [ 'dataProvider' => $this->dataProvider, ]); if (isset($_GET['test'])) { return $content; } else { $mpdf = new \mPDF(); $mpdf->WriteHTML($content); Yii::$app->response->getHeaders()->set('Content-Type', 'application/pdf');
php
{ "resource": "" }
q9570
Controller.actionPagination
train
public function actionPagination() { Yii::$app->session->set($this->MainModel . 'Pagination',
php
{ "resource": "" }
q9571
Controller.actionCreate
train
public function actionCreate() { $this->layout = static::FORM_LAYOUT; $model = new $this->MainModel; if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterCreate($model);
php
{ "resource": "" }
q9572
Controller.saveHistory
train
public function saveHistory($model, $historyField) { if (isset($model->{$historyField})) { $url_components = explode("\\", get_class($model)); $url_components[2] = trim(preg_replace("([A-Z])", " $0", $url_components[2]), " "); $history = new History; $history->name =
php
{ "resource": "" }
q9573
Controller.actionUpdate
train
public function actionUpdate($id) { $this->layout = static::FORM_LAYOUT; $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterUpdate($model);
php
{ "resource": "" }
q9574
Controller.allButtons
train
public function allButtons() { $buttons = []; if (\Yii::$app->user->checkAccess('read::' . $this->getCompatibilityId())) { $buttons['pdf'] = [ 'text' => 'Download PDF', 'url' => Url::toRoute(['pdf']), 'options' => [ 'target' => '_blank', ] ];
php
{ "resource": "" }
q9575
DispatchListener.setSiteLayout
train
public function setSiteLayout(MvcEvent $event) { /** @var \Zend\View\Model\ViewModel $viewModel */ $viewModel = $event->getViewModel(); /* Add on for non CMS pages */ $fakePage = new Page( Tracking::UNKNOWN_USER_ID, 'Fake page for non CMS pages in ' . get_class($this) ); $fakeRevision = new Revision( Tracking::UNKNOWN_USER_ID, 'Fake revision for non CMS pages in ' . get_class($this) ); $fakePage->setCurrentRevision($fakeRevision);
php
{ "resource": "" }
q9576
UserController.getUserById
train
private function getUserById($id) { $user = $this->userService->findUserById($id); if (empty($user)) {
php
{ "resource": "" }
q9577
Asset.getAsset
train
public function getAsset($asset) { if (!isset($this->assetCache[$asset])) { $this->assetCache[$asset] =
php
{ "resource": "" }
q9578
Formatter.formatSeoUrl
train
public static function formatSeoUrl($name) { $url = mb_strtolower($name); $url = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $url); $url = preg_replace("/[^a-z0-9_\s-]/", "", $url);
php
{ "resource": "" }
q9579
UserEmailTransformer.transform
train
public function transform($user) { if (empty($user)) { $className =
php
{ "resource": "" }
q9580
ForkableExtEventLoop.subscribeStreamEvent
train
private function subscribeStreamEvent($stream, $flag) { $key = (int) $stream; if (isset($this->streamEvents[$key])) { $event = $this->streamEvents[$key]; $flags = ($this->streamFlags[$key] |= $flag); $event->del(); $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback); } else {
php
{ "resource": "" }
q9581
ForkableExtEventLoop.unsubscribeStreamEvent
train
private function unsubscribeStreamEvent($stream, $flag) { $key = (int) $stream; $flags = $this->streamFlags[$key] &= ~$flag; if (0 === $flags) { $this->removeStream($stream); return; }
php
{ "resource": "" }
q9582
FontAwesomeIconEnumerator.enumFonts
train
public static function enumFonts() { return [ FontAwesomeIconInterface::FONT_AWESOME_FONT, FontAwesomeIconInterface::FONT_AWESOME_FONT_BOLD, FontAwesomeIconInterface::FONT_AWESOME_FONT_LIGHT,
php
{ "resource": "" }
q9583
ActiveRecord.deleteInternal
train
public function deleteInternal() { $result = false; if ($this->beforeDelete()) { // we do not check the return value of deleteAll() because it's possible // the record is already deleted in the database and thus the method will return 0 $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { $condition[$lock] = $this->$lock; }
php
{ "resource": "" }
q9584
CommentMutators.getAuthorAttribute
train
public function getAuthorAttribute() { return (object) [ 'name' => is_int($this->user_id) ? $this->user->name : $this->name, 'profile' => is_int($this->user_id) ? $this->user->profile : $this->name, 'avatar'
php
{ "resource": "" }
q9585
NearbyStops.setCoordinate
train
public function setCoordinate(Coordinate $coordinate): self { $this->options['coordX'] = $coordinate->getLatitude();
php
{ "resource": "" }
q9586
OAuthGuard.onAuthenticationSuccess
train
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) { $user = $token->getUser(); $this->dispatcher->dispatch(self::OAUTH_LOGIN_SUCCESS, new UserEvent($user));
php
{ "resource": "" }
q9587
OAuthGuard.onAuthenticationFailure
train
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { $this->dispatcher->dispatch(self::OAUTH_LOGIN_FAILURE, new AuthFailedEvent($request, $exception)); return $this->removeAuthCookieFromResponse(new Response(
php
{ "resource": "" }
q9588
OAuthGuard.start
train
public function start(Request $request, AuthenticationException $authException = null) {
php
{ "resource": "" }
q9589
DefaultController.actionLogin
train
public function actionLogin() { $model = new LoginForm(); //make the captcha required if the unsuccessful attempts are more of thee if ($this->getLoginAttempts() >= $this->module->attemptsBeforeCaptcha) { $model->scenario = 'withCaptcha'; } if(Yii::$app->request->post()) { if($model->load($_POST) && $model->login()) { $this->setLoginAttempts(0); //if login is successful, reset the attempts return $this->goBack(); } else
php
{ "resource": "" }
q9590
PagePermissionsController.pagePermissionsAction
train
public function pagePermissionsAction() { $view = new ViewModel(); //fixes rendering site's header and footer in the dialog $view->setTerminal(true); /** @var \Rcm\Entity\Site $currentSite */ $currentSite = $this->getServiceLocator()->get( \Rcm\Service\CurrentSite::class ); $currentSiteId = $currentSite->getSiteId(); $sourcePageName = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageName', 'index' ); $pageType = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageType', 'n' ); /** @var ResourceName $resourceName */ $resourceName = $this->getServiceLocator()->get( ResourceName::class ); $resourceId = $resourceName->get( ResourceName::RESOURCE_SITES, $currentSiteId, ResourceName::RESOURCE_PAGES, $pageType, $sourcePageName ); /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */ $aclDataService = $this->getServiceLocator()->get( \RcmUser\Acl\Service\AclDataService::class ); //getting all set rules by resource Id $rules = $aclDataService->getRulesByResource($resourceId)->getData(); //getting list of all dynamically created roles $allRoles = $aclDataService->getNamespacedRoles()->getData(); $rolesHasRules
php
{ "resource": "" }
q9591
BaseUser.singleView
train
public function singleView() { return [ 'id' => $this->getId(), 'displayName' => $this->getDisplayName(), 'roles' => $this->getRoles(),
php
{ "resource": "" }
q9592
FormFactory.updateCron
train
public function updateCron( EdgarEzCron $data, ?string $name = null ): ?FormInterface { $name = $name ?: sprintf('update-cron-%s', $data->getAlias()); return $this->formFactory->createNamed( $name,
php
{ "resource": "" }
q9593
EntityMetadataMiner.isLinkOnlyRelation
train
private static function isLinkOnlyRelation( \ReflectionClass $class, $name ) { $getterName = 'get' . Inflector::camelize($name);
php
{ "resource": "" }
q9594
Autoloader.attachNamespace
train
public function attachNamespace($namespace, $paths) { if (isset($this->namespaces[$namespace])) { if (is_array($paths)) { $this->namespaces[$namespace] = array_merge($this->namespaces[$namespace], $paths); } else { $this->namespaces[$namespace][] =
php
{ "resource": "" }
q9595
Autoloader.attachPearPrefixes
train
public function attachPearPrefixes(array $classes) { foreach ($classes as
php
{ "resource": "" }
q9596
Container.setValue
train
public function setValue($name, $value) {
php
{ "resource": "" }
q9597
Container.extend
train
public function extend($name, $extender) { if (!is_callable($extender, true)) { throw new FactoryUncallableException('$extender must appear callable'); } if (!array_key_exists($name, $this->factories)) { throw new NotFoundException("No factory available for: $name"); } $factory = $this->factories[$name];
php
{ "resource": "" }
q9598
Container.getKeys
train
public function getKeys() { $keys = array_keys($this->cache)
php
{ "resource": "" }
q9599
JsonHelper.isValid
train
public static function isValid($string) { if (is_int($string) || is_float($string)) {
php
{ "resource": "" }