idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
23,400 | protected function validateJson ( ResponseInterface $ response ) : array { try { return \ GuzzleHttp \ json_decode ( ( string ) $ response -> getBody ( ) , true ) ; } catch ( \ Exception $ e ) { return [ ] ; } } | Validate json . |
23,401 | public function addGlobal ( ) { foreach ( $ this -> getIndex ( ) as $ k => $ v ) { if ( null === $ v ) { continue ; } $ this -> getTwigEnvironment ( ) -> addGlobal ( str_replace ( "Interface" , "" , $ k ) , $ this -> getProviders ( ) [ $ v ] ) ; } } | Add the global . |
23,402 | protected function setProvider ( $ name , ThemeProviderInterface $ provider ) { $ k = ObjectHelper :: getShortName ( $ name ) ; $ v = $ this -> getIndex ( ) [ $ k ] ; if ( null !== $ v ) { $ this -> getProviders ( ) [ $ v ] = $ provider ; return $ this ; } $ this -> index [ $ k ] = count ( $ this -> getProviders ( ) ) ; return $ this -> addProvider ( $ provider ) ; } | Set a provider . |
23,403 | private function getRealMimeType ( ) { $ info = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ info , $ this -> temporaryFilename ) ; finfo_close ( $ info ) ; return $ mime ; } | Obtain the concrete mime type of uploaded file based signature . This mime type should be used for security check instead of the one provided in the HTTP request which could be spoofed . |
23,404 | public function setWalkingDistance ( int $ originDistance = 2000 , int $ destinationDistance = 2000 ) : self { $ this -> options [ 'maxWalkingDistanceDep' ] = $ originDistance ; $ this -> options [ 'maxWalkingDistanceDest' ] = $ destinationDistance ; return $ this ; } | Set walking distances in meters . |
23,405 | protected function getUrl ( array $ options ) : string { $ urlOptions = [ ] ; $ this -> setOriginAndDestinationOption ( $ urlOptions , $ options ) ; $ this -> setViaOption ( $ urlOptions , $ options ) ; $ this -> setDateOption ( $ urlOptions , $ options ) ; $ urlOptions = array_merge ( $ urlOptions , $ options ) ; return sprintf ( 'trip?%s&format=json' , http_build_query ( $ urlOptions ) ) ; } | Create the URL . |
23,406 | private function executeMethod ( array $ arguments ) { if ( $ this -> reflection -> isStatic ( ) ) { return $ this -> reflection -> invokeArgs ( null , $ arguments ) ; } elseif ( is_object ( $ this -> callback [ 0 ] ) ) { return $ this -> reflection -> invokeArgs ( $ this -> callback [ 0 ] , $ arguments ) ; } $ instance = new $ this -> callback [ 0 ] ( ) ; return $ this -> reflection -> invokeArgs ( $ instance , $ arguments ) ; } | Execute the specified callback object method . Works with static calls or instance method . |
23,407 | public function getAdminClasses ( ) { $ classCollection = [ ] ; if ( ! defined ( 'static::ADMIN_KEY' ) ) { return $ classCollection ; } $ classCollection = $ this -> getSubAdminClasses ( \ Flare :: config ( static :: ADMIN_KEY ) ) ; return $ classCollection ; } | Gets Admin classes based on the current users permissions which have been set . If a Admin class has not had the Permissions provided it will be displayed by default . |
23,408 | public function registerSubRoutes ( array $ classes ) { foreach ( $ classes as $ key => $ class ) { if ( is_array ( $ class ) ) { if ( $ this -> usableClass ( $ key ) ) { $ this -> registerAdminRoutes ( $ key ) ; } $ this -> registerSubRoutes ( $ class ) ; continue ; } $ this -> registerAdminRoutes ( $ class ) ; } } | Loops through an array of classes and registers their Route recursively . |
23,409 | public static function randomHex ( int $ length = 128 ) : string { $ bytes = ceil ( $ length / 2 ) ; $ hex = bin2hex ( self :: randomBytes ( $ bytes ) ) ; return $ hex ; } | Returns a random hex of desired length . |
23,410 | 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 now!' ) ; } $ difference = $ max - $ min ; for ( $ power = 8 ; pow ( 2 , $ power ) < $ difference ; $ power = $ power * 2 ) { } $ powerExp = $ power / 8 ; do { $ randDiff = hexdec ( bin2hex ( self :: randomBytes ( $ powerExp ) ) ) ; } while ( $ randDiff > $ difference ) ; return $ min + $ randDiff ; } | Returns a random integer between the provided min and max using random bytes . Throws exception if min and max arguments have inconsistencies . |
23,411 | public static function encrypt ( string $ data , string $ key ) : string { $ method = Configuration :: getSecurityConfiguration ( 'encryption_algorithm' ) ; $ initializationVector = self :: randomBytes ( openssl_cipher_iv_length ( $ method ) ) ; $ cipher = openssl_encrypt ( $ data , $ method , $ key , 0 , $ initializationVector ) ; return base64_encode ( $ initializationVector ) . ':' . base64_encode ( $ cipher ) ; } | Encrypts the given data using the configured encryption algorithm and the provided key . Returns a concatenation of the generated IV and the cipher . Resulting cipher should only be decrypted using the decrypt method . |
23,412 | 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 ( [ self :: USER_ID_KEY => $ user -> getId ( ) , self :: EXP_KEY => $ expirationTimestamp , self :: IAT_KEY => ( new \ DateTime ( ) ) -> getTimestamp ( ) ] , $ user -> getJWTPayload ( ) ) ) ; $ jws -> sign ( $ privateKey ) ; return new AuthTokenModel ( $ jws -> getTokenString ( ) , $ expirationTimestamp ) ; } | Creates a jws token model |
23,413 | public function isValid ( $ token ) { try { $ publicKey = openssl_pkey_get_public ( file_get_contents ( $ this -> projectDir . '/var/jwt/public.pem' ) ) ; $ jws = SimpleJWS :: load ( $ token ) ; return $ jws -> verify ( $ publicKey , self :: ALG ) && $ this -> isTokenNotExpired ( $ token ) ; } catch ( \ InvalidArgumentException $ ex ) { return false ; } } | Returns true if the token is valid |
23,414 | 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 ) ; if ( empty ( $ user ) ) { throw new ProgrammerException ( "Unknown user id in token, " . $ userId , ProgrammerException :: AUTH_TOKEN_NO_USER_WITH_ID_FOUND ) ; } return $ user ; } | Returns the user attached to the token |
23,415 | public function getPayload ( $ token ) { try { $ jws = SimpleJWS :: load ( $ token ) ; return $ jws -> getPayload ( ) ; } catch ( \ InvalidArgumentException $ ex ) { throw new ProgrammerException ( 'Unable to read jws token.' , ProgrammerException :: JWS_INVALID_TOKEN_FORMAT ) ; } } | Gets the payload out of the token . |
23,416 | private function isTokenNotExpired ( $ token ) { $ payload = $ this -> getPayload ( $ token ) ; return isset ( $ payload [ self :: EXP_KEY ] ) && $ payload [ self :: EXP_KEY ] > ( new \ DateTime ( ) ) -> getTimestamp ( ) ; } | Returns true if the token is not expired |
23,417 | public function insert ( $ data , $ priority = 0 ) { $ this -> data [ ] = [ 'data' => $ data , 'priority' => $ priority , ] ; $ priority = array ( $ priority , $ this -> max -- ) ; $ this -> getSplQueue ( ) -> insert ( $ data , $ priority ) ; return $ this ; } | Insert an item into the queue . |
23,418 | public function getController ( ) { if ( ! empty ( $ this -> controller ) ) { return $ this -> controller ; } else { preg_match ( '@(?:m[a-zA-Z0-9]{1,})_([a-zA-Z0-9]{1,})_(?:create)_([^/]+)_(?:table)@i' , get_class ( $ this ) , $ matches ) ; return $ matches [ 2 ] ; } } | Returns the name of the controller |
23,419 | public function createAuthItems ( ) { foreach ( $ this -> privileges as $ privilege ) { $ this -> insert ( 'AuthItem' , [ "name" => $ privilege . '::' . $ this -> getController ( ) , "type" => 0 , "description" => $ privilege . ' ' . $ this -> getController ( ) , "bizrule" => null , "data" => 'a:2:{s:6:"module";s:' . strlen ( $ this -> menu ) . ':"' . $ this -> menu . '";s:10:"controller";s:' . strlen ( $ this -> friendly ( $ this -> getController ( ) ) ) . ':"' . $ this -> friendly ( $ this -> getController ( ) ) . '";}' , ] ) ; $ this -> insert ( 'AuthItemChild' , [ "parent" => 1 , "child" => $ privilege . '::' . $ this -> getController ( ) , ] ) ; } } | Creates the AuthItems for a controller |
23,420 | public function deleteAuthItems ( ) { foreach ( $ this -> privileges as $ privilege ) { $ this -> delete ( 'AuthItem' , "name = '" . $ privilege . '::' . $ this -> getController ( ) . "'" ) ; } } | Deletes the AuthItems for the controller |
23,421 | 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 ; $ last_main_menu = $ query -> from ( 'AdminMenu' ) -> where ( 'AdminMenu_id IS NULL' ) -> orderby ( 'order DESC' ) -> one ( ) ; $ this -> insert ( 'AdminMenu' , [ "name" => $ this -> menu , "internal" => $ this -> menu , "url" => '' , "ap" => 'read::' . $ this -> getController ( ) , "order" => $ last_main_menu ? $ last_main_menu [ 'order' ] + 1 : 1 ] ) ; $ menu_id = $ connection -> getLastInsertID ( ) ; } else { $ menu_id = $ menu [ 'id' ] ; } } else { $ menu_id = NULL ; $ menu_name = $ this -> menu ; } $ query = new Query ; $ last_menu = $ query -> from ( 'AdminMenu' ) -> from ( 'AdminMenu' ) -> where ( 'AdminMenu_id=:AdminMenu_id' , [ ':AdminMenu_id' => $ menu_id ] ) -> orderby ( 'order DESC' ) -> one ( ) ; $ this -> insert ( 'AdminMenu' , [ "AdminMenu_id" => $ menu_id , "name" => $ menu_name , "internal" => $ this -> getController ( ) . 'Controller' , "url" => ( $ this -> module ? '/' . $ this -> module : '' ) . '/' . strtolower ( trim ( preg_replace ( "([A-Z])" , "-$0" , $ this -> getController ( ) ) , '-' ) ) . '/' , "ap" => 'read::' . $ this -> getController ( ) , "order" => $ last_menu ? $ last_menu [ 'order' ] + 1 : 1 ] ) ; } | Inserts the AdminMenus for the controller |
23,422 | public function create ( ) { event ( new BeforeCreate ( $ this ) ) ; $ this -> beforeCreate ( ) ; $ this -> doCreate ( ) ; $ this -> afterCreate ( ) ; event ( new AfterCreate ( $ this ) ) ; } | Create Action . |
23,423 | public function onBootstrap ( MvcEvent $ event ) { $ serviceManager = $ event -> getApplication ( ) -> getServiceManager ( ) ; $ request = $ serviceManager -> get ( 'request' ) ; if ( $ request instanceof ConsoleRequest ) { return ; } $ eventWrapper = $ serviceManager -> get ( \ Rcm \ EventListener \ EventWrapper :: class ) ; $ eventManager = $ event -> getApplication ( ) -> getEventManager ( ) ; $ eventManager -> attach ( MvcEvent :: EVENT_ROUTE , [ $ eventWrapper , 'routeEvent' ] , 10000 ) ; $ eventManager -> attach ( MvcEvent :: EVENT_DISPATCH , [ $ eventWrapper , 'dispatchEvent' ] , 10000 ) ; $ eventManager -> attach ( MvcEvent :: EVENT_FINISH , [ $ eventWrapper , 'finishEvent' ] , 10000 ) ; $ viewEventManager = $ serviceManager -> get ( 'ViewManager' ) -> getView ( ) -> getEventManager ( ) ; $ viewEventManager -> attach ( ViewEvent :: EVENT_RESPONSE , [ $ eventWrapper , 'viewResponseEvent' ] , - 10000 ) ; $ serviceManager -> get ( \ Rcm \ Service \ SessionManager :: class ) -> start ( ) ; } | Bootstrap For RCM . |
23,424 | public function getCompatibilityId ( ) { $ controller = $ this -> getUniqueId ( ) ; if ( strpos ( $ controller , "/" ) ) { $ controller = substr ( $ controller , strpos ( $ controller , "/" ) + 1 ) ; } return str_replace ( ' ' , '' , ucwords ( str_replace ( '-' , ' ' , $ controller ) ) ) ; } | Gets the simple name for the current controller |
23,425 | public function actionIndex ( ) { $ this -> getSearchCriteria ( ) ; $ this -> layout = static :: TABLE_LAYOUT ; return $ this -> render ( 'index' , [ 'searchModel' => $ this -> searchModel , 'dataProvider' => $ this -> dataProvider , ] ) ; } | Lists all the models . |
23,426 | public function getSearchCriteria ( ) { 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 ] ; } if ( count ( Yii :: $ app -> request -> queryParams ) ) { $ queryParams = array_merge ( $ queryParams , Yii :: $ app -> request -> queryParams ) ; } if ( isset ( $ queryParams [ 'page' ] ) ) { $ _GET [ 'page' ] = $ queryParams [ 'page' ] ; } if ( Yii :: $ app -> request -> getIsPjax ( ) ) { $ this -> layout = false ; } Yii :: $ app -> session -> set ( $ this -> MainModel . 'QueryParams' , $ queryParams ) ; $ this -> searchModel = new $ this -> MainModelSearch ; $ this -> dataProvider = $ this -> searchModel -> search ( $ queryParams ) ; } | creates the search criteria for the model |
23,427 | 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' ) ; Yii :: $ app -> response -> getHeaders ( ) -> set ( 'Content-Disposition' , 'attachment; filename="' . $ this -> getCompatibilityId ( ) . '.pdf"' ) ; return $ mpdf -> Output ( $ this -> getCompatibilityId ( ) . '.pdf' , 'S' ) ; } } | Creates a PDF file with the current list of the models |
23,428 | public function actionPagination ( ) { Yii :: $ app -> session -> set ( $ this -> MainModel . 'Pagination' , Yii :: $ app -> request -> queryParams [ 'records' ] ) ; $ this -> redirect ( [ 'index' ] ) ; } | Sets the pagination for the list |
23,429 | public function actionCreate ( ) { $ this -> layout = static :: FORM_LAYOUT ; $ model = new $ this -> MainModel ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { $ this -> afterCreate ( $ model ) ; if ( $ this -> hasView ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } else { return $ this -> redirect ( [ 'index' ] ) ; } } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } } | Creates a new model . If creation is successful the browser will be redirected to the view or index page . |
23,430 | 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 = $ model -> { $ historyField } ; $ history -> type = $ url_components [ 2 ] ; $ history -> url = Url :: toRoute ( [ 'update' , 'id' => $ model -> id ] ) ; $ history -> save ( ) ; } } | Saves the history for the model |
23,431 | 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 ) ; if ( $ this -> hasView ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } else { return $ this -> redirect ( [ 'index' ] ) ; } } else { return $ this -> render ( 'update' , [ 'model' => $ model , ] ) ; } } | Updates an existing model . If update is successful the browser will be redirected to the view or index page . |
23,432 | public function allButtons ( ) { $ buttons = [ ] ; if ( \ Yii :: $ app -> user -> checkAccess ( 'read::' . $ this -> getCompatibilityId ( ) ) ) { $ buttons [ 'pdf' ] = [ 'text' => 'Download PDF' , 'url' => Url :: toRoute ( [ 'pdf' ] ) , 'options' => [ 'target' => '_blank' , ] ] ; $ buttons [ 'csv' ] = [ 'text' => 'Download CSV' , 'url' => Url :: toRoute ( [ 'csv' ] ) , 'options' => [ 'target' => '_blank' , ] ] ; } return $ buttons ; } | Sets the buttons that can be performed on the entire result |
23,433 | public function setSiteLayout ( MvcEvent $ event ) { $ viewModel = $ event -> getViewModel ( ) ; $ 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 ) ; $ currentSite = $ this -> getCurrentSite ( ) ; $ viewModel -> setVariable ( 'page' , $ fakePage ) ; $ viewModel -> setVariable ( 'site' , $ currentSite ) ; $ template = $ this -> getSiteLayoutTemplate ( ) ; $ viewModel -> setTemplate ( 'layout/' . $ template ) ; return null ; } | Set Site Layout |
23,434 | private function getUserById ( $ id ) { $ user = $ this -> userService -> findUserById ( $ id ) ; if ( empty ( $ user ) ) { throw $ this -> createNotFoundException ( 'user not found' ) ; } return $ user ; } | Gets the user by the user s id |
23,435 | public function getAsset ( $ asset ) { if ( ! isset ( $ this -> assetCache [ $ asset ] ) ) { $ this -> assetCache [ $ asset ] = $ this -> assetRepository -> createAsset ( $ asset ) ; } return $ this -> assetCache [ $ asset ] ; } | Return asset file object |
23,436 | 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 ) ; $ url = preg_replace ( "/[\s-]+/" , " " , $ url ) ; $ url = trim ( $ url ) ; return preg_replace ( "/[\s_]/" , "-" , $ url ) ; } | Returns a SEO compatible url based on the specified string . Be sure to check the LC_CTYPE locale setting if getting any question marks in result . Run locale - a on server to see full list of supported locales . |
23,437 | public function transform ( $ user ) { if ( empty ( $ user ) ) { $ className = $ this -> userService -> getUserClass ( ) ; return new $ className ( ) ; } return $ user ; } | This always return null or the full object because we transforming the whole form with this transformer |
23,438 | 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 { $ event = new Event ( $ this -> eventBase , $ stream , Event :: PERSIST | $ flag , $ this -> streamCallback ) ; $ this -> streamEvents [ $ key ] = $ event ; $ this -> streamFlags [ $ key ] = $ flag ; } $ event -> add ( ) ; } | Create a new ext - event Event object or update the existing one . |
23,439 | private function unsubscribeStreamEvent ( $ stream , $ flag ) { $ key = ( int ) $ stream ; $ flags = $ this -> streamFlags [ $ key ] &= ~ $ flag ; if ( 0 === $ flags ) { $ this -> removeStream ( $ stream ) ; return ; } $ event = $ this -> streamEvents [ $ key ] ; $ event -> del ( ) ; $ event -> set ( $ this -> eventBase , $ stream , Event :: PERSIST | $ flags , $ this -> streamCallback ) ; $ event -> add ( ) ; } | Update the ext - event Event object for this stream to stop listening to the given event type or remove it entirely if it s no longer needed . |
23,440 | public static function enumFonts ( ) { return [ FontAwesomeIconInterface :: FONT_AWESOME_FONT , FontAwesomeIconInterface :: FONT_AWESOME_FONT_BOLD , FontAwesomeIconInterface :: FONT_AWESOME_FONT_LIGHT , FontAwesomeIconInterface :: FONT_AWESOME_FONT_REGULAR , FontAwesomeIconInterface :: FONT_AWESOME_FONT_SOLID , ] ; } | Enumerates the fonts . |
23,441 | public function deleteInternal ( ) { $ result = false ; if ( $ this -> beforeDelete ( ) ) { $ condition = $ this -> getOldPrimaryKey ( true ) ; $ lock = $ this -> optimisticLock ( ) ; if ( $ lock !== null ) { $ condition [ $ lock ] = $ this -> $ lock ; } $ this -> status = self :: STATUS_DELETED ; $ result = $ this -> save ( false ) ; if ( $ lock !== null && ! $ result ) { throw new StaleObjectException ( 'The object being deleted is outdated.' ) ; } $ this -> setOldAttributes ( null ) ; $ this -> afterDelete ( ) ; } return $ result ; } | Marks an ActiveRecord as deleted in the database . |
23,442 | 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' => is_int ( $ this -> user_id ) ? $ this -> user -> avatar : get_avatar ( $ this -> email ) , 'isOnline' => is_int ( $ this -> user_id ) ? $ this -> user -> isOnline ( ) : false , ] ; } | Don t touch this . Need when comments added from ajax |
23,443 | public function setCoordinate ( Coordinate $ coordinate ) : self { $ this -> options [ 'coordX' ] = $ coordinate -> getLatitude ( ) ; $ this -> options [ 'coordY' ] = $ coordinate -> getLongitude ( ) ; return $ this ; } | Set coordinate to get nearby stops . |
23,444 | public function onAuthenticationSuccess ( Request $ request , TokenInterface $ token , $ providerKey ) { $ user = $ token -> getUser ( ) ; $ this -> dispatcher -> dispatch ( self :: OAUTH_LOGIN_SUCCESS , new UserEvent ( $ user ) ) ; return $ this -> authResponseService -> authenticateResponse ( $ user , new Response ( $ this -> twig -> render ( '@StarterKitStart/oauth-success.html.twig' ) ) ) ; } | 5a ) Return an authorized response . |
23,445 | public function onAuthenticationFailure ( Request $ request , AuthenticationException $ exception ) { $ this -> dispatcher -> dispatch ( self :: OAUTH_LOGIN_FAILURE , new AuthFailedEvent ( $ request , $ exception ) ) ; return $ this -> removeAuthCookieFromResponse ( new Response ( $ this -> twig -> render ( '@StarterKitStart/oauth-failure.html.twig' , [ 'login_path' => $ this -> loginPath ] ) ) ) ; } | 5a ) Returns a 403 . |
23,446 | public function start ( Request $ request , AuthenticationException $ authException = null ) { return new Response ( $ this -> twig -> render ( '@StarterKitStart/oauth-start.html.twig' , [ 'login_path' => $ this -> loginPath ] ) ) ; } | This will be fired when the user clicks cancel on slack or third party site . This page will redirect the user back to the login path . |
23,447 | public function actionLogin ( ) { $ model = new LoginForm ( ) ; if ( $ this -> getLoginAttempts ( ) >= $ this -> module -> attemptsBeforeCaptcha ) { $ model -> scenario = 'withCaptcha' ; } if ( Yii :: $ app -> request -> post ( ) ) { if ( $ model -> load ( $ _POST ) && $ model -> login ( ) ) { $ this -> setLoginAttempts ( 0 ) ; return $ this -> goBack ( ) ; } else { $ this -> setLoginAttempts ( $ this -> getLoginAttempts ( ) + 1 ) ; } } return $ this -> render ( 'login' , [ 'model' => $ model , ] ) ; } | Shows the login form |
23,448 | public function pagePermissionsAction ( ) { $ view = new ViewModel ( ) ; $ view -> setTerminal ( true ) ; $ 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' ) ; $ resourceName = $ this -> getServiceLocator ( ) -> get ( ResourceName :: class ) ; $ resourceId = $ resourceName -> get ( ResourceName :: RESOURCE_SITES , $ currentSiteId , ResourceName :: RESOURCE_PAGES , $ pageType , $ sourcePageName ) ; $ aclDataService = $ this -> getServiceLocator ( ) -> get ( \ RcmUser \ Acl \ Service \ AclDataService :: class ) ; $ rules = $ aclDataService -> getRulesByResource ( $ resourceId ) -> getData ( ) ; $ allRoles = $ aclDataService -> getNamespacedRoles ( ) -> getData ( ) ; $ rolesHasRules = [ ] ; foreach ( $ rules as $ setRuleFor ) { if ( $ setRuleFor -> getRule ( ) == 'allow' ) { $ rolesHasRules [ ] = $ setRuleFor -> getRoleId ( ) ; } } $ selectedRoles = [ ] ; foreach ( $ allRoles as $ key => $ role ) { $ roleId = $ role -> getRoleId ( ) ; if ( in_array ( $ roleId , $ rolesHasRules ) ) { $ selectedRoles [ $ roleId ] = $ role ; } } $ data = [ 'siteId' => $ currentSiteId , 'pageType' => $ pageType , 'pageName' => $ sourcePageName , 'roles' => $ allRoles , 'selectedRoles' => $ selectedRoles , ] ; $ view -> setVariable ( 'data' , $ data ) ; $ view -> setVariable ( 'rcmPageName' , $ sourcePageName ) ; $ view -> setVariable ( 'rcmPageType' , $ pageType ) ; return $ view ; } | Getting all Roles list and rules if role has one |
23,449 | public function singleView ( ) { return [ 'id' => $ this -> getId ( ) , 'displayName' => $ this -> getDisplayName ( ) , 'roles' => $ this -> getRoles ( ) , 'email' => $ this -> getEmail ( ) , 'bio' => $ this -> getBio ( ) ] ; } | Return an array of the view for displaying as a single item |
23,450 | public function updateCron ( EdgarEzCron $ data , ? string $ name = null ) : ? FormInterface { $ name = $ name ? : sprintf ( 'update-cron-%s' , $ data -> getAlias ( ) ) ; return $ this -> formFactory -> createNamed ( $ name , CronType :: class , $ data , [ 'method' => Request :: METHOD_POST , 'csrf_protection' => true , ] ) ; } | Cron form interface . |
23,451 | private static function isLinkOnlyRelation ( \ ReflectionClass $ class , $ name ) { $ getterName = 'get' . Inflector :: camelize ( $ name ) ; return ! $ class -> hasMethod ( $ getterName ) || ! Reflection :: isMethodGetter ( $ class -> getMethod ( $ getterName ) ) ; } | Para relaciones que no van en el campo links del resource object . |
23,452 | 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 ] [ ] = $ paths ; } } else { $ this -> namespaces [ $ namespace ] = ( array ) $ paths ; } return $ this ; } | Register a namespace . |
23,453 | public function attachPearPrefixes ( array $ classes ) { foreach ( $ classes as $ prefix => $ paths ) { $ this -> attachPearPrefix ( $ prefix , $ paths ) ; } return $ this ; } | Registers an array of classes using the Pear naming convention |
23,454 | public function setValue ( $ name , $ value ) { unset ( $ this -> factories [ $ name ] ) ; $ this -> cache [ $ name ] = $ value ; } | Set a value to be later returned as is . You only need to use this if you wish to store a Closure . |
23,455 | 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 ] ; $ newFactory = function ( Container $ c ) use ( $ extender , $ factory ) { return call_user_func ( $ extender , call_user_func ( $ factory , $ c ) , $ c ) ; } ; $ this -> setFactory ( $ name , $ newFactory ) ; return $ newFactory ; } | Add a function that gets applied to the return value of an existing factory |
23,456 | public function getKeys ( ) { $ keys = array_keys ( $ this -> cache ) + array_keys ( $ this -> factories ) ; return array_unique ( $ keys ) ; } | Get all keys available |
23,457 | public static function isValid ( $ string ) { if ( is_int ( $ string ) || is_float ( $ string ) ) { return true ; } json_decode ( $ string ) ; return json_last_error ( ) === JSON_ERROR_NONE ; } | Validates JSON input . |
23,458 | protected function adminController ( $ route = null ) { if ( $ route ) { return $ this -> namespace . '\\' . $ this -> compatibilityVersion . '\AdminController@' . $ route ; } return $ this -> namespace . '\\' . $ this -> compatibilityVersion . '\AdminController' ; } | Return the Controller or Controller and Route if provided . |
23,459 | public function run ( ) { $ this -> controller -> getSearchCriteria ( ) ; $ this -> controller -> dataProvider -> pagination = false ; $ query = $ this -> controller -> dataProvider -> query ; $ config = new ExporterConfig ( ) ; $ exporter = new Exporter ( $ config ) ; $ result = $ query -> asArray ( ) -> all ( ) ; $ fields = $ this -> fields ; $ values = array_map ( function ( $ ar ) use ( $ fields ) { $ return = [ ] ; foreach ( $ fields as $ field ) { $ keyString = "['" . str_replace ( '.' , "']['" , $ field ) . "']" ; eval ( "\$return[] = \$ar" . $ keyString . ";" ) ; } return $ return ; } , $ result ) ; if ( isset ( $ _GET [ 'test' ] ) ) { return json_encode ( array_merge ( [ $ this -> fields ] , $ values ) ) ; } else { $ this -> setHttpHeaders ( 'csv' , $ this -> controller -> getCompatibilityId ( ) , 'text/plain' ) ; $ exporter -> export ( 'php://output' , array_merge ( [ $ this -> fields ] , $ values ) ) ; } } | Creates the pdf file for download |
23,460 | protected function setHttpHeaders ( $ type , $ name , $ mime , $ encoding = 'utf-8' ) { Yii :: $ app -> response -> format = Response :: FORMAT_RAW ; if ( strstr ( $ _SERVER [ "HTTP_USER_AGENT" ] , "MSIE" ) == false ) { header ( "Cache-Control: no-cache" ) ; header ( "Pragma: no-cache" ) ; } else { header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Pragma: public" ) ; } header ( "Expires: Sat, 26 Jul 1979 05:00:00 GMT" ) ; header ( "Content-Encoding: {$encoding}" ) ; header ( "Content-Type: {$mime}; charset={$encoding}" ) ; header ( "Content-Disposition: attachment; filename={$name}.{$type}" ) ; header ( "Cache-Control: max-age=0" ) ; } | Sets the HTTP headers needed by file download action . |
23,461 | public function getResource ( $ resourceId ) { if ( isset ( $ this -> resources [ $ resourceId ] ) ) { return $ this -> resources [ $ resourceId ] ; } $ dynamicResource = $ this -> dynamicResourceMapper ( $ resourceId ) ; if ( ! empty ( $ dynamicResource ) ) { return $ dynamicResource ; } return null ; } | getResource Return the requested resource Can be used to return resources dynamically at run - time |
23,462 | protected function dynamicResourceMapper ( $ resourceId ) { $ resource = $ this -> pageResourceMapper ( $ resourceId ) ; if ( ! empty ( $ resource ) ) { return $ resource ; } $ resource = $ this -> siteResourceMapper ( $ resourceId ) ; if ( ! empty ( $ resource ) ) { return $ resource ; } return null ; } | Dynamic Resource Mapper for Get Resource |
23,463 | protected function pageResourceMapper ( $ resourceId ) { if ( ! $ this -> resourceName -> isPagesResourceId ( $ resourceId ) ) { return null ; } $ resources = explode ( '.' , $ resourceId ) ; if ( empty ( $ resources [ 1 ] ) ) { return null ; } $ siteResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ resources [ 1 ] ) ; $ return = [ 'resourceId' => $ resourceId , 'parentResourceId' => $ siteResourceId , ] ; if ( $ this -> resourceName -> isPageResourceId ( $ resourceId ) ) { $ pagesResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ resources [ 1 ] , self :: RESOURCE_PAGES ) ; $ return [ 'parentResourceId' ] = $ pagesResourceId ; } return array_merge ( $ this -> resources [ self :: RESOURCE_PAGES ] , $ return ) ; } | Page Resource Mapper |
23,464 | protected function siteResourceMapper ( $ resourceId ) { if ( ! $ this -> resourceName -> isSitesResourceId ( $ resourceId ) ) { return null ; } $ sitesResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES ) ; $ return = [ 'resourceId' => $ resourceId , 'parentResourceId' => $ sitesResourceId , ] ; return array_merge ( $ this -> resources [ self :: RESOURCE_SITES ] , $ return ) ; } | Site Resource Mapper |
23,465 | protected function getSiteResources ( Site $ site ) { $ primaryDomain = $ site -> getDomain ( ) ; if ( empty ( $ primaryDomain ) ) { return array ( ) ; } $ primaryDomainName = $ primaryDomain -> getDomainName ( ) ; $ siteId = $ site -> getSiteId ( ) ; $ sitesResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES ) ; $ siteResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ siteId ) ; $ return [ $ siteResourceId ] = [ 'resourceId' => $ siteResourceId , 'parentResourceId' => $ sitesResourceId , 'name' => $ primaryDomainName , 'description' => "Resource for site '{$primaryDomainName}'" ] ; $ return [ $ siteResourceId ] = array_merge ( $ this -> resources [ $ sitesResourceId ] , $ return [ $ siteResourceId ] ) ; $ pagesResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ siteId , self :: RESOURCE_PAGES ) ; $ return [ $ pagesResourceId ] = [ 'resourceId' => $ pagesResourceId , 'parentResourceId' => $ siteResourceId , 'name' => $ primaryDomainName . ' - pages' , 'description' => "Resource for pages on site '{$primaryDomainName}'" ] ; $ return [ $ pagesResourceId ] = array_merge ( $ this -> resources [ self :: RESOURCE_PAGES ] , $ return [ $ pagesResourceId ] ) ; $ pages = $ site -> getPages ( ) ; foreach ( $ pages as & $ page ) { $ pageResources = $ this -> getPageResources ( $ page , $ site ) ; $ return = array_merge ( $ pageResources , $ return ) ; } return $ return ; } | Get all resources for a site |
23,466 | protected function getPageResources ( Page $ page , Site $ site ) { $ primaryDomainName = $ site -> getDomain ( ) -> getDomainName ( ) ; $ siteId = $ site -> getSiteId ( ) ; $ pageName = $ page -> getName ( ) ; $ pageType = $ page -> getPageType ( ) ; $ pagesResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ siteId , self :: RESOURCE_PAGES ) ; $ pageResourceId = $ this -> resourceName -> get ( self :: RESOURCE_SITES , $ siteId , self :: RESOURCE_PAGES , $ pageType , $ pageName ) ; $ return [ $ pageResourceId ] = [ 'resourceId' => $ pageResourceId , 'parentResourceId' => $ pagesResourceId , 'name' => $ primaryDomainName . ' - pages - ' . $ pageName , 'description' => "Resource for page '{$pageName}'" . " of type '{$pageType}' on site '{$primaryDomainName}'" ] ; $ return [ $ pageResourceId ] = array_merge ( $ this -> resources [ self :: RESOURCE_PAGES ] , $ return [ $ pageResourceId ] ) ; return $ return ; } | Get all Page Resources |
23,467 | 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 ) ; event_set ( $ event , $ stream , EV_PERSIST | $ flags , $ this -> streamCallback ) ; } else { $ event = event_new ( ) ; event_set ( $ event , $ stream , EV_PERSIST | $ flag , $ this -> streamCallback ) ; event_base_set ( $ event , $ this -> eventBase ) ; $ this -> streamEvents [ $ key ] = $ event ; $ this -> streamFlags [ $ key ] = $ flag ; } event_add ( $ event ) ; } | Create a new ext - libevent event resource or update the existing one . |
23,468 | private function unsubscribeStreamEvent ( $ stream , $ flag ) { $ key = ( int ) $ stream ; $ flags = $ this -> streamFlags [ $ key ] &= ~ $ flag ; if ( 0 === $ flags ) { $ this -> removeStream ( $ stream ) ; return ; } $ event = $ this -> streamEvents [ $ key ] ; event_del ( $ event ) ; event_set ( $ event , $ stream , EV_PERSIST | $ flags , $ this -> streamCallback ) ; event_add ( $ event ) ; } | Update the ext - libevent event resource for this stream to stop listening to the given event type or remove it entirely if it s no longer needed . |
23,469 | public function afterForkChild ( ) { unset ( $ this -> eventBase ) ; unset ( $ this -> nextTickQueue ) ; unset ( $ this -> futureTickQueue ) ; unset ( $ this -> timerEvents ) ; unset ( $ this -> running ) ; $ this -> streamEvents = array ( ) ; $ this -> streamFlags = array ( ) ; $ this -> readListeners = array ( ) ; $ this -> writeListeners = array ( ) ; $ this -> __construct ( ) ; return $ this ; } | called after each fork in child instance . should clean up ever resource bound to the parent process and should return an new stable instance or itself if reusable |
23,470 | public function getCategoryAttribute ( ) { if ( is_null ( $ category = $ this -> categories -> last ( ) ) ) { $ category = new \ stdClass ( ) ; $ category -> title = 'No name' ; $ category -> slug = 'none' ; $ category -> alt_url = null ; $ category -> template = null ; } return $ category ; } | Get a attributes to first category |
23,471 | public function renderErrors ( $ errors ) { if ( empty ( $ errors ) ) { return null ; } $ message = '' ; foreach ( $ errors as & $ error ) { foreach ( $ error as $ errorCode => & $ errorMsg ) { $ message .= $ this -> errorMapper ( $ errorCode , $ errorMsg ) ; } } return $ message ; } | Render errors in html |
23,472 | public function index ( ) { pageinfo ( [ 'title' => setting ( 'system.meta_title' , 'BixBite' ) , 'description' => setting ( 'system.meta_description' , 'BixBite - Content Management System' ) , 'keywords' => setting ( 'system.meta_keywords' , 'BixBite CMS, BBCMS, CMS' ) , 'onHomePage' => true , ] ) ; if ( ! setting ( 'themes.home_page_personalized' , false ) ) { return app ( '\BBCMS\Http\Controllers\ArticlesController' ) -> index ( ) ; } return $ this -> makeResponse ( 'index' ) ; } | Show the application home page . |
23,473 | public static function buildFromConfiguration ( ) : Database { if ( ! is_null ( self :: $ sharedInstance ) ) { return self :: $ sharedInstance ; } $ config = Configuration :: getDatabaseConfiguration ( ) ; $ instance = self :: initializeFromConfiguration ( $ config ) ; if ( $ config [ 'shared' ] ?? false ) { self :: $ sharedInstance = $ instance ; } return $ instance ; } | Constructs a database instance from the defined configurations . |
23,474 | protected static function activeNodes ( Request $ request , array $ nodes = [ ] , $ level = 0 ) { $ result = false ; foreach ( $ nodes as $ n ) { if ( false === ( $ n instanceof AbstractNavigationNode ) ) { continue ; } if ( true === self :: nodeMatch ( $ n , $ request ) ) { $ current = true ; } else { $ current = self :: activeNodes ( $ request , $ n -> getNodes ( ) , $ level + 1 ) ; } if ( false === $ current ) { continue ; } $ n -> setActive ( true ) ; $ result = true ; } return $ result ; } | Actives the nodes . |
23,475 | public static function activeTree ( NavigationTree $ tree , Request $ request ) { self :: activeNodes ( $ request , $ tree -> getNodes ( ) ) ; } | Active the tree . |
23,476 | public static function getBreadcrumbs ( AbstractNavigationNode $ node ) { $ breadcrumbs = [ ] ; if ( true === ( $ node instanceof NavigationNode || $ node instanceof BreadcrumbNode ) && true === $ node -> getActive ( ) ) { $ breadcrumbs [ ] = $ node ; } foreach ( $ node -> getNodes ( ) as $ current ) { if ( false === ( $ current instanceof AbstractNavigationNode ) ) { continue ; } $ breadcrumbs = array_merge ( $ breadcrumbs , self :: getBreadcrumbs ( $ current ) ) ; } return $ breadcrumbs ; } | Get the breadcrumbs . |
23,477 | protected static function nodeMatch ( AbstractNavigationNode $ node , Request $ request ) { $ result = false ; switch ( $ node -> getMatcher ( ) ) { case NavigationInterface :: NAVIGATION_MATCHER_REGEXP : $ result = preg_match ( "/" . $ node -> getUri ( ) . "/" , $ request -> getUri ( ) ) ; break ; case NavigationInterface :: NAVIGATION_MATCHER_ROUTER : $ result = $ request -> get ( "_route" ) === $ node -> getUri ( ) ; break ; case NavigationInterface :: NAVIGATION_MATCHER_URL : $ result = $ request -> getUri ( ) === $ node -> getUri ( ) || $ request -> getRequestUri ( ) === $ node -> getUri ( ) ; break ; } return boolval ( $ result ) ; } | Determines if a node match an URL . |
23,478 | public function buildForm ( FormBuilderInterface $ builder , array $ options ) { $ builder -> add ( 'expression' , TextType :: class , [ 'required' => true , 'constraints' => [ new ExpressionConstraint ( ) ] , ] ) -> add ( 'arguments' , TextType :: class , [ 'required' => false , 'constraints' => [ new ArgumentsConstraint ( ) ] , ] ) -> add ( 'priority' , IntegerType :: class , [ 'required' => true , ] ) -> add ( 'enabled' , CheckboxType :: class , [ 'required' => false , ] ) -> add ( 'update' , SubmitType :: class , [ 'label' => 'cron_update_form.update' , ] ) ; } | Build cron form . |
23,479 | public static function protocolHostPort ( ) { if ( RequestHelper :: isCli ( ) ) { return null ; } $ isHttps = RequestHelper :: isHttps ( ) ; $ protocol = 'http' . ( $ isHttps ? 's' : '' ) ; $ serverName = $ _SERVER [ 'SERVER_NAME' ] ; $ serverPort = ( int ) $ _SERVER [ 'SERVER_PORT' ] ; $ protocolHostPort = $ protocol . '://' ; if ( ( ! $ isHttps && $ serverPort !== 80 ) || ( $ isHttps && $ serverPort !== 443 ) ) { $ protocolHostPort .= $ serverName . ':' . $ serverPort ; } else { $ protocolHostPort .= $ serverName ; } return $ protocolHostPort ; } | Returns string of protocol server name and port of server - side configured values . |
23,480 | public static function query ( array $ parameters = null , bool $ mergeGetVariables = true ) { if ( $ mergeGetVariables ) { if ( $ parameters === null ) { $ parameters = $ _GET ; } else { $ parameters = array_replace_recursive ( $ _GET , $ parameters ) ; } } if ( empty ( $ parameters ) ) { return null ; } $ query = http_build_query ( $ parameters , '' , '&' ) ; return ( $ query === '' ) ? '' : ( '?' . $ query ) ; } | Builds query part of url . |
23,481 | protected function makeResponse ( string $ template , array $ vars = [ ] ) { if ( request ( ) -> ajax ( ) ) { return $ this -> jsonOutput ( $ vars ) ; } return $ this -> renderOutput ( $ template , $ vars ) ; } | Make response description . |
23,482 | public function jQueryInputMaskPhoneNumberFunction ( array $ args = [ ] ) { $ defaultMask = "99 99 99 99 99" ; return $ this -> jQueryInputMask ( ArrayHelper :: get ( $ args , "selector" ) , $ defaultMask , $ this -> prepareOptions ( $ args , $ defaultMask ) , ArrayHelper :: get ( $ args , "scriptTag" , false ) ) ; } | Displays a jQuery input mask Phone number . |
23,483 | public function jQueryInputMaskTime12Function ( array $ args = [ ] ) { $ defaultMask = "hh:mm t" ; return $ this -> jQueryInputMask ( ArrayHelper :: get ( $ args , "selector" ) , $ defaultMask , array_merge ( $ this -> prepareOptions ( $ args , null ) , [ "hourFormat" => "12" , "placeholder" => "__:__ _m" ] ) , ArrayHelper :: get ( $ args , "scriptTag" , false ) ) ; } | Displays a jQuery input mask Time 12 hour . |
23,484 | public function viewResponseEvent ( ViewEvent $ event ) { $ viewEventListener = $ this -> serviceLocator -> get ( \ Rcm \ EventListener \ ViewEventListener :: class ) ; $ return = $ viewEventListener -> processRcmResponses ( $ event ) ; if ( ! empty ( $ return ) ) { return $ return ; } return null ; } | View Response Event |
23,485 | public function actionSave ( ) { $ post = Yii :: $ app -> request -> post ( ) ; $ id = $ post [ 'Note' ] [ 'id' ] ; if ( $ id ) { $ model = Note :: findOne ( $ id ) ; } else { $ model = new Note ; } Yii :: $ app -> response -> format = 'json' ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return [ 'success' => true ] ; } else { return [ 'success' => false , 'errors' => $ model -> getErrors ( ) ] ; } } | Saves a model . If creation is successful the browser will be redirected to the view or index page . |
23,486 | protected function init_handlers ( ) { $ keys = [ self :: KEY_SCRIPTS , self :: KEY_STYLES ] ; foreach ( $ keys as $ key ) { if ( $ this -> hasConfigKey ( $ key ) ) { $ this -> add_handler ( $ key ) ; } } } | Initialize the dependency handlers . |
23,487 | protected function add_handler ( $ dependency ) { if ( $ this -> hasConfigKey ( $ dependency ) ) { $ handler = $ this -> hasConfigKey ( self :: KEY_HANDLERS , $ dependency ) ? $ this -> getConfigKey ( self :: KEY_HANDLERS , $ dependency ) : $ this -> get_default_handler ( $ dependency ) ; if ( $ handler ) { $ this -> handlers [ $ dependency ] = new $ handler ; } } } | Add a single dependency handler . |
23,488 | protected function get_default_handler ( $ dependency ) { switch ( $ dependency ) { case self :: KEY_STYLES : return self :: DEFAULT_STYLE_HANDLER ; case self :: KEY_SCRIPTS : return self :: DEFAULT_SCRIPT_HANDLER ; default : return null ; } } | Get the default handler class for a given type of dependency . |
23,489 | protected function init_dependencies ( ) { array_walk ( $ this -> handlers , function ( $ handler , $ dependency_type ) { if ( $ this -> hasConfigKey ( $ dependency_type ) ) { $ this -> dependencies [ $ dependency_type ] = $ this -> init_dependency_type ( $ dependency_type ) ; } } ) ; } | Initialize the actual dependencies . |
23,490 | protected function init_dependency_type ( $ type ) { $ array = [ ] ; $ data = $ this -> getConfigKey ( $ type ) ; foreach ( $ data as $ dependency ) { $ handle = array_key_exists ( 'handle' , $ dependency ) ? $ dependency [ 'handle' ] : '' ; $ array [ $ handle ] = $ dependency ; } return $ array ; } | Initialize the dependencies of a given type . |
23,491 | public function register ( $ context = null ) { $ context = $ this -> validate_context ( $ context ) ; array_walk ( $ this -> dependencies , [ $ this , 'register_dependency_type' ] , $ context ) ; } | Register all dependencies . |
23,492 | public function enqueue ( $ context = null ) { $ context = $ this -> validate_context ( $ context ) ; array_walk ( $ this -> dependencies , [ $ this , 'enqueue_dependency_type' ] , $ context ) ; } | Enqueue all dependencies . |
23,493 | public function enqueue_handle ( $ handle , $ context = null , $ fallback = false ) { if ( ! $ this -> enqueue_internal_handle ( $ handle , $ context ) ) { return $ this -> enqueue_fallback_handle ( $ handle ) ; } return true ; } | Enqueue a single dependency retrieved by its handle . |
23,494 | protected function enqueue_internal_handle ( $ handle , $ context = null ) { list ( $ dependency_type , $ dependency ) = $ this -> get_dependency_array ( $ handle ) ; $ context [ 'dependency_type' ] = $ dependency_type ; if ( ! $ dependency ) { return false ; } $ this -> enqueue_dependency ( $ dependency , $ handle , $ context ) ; $ this -> maybe_localize ( $ dependency , $ context ) ; $ this -> maybe_add_inline_script ( $ dependency , $ context ) ; return true ; } | Enqueue a single dependency from the internal dependencies retrieved by its handle . |
23,495 | protected function get_dependency_array ( $ handle ) { foreach ( $ this -> dependencies as $ type => $ dependencies ) { if ( array_key_exists ( $ handle , $ dependencies ) ) { return [ $ type , $ dependencies [ $ handle ] ] ; } } return [ '' , null ] ; } | Get the matching dependency for a given handle . |
23,496 | protected function enqueue_dependency ( $ dependency , $ dependency_key , $ context = null ) { if ( ! $ this -> is_needed ( $ dependency , $ context ) ) { return ; } $ handler = $ this -> handlers [ $ context [ 'dependency_type' ] ] ; $ handler -> enqueue ( $ dependency ) ; } | Enqueue a single dependency . |
23,497 | protected function is_needed ( $ dependency , $ context ) { $ is_needed = array_key_exists ( 'is_needed' , $ dependency ) ? $ dependency [ 'is_needed' ] : null ; if ( null === $ is_needed ) { return true ; } return is_callable ( $ is_needed ) && $ is_needed ( $ context ) ; } | Check whether a specific dependency is needed . |
23,498 | protected function maybe_localize ( $ dependency , $ context ) { if ( ! array_key_exists ( 'localize' , $ dependency ) ) { return ; } $ localize = $ dependency [ 'localize' ] ; $ data = $ localize [ 'data' ] ; if ( is_callable ( $ data ) ) { $ data = $ data ( $ context ) ; } wp_localize_script ( $ dependency [ 'handle' ] , $ localize [ 'name' ] , $ data ) ; } | Localize the script of a given dependency . |
23,499 | protected function maybe_add_inline_script ( $ dependency , $ context ) { if ( ! array_key_exists ( 'add_inline' , $ dependency ) ) { return ; } $ inline_script = $ dependency [ 'add_inline' ] ; if ( is_callable ( $ inline_script ) ) { $ inline_script = $ inline_script ( $ context ) ; } wp_add_inline_script ( $ dependency [ 'handle' ] , $ inline_script ) ; } | Add an inline script snippet to a given dependency . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.