idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
58,400
|
public function setTooltip ( $ txt , $ placement = null , $ html = null , $ container = null , $ delay = null ) { if ( Container :: getDevice ( ) -> isMobileOrTablet ( ) ) { return $ this ; } if ( $ txt === null || $ txt === '' ) { $ this -> tooltip = null ; $ this -> tooltipOptions = [ ] ; } $ this -> tooltip = ( string ) $ txt ; $ placement !== null && Checkers :: checkPlacement ( $ placement ) ; $ placement !== null && $ this -> tooltipOptions [ 'data-placement' ] = $ placement ; $ html !== null && $ this -> tooltipOptions [ 'data-html' ] = ( int ) ( bool ) $ html ; $ container !== null && $ this -> tooltipOptions [ 'data-container' ] = ( string ) $ container ; $ delay !== null && $ this -> tooltipOptions [ 'data-delay' ] = ( int ) $ delay ; return $ this ; }
|
Set the tooltip
|
58,401
|
public function getTooltipAttributes ( ) : array { if ( $ this -> tooltip !== null ) { $ attrs = $ this -> tooltipOptions ; $ attrs [ 'data-toggle' ] = 'tooltip' ; $ attrs [ 'title' ] = $ this -> tooltip ; return $ attrs ; } return [ ] ; }
|
Attributes to add to an element
|
58,402
|
protected function addThemes ( Theme $ theme , $ config ) { if ( ! is_array ( $ config ) && ! ( $ config instanceof \ Traversable ) ) { return $ this ; } foreach ( $ config as $ name => $ conf ) { if ( ! isset ( $ conf [ 'path' ] ) ) { continue ; } $ theme -> addLocation ( $ name , $ conf [ 'path' ] ) ; } return $ this ; }
|
Add config themes
|
58,403
|
public function verifyRegistration ( TokenEntity $ token ) { if ( $ token -> isNew ( ) ) { throw new OutOfBoundsException ( 'NOT_FOUND' , self :: TOKEN_NOT_FOUND ) ; } if ( ( int ) $ token -> getTokenTypeId ( ) !== TokenEntity :: TYPE_VERIFY_REGISTRATION ) { throw new OutOfBoundsException ( 'NOT_FOUND' , self :: INCORRECT_TOKEN_TYPE ) ; } if ( $ token -> getExpires ( ) < time ( ) ) { throw new OutOfBoundsException ( 'EXPIRED' , self :: TOKEN_EXPIRED ) ; } $ user = $ this -> findById ( $ token -> getUserId ( ) ) ; $ user -> setVerified ( true ) ; $ this -> userMapper -> persist ( $ user ) ; $ this -> tokenMapper -> delete ( $ token ) ; return $ user ; }
|
Verify the user given a verify registration token
|
58,404
|
public function createUserToken ( array $ data ) { $ userToken = new TokenEntity ; $ expires = Arr :: get ( $ data , 'expires' ) ? : strtotime ( '+1 day' , time ( ) ) ; $ defaults = [ 'created' => time ( ) , 'expires' => $ expires , 'token' => $ userToken -> generateToken ( ) , ] ; $ userToken = $ userToken -> exchangeArray ( array_merge ( $ defaults , $ data ) ) ; return $ this -> tokenMapper -> persist ( $ userToken ) ; }
|
Create a user token and persist it in the database
|
58,405
|
public function registerClientScript ( ) { $ js = [ ] ; $ view = $ this -> getView ( ) ; DateTimePickerAsset :: register ( $ view ) ; $ id = $ this -> options [ 'id' ] ; $ selector = ";jQuery('#$id')" ; if ( strpos ( $ this -> template , '{button}' ) !== false || $ this -> inline ) { $ selector .= ".parent()" ; } $ options = ! empty ( $ this -> clientOptions ) ? Json :: encode ( $ this -> clientOptions ) : '' ; $ js [ ] = "$selector.datetimepicker($options);" ; if ( $ this -> inline ) { $ js [ ] = "$selector.find('.datetimepicker-inline').addClass('center-block');" ; $ js [ ] = "$selector.find('table.table-condensed').attr('align','center').css('margin','auto');" ; } if ( ! empty ( $ this -> clientEvents ) ) { foreach ( $ this -> clientEvents as $ event => $ handler ) { $ js [ ] = "$selector.on('$event', $handler);" ; } } $ view -> registerJs ( implode ( "\n" , $ js ) , $ view :: POS_READY ) ; }
|
Registers required script for the plugin to work as a DateTimePicker
|
58,406
|
public static function getValue ( $ data , $ key , $ defaultvalue = false ) { if ( is_array ( $ data ) ) { return ( array_key_exists ( $ key , $ data ) ) ? $ data [ $ key ] : $ defaultvalue ; } else { return $ defaultvalue ; } }
|
Return value of array
|
58,407
|
public static function assocSort ( & $ arr , $ key , $ type = SORT_STRING ) { $ ret = usort ( $ arr , function ( $ a , $ b ) use ( $ key , $ type ) { switch ( $ type ) { case SORT_STRING : return strcasecmp ( $ a [ $ key ] , $ b [ $ key ] ) ; break ; case SORT_NUMERIC : return $ a [ $ key ] > $ b [ $ key ] ; break ; default : return 0 ; } } ) ; return $ ret ; }
|
Tri d un tableau associatif
|
58,408
|
public function hasExceededRetries ( $ retries ) { $ delay = $ this -> getDelay ( $ retries , false ) ; return ( ( ! $ this -> max_retries && ( $ delay >= $ this -> max_backoff ) ) || ( $ this -> max_retries && ( $ retries > $ this -> max_retries ) ) ) ; }
|
Returns bool to indicate whether the processes has exceeded the maximum number of retries
|
58,409
|
public static function Merge ( array $ array1 = null , array $ array2 = null ) { self :: setImplmentationClass ( ) ; try { $ array1 = ( ! is_null ( $ array1 ) ) ? $ array1 : self :: $ ArrayHelperClassInstance -> getOutputElement ( ) ; $ array2 = ( ! is_null ( $ array2 ) ) ? $ array2 : self :: $ ArrayHelperClassInstance -> getOutputElement ( ) ; if ( $ array === null ) throw new ArrayHelperException ( "NULL \$array1 value passed to ArrayHelper::Merge() method which merges the elements of two arrays. A valid array1 is expected!" , 1 ) ; if ( $ array2 === null ) throw new ArrayHelperException ( "NULL \$array2 value passed to ArrayHelper::Merge() method which merges the elements of two arrays. A valid array2 is expected!" , 1 ) ; self :: $ ArrayHelperClassInstance -> Merge ( $ array1 , $ array2 ) ; return new static ; } catch ( ArrayHelperException $ ArrayHelperExceptionInstance ) { $ ArrayHelperExceptionInstance -> errorShow ( ) ; } }
|
This method merges the elements of an array
|
58,410
|
public function onBeforeSend ( Event $ event ) { $ request = $ event [ 'request' ] ; $ id = $ this -> signatureCredentials -> getMacId ( ) ; $ ts = $ this -> timeProvider -> getCurrentTime ( ) -> getTimestamp ( ) ; $ nonce = $ this -> randomProvider -> generateStringForRanges ( $ this -> nonceLength , self :: $ characterRanges ) ; $ ext = $ this -> extensionProvider -> getExtensionParameters ( $ request , $ this -> signatureCredentials , $ ts , $ nonce ) ; $ ext = http_build_query ( $ ext , null , '&' ) ; $ mac = $ this -> algorithmManager -> generateMac ( $ request , $ this -> signatureCredentials , $ ts , $ nonce , $ ext ) ; $ params = array ( 'id' => $ id , 'ts' => $ ts , 'nonce' => $ nonce , 'ext' => $ ext , 'mac' => $ mac , ) ; $ list = array ( ) ; foreach ( $ params as $ key => $ value ) { $ list [ ] = $ key . '="' . $ value . '"' ; } $ header = 'MAC ' . implode ( ', ' , $ list ) ; $ request -> setHeader ( 'Authorization' , $ header ) ; }
|
Adds MAC Authorization header to request before sending
|
58,411
|
public function validate ( $ subject ) : bool { if ( \ is_bool ( $ this -> schema [ 'uniqueItems' ] ) && ( $ this -> schema [ 'uniqueItems' ] === true ) ) { if ( \ count ( $ subject ) !== \ count ( \ array_unique ( $ subject ) ) ) { return false ; } } return true ; }
|
Validates subject against uniqueItems
|
58,412
|
public function loadRouteCollection ( $ source = null ) { $ collection = new RouteCollection ( ) ; $ routes = $ this -> loadResource ( $ source ) ; foreach ( $ routes as $ name => $ route ) { $ collection -> add ( $ name , $ this -> parseRoute ( $ route ) ) ; } return $ collection ; }
|
Loads RouteCollection from source
|
58,413
|
public function resolveResorceSource ( $ source = null ) { $ basePath = '../' ; if ( $ source == null ) { $ source = "app/config/routing.yml" ; } $ extension = Path :: getExtension ( $ source ) ; if ( ! in_array ( $ extension , self :: $ knownSourceTypes ) && empty ( $ extension ) ) { $ source = $ source . '/routing.yml' ; } return $ basePath . $ source ; }
|
Resolves name of the file to get resource from
|
58,414
|
public function loadResource ( $ source = null ) { $ routes = array ( ) ; $ source = $ this -> resolveResorceSource ( $ source ) ; $ extension = Path :: getExtension ( $ source ) ; if ( file_exists ( $ source ) ) { $ content = File :: load ( $ source ) ; if ( $ extension == 'yml' ) { $ array = Yaml :: parse ( $ content ) ; } elseif ( $ extension == 'json' ) { $ array = json_decode ( $ content , true ) ; } else { throw new \ Exception ( "Unsupported routing file type. Routes can only be loaded from yml or json files" ) ; } if ( is_array ( $ array ) ) { if ( isset ( $ array [ 'imports' ] ) ) { foreach ( $ array [ 'imports' ] as $ import ) { if ( isset ( $ import [ 'resource' ] ) ) { $ extraSource = $ this -> resolveResorceSource ( $ import [ 'resource' ] ) ; foreach ( $ this -> loadResource ( $ import [ 'resource' ] ) as $ name => $ route ) { $ routes [ $ name ] = $ route ; } } } } if ( isset ( $ array [ 'routes' ] ) ) { foreach ( $ array [ 'routes' ] as $ name => $ route ) { $ routes [ $ name ] = $ route ; } } } } $ this -> resource = $ routes ; return $ routes ; }
|
Loads array of routes from resource
|
58,415
|
public function parseRoute ( $ routeSpec ) { $ path = isset ( $ routeSpec [ 'path' ] ) ? $ routeSpec [ 'path' ] : null ; $ methods = isset ( $ routeSpec [ 'methods' ] ) ? $ routeSpec [ 'methods' ] : array ( ) ; $ controller = isset ( $ routeSpec [ 'controller' ] ) ? $ routeSpec [ 'controller' ] : null ; $ calls = isset ( $ routeSpec [ 'calls' ] ) ? $ routeSpec [ 'calls' ] : null ; $ requirements = isset ( $ routeSpec [ 'requirements' ] ) ? $ routeSpec [ 'requirements' ] : array ( ) ; $ regex = isset ( $ routeSpec [ 'path' ] ) ? $ routeSpec [ 'path' ] : null ; $ route = new Route ( $ path , $ methods , $ controller , $ calls , $ requirements , $ regex ) ; return $ route ; }
|
Parses array of spec into Route object
|
58,416
|
public function __init ( $ method , $ params ) { $ this -> SKY = ( object ) [ 'method' => $ method , 'params' => $ params ] ; if ( ! method_exists ( $ this , $ method ) ) { Loader :: getClass ( 'Sky.core.Log' ) -> write ( 300 , $ method . ' Page Not Found' ) ; Exceptions :: show404 ( ) ; } if ( method_exists ( $ this , '__before' ) ) { $ this -> __before ( ) ; } call_user_func_array ( [ $ this , $ method ] , $ params ) ; if ( method_exists ( $ this , '__after' ) ) { $ this -> __after ( ) ; } }
|
Start initialize controller
|
58,417
|
public function getDeviceValidationToken ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ token = $ this -> getLoginInstance ( ) -> generateDeviceValidationToken ( $ username ) ; return [ 'deviceValidationToken' => $ token ] ; }
|
For the provided username returns deviceValidationToken .
|
58,418
|
public function validateDeviceValidationToken ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ deviceValidationToken = $ this -> httpRequest ( ) -> post ( 'deviceValidationToken' ) ; $ result = $ this -> getLoginInstance ( ) -> validateDeviceConfirmationToken ( $ username , $ deviceValidationToken ) ; if ( $ result ) { return [ 'deviceToken' => $ result ] ; } else { throw new RestErrorException ( 'Device validation error.' , 'The provided device validation token is invalid.' ) ; } }
|
Validates if the provided deviceValidationToken for the given username . Returns deviceToken if validation is successful otherwise false .
|
58,419
|
public function getAccountActivationToken ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ token = $ this -> getLoginInstance ( ) -> getAccountConfirmationToken ( $ username ) ; return [ 'accountActivationToken' => $ token ] ; }
|
Returns accountActivationToken for the provided username .
|
58,420
|
public function validateAccountActivationToken ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ accountActivationToken = $ this -> httpRequest ( ) -> post ( 'accountActivationToken' ) ; $ result = $ this -> getLoginInstance ( ) -> validateAccountConfirmationToken ( $ username , $ accountActivationToken ) ; if ( $ result ) { return [ 'result' => 'success' ] ; } else { throw new RestErrorException ( 'Account activation error.' , 'The provided token is not valid.' ) ; } }
|
Sets the activated flag to true if the accountActivationToken is valid for the provided username .
|
58,421
|
public function logout ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ session = $ this -> httpRequest ( ) -> post ( 'authToken' ) ; $ this -> getLoginInstance ( ) -> revokeSessions ( $ username , $ session ) ; return [ 'result' => 'success' ] ; }
|
Revokes the given session for the provided username .
|
58,422
|
public function generateForgotPasswordResetToken ( ) { $ username = $ this -> httpRequest ( ) -> post ( 'username' ) ; $ token = $ this -> getLoginInstance ( ) -> generateDeviceValidationToken ( $ username ) ; return [ 'passwordResetToken' => $ token ] ; }
|
Generates a password reset token for the provided username .
|
58,423
|
private function getCommandNamespace ( array $ composer ) { if ( ! $ this -> isset ( 'autoload.psr-4' , $ composer ) ) { return null ; } foreach ( $ composer [ 'autoload' ] [ 'psr-4' ] as $ namespace => $ folder ) { if ( $ folder === 'src/' ) return $ namespace . 'Commands\\' ; } return null ; }
|
Only supports psr4 for now .
|
58,424
|
public function add_emoticon ( $ key , $ url , $ replace = true ) { if ( isset ( $ this -> emoticons [ $ key ] ) && ! $ replace ) return false ; $ this -> emoticons [ $ key ] = $ url ; return true ; }
|
Adds an emoticon to the parser .
|
58,425
|
public function add_emoticons ( Array $ emoticons , $ replace = true ) { foreach ( $ emoticons as $ key => $ url ) $ this -> add_emoticon ( $ key , $ url , $ replace ) ; }
|
Adds multipule emoticons to the parser . Should be in emoticon_key = > image_url format .
|
58,426
|
public function remove_emoticon ( $ key , $ url ) { if ( ! isset ( $ this -> emoticons [ $ key ] ) ) return false ; unset ( $ this -> emoticons [ $ key ] ) ; return true ; }
|
Removes an emoticon from the parser .
|
58,427
|
public function add_bbcode ( BBCode $ bbcode , $ replace = true ) { if ( ! $ replace && isset ( $ this -> bbcodes [ $ bbcode -> tag ( ) ] ) ) return false ; $ this -> bbcodes [ $ bbcode -> tag ( ) ] = $ bbcode ; return true ; }
|
Adds a bbcode to the parser
|
58,428
|
public function add_bbcodes ( Array $ bbcodes , $ replace = true ) { foreach ( $ bbcodes as $ bbcode ) $ this -> add_bbcode ( $ bbcode , $ replace ) ; }
|
Adds an array of BBCode s to the document
|
58,429
|
public function remove_bbcode ( $ bbcode ) { if ( $ bbcode instanceof BBCode ) $ bbcode = $ bbcode -> tag ( ) ; unset ( $ this -> bbcodes [ $ bbcode ] ) ; }
|
Removes a BBCode from the document
|
58,430
|
public function get_bbcode ( $ tag ) { if ( ! isset ( $ this -> bbcodes [ $ tag ] ) ) return null ; return $ this -> bbcodes [ $ tag ] ; }
|
Returns the BBCode object for the passed tag .
|
58,431
|
public function get_base_uri ( ) { if ( $ this -> base_uri != null ) return $ this -> base_uri ; return htmlentities ( dirname ( $ _SERVER [ 'PHP_SELF' ] ) , ENT_QUOTES | ENT_IGNORE , "UTF-8" ) . '/' ; }
|
Gets the base URI to be used in links images ect .
|
58,432
|
public function parse ( $ str ) { $ str = str_replace ( "\r" , "" , $ str ) ; $ len = strlen ( $ str ) ; $ tag_open = false ; $ tag_text = '' ; $ tag = '' ; $ this -> current_tag = $ this ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { if ( $ str [ $ i ] === '[' ) { if ( $ tag_open ) $ tag_text .= '[' . $ tag ; $ tag_open = true ; $ tag = '' ; } else if ( $ str [ $ i ] === ']' && $ tag_open ) { if ( $ tag !== '' ) { $ bits = preg_split ( '/([ =])/' , trim ( $ tag ) , 2 , PREG_SPLIT_DELIM_CAPTURE ) ; $ tag_attrs = ( isset ( $ bits [ 2 ] ) ? $ bits [ 1 ] . $ bits [ 2 ] : '' ) ; $ tag_closing = ( $ bits [ 0 ] [ 0 ] === '/' ) ; $ tag_name = ( $ bits [ 0 ] [ 0 ] === '/' ? substr ( $ bits [ 0 ] , 1 ) : $ bits [ 0 ] ) ; if ( isset ( $ this -> bbcodes [ $ tag_name ] ) ) { $ this -> tag_text ( $ tag_text ) ; $ tag_text = '' ; if ( $ tag_closing ) { if ( ! $ this -> tag_close ( $ tag_name ) ) $ tag_text = "[{$tag}]" ; } else { if ( ! $ this -> tag_open ( $ tag_name , $ this -> parse_attribs ( $ tag_attrs ) ) ) $ tag_text = "[{$tag}]" ; } } else $ tag_text .= "[{$tag}]" ; } else $ tag_text .= '[]' ; $ tag_open = false ; $ tag = '' ; } else if ( $ tag_open ) $ tag .= $ str [ $ i ] ; else $ tag_text .= $ str [ $ i ] ; } $ this -> tag_text ( $ tag_text ) ; if ( $ this -> throw_errors && ! $ this -> current_tag instanceof Node_Container_Document ) throw new Exception_MissingEndTag ( "Missing closing tag for tag [{$this->current_tag->tag()}]" ) ; return $ this ; }
|
Parses a BBCode string into the current document
|
58,433
|
private function tag_open ( $ tag , $ attrs ) { if ( $ this -> current_tag instanceof Node_Container_Tag ) { $ closing_tags = $ this -> bbcodes [ $ this -> current_tag -> tag ( ) ] -> closing_tags ( ) ; if ( in_array ( $ tag , $ closing_tags ) ) $ this -> tag_close ( $ this -> current_tag -> tag ( ) ) ; } if ( $ this -> current_tag instanceof Node_Container_Tag ) { $ accepted_children = $ this -> bbcodes [ $ this -> current_tag -> tag ( ) ] -> accepted_children ( ) ; if ( ! empty ( $ accepted_children ) && ! in_array ( $ tag , $ accepted_children ) ) return false ; if ( $ this -> throw_errors && ! $ this -> bbcodes [ $ tag ] -> is_inline ( ) && $ this -> bbcodes [ $ this -> current_tag -> tag ( ) ] -> is_inline ( ) ) throw new Exception_InvalidNesting ( "Block level tag [{$tag}] was opened within an inline tag [{$this->current_tag->tag()}]" ) ; } $ node = new Node_Container_Tag ( $ tag , $ attrs ) ; $ this -> current_tag -> add_child ( $ node ) ; if ( ! $ this -> bbcodes [ $ tag ] -> is_self_closing ( ) ) $ this -> current_tag = $ node ; return true ; }
|
Handles a BBCode opening tag
|
58,434
|
private function tag_text ( $ text ) { if ( $ this -> current_tag instanceof Node_Container_Tag ) { $ accepted_children = $ this -> bbcodes [ $ this -> current_tag -> tag ( ) ] -> accepted_children ( ) ; if ( ! empty ( $ accepted_children ) && ! in_array ( 'text_node' , $ accepted_children ) ) return ; } $ this -> current_tag -> add_child ( new Node_Text ( $ text ) ) ; }
|
Handles tag text
|
58,435
|
private function tag_close ( $ tag ) { if ( ! $ this -> current_tag instanceof Node_Container_Document && $ tag !== $ this -> current_tag -> tag ( ) ) { $ closing_tags = $ this -> bbcodes [ $ this -> current_tag -> tag ( ) ] -> closing_tags ( ) ; if ( in_array ( $ tag , $ closing_tags ) || in_array ( '/' . $ tag , $ closing_tags ) ) $ this -> current_tag = $ this -> current_tag -> parent ( ) ; } if ( $ this -> current_tag instanceof Node_Container_Document ) return false ; else if ( $ tag !== $ this -> current_tag -> tag ( ) ) { $ node = $ this -> current_tag -> find_parent_by_tag ( $ tag ) ; if ( $ node !== null ) { $ this -> current_tag = $ node -> parent ( ) ; while ( ( $ node = $ node -> last_tag_node ( ) ) !== null ) { $ new_node = new Node_Container_Tag ( $ node -> tag ( ) , $ node -> attributes ( ) ) ; $ this -> current_tag -> add_child ( $ new_node ) ; $ this -> current_tag = $ new_node ; } } else return false ; } else $ this -> current_tag = $ this -> current_tag -> parent ( ) ; return true ; }
|
Handles BBCode closing tag
|
58,436
|
private function parse_attribs ( $ attribs ) { $ ret = array ( 'default' => null ) ; $ attribs = trim ( $ attribs ) ; if ( $ attribs == '' ) return $ ret ; if ( $ attribs [ 0 ] == '=' && strrpos ( $ attribs , '=' ) === 0 ) $ ret [ 'default' ] = htmlentities ( substr ( $ attribs , 1 ) , ENT_QUOTES | ENT_IGNORE , "UTF-8" ) ; else { preg_match_all ( '/(\S+)=((?:(?:(["\'])(?:\\\3|[^\3])*?\3))|(?:[^\'"\s]+))/' , $ attribs , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) $ ret [ $ match [ 1 ] ] = htmlentities ( $ match [ 2 ] , ENT_QUOTES | ENT_IGNORE , "UTF-8" ) ; } return $ ret ; }
|
Parses a bbcode attribute string into an array
|
58,437
|
public function detect_links ( ) { $ this -> loop_text_nodes ( function ( $ child ) { preg_match_all ( "/(?:(?:https?|ftp):\/\/|(?:www|ftp)\.)(?:[a-zA-Z0-9\-\.]{1,255}\.[a-zA-Z]{1,20})(?::[0-9]{1,5})?(?:\/[^\s'\"]*)?(?:(?<![,\)\.])|[\S])/" , $ child -> get_text ( ) , $ matches , PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) ; if ( count ( $ matches [ 0 ] ) == 0 ) return ; $ replacment = array ( ) ; $ last_pos = 0 ; foreach ( $ matches [ 0 ] as $ match ) { if ( substr ( $ match [ 0 ] , 0 , 3 ) === 'ftp' && $ match [ 0 ] [ 3 ] !== ':' ) $ url = 'ftp://' . $ match [ 0 ] ; else if ( $ match [ 0 ] [ 0 ] === 'w' ) $ url = 'http://' . $ match [ 0 ] ; else $ url = $ match [ 0 ] ; $ url = new Node_Container_Tag ( 'url' , array ( 'default' => htmlentities ( $ url , ENT_QUOTES | ENT_IGNORE , "UTF-8" ) ) ) ; $ url_text = new Node_Text ( $ match [ 0 ] ) ; $ url -> add_child ( $ url_text ) ; $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos , $ match [ 1 ] - $ last_pos ) ) ; $ replacment [ ] = $ url ; $ last_pos = $ match [ 1 ] + strlen ( $ match [ 0 ] ) ; } $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos ) ) ; $ child -> parent ( ) -> replace_child ( $ child , $ replacment ) ; } , $ this -> get_excluded_tags ( BBCode :: AUTO_DETECT_EXCLUDE_URL ) ) ; return $ this ; }
|
Detects any none clickable links and makes them clickable
|
58,438
|
public function detect_emails ( ) { $ this -> loop_text_nodes ( function ( $ child ) { preg_match_all ( "/(?:[a-zA-Z0-9\-\._]){1,}@(?:[a-zA-Z0-9\-\.]{1,255}\.[a-zA-Z]{1,20})/" , $ child -> get_text ( ) , $ matches , PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) ; if ( count ( $ matches [ 0 ] ) == 0 ) return ; $ replacment = array ( ) ; $ last_pos = 0 ; foreach ( $ matches [ 0 ] as $ match ) { $ url = new Node_Container_Tag ( 'email' , array ( ) ) ; $ url_text = new Node_Text ( $ match [ 0 ] ) ; $ url -> add_child ( $ url_text ) ; $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos , $ match [ 1 ] - $ last_pos ) ) ; $ replacment [ ] = $ url ; $ last_pos = $ match [ 1 ] + strlen ( $ match [ 0 ] ) ; } $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos ) ) ; $ child -> parent ( ) -> replace_child ( $ child , $ replacment ) ; } , $ this -> get_excluded_tags ( BBCode :: AUTO_DETECT_EXCLUDE_EMAIL ) ) ; return $ this ; }
|
Detects any none clickable emails and makes them clickable
|
58,439
|
public function detect_emoticons ( ) { $ pattern = '' ; foreach ( $ this -> emoticons as $ key => $ url ) $ pattern .= ( $ pattern === '' ? '/(?:' : '|' ) . preg_quote ( $ key , '/' ) ; $ pattern .= ')/' ; $ emoticons = $ this -> emoticons ; $ this -> loop_text_nodes ( function ( $ child ) use ( $ pattern , $ emoticons ) { preg_match_all ( $ pattern , $ child -> get_text ( ) , $ matches , PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) ; if ( count ( $ matches [ 0 ] ) == 0 ) return ; $ replacment = array ( ) ; $ last_pos = 0 ; foreach ( $ matches [ 0 ] as $ match ) { $ url = new Node_Container_Tag ( 'img' , array ( 'alt' => $ match [ 0 ] ) ) ; $ url_text = new Node_Text ( $ emoticons [ $ match [ 0 ] ] ) ; $ url -> add_child ( $ url_text ) ; $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos , $ match [ 1 ] - $ last_pos ) ) ; $ replacment [ ] = $ url ; $ last_pos = $ match [ 1 ] + strlen ( $ match [ 0 ] ) ; } $ replacment [ ] = new Node_Text ( substr ( $ child -> get_text ( ) , $ last_pos ) ) ; $ child -> parent ( ) -> replace_child ( $ child , $ replacment ) ; } , $ this -> get_excluded_tags ( BBCode :: AUTO_DETECT_EXCLUDE_EMOTICON ) ) ; return $ this ; }
|
Detects any emoticons and replaces them with their images
|
58,440
|
private function get_excluded_tags ( $ exclude ) { $ ret = array ( ) ; foreach ( $ this -> bbcodes as $ bbcode ) if ( $ bbcode -> auto_detect_exclude ( ) & $ exclude ) $ ret [ ] = $ bbcode -> tag ( ) ; return $ ret ; }
|
Gets an array of tages to be excluded from the elcude param
|
58,441
|
public static function add ( $ hook , $ plugin ) { if ( ! isset ( static :: $ plugins [ $ hook ] ) ) { static :: $ plugins [ $ hook ] = array ( ) ; } static :: $ plugins [ $ hook ] [ ] = $ plugin ; }
|
Adds a plugin to the library
|
58,442
|
public static function run ( $ hook , array $ params = array ( ) ) { if ( ! isset ( static :: $ plugins [ $ hook ] ) ) { return false ; } foreach ( static :: $ plugins [ $ hook ] as $ plugin ) { call_user_func_array ( $ plugin , $ params ) ; } }
|
Executes a hook
|
58,443
|
public function getStats ( ) { echo sprintf ( "Total %d Matched %d (%s%%)" , $ this -> total , $ this -> matched , number_format ( $ this -> matched * 100.0 / $ this -> total , 1 ) ) ; }
|
Returns the stats collected
|
58,444
|
protected function loadCarouselItemsForBlock ( BlockInterface $ block ) { $ settings = $ block -> getSettings ( ) ; return $ this -> container -> get ( 'doctrine' ) -> getRepository ( 'Presta\CMSMediaBundle\Doctrine\Orm\Carousel' ) -> findLimited ( ) ; }
|
Load carousel items to display
|
58,445
|
public function addLogLinkVisitAction ( \ BlackForest \ PiwikBundle \ Entity \ PiwikLogLinkVisitAction $ logLinkVisitAction ) { $ this -> logLinkVisitAction [ ] = $ logLinkVisitAction ; return $ this ; }
|
Add logLinkVisitAction .
|
58,446
|
public function removeLogLinkVisitAction ( \ BlackForest \ PiwikBundle \ Entity \ PiwikLogLinkVisitAction $ logLinkVisitAction ) { return $ this -> logLinkVisitAction -> removeElement ( $ logLinkVisitAction ) ; }
|
Remove logLinkVisitAction .
|
58,447
|
public function check ( string $ sentence ) : bool { $ this -> validateSentence ( $ sentence ) ; return $ this -> isCorrect ( $ sentence ) ; }
|
Check brackets in sentence
|
58,448
|
protected function isCorrect ( string $ sentence ) : bool { $ bracketsStack = [ ] ; $ sentenceChars = str_split ( $ sentence ) ; $ openBrackets = array_keys ( $ this -> brackets ) ; foreach ( $ sentenceChars as $ char ) { if ( in_array ( $ char , $ openBrackets ) ) { $ bracketsStack [ ] = $ this -> brackets [ $ char ] ; continue ; } if ( in_array ( $ char , $ this -> brackets ) ) { $ idx = array_search ( $ char , $ bracketsStack ) ; if ( $ idx !== false ) { unset ( $ bracketsStack [ $ idx ] ) ; continue ; } return false ; } } return count ( $ bracketsStack ) === 0 ; }
|
Parse and check the correctness of the sentence
|
58,449
|
protected function validateSentence ( string $ sentence ) : void { if ( empty ( $ sentence ) ) { throw new EmptySentenceException ( "Sentence can not be empty" ) ; } $ sentenceChars = str_split ( $ sentence ) ; if ( count ( array_diff ( $ sentenceChars , $ this -> availableChars ) ) ) { throw new InvalidCharactersException ( "Sentence contains invalid symbols" ) ; } }
|
Validate sentence string
|
58,450
|
private function register ( Entity $ meta ) : self { $ this -> mapping = $ this -> mapping -> put ( ( string ) $ meta -> class ( ) , $ meta ) ; return $ this ; }
|
Register a new entity metadata
|
58,451
|
protected function createEntityForm ( Request $ request = NULL ) { $ form = $ this -> createForm ( $ this -> type , $ this -> entity ) ; return $ request ? $ form -> handleRequest ( $ request ) : $ form ; }
|
Build a create form to create an entity .
|
58,452
|
protected function editEntityForm ( $ id , Request $ request = NULL ) { $ attributes [ 'method' ] = 'PUT' ; $ form = $ this -> createForm ( $ this -> type , $ this -> repository -> find ( $ id ) , $ attributes ) ; return $ request ? $ form -> handleRequest ( $ request ) : $ form ; }
|
Build an edit form to edit an entity .
|
58,453
|
protected function deleteEntityLink ( $ id ) { $ post = $ this -> repository -> find ( $ id ) ; $ this -> manager -> remove ( $ post ) ; $ this -> manager -> flush ( ) ; }
|
Delete an entity from the database .
|
58,454
|
public function getReturnUri ( ) { if ( null === $ this -> returnUri ) { $ request = $ this -> getRequest ( ) ; $ session = $ this -> getSessionContainer ( ) ; $ returnUri = $ request -> getQuery ( 'requestUri' ) ; if ( empty ( $ returnUri ) ) { $ returnUri = $ request -> getPost ( 'requestUri' ) ; } if ( empty ( $ returnUri ) ) { if ( isset ( $ session [ 'returnUri' ] ) ) { $ returnUri = $ session [ 'returnUri' ] ; } else { $ returnUri = self :: DEFAULT_RETURN_URI ; } } else { $ session [ 'returnUri' ] = $ returnUri ; } if ( empty ( $ returnUri ) ) { return '/' ; } $ this -> returnUri = $ returnUri ; } return $ this -> returnUri ; }
|
Get return - uri
|
58,455
|
protected function getValidReturnUri ( $ returnUri ) { $ match = array ( ) ; $ returnUri = ltrim ( str_replace ( '\\' , '/' , $ returnUri ) , "\n\r\t\v\e\f" ) ; if ( ! preg_match ( '#^/([^/].*)?$#' , $ returnUri , $ match ) ) { $ returnUri = static :: DEFAULT_RETURN_URI ; } return $ returnUri ; }
|
Get valid return - uri
|
58,456
|
public function getDefaultPathGenerator ( ) { if ( null === $ this -> defaultPathGenerator ) { $ this -> setDefaultPathGenerator ( $ this -> getOptions ( ) -> getDefaultUploadPathGenerator ( ) ) ; } return $ this -> defaultPathGenerator ; }
|
Returns path generator
|
58,457
|
public function getDefaultPath ( ) { if ( null === $ this -> defaultPath ) { $ this -> setDefaultPath ( $ this -> getOptions ( ) -> getDefaultUploadPath ( ) ) ; } return $ this -> defaultPath ; }
|
Returns default path
|
58,458
|
public function warning ( $ mes , $ alert = true ) { \ AsyncWeb \ Storage \ Log :: log ( "MessagesWarning" , "Bola zobrazena varovacia hlaska: " . addslashes ( $ mes ) , ML__LOW_PRIORITY ) ; $ this -> warn .= '<div class="error alert alert-warning">' . $ mes . '</div>' . "\n" ; \ AsyncWeb \ Storage \ Session :: set ( $ this -> conf_ses_save_err , $ this -> warn ) ; if ( $ alert ) { $ this -> addAlert ( $ mes ) ; } }
|
Tu je zatial class = error
|
58,459
|
public function addEventListener ( $ function , $ event = null , $ node = null , $ wrap = false , $ position = 1000 ) { $ event = $ event ? : 'DOMContentLoaded' ; $ node = $ node ? : 'document' ; $ function = ( $ wrap ? "function(event) { {$function} }" : $ function ) ; $ this -> addInline ( "{$node}.addEventListener(\"{$event}\", {$function});" , $ position ) ; return $ this ; }
|
add an event listner
|
58,460
|
public function eventCaptureStart ( $ event = null , $ node = null , $ wrap = false , $ position = 1000 ) { $ this -> capture [ ] = [ 'func' => 'addEventListener' , 'args' => [ $ event , $ node , $ wrap , $ position ] ] ; ob_start ( ) ; return $ this ; }
|
start capturing an event to bind
|
58,461
|
public function actionGenerate ( ) { $ tableName = Enter :: display ( 'Enter table name' ) ; $ className = MigrationHelper :: generateByTableName ( $ tableName ) ; Output :: block ( $ className , 'Migration created!' ) ; }
|
Generate migration with columns and foreign keys
|
58,462
|
protected function cleanZendType ( ? string $ type ) : ? string { if ( ! $ type || strtolower ( $ type ) == 'null' ) { return null ; } if ( strtolower ( $ type ) == 'array' ) { return 'array' ; } if ( strpos ( '\\' , $ type ) ) { return '\\' . $ type ; } return $ type ; }
|
Clean data types for zend generator
|
58,463
|
public function created ( $ item = null , $ transformer , $ status = 201 ) { if ( ! $ item || $ transformer ) return $ this -> respond ( null , $ status ) ; return $ this -> item ( $ item , $ transformer , $ status ) ; }
|
Respond without a comment or respond with data
|
58,464
|
public function add ( $ key , $ value , $ override = false ) { if ( $ override || ! isset ( $ this -> _data [ $ key ] ) ) { $ this -> _data [ $ key ] = $ value ; } }
|
Adds data to the response .
|
58,465
|
public function addArray ( $ array , $ override ) { foreach ( $ array as $ key => $ value ) { $ this -> add ( $ key , $ value , $ override ) ; } }
|
Adds an array of data to the response .
|
58,466
|
public function success ( $ message = null , $ data = array ( ) , $ return = false ) { if ( ! empty ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ this -> add ( $ key , $ value ) ; } } $ json = $ this -> jsonEncode ( array ( 'success' => true , 'message' => $ message , 'data' => $ this -> _data , ) ) ; if ( ! $ return ) { echo $ json ; Yii :: app ( ) -> end ( ) ; } else { return $ json ; } }
|
Outputs the JSON for AJAX success .
|
58,467
|
public function error ( $ message , $ return = false ) { $ json = $ this -> jsonEncode ( array ( 'error' => true , 'message' => $ message , ) ) ; if ( ! $ return ) { echo $ json ; Yii :: app ( ) -> end ( ) ; } else { return $ json ; } }
|
Outputs the JSON for AJAX error .
|
58,468
|
private function getAttr ( \ DOMNode $ node , $ attr , $ default = null ) { $ attr = $ node -> attributes -> getNamedItem ( $ attr ) ; return isset ( $ attr ) ? $ attr -> nodeValue : $ default ; }
|
Safely get an attribute value .
|
58,469
|
protected function getValue ( $ key ) { if ( isset ( $ key [ 0 ] ) && $ key [ 0 ] === self :: CONST_PREFIX ) { return substr ( $ key , 1 ) ; } $ data = $ this -> object ; foreach ( explode ( '.' , $ key ) as $ step ) { if ( is_array ( $ data ) ) { $ data = $ data [ $ step ] ; } else { $ data = $ data -> $ step ; } } return ( string ) $ data ; }
|
Get value for node or attribute .
|
58,470
|
public function getTemplateNamesForFilename ( $ filename ) { $ map = $ this -> getMap ( ) ; $ matching = array_filter ( array_keys ( $ map ) , function ( $ path ) use ( $ filename ) { return $ filename [ 0 ] === $ path [ 0 ] && 0 === strpos ( $ filename , $ path ) ; } ) ; $ templateNames = [ ] ; foreach ( $ matching as $ match ) { $ namespace = $ map [ $ match ] ; $ templateNames [ ] = self :: MAIN_NAMESPACE === $ namespace ? ltrim ( substr ( $ filename , strlen ( $ match ) ) , '/\\' ) : '@' . $ namespace . substr ( $ filename , strlen ( $ match ) ) ; } return $ templateNames ; }
|
Lookup the possible twig names that correspond with a given filename .
|
58,471
|
public function build ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ str = '' ; $ strFunctions = '' ; $ strListen = '' ; $ strOnload = '' ; $ trigs = $ this -> getTriggers ( ) ; $ this -> debug -> log ( 'trigs' , $ trigs ) ; foreach ( $ trigs as $ trigName => $ trig ) { $ strFunc = $ this -> buildOnChangeFunc ( $ trig ) ; $ strFunctions .= $ strFunc . "\n" ; $ strOnload .= "\t" . $ trig [ 'funcName' ] . "();\n" ; $ trigFields = $ this -> getFieldsWithName ( $ trigName ) ; foreach ( $ trigFields as $ field ) { $ strListen .= $ this -> buildListen ( $ field , $ trig [ 'funcName' ] ) . "\n" ; } } if ( ! empty ( $ strFunctions ) || ! empty ( $ strListen ) ) { $ str = '<script type="text/javascript">' . "\n" . '//<![CDATA[' . "\n" . '$(function(){' . "\n" . 'BDKForm.init("#' . $ this -> form -> cfg [ 'attribs' ] [ 'id' ] . '");' . "\n" . $ strFunctions . $ strListen . '$(window).on("focus", function() {' . "\n" . $ strOnload . '});' . "\n" . '});' . "\n" . '//]]>' . "\n" . '</script>' ; } $ this -> debug -> log ( 'str!!' , $ str ) ; $ this -> debug -> groupEnd ( ) ; return $ str ; }
|
Build form form - specific javascript Script updates require attribute if req is dependant on other fields
|
58,472
|
private function buildIsReq ( $ strJs , $ trigField ) { $ trigName = $ trigField -> attribs [ 'name' ] ; $ strJs = \ str_replace ( '{{' . $ trigName . '}}' , 'val' , $ strJs ) ; $ strJs = \ preg_replace_callback ( $ this -> regExOther , array ( $ this , 'replaceOther' ) , $ strJs ) ; $ strJs = \ preg_replace_callback ( $ this -> regExThis , array ( $ this , 'replaceCurrent' ) , $ strJs ) ; $ strJs = \ preg_replace ( '#in_array\(' . '(.*?),\s*array\((.*?)\)' . '\)#' , 'BDKForm.inArray($1, [$2])' , $ strJs ) ; $ strJs = \ str_replace ( 'is_numeric' , 'parseFloat' , $ strJs ) ; if ( $ trigField -> returnArray ) { $ strJs = \ preg_replace ( '/(^|[\s!])val(\s|$)/' , '$1val.length$2' , $ strJs ) ; } return $ strJs ; }
|
Buiild isRequired script for given trigger field
|
58,473
|
private function getFieldsWithName ( $ name ) { $ trigFields = array ( ) ; $ fields = & $ this -> form -> currentFields ; if ( isset ( $ fields [ $ name ] ) ) { $ trigFields [ ] = $ fields [ $ name ] ; } else { foreach ( $ fields as $ f ) { if ( $ f -> attribs [ 'name' ] == $ name ) { $ trigFields [ ] = $ f ; } } } return $ trigFields ; }
|
Get all form fields having given name
|
58,474
|
public function resolveQuery ( array $ toResolve , QueryService $ query ) { foreach ( $ toResolve as $ field => $ valueExpression ) { if ( ! is_a ( $ valueExpression , ValueExpression :: class ) ) { throw QueryException :: queryParseErrorException ( ) ; } $ method = sprintf ( "query%s" , ucfirst ( camel_case ( $ field ) ) ) ; if ( ! method_exists ( $ this , $ method ) ) { throw QueryException :: queryMethodNotFoundException ( $ method ) ; } $ this -> { $ method } ( $ query , $ valueExpression ) ; } return true ; }
|
Resolve unfinished queries
|
58,475
|
protected function getAllowedQueryParameters ( ) { $ queryParameters = QueryService :: getDefaultQueryParameters ( ) ; $ customParameters = $ this -> getCustomQueryParameters ( ) ; if ( is_array ( $ customParameters ) && count ( $ customParameters ) > 0 ) { $ queryParameters = array_merge ( $ queryParameters , $ customParameters ) ; } return $ queryParameters ; }
|
Get the query parameters for the current controller
|
58,476
|
public function context ( string $ prefix , $ invoker ) { if ( ! $ invoker instanceof \ Closure ) { throw new \ InvalidArgumentException ( 'Context invoker must be instance of Closure.' ) ; } $ this -> currentContext -> addSubContext ( $ prefix , $ invoker ) ; return $ this ; }
|
Adds a new routing context
|
58,477
|
public function get ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_GET | Request :: HTTP_HEAD , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts GET and HEAD requests .
|
58,478
|
public function post ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_POST , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts POST requests .
|
58,479
|
public function put ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_PUT , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts PUT requests .
|
58,480
|
public function patch ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_PATCH , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts PATCH requests .
|
58,481
|
public function delete ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_DELETE , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts DELETE requests .
|
58,482
|
public function any ( string $ path , $ handler ) { return $ this -> request ( $ path , Request :: HTTP_ALL , $ handler ) ; }
|
Adds a new route with given path to the current context that accepts all requests .
|
58,483
|
public function validate ( string $ name , string $ pattern ) { $ this -> currentContext -> addPattern ( $ name , $ pattern ) ; return $ this ; }
|
Sets a global variable pattern for the given name .
|
58,484
|
private function resultToResponse ( $ result ) : Response { switch ( true ) { case $ result instanceof Response : return $ result ; case is_string ( $ result ) || is_numeric ( $ result ) : return new Response ( $ result ) ; case $ result instanceof Uri : return new RedirectResponse ( $ uri ) ; case is_array ( $ result ) || is_object ( $ result ) : return new JsonResponse ( $ result ) ; default : throw new \ InvalidArgumentException ( 'Invalid route handler return value' ) ; } }
|
Transforms any skalar handler result to a Everest \ Http \ Response object
|
58,485
|
public function execute ( ) { $ query = $ this -> factory -> builder ( $ this -> update ) -> process ( ) ; $ result = $ this -> pdo -> query ( $ query ) ; if ( ! $ result ) { throw new \ Exception ( 'An error while updating is occurred' ) ; } }
|
Execute the query and update the expected entries in the database .
|
58,486
|
protected function parseData ( $ data ) { if ( is_scalar ( $ data ) ) { return $ data ; } if ( $ data instanceof Serializable ) { $ data = $ data -> ayeAyeSerialize ( ) ; } elseif ( $ data instanceof \ JsonSerializable ) { $ data = $ data -> jsonSerialize ( ) ; } elseif ( ! is_array ( $ data ) ) { $ data = ( array ) $ data ; } foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = $ this -> parseData ( $ value ) ; } return $ data ; }
|
Recursively turn data into arrays for output . This method is used to make sure only desired data is output from objects . AyeAye \ Formatters \ Serializable takes precedence over JsonSerializable everything else is cast straight to array
|
58,487
|
public function content ( ) { $ out = [ 'content' => [ ] ] ; foreach ( $ this -> _contentAreas as $ contentArea ) { $ out [ 'content' ] [ ] = $ contentArea -> toArray ( ) ; } return $ out ; }
|
Construct the default content for this layout consisting of the defined content areas . By default these content areas hold no other content and are used by the page builder .
|
58,488
|
protected function _extractId ( ) { list ( , $ className ) = namespaceSplit ( get_class ( $ this ) ) ; $ id = explode ( 'Layout' , $ className ) [ 0 ] ; if ( ! $ className || ! $ id ) { user_error ( __d ( 'wasabi_cms' , 'The layout Class {0} has an invalid name. The name has to end with "Layout".' , $ className ) ) ; } return $ id ; }
|
Extract the lower cased id from the layout class name .
|
58,489
|
public static function makeComplexSortFunction ( $ sortFnArr , $ index = 0 ) { if ( isset ( $ sortFnArr [ $ index ] ) ) { $ fn1 = $ sortFnArr [ $ index ] ; } else { throw new InvalidArgumentException ( 'First argument must be an array conatining at least one callable' ) ; } $ fn2 = null ; if ( isset ( $ sortFnArr [ $ index + 1 ] ) ) { $ fn2 = self :: makeComplexSortFunction ( $ sortFnArr , $ index + 1 ) ; } return self :: makeChainedSortFunction ( $ fn1 , $ fn2 ) ; }
|
Given an ordered array of comparison functions return one function that starts with the first and uses the subsequent functions in order in the event of equal items .
|
58,490
|
private static function makeChainedSortFunction ( $ fn1 , $ fn2 ) { if ( ! is_callable ( $ fn2 ) ) { return $ fn1 ; } return function ( $ a , $ b ) use ( $ fn1 , $ fn2 ) { $ comp = $ fn1 ( $ a , $ b ) ; if ( $ comp !== 0 ) { return $ comp ; } return $ fn2 ( $ a , $ b ) ; } ; }
|
Given two comparison functions return a comparison function that uses the first unless it evaluates as equal then uses the second .
|
58,491
|
private function expandPath ( $ path ) { if ( 0 === strspn ( $ path , '\\/' , 0 , 1 ) || null === parse_url ( $ path , PHP_URL_PATH ) ) { $ path = $ this -> cwd . DIRECTORY_SEPARATOR . $ path ; } return realpath ( $ path ) ; }
|
Expands a path to full path .
|
58,492
|
public static function dispatch ( ) { if ( is_null ( self :: $ route ) ) die ( Utils :: colorize ( "No console route found" , 'FAILURE' ) ) ; $ segments = explode ( '@' , self :: $ route ) ; $ controller = $ segments [ 0 ] ; $ action = $ segments [ 1 ] . 'Action' ; $ object = new $ controller ( ) ; if ( ! method_exists ( $ object , $ action ) ) die ( Utils :: colorize ( "No action '{$segments[1]}' find in {$controller}!" , 'FAILURE' ) ) ; call_user_func_array ( array ( $ controller , $ action ) , self :: $ parameters ) ; }
|
Console route dispatcher
|
58,493
|
public function scopeKey ( Illuminate \ Database \ Query \ Builder $ query , $ key ) { return $ query -> whereKey ( $ key ) ; }
|
Look up by key
|
58,494
|
public function setIndent ( $ spacesNum ) { if ( $ spacesNum ) { $ this -> writer -> setIndent ( true ) ; $ this -> writer -> setIndentString ( str_repeat ( ' ' , ( int ) $ spacesNum ) ) ; } else { $ this -> writer -> setIndent ( false ) ; } return $ this ; }
|
Sets number of spaces uses for indentation . Set 0 to disable indentation .
|
58,495
|
public function get ( $ name ) { if ( ! isset ( $ this -> permissions [ $ name ] ) ) { throw new InvalidArgumentException ( "Permissions $name for type $objectType not found." ) ; } return $ this -> permissions [ $ name ] ; }
|
Return permissions .
|
58,496
|
public function getSynthesize ( ) { if ( ! $ this -> _objSynthesize instanceof Synthesize ) { $ this -> _objSynthesize = $ this -> _createSynthesize ( ) ; } return $ this -> _objSynthesize ; }
|
Get Synthesize Method
|
58,497
|
private function _createSynthesize ( $ mixSynthesize = null ) { if ( $ mixSynthesize ) { $ this -> _mixSynthesizeOptions = $ mixSynthesize ; } else { if ( ! empty ( $ this -> arrSynthesize ) ) { $ this -> _mixSynthesizeOptions = $ this -> arrSynthesize ; } else if ( isset ( $ this -> mixSynthesize ) ) { $ this -> _mixSynthesizeOptions = $ this -> mixSynthesize ; } else { $ this -> _mixSynthesizeOptions = $ this -> _loadOptionsFromFile ( get_class ( ) ) ; } } return new Synthesize ( $ this -> _mixSynthesizeOptions ) ; }
|
Create Synthesize Method
|
58,498
|
private function _loadOptionsFromFile ( $ strFileName ) { $ objReflector = new \ ReflectionClass ( $ this ) ; $ strFileName = dirname ( $ objReflector -> getFileName ( ) ) . '/' . $ strFileName . '.json' ; if ( file_exists ( $ strFileName ) ) { return file_get_contents ( $ strFileName ) ; } throw new MissingOptionsFileException ( $ strFileName ) ; }
|
Load Options From File Method
|
58,499
|
public function createRequest ( $ method , $ uri ) { if ( is_string ( $ uri ) ) { $ uri = ( new UriFactory ( ) ) -> createUri ( $ uri ) ; } return new Request ( $ method , $ uri ) ; }
|
Create a new request
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.