idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
39,500 | public function readSession ( $ id ) { $ data = $ this -> cache -> get ( $ this -> calculateKey ( $ id ) ) ; return $ data === null ? '' : $ data ; } | Session read handler . |
39,501 | public function init ( ) : void { if ( $ this -> sourcePath !== null ) { $ this -> sourcePath = $ this -> findPath ( $ this -> sourcePath ) ; } if ( $ this -> basePath !== null ) { $ this -> basePath = $ this -> findPath ( $ this -> basePath ) ; } if ( $ this -> baseUrl !== null ) { $ this -> baseUrl = rtrim ( Yii :: g... | Initializes the bundle . If you override this method make sure you call the parent implementation in the last . |
39,502 | public function setRawBody ( $ rawBody ) { $ body = new MemoryStream ( ) ; $ body -> write ( $ rawBody ) ; $ this -> setBody ( $ body ) ; } | Sets the raw HTTP request body this method is mainly used by test scripts to simulate raw HTTP requests . |
39,503 | public function getParsedBodyParam ( $ name , $ defaultValue = null ) { $ params = $ this -> getParsedBody ( ) ; if ( is_object ( $ params ) ) { try { return $ params -> { $ name } ; } catch ( \ Exception $ e ) { return $ defaultValue ; } } return $ params [ $ name ] ?? $ defaultValue ; } | Returns the named request body parameter value . If the parameter does not exist the second parameter passed to this method will be returned . |
39,504 | public function post ( $ name = null , $ defaultValue = null ) { if ( $ name === null ) { return $ this -> getParsedBody ( ) ; } return $ this -> getParsedBodyParam ( $ name , $ defaultValue ) ; } | Returns POST parameter with a given name . If name isn t specified returns an array of all POST parameters . |
39,505 | public function getQueryParam ( $ name , $ defaultValue = null ) { $ params = $ this -> getQueryParams ( ) ; return $ params [ $ name ] ?? $ defaultValue ; } | Returns the named GET parameter value . If the GET parameter does not exist the second parameter passed to this method will be returned . |
39,506 | public function getServerParam ( $ name , $ default = null ) { $ params = $ this -> getServerParams ( ) ; if ( ! isset ( $ params [ $ name ] ) ) { return $ default ; } return $ params [ $ name ] ; } | Return the server environment parameter by name . |
39,507 | public function getScriptUrl ( ) { if ( $ this -> _scriptUrl === null ) { $ scriptFile = $ this -> getScriptFile ( ) ; $ scriptName = basename ( $ scriptFile ) ; $ serverParams = $ this -> getServerParams ( ) ; if ( isset ( $ serverParams [ 'SCRIPT_NAME' ] ) && basename ( $ serverParams [ 'SCRIPT_NAME' ] ) === $ script... | Returns the relative URL of the entry script . The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework . |
39,508 | public function getAcceptableContentTypes ( ) { if ( $ this -> _contentTypes === null ) { if ( $ this -> hasHeader ( 'Accept' ) ) { $ this -> _contentTypes = $ this -> parseAcceptHeader ( $ this -> getHeaderLine ( 'Accept' ) ) ; } else { $ this -> _contentTypes = [ ] ; } } return $ this -> _contentTypes ; } | Returns the content types acceptable by the end user . |
39,509 | protected function generateCsrfToken ( ) { $ token = $ this -> app -> getSecurity ( ) -> generateRandomString ( ) ; if ( $ this -> enableCsrfCookie ) { $ cookie = $ this -> createCsrfCookie ( $ token ) ; $ this -> app -> getResponse ( ) -> getCookies ( ) -> add ( $ cookie ) ; } else { $ this -> app -> getSession ( ) ->... | Generates an unmasked random token used to perform CSRF validation . |
39,510 | protected function restoreResponse ( $ response , $ data ) { foreach ( [ 'format' , 'protocolVersion' , 'statusCode' , 'reasonPhrase' , 'content' ] as $ name ) { $ response -> { $ name } = $ data [ $ name ] ; } if ( isset ( $ data [ 'headers' ] ) ) { $ response -> setHeaders ( $ data [ 'headers' ] ) ; } if ( isset ( $ ... | Restores response properties from the given data . |
39,511 | public function cacheResponse ( ) { $ this -> getView ( ) -> popDynamicContent ( ) ; $ beforeCacheResponseResult = $ this -> beforeCacheResponse ( ) ; if ( $ beforeCacheResponseResult === false ) { echo $ this -> updateDynamicContent ( ob_get_clean ( ) , $ this -> getDynamicPlaceholders ( ) ) ; return ; } $ response = ... | Caches response properties . |
39,512 | private function parseHeaders ( $ headerContent ) { $ headers = [ ] ; $ headerParts = preg_split ( '/\\R/s' , $ headerContent , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ headerParts as $ headerPart ) { if ( strpos ( $ headerPart , ':' ) === false ) { continue ; } [ $ headerName , $ headerValue ] = explode ( ':' , $ hea... | Parses content part headers . |
39,513 | public static function before ( IdentityInterface $ identity , bool $ cookieBased , int $ duration ) : self { return new static ( static :: BEFORE , $ identity , $ cookieBased , $ duration ) ; } | Creates BEFORE event with result . |
39,514 | public static function after ( IdentityInterface $ identity , bool $ cookieBased , int $ duration ) : self { return new static ( static :: AFTER , $ identity , $ cookieBased , $ duration ) ; } | Creates AFTER_RUN event with result . |
39,515 | public function negotiate ( ) { $ request = $ this -> request ? : Yii :: getApp ( ) -> getRequest ( ) ; $ response = $ this -> response ? : Yii :: getApp ( ) -> getResponse ( ) ; if ( ! empty ( $ this -> formats ) ) { $ this -> negotiateContentType ( $ request , $ response ) ; } if ( ! empty ( $ this -> languages ) ) {... | Negotiates the response format and application language . |
39,516 | protected function negotiateContentType ( $ request , $ response ) { if ( ! empty ( $ this -> formatParam ) && ( $ format = $ request -> get ( $ this -> formatParam ) ) !== null ) { if ( is_array ( $ format ) ) { throw new BadRequestHttpException ( "Invalid data received for GET parameter '{$this->formatParam}'." ) ; }... | Negotiates the response format . |
39,517 | public function getAssetPath ( $ bundle , $ asset ) { if ( ( $ actualAsset = $ this -> resolveAsset ( $ bundle , $ asset ) ) !== false ) { return Url :: isRelative ( $ actualAsset ) ? $ this -> getRealBasePath ( ) . '/' . $ actualAsset : false ; } return Url :: isRelative ( $ asset ) ? $ bundle -> basePath . '/' . $ as... | Returns the actual file path for the specified asset . |
39,518 | public function getConverter ( ) { if ( $ this -> _converter === null ) { $ this -> _converter = $ this -> app -> createObject ( AssetConverter :: class ) ; } elseif ( is_array ( $ this -> _converter ) || is_string ( $ this -> _converter ) ) { if ( is_array ( $ this -> _converter ) && ! isset ( $ this -> _converter [ '... | Returns the asset converter . |
39,519 | public function publish ( $ path , $ options = [ ] ) { $ path = $ this -> app -> getAlias ( $ path ) ; if ( isset ( $ this -> _published [ $ path ] ) ) { return $ this -> _published [ $ path ] ; } if ( ! is_string ( $ path ) || ( $ src = realpath ( $ path ) ) === false ) { throw new InvalidArgumentException ( "The file... | Publishes a file or a directory . |
39,520 | public function addFlash ( $ key , $ value = true , $ removeAfterAccess = true ) { $ counters = $ this -> get ( $ this -> flashParam , [ ] ) ; $ counters [ $ key ] = $ removeAfterAccess ? - 1 : 0 ; $ _SESSION [ $ this -> flashParam ] = $ counters ; if ( empty ( $ _SESSION [ $ key ] ) ) { $ _SESSION [ $ key ] = [ $ valu... | Adds a flash message . If there are existing flash messages with the same key the new one will be appended to the existing message array . |
39,521 | protected function unfreeze ( ) { if ( null !== $ this -> frozenSessionData ) { YII_DEBUG ? session_start ( ) : @ session_start ( ) ; if ( $ this -> getIsActive ( ) ) { Yii :: info ( 'Session unfrozen' , __METHOD__ ) ; } else { $ error = error_get_last ( ) ; $ message = $ error [ 'message' ] ?? 'Failed to unfreeze sess... | Starts session and restores data from temporary variable |
39,522 | protected function composeFields ( $ id , $ data ) { $ fields = [ 'data' => $ data , ] ; if ( $ this -> writeCallback !== null ) { $ fields = array_merge ( $ fields , call_user_func ( $ this -> writeCallback , $ this ) ) ; if ( ! is_string ( $ fields [ 'data' ] ) ) { $ _SESSION = $ fields [ 'data' ] ; $ fields [ 'data'... | Composes storage field set for session writing . |
39,523 | protected function extractData ( $ fields ) { if ( $ this -> readCallback !== null ) { if ( ! isset ( $ fields [ 'data' ] ) ) { $ fields [ 'data' ] = '' ; } $ extraData = call_user_func ( $ this -> readCallback , $ fields ) ; if ( ! empty ( $ extraData ) ) { session_decode ( $ fields [ 'data' ] ) ; $ _SESSION = array_m... | Extracts session data from storage field set . |
39,524 | public function convert ( $ asset , $ basePath ) { $ pos = strrpos ( $ asset , '.' ) ; if ( $ pos !== false ) { $ srcExt = substr ( $ asset , $ pos + 1 ) ; if ( isset ( $ this -> commands [ $ srcExt ] ) ) { [ $ ext , $ command ] = $ this -> commands [ $ srcExt ] ; $ result = substr ( $ asset , 0 , $ pos + 1 ) . $ ext ;... | Converts a given asset file into a CSS or JS file . |
39,525 | protected function isOutdated ( $ basePath , $ sourceFile , $ targetFile , $ sourceExtension , $ targetExtension ) { $ resultModificationTime = @ filemtime ( "$basePath/$targetFile" ) ; if ( $ resultModificationTime === false || $ resultModificationTime === null ) { return true ; } if ( $ resultModificationTime < @ fil... | Checks whether asset convert result is outdated and thus should be reconverted . |
39,526 | public function normalize ( $ widget ) : void { $ presenter = $ this -> figureOutPresenterClass ( $ widget ) ; if ( $ widget -> presenter ) { $ this -> checkPresentMethodExists ( $ presenter ) ; $ widget -> presenter = $ presenter . '@present' ; } } | Figures out which method should be called as the presenter . |
39,527 | public function normalizeWidgetConfig ( $ widget ) : void { if ( isset ( $ widget -> isNormalized ) ) { return ; } foreach ( $ this -> normalizers as $ normalizer ) { $ normalizer -> normalize ( $ widget ) ; } $ widget -> isNormalized = true ; } | Figures out and sets the widget configs according to conventions . |
39,528 | public function normalize ( $ widget ) : void { $ contextAs = 'data' ; if ( property_exists ( $ widget , 'contextAs' ) ) { $ contextAs = str_replace ( '$' , '' , ( string ) $ widget -> contextAs ) ; } $ widget -> contextAs = $ contextAs ; } | Figures out what the variable name should be in view file . |
39,529 | private function addDebugInfo ( ) : void { $ tpl = $ this -> getTplPath ( $ this -> widget -> template ) ; $ this -> html = "<span title='WidgetObj : " . get_class ( $ this -> widget ) . ".php
Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>" ; } | Adds debug info to html as HTML title tags . |
39,530 | public function cacheResult ( array $ args , callable $ phpCode , $ widgetObj , $ form = 'HTML' ) { $ key = $ this -> makeCacheKey ( $ args , $ widgetObj , $ form ) ; $ cache = app ( 'cache' ) ; if ( ! empty ( $ widgetObj -> cacheTags ) && $ this -> cacheDriverSupportsTags ( ) ) { $ cache = $ cache -> tags ( $ widgetOb... | Caches the widget output . |
39,531 | private function makeCacheKey ( array $ arg , $ widget , string $ form ) : string { if ( method_exists ( $ widget , 'cacheKey' ) ) { return $ widget -> cacheKey ( $ arg ) ; } $ _key = '' ; if ( method_exists ( $ widget , 'extraCacheKeyDependency' ) ) { $ _key = json_encode ( $ widget -> extraCacheKeyDependency ( $ arg ... | Creates a unique cache key for each possible output . |
39,532 | public function generateNewToken ( string $ tag ) : string { $ token = str_random ( 7 ) ; $ this -> setTokenInMemory ( $ tag , $ token ) ; $ this -> persistToken ( $ tag , $ token ) ; return $ token ; } | Generates a brand new token . |
39,533 | private function setTokenInMemory ( string $ tag , string $ token ) : string { return $ this -> tagTokens [ $ tag ] = $ token ; } | Set token in Memory for fast access within the same request . |
39,534 | private function persistToken ( string $ tag , string $ token ) : void { \ Cache :: forever ( '9z10_o6cg_r' . $ tag , $ token ) ; } | Save token to disk for later requests . |
39,535 | public function normalize ( $ widget ) : void { list ( $ controllerMethod , $ ctrlClass ) = $ this -> determineDataMethod ( $ widget ) ; $ this -> checkControllerExists ( $ ctrlClass ) ; $ this -> checkDataMethodExists ( $ ctrlClass ) ; $ widget -> controller = $ controllerMethod ; } | Figures out which method should be called as the controller . |
39,536 | public function normalize ( $ widget ) : void { $ className = str_replace ( 'App\\Widgets\\' , '' , get_class ( $ widget ) ) ; $ className = str_replace ( [ '\\' , '/' ] , '.' , $ className ) ; if ( ! property_exists ( $ widget , 'template' ) ) { $ widget -> template = 'Widgets::' . $ className . 'View' ; } if ( ! view... | Figures out which template to render . |
39,537 | private function createView ( ) : void { $ path = $ this -> getViewPath ( ) ; if ( $ this -> files -> exists ( $ path ) ) { $ this -> error ( $ this -> qualifyClass ( $ this -> getNameInput ( ) ) . 'View.blade.php - Already exists! (@_@)' ) ; return ; } $ this -> files -> put ( $ path , $ this -> getViewStub ( ) ) ; $ ... | Create a new view file for the widget . |
39,538 | public function registerGuest ( array $ credentials ) { $ user = $ this -> findGuestUserByCredentials ( $ credentials ) ; $ newUser = false ; if ( ! $ user ) { $ user = $ this -> createUserModel ( ) ; $ newUser = true ; } $ user -> fill ( $ credentials ) ; $ user -> is_guest = true ; $ user -> save ( ) ; if ( $ newUser... | Registers a guest user by giving the required credentials . |
39,539 | public function convertGuestToUser ( $ user , $ credentials , $ activate = false ) { $ user -> fill ( $ credentials ) ; $ user -> convertToRegistered ( false ) ; if ( $ group = UserGroupModel :: getGuestGroup ( ) ) { $ user -> groups ( ) -> remove ( $ group ) ; } if ( $ activate ) { $ user -> attemptActivation ( $ user... | Converts a guest user to a registered user . |
39,540 | public function formExtendFields ( $ form ) { if ( UserSettings :: get ( 'login_attribute' ) == UserSettings :: LOGIN_USERNAME && array_key_exists ( 'username' , $ form -> getFields ( ) ) ) { $ form -> getField ( 'username' ) -> hidden = false ; } } | Display username field if settings permit |
39,541 | public function preview_onActivate ( $ recordId = null ) { $ model = $ this -> formFindModelObject ( $ recordId ) ; $ model -> attemptActivation ( $ model -> activation_code ) ; Flash :: success ( Lang :: get ( 'rainlab.user::lang.users.activated_success' ) ) ; if ( $ redirect = $ this -> makeRedirect ( 'update-close' ... | Manually activate a user |
39,542 | public function preview_onUnban ( $ recordId = null ) { $ model = $ this -> formFindModelObject ( $ recordId ) ; $ model -> unban ( ) ; Flash :: success ( Lang :: get ( 'rainlab.user::lang.users.unbanned_success' ) ) ; if ( $ redirect = $ this -> makeRedirect ( 'update-close' , $ model ) ) { return $ redirect ; } } | Manually unban a user |
39,543 | public function preview_onLoadConvertGuestForm ( $ recordId ) { $ this -> vars [ 'groups' ] = UserGroup :: where ( 'code' , '!=' , UserGroup :: GROUP_GUEST ) -> get ( ) ; return $ this -> makePartial ( 'convert_guest_form' ) ; } | Display the convert to registered user popup |
39,544 | public function preview_onConvertGuest ( $ recordId ) { $ model = $ this -> formFindModelObject ( $ recordId ) ; $ model -> convertToRegistered ( post ( 'send_registration_notification' , false ) ) ; if ( $ group = UserGroup :: getGuestGroup ( ) ) { $ model -> groups ( ) -> remove ( $ group ) ; } if ( ( $ groupId = pos... | Manually convert a guest user to a registered one |
39,545 | public function preview_onImpersonateUser ( $ recordId ) { if ( ! $ this -> user -> hasAccess ( 'rainlab.users.impersonate_user' ) ) { return Response :: make ( Lang :: get ( 'backend::lang.page.access_denied.label' ) , 403 ) ; } $ model = $ this -> formFindModelObject ( $ recordId ) ; Auth :: impersonate ( $ model ) ;... | Impersonate this user |
39,546 | public function update_onDelete ( $ recordId = null ) { $ model = $ this -> formFindModelObject ( $ recordId ) ; $ model -> forceDelete ( ) ; Flash :: success ( Lang :: get ( 'backend::lang.form.delete_success' ) ) ; if ( $ redirect = $ this -> makeRedirect ( 'delete' , $ model ) ) { return $ redirect ; } } | Force delete a user . |
39,547 | public function index_onBulkAction ( ) { if ( ( $ bulkAction = post ( 'action' ) ) && ( $ checkedIds = post ( 'checked' ) ) && is_array ( $ checkedIds ) && count ( $ checkedIds ) ) { foreach ( $ checkedIds as $ userId ) { if ( ! $ user = User :: withTrashed ( ) -> find ( $ userId ) ) { continue ; } switch ( $ bulkActio... | Perform bulk action on selected users |
39,548 | public static function checkForEmail ( $ template , $ email ) { if ( in_array ( $ template , static :: $ safeTemplates ) ) { return [ ] ; } if ( empty ( $ email ) ) { return [ ] ; } if ( ! is_array ( $ email ) ) { $ email = [ $ email => null ] ; } $ emails = array_keys ( $ email ) ; return static :: where ( function ( ... | Checks if an email address has blocked a given template returns an array of blocked emails . |
39,549 | public static function filterMessage ( $ template , $ message ) { $ recipients = $ message -> getTo ( ) ; $ blockedAddresses = static :: checkForEmail ( $ template , $ recipients ) ; if ( ! count ( $ blockedAddresses ) ) { return null ; } foreach ( $ recipients as $ address => $ name ) { if ( in_array ( $ address , $ b... | Filters a Illuminate \ Mail \ Message and removes blocked recipients . If no recipients remain false is returned . Returns null if mailing should proceed . |
39,550 | public function onRestorePassword ( ) { $ rules = [ 'email' => 'required|email|between:6,255' ] ; $ validation = Validator :: make ( post ( ) , $ rules ) ; if ( $ validation -> fails ( ) ) { throw new ValidationException ( $ validation ) ; } $ user = UserModel :: findByEmail ( post ( 'email' ) ) ; if ( ! $ user || $ us... | Trigger the password reset email |
39,551 | public function onResetPassword ( ) { $ rules = [ 'code' => 'required' , 'password' => 'required|between:4,255' ] ; $ validation = Validator :: make ( post ( ) , $ rules ) ; if ( $ validation -> fails ( ) ) { throw new ValidationException ( $ validation ) ; } $ errorFields = [ 'code' => Lang :: get ( 'rainlab.user::lan... | Perform the password reset |
39,552 | protected function makeResetUrl ( $ code ) { $ params = [ $ this -> property ( 'paramCode' ) => $ code ] ; if ( $ pageName = $ this -> property ( 'resetPage' ) ) { $ url = $ this -> pageUrl ( $ pageName , $ params ) ; } else { $ url = $ this -> currentPageUrl ( $ params ) ; } if ( strpos ( $ url , $ code ) === false ) ... | Returns a link used to reset the user account . |
39,553 | public function user ( ) { if ( ! $ user = Auth :: getUser ( ) ) { return null ; } if ( ! Auth :: isImpersonator ( ) ) { $ user -> touchLastSeen ( ) ; } return $ user ; } | Returns the logged in user if available and touches the last seen timestamp . |
39,554 | public function onLogout ( ) { $ user = Auth :: getUser ( ) ; Auth :: logout ( ) ; if ( $ user ) { Event :: fire ( 'rainlab.user.logout' , [ $ user ] ) ; } $ url = post ( 'redirect' , Request :: fullUrl ( ) ) ; Flash :: success ( Lang :: get ( 'rainlab.user::lang.session.logout' ) ) ; return Redirect :: to ( $ url ) ; ... | Log out the user |
39,555 | public function onStopImpersonating ( ) { if ( ! Auth :: isImpersonator ( ) ) { return $ this -> onLogout ( ) ; } Auth :: stopImpersonate ( ) ; $ url = post ( 'redirect' , Request :: fullUrl ( ) ) ; Flash :: success ( Lang :: get ( 'rainlab.user::lang.session.stop_impersonate_success' ) ) ; return Redirect :: to ( $ ur... | If impersonating revert back to the previously signed in user . |
39,556 | protected function checkUserSecurity ( ) { $ allowedGroup = $ this -> property ( 'security' , self :: ALLOW_ALL ) ; $ allowedUserGroups = $ this -> property ( 'allowedUserGroups' , [ ] ) ; $ isAuthenticated = Auth :: check ( ) ; if ( $ isAuthenticated ) { if ( $ allowedGroup == self :: ALLOW_GUEST ) { return false ; } ... | Checks if the user can access this page based on the security rules |
39,557 | public function attemptActivation ( $ code ) { $ result = parent :: attemptActivation ( $ code ) ; if ( $ result === false ) { return false ; } Event :: fire ( 'rainlab.user.activate' , [ $ this ] ) ; return true ; } | Sends the confirmation email to a user after activating . |
39,558 | public function convertToRegistered ( $ sendNotification = true ) { if ( ! $ this -> is_guest ) { return ; } if ( $ sendNotification ) { $ this -> generatePassword ( ) ; } $ this -> is_guest = false ; $ this -> save ( ) ; if ( $ sendNotification ) { $ this -> sendInvitation ( ) ; } } | Converts a guest user to a registered one and sends an invitation notification . |
39,559 | public function getAvatarThumb ( $ size = 25 , $ options = null ) { if ( is_string ( $ options ) ) { $ options = [ 'default' => $ options ] ; } elseif ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ default = array_get ( $ options , 'default' , 'mm' ) ; if ( $ this -> avatar ) { return $ this -> avatar -> getThumb... | Returns the public image file path to this user s avatar . |
39,560 | public function beforeValidate ( ) { if ( $ this -> is_guest && ! $ this -> password ) { $ this -> generatePassword ( ) ; } if ( ( ! $ this -> username ) || ( $ this -> isDirty ( 'email' ) && $ this -> getOriginal ( 'email' ) == $ this -> username ) ) { $ this -> username = $ this -> email ; } } | Before validation event |
39,561 | public function beforeLogin ( ) { if ( $ this -> is_guest ) { $ login = $ this -> getLogin ( ) ; throw new AuthException ( sprintf ( 'Cannot login user "%s" as they are not registered.' , $ login ) ) ; } parent :: beforeLogin ( ) ; } | Before login event |
39,562 | public function afterLogin ( ) { $ this -> last_login = $ this -> freshTimestamp ( ) ; if ( $ this -> trashed ( ) ) { $ this -> restore ( ) ; Mail :: sendTo ( $ this , 'rainlab.user::mail.reactivate' , [ 'name' => $ this -> name ] ) ; Event :: fire ( 'rainlab.user.reactivate' , [ $ this ] ) ; } else { parent :: afterLo... | After login event |
39,563 | public function isBanned ( ) { $ throttle = Auth :: createThrottleModel ( ) -> where ( 'user_id' , $ this -> id ) -> first ( ) ; return $ throttle ? $ throttle -> is_banned : false ; } | Check if the user is banned . |
39,564 | public function touchLastSeen ( ) { if ( $ this -> isOnline ( ) ) { return ; } $ oldTimestamps = $ this -> timestamps ; $ this -> timestamps = false ; $ this -> newQuery ( ) -> where ( 'id' , $ this -> id ) -> update ( [ 'last_seen' => $ this -> freshTimestamp ( ) ] ) ; $ this -> last_seen = $ this -> freshTimestamp ( ... | Checks if the user has been seen in the last 5 minutes and if not updates the last_seen timestamp to reflect their online status . |
39,565 | public function getNotificationVars ( ) { $ vars = [ 'name' => $ this -> name , 'email' => $ this -> email , 'username' => $ this -> username , 'login' => $ this -> getLogin ( ) , 'password' => $ this -> getOriginalHashValue ( 'password' ) ] ; $ result = Event :: fire ( 'rainlab.user.getNotificationVars' , [ $ this ] )... | Returns the variables available when sending a user notification . |
39,566 | public static function getGuestGroup ( ) { if ( self :: $ guestGroup !== null ) { return self :: $ guestGroup ; } $ group = self :: where ( 'code' , self :: GROUP_GUEST ) -> first ( ) ? : false ; return self :: $ guestGroup = $ group ; } | Returns the guest user group . |
39,567 | public function prepareVars ( ) { $ this -> page [ 'user' ] = $ this -> user ( ) ; $ this -> page [ 'canRegister' ] = $ this -> canRegister ( ) ; $ this -> page [ 'loginAttribute' ] = $ this -> loginAttribute ( ) ; $ this -> page [ 'loginAttributeLabel' ] = $ this -> loginAttributeLabel ( ) ; } | Executed when this component is initialized |
39,568 | public function activationCode ( ) { $ routeParameter = $ this -> property ( 'paramCode' ) ; if ( $ code = $ this -> param ( $ routeParameter ) ) { return $ code ; } return get ( 'activate' ) ; } | Looks for the activation code from the URL parameter . If nothing is found the GET parameter activate is used instead . |
39,569 | public function onSignin ( ) { try { $ data = post ( ) ; $ rules = [ ] ; $ rules [ 'login' ] = $ this -> loginAttribute ( ) == UserSettings :: LOGIN_USERNAME ? 'required|between:2,255' : 'required|email|between:6,255' ; $ rules [ 'password' ] = 'required|between:4,255' ; if ( ! array_key_exists ( 'login' , $ data ) ) {... | Sign in the user |
39,570 | public function onRegister ( ) { try { if ( ! $ this -> canRegister ( ) ) { throw new ApplicationException ( Lang :: get ( 'rainlab.user::lang.account.registration_disabled' ) ) ; } $ data = post ( ) ; if ( ! array_key_exists ( 'password_confirmation' , $ data ) ) { $ data [ 'password_confirmation' ] = post ( 'password... | Register the user |
39,571 | public function onSendActivationEmail ( ) { try { if ( ! $ user = $ this -> user ( ) ) { throw new ApplicationException ( Lang :: get ( 'rainlab.user::lang.account.login_first' ) ) ; } if ( $ user -> is_activated ) { throw new ApplicationException ( Lang :: get ( 'rainlab.user::lang.account.already_active' ) ) ; } Flas... | Trigger a subsequent activation email |
39,572 | protected function sendActivationEmail ( $ user ) { $ code = implode ( '!' , [ $ user -> id , $ user -> getActivationCode ( ) ] ) ; $ link = $ this -> makeActivationUrl ( $ code ) ; $ data = [ 'name' => $ user -> name , 'link' => $ link , 'code' => $ code ] ; Mail :: send ( 'rainlab.user::mail.activate' , $ data , func... | Sends the activation email to a user |
39,573 | protected function makeRedirection ( $ intended = false ) { $ method = $ intended ? 'intended' : 'to' ; $ property = $ this -> property ( 'redirect' ) ; if ( ! strlen ( $ property ) ) { return ; } $ redirectUrl = $ this -> pageUrl ( $ property ) ? : $ property ; if ( $ redirectUrl = post ( 'redirect' , $ redirectUrl ) ... | Redirect to the intended page after successful update sign in or registration . The URL can come from the redirect property or the redirect postback value . |
39,574 | protected function redirectForceSecure ( ) { if ( Request :: secure ( ) || Request :: ajax ( ) || ! $ this -> property ( 'forceSecure' ) ) { return ; } return Redirect :: secure ( Request :: path ( ) ) ; } | Checks if the force secure property is enabled and if so returns a redirect object . |
39,575 | public function isTrue ( & $ params ) { $ hostObj = $ this -> host ; $ attribute = $ hostObj -> subcondition ; if ( ! $ user = array_get ( $ params , 'user' ) ) { throw new ApplicationException ( 'Error evaluating the user attribute condition: the user object is not found in the condition parameters.' ) ; } return pare... | Checks whether the condition is TRUE for specified parameters |
39,576 | protected function createModel ( string $ name , $ properties , $ methods , bool $ hasExtensions = false ) : Stmt \ Class_ { return new Stmt \ Class_ ( new Name ( $ this -> getNaming ( ) -> getClassName ( $ name ) ) , [ 'stmts' => array_merge ( $ properties , $ methods ) , 'extends' => $ hasExtensions ? new Name ( '\Ar... | Return a model class . |
39,577 | public function addType ( Type $ type ) { if ( $ type instanceof self ) { foreach ( $ type -> getTypes ( ) as $ subType ) { $ this -> types [ ] = $ subType ; } return $ this ; } $ this -> types [ ] = $ type ; return $ this ; } | Add a type . |
39,578 | protected function getTypesSorted ( ) { $ types = $ this -> getTypes ( ) ; usort ( $ types , function ( $ first , $ second ) { return $ first -> name == 'mixed' ? 1 : 0 ; } ) ; return $ types ; } | We have to place mixed normalization path at the last . |
39,579 | public function getUniqueName ( $ name ) { if ( ! isset ( $ this -> registry [ $ name ] ) ) { $ this -> registry [ $ name ] = 0 ; return $ name ; } ++ $ this -> registry [ $ name ] ; return sprintf ( '%s_%s' , $ name , $ this -> registry [ $ name ] ) ; } | Return an unique name for a variable . |
39,580 | private function getDefaultAsExpr ( $ parameter ) { $ expr = $ this -> parser -> parse ( '<?php ' . var_export ( $ parameter -> getSchema ( ) -> getDefault ( ) , true ) . ';' ) [ 0 ] ; if ( $ expr instanceof Stmt \ Expression ) { return $ expr -> expr ; } return $ expr ; } | Generate a default value as an Expr . |
39,581 | protected function getClassFromOperation ( $ name , Operation $ operation = null , $ reference , $ registry ) { if ( null === $ operation ) { return ; } if ( $ operation -> getParameters ( ) ) { foreach ( $ operation -> getParameters ( ) as $ key => $ parameter ) { if ( $ parameter instanceof BodyParameter ) { $ this -... | Discover classes in operation . |
39,582 | public function parseSchema ( string $ openApiSpecPath ) : OpenApi { $ openApiSpecContents = file_get_contents ( $ openApiSpecPath ) ; $ jsonException = null ; $ yamlException = null ; try { return $ this -> deserialize ( $ openApiSpecContents , $ openApiSpecPath ) ; } catch ( \ Exception $ exception ) { $ jsonExceptio... | Parse an file into a OpenAPI Schema model . |
39,583 | public function generate ( Schema $ schema , string $ className , Context $ context ) { foreach ( $ schema -> getClasses ( ) as $ class ) { $ properties = [ ] ; $ methods = [ ] ; foreach ( $ class -> getProperties ( ) as $ property ) { $ properties [ ] = $ this -> createProperty ( $ property , $ schema -> getNamespace ... | Generate a model given a schema . |
39,584 | public static function create ( bool $ private = true , MapperClassLoaderInterface $ loader = null , AdvancedNameConverterInterface $ nameConverter = null , string $ classPrefix = 'Mapper_' ) : self { $ classMetadataFactory = new ClassMetadataFactory ( new AnnotationLoader ( new AnnotationReader ( ) ) ) ; if ( $ loader... | Use this for test benchmark and fast prototyping . |
39,585 | public function resolve ( callable $ deserializeCallback = null ) { if ( null === $ deserializeCallback ) { $ deserializeCallback = function ( $ data ) { return $ data ; } ; } if ( null === $ this -> resolved ) { $ this -> resolved = $ this -> doResolve ( ) ; } return $ deserializeCallback ( $ this -> resolved ) ; } | Resolve a JSON Reference . |
39,586 | protected function doResolve ( ) { $ json = file_get_contents ( ( string ) $ this -> mergedUri -> withFragment ( '' ) ) ; if ( ! json_decode ( $ json ) || JSON_ERROR_NONE !== json_last_error ( ) ) { $ decoded = Yaml :: parse ( $ json , Yaml :: PARSE_OBJECT | Yaml :: PARSE_OBJECT_FOR_MAP | Yaml :: PARSE_DATETIME | Yaml ... | Resolve a JSON Reference for a Schema . |
39,587 | public function parse ( $ input = null , $ options = 0 ) { if ( ! is_null ( $ input ) ) { $ this -> setInput ( $ input ) ; } if ( 0 !== $ options ) { $ this -> options = $ options ; } if ( is_null ( $ this -> input ) ) { throw new EofException ( 'End of input stream, or no input supplied' ) ; } switch ( $ this -> input... | Parse xCal or xCard . |
39,588 | protected function parseVCalendarComponents ( Component $ parentComponent ) { foreach ( $ this -> pointer [ 'value' ] ? : [ ] as $ children ) { switch ( static :: getTagName ( $ children [ 'name' ] ) ) { case 'properties' : $ this -> pointer = & $ children [ 'value' ] ; $ this -> parseProperties ( $ parentComponent ) ;... | Parse a xCalendar component . |
39,589 | protected function parseVCardComponents ( Component $ parentComponent ) { $ this -> pointer = & $ this -> pointer [ 'value' ] ; $ this -> parseProperties ( $ parentComponent ) ; } | Parse a xCard component . |
39,590 | protected function parseComponent ( Component $ parentComponent ) { $ components = $ this -> pointer [ 'value' ] ? : [ ] ; foreach ( $ components as $ component ) { $ componentName = static :: getTagName ( $ component [ 'name' ] ) ; $ currentComponent = $ this -> root -> createComponent ( $ componentName , null , false... | Parse a component . |
39,591 | protected function createProperty ( Component $ parentComponent , $ name , $ parameters , $ type , $ value ) { $ property = $ this -> root -> createProperty ( $ name , null , $ parameters , $ type ) ; $ parentComponent -> add ( $ property ) ; $ property -> setXmlValue ( $ value ) ; } | Create a property . |
39,592 | public function getDtEnd ( ) { if ( ! $ this -> valid ( ) ) { return ; } $ end = clone $ this -> currentDate ; return $ end -> modify ( '+' . $ this -> eventDuration . ' seconds' ) ; } | This method returns the end date for the current iteration of the event . |
39,593 | public function getEventObject ( ) { if ( $ this -> currentOverriddenEvent ) { return $ this -> currentOverriddenEvent ; } $ event = clone $ this -> masterEvent ; unset ( $ event -> RRULE , $ event -> EXDATE , $ event -> RDATE , $ event -> EXRULE , $ event -> { 'RECURRENCE-ID' } ) ; $ event -> DTSTART -> setDateTime ( ... | Returns a VEVENT for the current iterations of the event . |
39,594 | public function valid ( ) { if ( $ this -> counter > Settings :: $ maxRecurrences && - 1 !== Settings :: $ maxRecurrences ) { throw new MaxInstancesExceededException ( 'Recurring events are only allowed to generate ' . Settings :: $ maxRecurrences ) ; } return ( bool ) $ this -> currentDate ; } | This is called after next to see if the iterator is still at a valid position or if it s at the end . |
39,595 | public function rewind ( ) { $ this -> recurIterator -> rewind ( ) ; $ index = [ ] ; foreach ( $ this -> overriddenEvents as $ key => $ event ) { $ stamp = $ event -> DTSTART -> getDateTime ( $ this -> timeZone ) -> getTimeStamp ( ) ; $ index [ $ stamp ] [ ] = $ key ; } krsort ( $ index ) ; $ this -> counter = 0 ; $ th... | Sets the iterator back to the starting point . |
39,596 | public function next ( ) { $ this -> currentOverriddenEvent = null ; ++ $ this -> counter ; if ( $ this -> nextDate ) { $ nextDate = $ this -> nextDate ; $ this -> nextDate = null ; } else { do { if ( ! $ this -> recurIterator -> valid ( ) ) { $ nextDate = null ; break ; } $ nextDate = $ this -> recurIterator -> curren... | Advances the iterator with one step . |
39,597 | public function fastForward ( DateTimeInterface $ dateTime ) { while ( $ this -> valid ( ) && $ this -> getDtEnd ( ) <= $ dateTime ) { $ this -> next ( ) ; } } | Quickly jump to a date in the future . |
39,598 | public function getParts ( ) { if ( is_null ( $ this -> value ) ) { return [ ] ; } elseif ( is_array ( $ this -> value ) ) { return $ this -> value ; } else { return [ $ this -> value ] ; } } | Returns a multi - valued property . |
39,599 | public function offsetExists ( $ name ) { if ( is_int ( $ name ) ) { return parent :: offsetExists ( $ name ) ; } $ name = strtoupper ( $ name ) ; foreach ( $ this -> parameters as $ parameter ) { if ( $ parameter -> name == $ name ) { return true ; } } return false ; } | Checks if an array element exists . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.