idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
20,400
private function removePatternPropertiesFromSubject ( array $ subject , array $ schema ) : array { if ( isset ( $ schema [ 'patternProperties' ] ) && \ is_array ( $ schema [ 'patternProperties' ] ) ) { $ patterns = \ array_keys ( $ schema [ 'patternProperties' ] ) ; $ propertyNames = \ array_keys ( $ subject ) ; foreach ( $ patterns as $ pattern ) { foreach ( $ propertyNames as $ propertyName ) { if ( \ preg_match ( sprintf ( '/%s/' , $ pattern ) , $ propertyName ) ) { unset ( $ subject [ $ propertyName ] ) ; } } } } return $ subject ; }
Removes properties defined in patternProperties from subject
20,401
public function setListeners ( array $ listeners ) { $ this -> listeners = [ ] ; foreach ( $ listeners as $ name => $ listener ) { $ this -> addListener ( $ name , $ listener ) ; } }
Set render listeners .
20,402
protected function runScripts ( $ keyList ) { $ this -> info ( 'Run scripts' ) ; $ this -> laravel -> configure ( 'phar' ) ; $ scripts = $ this -> laravel [ 'config' ] -> get ( $ keyList , [ ] ) ; foreach ( $ scripts as $ item ) { try { $ this -> info ( '..' . $ item ) ; $ out = [ ] ; exec ( $ item , $ out ) ; $ this -> info ( ' ' . trim ( implode ( "\r\n" , $ out ) ) ) ; } catch ( \ Exception $ e ) { $ this -> error ( sprintf ( "Error build: %s\r\nMessage: %s" , $ item , $ e -> getMessage ( ) ) ) ; } } }
Executar scripts .
20,403
public function transform ( string $ mode , array $ modeData ) { $ return = array ( ) ; foreach ( $ modeData as $ data ) { $ modeClass = $ this -> entryHelper -> getModeClass ( $ mode , $ data [ 'entry' ] ) ; $ entity = new $ modeClass ( $ data [ 'content' ] ) ; $ entryData = array ( ) ; $ entryData [ 'entry' ] = $ data [ 'entry' ] ; $ entryData [ 'content' ] = $ entity -> generateBody ( ) ; $ entryData [ 'parameters' ] = isset ( $ data [ 'parameters' ] ) ? $ data [ 'parameters' ] : array ( ) ; $ return [ ] = $ entryData ; } return $ return ; }
Transforms the mode specific data for each entry to the mapped entry data .
20,404
public static function create ( $ resource ) { $ type = gettype ( $ resource ) ; if ( $ type == 'string' ) { $ stream = fopen ( 'php://temp' , 'r+' ) ; if ( $ resource !== '' ) { fwrite ( $ stream , $ resource ) ; fseek ( $ stream , 0 ) ; } return new self ( $ stream ) ; } if ( $ type == 'resource' ) { return new self ( $ resource ) ; } if ( $ resource instanceof StreamableInterface ) { return $ resource ; } throw new \ InvalidArgumentException ( 'Invalid resource type: ' . $ type ) ; }
Creates a new stream
20,405
public function checkVers ( $ options = "-i" ) { $ output = $ this -> cmd ( sprintf ( 'identify %s' , $ options ) ) ; $ output = substr ( $ output [ 'output' ] , 0 , 11 ) ; return $ output ; }
Check current version
20,406
public function checkFiles ( $ options = "-m" ) { try { $ output = $ this -> cmd ( sprintf ( 'status %s' , $ options ) ) ; if ( strlen ( $ output [ 'output' ] ) == 0 ) { $ output [ 'output' ] = "No files modified." ; $ output [ 'modified' ] = false ; } else { $ output [ 'modified' ] = true ; } return $ output ; } catch ( Exception $ ex ) { return $ ex ; } }
Check if they are local files modified
20,407
public function updateClean ( $ options = "-C" ) { try { $ output = $ this -> cmd ( sprintf ( 'update %s' , $ options ) ) ; return $ output ; } catch ( Exception $ ex ) { return $ ex ; } }
Clean local modified files
20,408
public function position ( int $ value ) : self { $ this -> offset = $ value ; $ this -> bytes = substr ( hex2bin ( $ this -> hex ) , $ value ) ; return $ this ; }
Set the cursor to N .
20,409
public function skip ( int $ value ) : self { $ this -> offset += $ value ; $ this -> bytes = substr ( $ this -> bytes , $ value ) ; return $ this ; }
Move the cursor by N amount of bytes .
20,410
public static function isUser ( string $ username ) : bool { $ userdbname = setup :: getValidation ( "username" ) ; if ( R :: findOne ( 'user' , ' ' . $ userdbname . ' = ? ' , [ $ username ] ) ) { return true ; } return false ; }
checks if a user exists
20,411
public static function removeByUsername ( string $ username ) { $ userdbname = setup :: getValidation ( "username" ) ; if ( $ user = R :: findOne ( 'user' , ' ' . $ userdbname . ' = ? ' , [ $ username ] ) ) { R :: trash ( $ user ) ; } }
Removes an user by his name
20,412
public static function removeById ( int $ id ) { if ( $ user = R :: findOne ( 'user' , ' id = ? ' , [ $ id ] ) ) { R :: trash ( $ user ) ; } }
Removes an user by his id
20,413
private function _parseComponent ( $ components ) { $ address = new GeoAddress ( ) ; $ address -> geoCoding = $ this -> name ; $ streetNumber = '' ; $ routeName = '' ; foreach ( $ components as $ component ) { if ( isset ( $ component [ 'types' ] ) ) { if ( in_array ( 'street_number' , $ component [ 'types' ] ) ) { $ streetNumber = $ component [ 'short_name' ] ; } if ( in_array ( 'route' , $ component [ 'types' ] ) ) { $ routeName = $ component [ 'short_name' ] ; } if ( in_array ( 'administrative_area_level_1' , $ component [ 'types' ] ) ) { $ address -> state = $ component [ 'short_name' ] ; } if ( in_array ( 'locality' , $ component [ 'types' ] ) ) { $ address -> suburb = $ component [ 'short_name' ] ; } if ( in_array ( 'postal_code' , $ component [ 'types' ] ) ) { $ address -> postcode = $ component [ 'short_name' ] ; } if ( in_array ( 'country' , $ component [ 'types' ] ) ) { $ address -> country = $ component [ 'long_name' ] ; } } } if ( $ routeName || $ streetNumber ) { $ address -> addressLine1 = trim ( $ streetNumber . ' ' . $ routeName ) ; } return $ address ; }
This function use to parse the return components from google geocoding api
20,414
public function createAliasMock ( $ alias , $ original = null , $ autoload = true ) { if ( is_array ( $ alias ) ) { foreach ( $ alias as $ mock => $ original ) { $ this -> createAliasMock ( $ mock , $ original ) ; } return ; } try { $ mockable = new ReflectionClass ( $ original ) ; if ( $ mockable -> implementsInterface ( static :: $ mockableInterface ) ) { $ traits = $ mockable -> getTraits ( ) ; if ( ! array_key_exists ( static :: $ mockableTrait , $ traits ) ) { throw new Exception ( "Mocked class for alias '{$alias}'=>'{$original}' must use the trait 'Budkit\\Application\\Mock'" ) ; return ; } $ class = $ alias = ucfirst ( $ alias ) ; if ( $ mockable -> isInstantiable ( ) ) { if ( ! class_exists ( $ class ) ) { class_alias ( $ original , $ class ) ; return $ class :: resolveOriginalClass ( $ this , $ original ) ; } } } } catch ( ReflectionException $ E ) { } }
Create a mock of the container object
20,415
public function addNav ( Nav $ nav ) { $ nav -> setStacked ( ) ; $ this -> setContent ( ( string ) $ nav ) ; $ this -> setStackContainer ( ) ; return $ this ; }
Add nav in content
20,416
public function setContentHtmlTable ( bool $ responsive = true ) { $ this -> setStackContainer ( ) ; $ this -> addCssClass ( $ responsive ? 'table-responsive' : 'table' ) ; return $ this ; }
Content is html table
20,417
public function render ( ) { $ this -> addCssClass ( 'box' ) ; $ this -> addCssClass ( 'box-' . $ this -> getStatus ( ) , $ this -> getStatus ( ) ) ; $ this -> addCssClass ( 'collapsed-box' , $ this -> expandable ) ; $ this -> addCssClass ( 'box-solid' , $ this -> coloredTitleBox ) ; $ boxTools = isset ( $ this -> badges [ 0 ] ) || $ this -> expandable || $ this -> collapsable || $ this -> removable ; $ badges = isset ( $ this -> badges [ 0 ] ) ? $ this -> getBadgesHtml ( ) : '' ; return $ this -> html ( '<div id="' . $ this -> containerId . '">' , $ this -> containerId ) -> html ( $ this -> getPrepend ( ) , $ this -> hasPrepend ( ) ) -> html ( '<div' . $ this -> getEltDecorationStr ( ) . '>' ) -> html ( ' <div class="box-header with-border">' ) -> html ( ' <div class="lg-head">' , $ this -> largeHeader ) -> html ( ' ' . $ this -> getIconHtml ( ) , $ this -> icon ) -> html ( ' <h3 class="box-title">' . $ this -> title . '</h3>' ) -> html ( ' </div>' , $ this -> largeHeader ) -> html ( ' <div class="box-tools pull-right">' , $ boxTools ) -> html ( $ badges ) -> html ( ' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>' , $ this -> expandable ) -> html ( ' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>' , $ this -> collapsable ) -> html ( ' <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>' , $ this -> removable ) -> html ( ' </div>' , $ boxTools ) -> html ( ' <div class="pull-right">' . $ this -> header . '</div>' , $ this -> header ) -> html ( ' </div>' ) -> html ( ' <div class="box-body' . ( $ this -> stackContainer ? ' no-padding' : '' ) . '">' . $ this -> content . '</div>' ) -> html ( ' <div class="' . implode ( ' ' , $ this -> footerClasses ) . '">' , $ this -> footer ) -> html ( ' <div class="pull-right">' , $ this -> footer && $ this -> footerAlignRight ) -> html ( $ this -> footer , $ this -> footer ) -> html ( ' </div>' , $ this -> footer && $ this -> footerAlignRight ) -> html ( ' </div>' , $ this -> footer ) -> html ( '</div>' ) -> html ( $ this -> getAppend ( ) , $ this -> hasAppend ( ) ) -> html ( '</div>' , $ this -> containerId ) -> getHtml ( ) ; }
Render the box at the end of configuration
20,418
public function isValid ( $ value , $ file = null ) { if ( $ this -> allowEmpty && $ this -> isFileEmpty ( $ value , $ file ) ) { return true ; } return parent :: isValid ( $ value , $ file ) ; }
Returns true if and only if the file input is an image .
20,419
public function name ( $ width , $ height = null ) { $ parts = explode ( '.' , $ this -> file -> filename ) ; $ extension = array_pop ( $ parts ) ; $ prefix = '-' . $ width . 'x' . ( $ height ? : $ width ) ; $ name = implode ( '.' , $ parts ) . $ prefix ; return "{$name}.{$extension}" ; }
Resolves thumbnail name .
20,420
public function exists ( $ filename ) { return $ this -> file -> storage -> exists ( $ this -> file -> path ( $ filename ) ) ; }
Check if thumbnail with given name exists .
20,421
public function create ( $ filename , $ width , $ height = null ) { try { $ image = app ( 'image' ) -> make ( $ this -> file -> realPath ) -> fit ( $ width , ( $ height ? : $ width ) ) -> encode ( ) ; $ this -> file -> storage -> put ( $ this -> file -> path ( $ filename ) , $ image ) ; } catch ( NotReadableException $ e ) { return null ; } return $ this -> file -> storage -> url ( $ this -> file -> path ( $ filename ) ) ; }
Create thumbnail .
20,422
public function lists ( ) { $ parts = explode ( '.' , $ this -> file -> filename ) ; $ extension = array_pop ( $ parts ) ; $ name = $ this -> file -> path ( implode ( '.' , $ parts ) ) ; $ files = glob ( $ this -> file -> realPath ( "{$name}-*" ) ) ; array_walk ( $ files , function ( & $ file ) { $ file = substr ( $ file , strrpos ( $ file , '/' ) + 1 , strlen ( $ file ) ) ; $ file = $ this -> file -> path ( $ file ) ; } ) ; return collect ( $ files ) ; }
Return all thumbnails .
20,423
public function connect ( Application $ app ) { $ this -> modelProvider = function ( $ id ) use ( $ app ) { return $ app [ 'redbean' ] -> load ( $ this -> table , $ id ) ; } ; return $ app [ 'controllers_factory' ] ; }
Silex method that exposes routes to the app Attaches a model provider to the controller
20,424
public function getNormalizeResponseChunkSize ( ) : int { $ chunkSize = $ this -> getConfiguration ( 'responseChunkSize' , static :: DEFAULT_CHUNK_SIZE ) ; $ chunkSize = ! is_numeric ( $ chunkSize ) ? static :: DEFAULT_CHUNK_SIZE : intval ( abs ( $ chunkSize ) ) ; $ chunkSize = $ chunkSize < 512 ? 512 : $ chunkSize ; return $ chunkSize ; }
Get normalized chunk size from configuration
20,425
public function setConfig ( ConfigInterface $ config ) { $ configKeys = array_flip ( $ config -> keys ( ) ) ; foreach ( $ this -> defaultConfiguration as $ key => $ value ) { if ( ! isset ( $ configKeys [ $ key ] ) ) { $ config -> set ( $ key , $ value ) ; } } $ this -> config = $ config ; }
Set config object Behavior this will be override your current configuration
20,426
public function getRouter ( ) : RouterInterface { if ( ! $ this -> router instanceof RouterInterface ) { $ router = new Router ( ) ; $ resolver = $ this -> getCallbackResolver ( ) ; if ( $ resolver instanceof CallbackResolverInterface ) { $ router -> setCallbackResolver ( $ resolver ) ; } $ routerCacheFile = $ this -> getConfiguration ( 'routerCacheFile' , false ) ; if ( $ routerCacheFile ) { $ router -> setCacheFile ( $ routerCacheFile ) ; } $ this -> router = $ router ; } return $ this -> router ; }
Get router handler
20,427
public function getCallbackResolver ( ) { if ( ! $ this -> callbackResolver instanceof CallbackResolverInterface ) { $ this -> callbackResolver = new CallbackResolver ( $ this ) ; } return $ this -> callbackResolver ; }
Get callable resolver
20,428
protected function shutdownHandlerCallback ( ServerRequestInterface $ request , ResponseInterface $ response ) : callable { return function ( ) use ( $ request , $ response ) { if ( $ this -> haltShutDown === true ) { return ; } $ lastError = error_get_last ( ) ; if ( empty ( $ lastError [ 'type' ] ) || ! in_array ( $ lastError [ 'type' ] , [ E_ERROR , E_CORE_ERROR , E_COMPILE_ERROR ] ) ) { return ; } $ this -> serveResponse ( $ this -> getErrorHandler ( ) ( $ request , $ response , new \ Error ( $ lastError [ 'message' ] , $ lastError [ 'type' ] ) ) ) ; exit ( 255 ) ; } ; }
Shutdown Handler callback to print Output Response
20,429
protected function handleForResponseException ( ServerRequestInterface $ request , ResponseInterface $ response , \ Throwable $ e ) : ResponseInterface { if ( $ e instanceof MethodNotAllowedException ) { $ handler = $ this -> getNotAllowedHandler ( ) ; } elseif ( $ e instanceof NotFoundException ) { $ handler = $ this -> getNotFoundHandler ( ) ; } elseif ( $ e instanceof \ Exception ) { $ handler = $ this -> getExceptionHandler ( ) ; } else { $ handler = $ this -> getErrorHandler ( ) ; } $ response = $ handler ( $ request , $ response , $ e ) ; if ( ob_get_level ( ) === 0 ) { $ this -> addCreateBuffer ( ) ; } return $ response ; }
Handle Response Exception
20,430
protected function dispatchRouterRoute ( ServerRequestInterface $ request , RouterInterface $ router ) : ServerRequestInterface { $ routeInfo = $ router -> dispatch ( $ request ) ; if ( $ routeInfo [ 0 ] === Dispatcher :: FOUND ) { $ routeArguments = [ ] ; foreach ( $ routeInfo [ 2 ] as $ k => $ v ) { $ routeArguments [ $ k ] = urldecode ( $ v ) ; } $ route = $ router -> getRouteByIdentifier ( $ routeInfo [ 1 ] ) ; $ route -> prepare ( $ request , $ routeArguments ) ; $ request = $ request -> withAttribute ( 'route' , $ route ) ; } $ routeInfo [ 'request' ] = [ $ request -> getMethod ( ) , ( string ) $ request -> getUri ( ) ] ; return $ request -> withAttribute ( 'routeInfo' , $ routeInfo ) ; }
Dispatch the router to find the route . Prepare the route for use .
20,431
public static function highlight_string ( $ source , $ language , $ return = false , $ opts = 0 ) { if ( is_int ( $ return ) ) { $ opts = $ return ; $ return = false ; } $ gs = new static ( $ source , $ language , $ opts ) ; $ s = $ gs -> parseCode ( ) ; if ( $ gs -> error ( ) ) { return false ; } if ( $ return ) { return '<code>' . $ s . '</code>' ; } echo '<code>' . $ s . '</code>' ; return true ; }
Easy way to highlight stuff . Behaves just like highlight_string
20,432
public static function highlight_file ( $ filename , $ language = '' , $ return = false , $ opts = 0 ) { if ( is_bool ( $ language ) ) { ! is_int ( $ return ) ? : $ opts = $ return ; $ return = $ language ; $ language = '' ; } elseif ( is_int ( $ language ) ) { $ opts = $ language ; $ language = '' ; } if ( file_exists ( $ filename ) && is_readable ( $ filename ) ) { $ gs = new static ( $ filename , '' , $ opts ) ; if ( $ language == '' ) { $ ext = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; $ language = $ gs -> get_language_name_from_extension ( $ ext ) ; } $ gs -> setLanguage ( $ language ) ; $ s = $ gs -> parseCode ( ) ; if ( $ gs -> error ( ) ) { return false ; } if ( $ return ) { return '<code>' . $ s . '</code>' ; } echo '<code>' . $ s . '</code>' ; return true ; } return false ; }
Easy way to highlight stuff . Behaves just like highlight_file
20,433
function enable_highlighting ( $ flag = true ) { $ flag = $ flag ? true : false ; foreach ( $ this -> lexic_permissions as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ this -> lexic_permissions [ $ key ] [ $ k ] = $ flag ; } } else { $ this -> lexic_permissions [ $ key ] = $ flag ; } } }
Enables all highlighting
20,434
public function error ( ) { if ( $ this -> error ) { $ debug_tpl_vars = [ '{LANGUAGE}' => $ this -> language , '{PATH}' => self :: LANG_ROOT , ] ; $ msg = strtr ( $ this -> error_messages [ $ this -> error ] , $ debug_tpl_vars ) ; return "<br /><strong>GenSynth Error:</strong> $msg (code {$this->error})<br />" ; } return false ; }
Returns an error message associated with the last GenSynth operation
20,435
function get_language_name_from_extension ( $ ext , $ lookup = [ ] ) { $ ext = strtolower ( $ ext ) ; if ( ! is_array ( $ lookup ) || empty ( $ lookup ) ) { $ lookup = [ 'as' => 'actionscript' , 'as3' => 'actionscript3' , 'conf' => 'apache' , 'asp' => 'asp' , 'sh' => 'bash' , 'bf' => 'bf' , 'c' => 'c' , 'h' => 'c' , 'cbl' => 'cobol' , 'cpp' => 'cpp' , 'hpp' => 'cpp' , 'C' => 'cpp' , 'H' => 'cpp' , 'CPP' => 'cpp' , 'HPP' => 'cpp' , 'cs' => 'csharp' , 'css' => 'css' , 'bat' => 'dos' , 'cmd' => 'dos' , 'html' => 'html' , 'htm' => 'html' , 'ini' => 'ini' , 'desktop' => 'ini' , 'java' => 'java' , 'js' => 'javascript' , 'sql' => 'mysql' , 'pl' => 'perl' , 'pm' => 'perl' , 'php' => 'php' , 'php5' => 'php' , 'phtml' => 'php' , 'phps' => 'php' , 'py' => 'python' , 'rb' => 'ruby' , 'txt' => 'text' , 'bas' => 'vb' , 'vb' => 'vbnet' , 'xml' => 'xml' , 'svg' => 'xml' , 'xrc' => 'xml' , ] ; } return $ lookup [ $ ext ] ? : 'text' ; }
Given a file extension this method returns either a valid GenSynth language name or the empty string if it couldn t be found
20,436
function remove_keyword ( $ key , $ word , $ recompile = true ) { $ key_to_remove = array_search ( $ word , $ this -> language_data [ 'KEYWORDS' ] [ $ key ] ) ; if ( $ key_to_remove !== false ) { unset ( $ this -> language_data [ 'KEYWORDS' ] [ $ key ] [ $ key_to_remove ] ) ; if ( $ recompile && $ this -> parse_cache_built ) { $ this -> optimize_keyword_group ( $ key ) ; } } }
Removes a keyword from a keyword group
20,437
function highlight_lines_extra ( $ lines , $ style = null ) { if ( is_array ( $ lines ) ) { foreach ( $ lines as $ line ) { $ this -> highlight_lines_extra ( $ line , $ style ) ; } } else { $ lines = intval ( $ lines ) ; $ this -> highlight_extra_lines [ $ lines ] = $ lines ; if ( $ style === null ) { unset ( $ this -> highlight_extra_lines_styles [ $ lines ] ) ; } elseif ( $ style === false ) { unset ( $ this -> highlight_extra_lines [ $ lines ] ) ; unset ( $ this -> highlight_extra_lines_styles [ $ lines ] ) ; } else { $ this -> highlight_extra_lines_styles [ $ lines ] = $ style ; } } }
Specifies which lines to highlight extra
20,438
private function replace_keywords ( $ instr ) { $ keywords = $ replacements = [ ] ; $ keywords [ ] = '<TIME>' ; $ keywords [ ] = '{TIME}' ; $ replacements [ ] = $ replacements [ ] = number_format ( $ time = $ this -> get_time ( ) , 3 ) ; $ keywords [ ] = '<LANGUAGE>' ; $ keywords [ ] = '{LANGUAGE}' ; $ replacements [ ] = $ replacements [ ] = $ this -> language_data [ 'LANG_NAME' ] ; $ keywords [ ] = '<VERSION>' ; $ keywords [ ] = '{VERSION}' ; $ replacements [ ] = $ replacements [ ] = self :: VERSION ; $ keywords [ ] = '<SPEED>' ; $ keywords [ ] = '{SPEED}' ; if ( $ time <= 0 ) { $ speed = 'N/A' ; } else { $ speed = strlen ( $ this -> source ) / $ time ; if ( $ speed >= 1024 ) { $ speed = sprintf ( "%.2f KB/s" , $ speed / 1024.0 ) ; } else { $ speed = sprintf ( "%.0f B/s" , $ speed ) ; } } $ replacements [ ] = $ replacements [ ] = $ speed ; return str_replace ( $ keywords , $ replacements , $ instr ) ; }
Replaces certain keywords in the header and footer with certain configuration values
20,439
private function get_line_style ( $ line ) { $ style = null ; if ( isset ( $ this -> highlight_extra_lines_styles [ $ line ] ) ) { $ style = $ this -> highlight_extra_lines_styles [ $ line ] ; } else { $ style = $ this -> highlight_extra_lines_style ; } return $ style ; }
Get s the style that is used for the specified line
20,440
private function handle_keyword_replace ( $ match ) { $ k = $ this -> _kw_replace_group ; $ keyword = $ match [ 0 ] ; $ keyword_match = $ match [ 1 ] ; $ before = '' ; $ after = '' ; if ( $ this -> keyword_links ) { if ( isset ( $ this -> language_data [ 'URLS' ] [ $ k ] ) && $ this -> language_data [ 'URLS' ] [ $ k ] != '' ) { if ( ! $ this -> language_data [ 'CASE_SENSITIVE' ] [ $ k ] && strpos ( $ this -> language_data [ 'URLS' ] [ $ k ] , '{FNAME}' ) !== false ) { foreach ( $ this -> language_data [ 'KEYWORDS' ] [ $ k ] as $ word ) { if ( strcasecmp ( $ word , $ keyword_match ) == 0 ) { break ; } } } else { $ word = $ keyword_match ; } $ before = '<|UR1|"' . str_replace ( [ '{FNAME}' , '{FNAMEL}' , '{FNAMEU}' , '.' ] , [ str_replace ( '+' , '%20' , urlencode ( $ this -> hsc ( $ word ) ) ) , str_replace ( '+' , '%20' , urlencode ( $ this -> hsc ( strtolower ( $ word ) ) ) ) , str_replace ( '+' , '%20' , urlencode ( $ this -> hsc ( strtoupper ( $ word ) ) ) ) , '<DOT>' ] , $ this -> language_data [ 'URLS' ] [ $ k ] ) . '">' ; $ after = '</a>' ; } } return $ before . '<|/' . $ k . '/>' . $ this -> change_case ( $ keyword ) . '|>' . $ after ; }
Handles replacements of keywords to include markup and links if requested
20,441
public function execute ( $ objectContext ) { if ( method_exists ( $ objectContext , $ this -> method ) ) { if ( ! empty ( $ this -> parameters ) ) { $ objectContext -> { $ this -> method } ( $ this -> parameters ) ; } else { $ objectContext -> { $ this -> method } ( $ this -> parameters ) ; } } }
Execute a sequence
20,442
public static function Start ( ) { if ( ! $ argv ) $ argv = $ _SERVER [ "argv" ] ; $ functionName = $ argv [ 1 ] ; $ rows = explode ( "," , $ argv [ 2 ] ) ; $ vars = array ( ) ; foreach ( $ rows as $ row ) { $ parts = explode ( "=" , $ row ) ; $ vars [ $ parts [ 0 ] ] = $ parts [ 1 ] ; } $ console = new Console ; try { return $ console -> Run ( $ functionName , $ vars ) ; } catch ( \ Exception $ ex ) { return "\nError: " . $ ex -> getMessage ( ) . "\n" ; } }
Start the Console
20,443
public function Run ( $ functionName , $ parameters ) { if ( ! array_key_exists ( $ functionName , $ this -> functions ) ) return "\nError: The command '{$functionName}' does not exist\n" ; $ response = $ this -> functions [ $ functionName ] ( $ parameters ) ; return "\n{$response}\n" ; }
Generic function caller
20,444
public static function create ( $ comment ) { if ( is_numeric ( $ comment ) ) { $ transientKey = sprintf ( 'WPMVC\Models\Comment(%d)' , $ comment ) ; $ storedData = get_transient ( $ transientKey ) ; if ( $ storedData === false ) { $ comment = get_comment ( intval ( $ comment ) ) ; set_transient ( $ transientKey , $ comment , $ this -> transientTimeout ) ; } else { $ comment = $ storedData ; } } elseif ( is_array ( $ comment ) ) { $ comment = ( object ) $ comment ; } return new static ( $ comment ) ; }
Creates a new instance by the comment ID
20,445
public function editComment ( $ link = null , $ before = '' , $ after = '' ) { if ( ! current_user_can ( 'edit_comment' , $ this -> id ( ) ) ) { return ; } if ( null === $ link ) { $ link = __ ( 'Edit This' ) ; } $ link = '<a class="comment-edit-link" href="' . get_edit_comment_link ( $ this -> id ( ) ) . '">' . $ link . '</a>' ; return $ before . apply_filters ( 'edit_comment_link' , $ link , $ this -> id ( ) ) . $ after ; }
Retrieve the comment editing link
20,446
public function replyComment ( $ depth = 0 ) { $ args = array ( 'depth' => $ depth , 'max_depth' => 3 ) ; return get_comment_reply_link ( $ args , $ this -> id ( ) , $ this -> postId ( ) ) ; }
Retrive the comment reply link
20,447
public static function user ( $ user = null ) { if ( $ user !== null ) { self :: $ _user = $ user ; } if ( ! self :: $ _user ) { return null ; } return self :: $ _user ; }
Get or set the currently logged in user .
20,448
public static function setting ( $ path , $ default = null ) { $ setting = Configure :: read ( 'Settings.' . $ path ) ; if ( $ setting === null ) { $ setting = Configure :: read ( 'Wasabi.' . $ path ) ; } if ( $ setting === null ) { return $ default ; } return $ setting ; }
Get a setting stored in Wasabi Settings .
20,449
public static function loadLanguages ( $ langId = null , $ backend = false ) { $ languages = Cache :: remember ( 'languages' , function ( ) { $ Languages = TableRegistry :: get ( 'Wasabi/Core.Languages' ) ; $ langs = $ Languages -> find ( 'allFrontendBackend' ) -> all ( ) ; return [ 'frontend' => array_values ( $ Languages -> filterFrontend ( $ langs ) -> toArray ( ) ) , 'backend' => array_values ( $ Languages -> filterBackend ( $ langs ) -> toArray ( ) ) ] ; } , 'wasabi/core/longterm' ) ; Configure :: write ( 'languages' , $ languages ) ; if ( $ backend === true ) { $ request = Router :: getRequest ( ) ; $ backendLanguage = $ languages [ 'backend' ] [ 0 ] ; if ( $ request -> session ( ) -> check ( 'Auth.User.language_id' ) ) { $ backendLanguageId = $ request -> session ( ) -> read ( 'Auth.User.language_id' ) ; if ( $ backendLanguageId !== null ) { foreach ( $ languages [ 'backend' ] as $ lang ) { if ( $ lang -> id === $ backendLanguageId ) { $ backendLanguage = $ lang ; break ; } } } } $ contentLanguage = $ languages [ 'frontend' ] [ 0 ] ; if ( $ request -> session ( ) -> check ( 'contentLanguageId' ) ) { $ contentLanguageId = $ request -> session ( ) -> read ( 'contentLanguageId' ) ; foreach ( $ languages [ 'frontend' ] as $ lang ) { if ( $ lang -> id === $ contentLanguageId ) { $ contentLanguage = $ lang ; break ; } } } Configure :: write ( 'contentLanguage' , $ contentLanguage ) ; Configure :: write ( 'backendLanguage' , $ backendLanguage ) ; I18n :: locale ( $ backendLanguage -> iso2 ) ; } else { if ( $ langId !== null ) { foreach ( $ languages [ 'frontend' ] as $ frontendLanguage ) { if ( $ frontendLanguage -> id === $ langId ) { Configure :: write ( 'contentLanguage' , $ frontendLanguage ) ; I18n :: locale ( $ frontendLanguage -> iso2 ) ; break ; } } } else { Configure :: write ( 'contentLanguage' , $ languages [ 'frontend' ] [ 0 ] ) ; I18n :: locale ( $ languages [ 'frontend' ] [ 0 ] -> iso2 ) ; } } }
Load and setup all languages .
20,450
public static function getCurrentUrlArray ( ) { $ request = Router :: getRequest ( ) ; return [ 'plugin' => $ request -> params [ 'plugin' ] , 'controller' => $ request -> params [ 'controller' ] , 'action' => $ request -> params [ 'action' ] ] ; }
Get the plugin controller action url array from the request .
20,451
public function get ( Request $ request , Fractal $ fractal , FractalCollection $ collection ) { $ this -> beforeRequest ( $ request , func_get_args ( ) ) ; $ transformer = $ this -> getTransformer ( ) ; $ includes = $ request -> input ( 'include' , '' ) ; $ filter = $ request -> input ( 'filter' , false ) ; $ items = $ this -> getRepository ( ) ; if ( $ filter && is_string ( $ filter ) ) { $ filter = json_decode ( $ filter , true ) ; } $ queryFilter = [ ] ; if ( ! empty ( $ filter ) ) { $ queryFilter = new QueryFilter ( $ filter , $ items -> model ( ) , $ this -> getTransformer ( ) ) ; } $ fractal -> parseIncludes ( $ includes ) ; $ resource = $ collection -> setTransformer ( $ transformer ) -> setResourceKey ( $ this -> getResourceKey ( ) ) ; $ paginator = $ items -> paginate ( $ queryFilter , $ transformer -> getSafeEagerLoad ( $ fractal -> getRequestedIncludes ( ) ) , app ( 'context' ) ) ; $ itemCollection = $ paginator -> getCollection ( ) ; $ resource -> setData ( $ itemCollection ) ; $ resource -> setPaginator ( new IlluminatePaginatorAdapter ( $ paginator ) ) ; return $ this -> respondWithCollection ( $ fractal -> createData ( $ resource ) ) ; }
Get a list of objects
20,452
public function addMessage ( $ text , $ type = null ) { $ this -> set ( null , new \ OtherCode \ FController \ Components \ Messages \ Message ( $ text , $ type ) ) ; }
Add a new message to the queue
20,453
public function createParser ( $ name ) { $ parser = new Parser ( ) ; $ parser -> setServer ( $ this -> createServer ( $ name ) ) ; $ compiler = new Compiler ( $ parser -> getServer ( ) -> getStartMultiLine ( ) , $ parser -> getServer ( ) -> getEndMultiLine ( ) , $ parser -> getServer ( ) -> getSimpleDirective ( ) ) ; $ parser -> setCompiler ( $ compiler ) ; return $ parser ; }
Builds a parser instance .
20,454
public function createServer ( $ name ) { $ server = new Server ( ) ; if ( in_array ( $ name , $ this -> getKnownServers ( ) ) ) { $ server -> setChecker ( new Checker ( ) ) -> setStartMultiLine ( $ this -> servers [ $ name ] [ 'directives' ] [ 'start_multiline' ] ) -> setEndMultiLine ( $ this -> servers [ $ name ] [ 'directives' ] [ 'end_multiline' ] ) -> setSimpleDirective ( $ this -> servers [ $ name ] [ 'directives' ] [ 'simple' ] ) -> setBinaries ( $ this -> servers [ $ name ] [ 'controlers' ] ) -> setDetectionParameter ( $ this -> servers [ $ name ] [ 'switch' ] [ 'detect' ] ) -> setBeforeMethods ( $ this -> servers [ $ name ] [ 'parser' ] [ 'before' ] ) -> setAfterMethods ( $ this -> servers [ $ name ] [ 'parser' ] [ 'after' ] ) -> setDumperSimpleDirective ( $ this -> servers [ $ name ] [ 'dumper' ] [ 'simple' ] ) -> setDumperStartDirective ( $ this -> servers [ $ name ] [ 'dumper' ] [ 'start_multiline' ] ) -> setDumperEndDirective ( $ this -> servers [ $ name ] [ 'dumper' ] [ 'end_multiline' ] ) -> setKnownDirectives ( $ this -> servers [ $ name ] [ 'known_directives' ] ) ; } return $ server ; }
Builds a server instance .
20,455
public function levelToString ( $ level ) { $ mapping = [ self :: LOG_LEVEL_DEBUG => 'debug' , self :: LOG_LEVEL_INFO => 'info' , self :: LOG_LEVEL_WARN => 'warn' , self :: LOG_LEVEL_ERROR => 'error' , self :: LOG_LEVEL_FATAL => 'fatal' , ] ; return isset ( $ mapping [ $ level ] ) ? $ mapping [ $ level ] : 'unknown' ; }
level convert to string
20,456
public function class_uses_deep ( $ class ) { $ traits = [ ] ; do { $ traits = array_merge ( $ traits , class_uses ( $ class , false ) ) ; } while ( $ class = get_parent_class ( $ class ) ) ; foreach ( $ traits as $ trait ) { $ traits = array_merge ( $ traits , class_uses ( $ trait , false ) ) ; } return array_unique ( $ traits ) ; }
get use traits deep
20,457
public function redirect ( ) { if ( isset ( $ _GET [ 'template' ] ) === false ) { return redirect ( $ this -> router -> generate ( 'navigations-page' ) ) ; } else { return 'Redirect: ' . $ this -> router -> generate ( 'navigations-page' ) ; } }
Redirect to the dashboard
20,458
public function showNavigations ( array $ request = [ ] ) { $ navigations_list = $ this -> core -> api ( 'Navigation/all/flatten' , 'GET' ) -> run ( 0 , null , [ ] ) ; if ( ( $ navigations_list [ "headers" ] [ 0 ] [ 2 ] - 200 ) * ( $ navigations_list [ "headers" ] [ 0 ] [ 2 ] - 299 ) > 0 ) { if ( headers_sent ( ) === false ) { foreach ( $ navigations_list [ "headers" ] as $ header ) { header ( $ header [ 0 ] , $ header [ 1 ] , $ header [ 2 ] ) ; } } return $ this -> templates -> render ( "500" , [ "error" => $ navigations_list [ 'response' ] , "result" => '' ] ) ; } $ navigations_list = $ navigations_list [ 'response' ] ; $ pages = $ this -> core -> api ( 'Page/all' , 'GET' ) -> run ( ) ; $ pages_list = [ ] ; foreach ( $ pages [ 'response' ] as $ key => $ page ) { if ( $ page -> status === true && $ page -> navigation === null ) { $ pages_list [ ] = $ page ; } } $ messages = [ 'error' => '' , 'info' => '' , 'success' => '' , 'warning' => '' ] ; if ( empty ( $ request [ 'm' ] ) === false ) { if ( $ request [ 'm' ] == 1 ) { $ messages [ 'success' ] = 'Navigation element added successfully.' ; } elseif ( $ request [ 'm' ] == 2 ) { $ messages [ 'success' ] = 'Navigations list edited successfully.' ; } elseif ( $ request [ 'm' ] == 3 ) { if ( headers_sent ( ) === false ) { header ( 'X-PHP-Response-Code: 202' , true , 202 ) ; } $ messages [ 'success' ] = 'Navigation element deleted successfully.' ; } elseif ( $ request [ 'm' ] == 4 ) { if ( headers_sent ( ) === false ) { header ( 'X-PHP-Response-Code: 422' , true , 422 ) ; } $ messages [ 'error' ] = 'Error - Navigation element not found.' ; } } return $ this -> templates -> render ( "Main::Navigation" , [ "messages" => $ messages , "navigations" => $ navigations_list , "pages" => $ pages_list ] ) ; }
Show the navigations list page
20,459
public static function distribute ( int $ tiles , int $ columns , float $ tallRateTarget , float $ wideRateTarget ) { $ tallTilesTarget = ( int ) round ( $ tallRateTarget * $ tiles ) ; $ wideTilesTarget = ( int ) round ( $ wideRateTarget * $ tiles ) ; $ smallTilesTarget = $ tiles - $ tallTilesTarget - $ wideTilesTarget ; $ cellsTarget = 2 * $ tallTilesTarget + 2 * $ wideTilesTarget + $ smallTilesTarget ; $ rows = ( int ) round ( $ cellsTarget / $ columns ) ; if ( $ columns >= $ cellsTarget || $ tallTilesTarget > 0 && $ rows < 2 ) { throw new InvalidArgumentException ( "Cannot fill {$tiles} items in {$columns} columns" ) ; } $ distribution = Distribution :: fromLargeTiles ( $ tiles , $ tallTilesTarget , $ wideTilesTarget ) ; while ( ( $ cells = $ distribution -> getCells ( ) ) !== $ rows * $ columns ) { if ( $ cells > $ rows * $ columns ) { $ distribution -> decrementLargeTiles ( ) ; } else { $ distribution -> incrementLargeTiles ( ) ; } } return [ $ distribution , new Grid ( $ rows , $ columns ) ] ; }
Create a Distribution that fits a given number of tiles within a grid .
20,460
public function setParam ( $ name , $ value ) { if ( null === $ this -> params ) { $ this -> params = $ this -> loadParams ( ) ; } $ this -> params -> set ( $ name , $ value ) ; return $ this ; }
Set the value of a parameter .
20,461
public function saved ( Model $ model ) { $ attributes = $ this -> processAttributes ( Request :: input ( 'attributes' ) ) ; $ this -> syncAttributes ( $ model , $ attributes ) ; }
On save process attributes .
20,462
protected function processAttributes ( $ attributes ) { if ( ! $ attributes ) { return [ ] ; } $ attributes = explode ( ',' , $ attributes ) ; foreach ( $ attributes as $ key => $ attribute ) { $ attributes [ $ key ] = trim ( $ attribute ) ; } return $ attributes ; }
Convert string of attributes to array .
20,463
public function addVariables ( $ variables ) { if ( $ variables instanceof stdClass ) { $ variables = ( array ) $ variables ; } elseif ( $ variables instanceof Traversable ) { $ variables = iterator_to_array ( $ variables ) ; } elseif ( ! is_array ( $ variables ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid variables provided; must be an array or Traversable ' . 'or instance of stdClass, "%s" received.' , is_object ( $ variables ) ? get_class ( $ variables ) : gettype ( $ variables ) ) ) ; } $ this -> container = array_merge ( $ this -> container , $ variables ) ; return $ this ; }
Adds the variables .
20,464
public function addChild ( ViewModelInterface $ child , $ groupId = null ) { $ this -> children [ ] = $ child ; if ( ! is_null ( $ groupId ) ) { $ child -> setGroupId ( $ groupId ) ; } return $ this ; }
Adds the child model .
20,465
public function calculate ( $ aShippableItems , $ oBasket ) { $ iCostPerItem = ( int ) $ this -> getSetting ( 'iCostPerItem' ) ? : 0 ; $ iItemCount = 0 ; foreach ( $ aShippableItems as $ oItem ) { $ iItemCount += $ oItem -> quantity ; } return $ iItemCount * $ iCostPerItem ; }
Calculates the cost of shipping all shippable items in a basket
20,466
public function removeParam ( $ key ) { if ( null !== $ this -> params ) { unset ( $ this -> params [ $ key ] ) ; if ( empty ( $ this -> params ) ) { $ this -> params = null ; } } }
Removes the parameters .
20,467
public function setParams ( array $ params = null ) { $ this -> params = $ params ; if ( null !== $ params && empty ( $ params ) ) { $ this -> params = null ; } }
Sets the parameters .
20,468
public static function fromString ( string $ propertyString ) : self { $ propertyData = @ parse_ini_string ( $ propertyString , true ) ; if ( false === $ propertyData ) { throw new \ InvalidArgumentException ( 'Property string contains errors and can not be parsed: ' . lastErrorMessage ( ) -> value ( ) ) ; } return new static ( $ propertyData ) ; }
construct class from string
20,469
public static function fromFile ( string $ propertiesFile ) : self { if ( ! file_exists ( $ propertiesFile ) || ! is_readable ( $ propertiesFile ) ) { throw new \ InvalidArgumentException ( 'Property file ' . $ propertiesFile . ' not found' ) ; } $ propertyData = @ parse_ini_file ( $ propertiesFile , true ) ; if ( false === $ propertyData ) { throw new \ UnexpectedValueException ( 'Property file at ' . $ propertiesFile . ' contains errors and can not be parsed: ' . lastErrorMessage ( ) -> value ( ) ) ; } return new static ( $ propertyData ) ; }
construct class from a file
20,470
public function section ( string $ section , array $ default = [ ] ) : array { if ( isset ( $ this -> propertyData [ $ section ] ) ) { return $ this -> propertyData [ $ section ] ; } return $ default ; }
returns a whole section if it exists or the default if the section does not exist
20,471
public function keysForSection ( string $ section , array $ default = [ ] ) : array { if ( isset ( $ this -> propertyData [ $ section ] ) ) { return array_keys ( $ this -> propertyData [ $ section ] ) ; } return $ default ; }
returns a list of all keys of a specific section
20,472
public function containValue ( string $ section , string $ key ) : bool { if ( isset ( $ this -> propertyData [ $ section ] ) && isset ( $ this -> propertyData [ $ section ] [ $ key ] ) ) { return true ; } return false ; }
checks if a certain section contains a certain key
20,473
public function value ( string $ section , string $ key , $ default = null ) { if ( isset ( $ this -> propertyData [ $ section ] ) && isset ( $ this -> propertyData [ $ section ] [ $ key ] ) ) { return $ this -> propertyData [ $ section ] [ $ key ] ; } return $ default ; }
returns a value from a section or a default value if the section or key does not exist
20,474
public function parseValue ( string $ section , string $ key , $ default = null ) { if ( isset ( $ this -> propertyData [ $ section ] ) && isset ( $ this -> propertyData [ $ section ] [ $ key ] ) ) { if ( $ this -> propertyData [ $ section ] [ $ key ] instanceof Secret ) { return $ this -> propertyData [ $ section ] [ $ key ] ; } return Parse :: toType ( $ this -> propertyData [ $ section ] [ $ key ] ) ; } return $ default ; }
parses value and returns the parsing result
20,475
protected function getRepository ( ) { if ( null === $ this -> repository ) { $ this -> repository = $ this -> getEntityManager ( ) -> getRepository ( $ this -> getModuleNamespace ( ) . '\Entity\\' . $ this -> getEntityName ( ) ) ; } return $ this -> repository ; }
Get the accounts repository
20,476
public function equals ( HostnameInterface $ hostname ) : bool { return $ this -> getDomainParts ( ) === $ hostname -> getDomainParts ( ) && $ this -> getTld ( ) === $ hostname -> getTld ( ) ; }
Returns true if the hostname equals other hostname false otherwise .
20,477
public function getDomainName ( ) : string { return $ this -> myDomainParts [ count ( $ this -> myDomainParts ) - 1 ] . ( $ this -> myTld !== null ? '.' . $ this -> myTld : '' ) ; }
Returns the domain name including top - level domain .
20,478
public function withTld ( string $ tld ) : HostnameInterface { if ( ! self :: myValidateTld ( $ tld , $ error ) ) { throw new HostnameInvalidArgumentException ( $ error ) ; } self :: myNormalizeTld ( $ tld ) ; return new self ( $ this -> myDomainParts , $ tld ) ; }
Returns a copy of the Hostname instance with the specified top - level domain .
20,479
public static function fromParts ( array $ domainParts , ? string $ tld = null ) : HostnameInterface { if ( count ( $ domainParts ) === 0 ) { throw new HostnameInvalidArgumentException ( 'Domain parts [] is empty.' ) ; } if ( ! self :: myValidateDomainParts ( $ domainParts , $ error ) ) { throw new HostnameInvalidArgumentException ( 'Domain parts ["' . implode ( '", "' , $ domainParts ) . '"] is invalid: ' . $ error ) ; } if ( ! self :: myValidateTld ( $ tld , $ error ) ) { throw new HostnameInvalidArgumentException ( $ error ) ; } self :: myNormalizeDomainParts ( $ domainParts ) ; self :: myNormalizeTld ( $ tld ) ; return new self ( $ domainParts , $ tld ) ; }
Creates a hostname from hostname parts .
20,480
private static function myParse ( string $ hostname , ? array & $ domainParts = null , ? string & $ tld = null , ? string & $ error = null ) : bool { if ( $ hostname === '' ) { $ error = 'Hostname "' . $ hostname . '" is empty.' ; return false ; } if ( strlen ( $ hostname ) > 255 ) { $ error = 'Hostname "' . $ hostname . '" is too long: Maximum allowed length is 255 characters."' ; return false ; } $ domainParts = explode ( '.' , substr ( $ hostname , - 1 ) === '.' ? substr ( $ hostname , 0 , - 1 ) : $ hostname ) ; $ tld = count ( $ domainParts ) > 1 ? array_pop ( $ domainParts ) : null ; if ( $ tld !== null ) { if ( ! self :: myValidateTld ( $ tld , $ error ) ) { $ error = 'Hostname "' . $ hostname . '" is invalid: ' . $ error ; return false ; } } if ( ! self :: myValidateDomainParts ( $ domainParts , $ error ) ) { $ error = 'Hostname "' . $ hostname . '" is invalid: ' . $ error ; return false ; } self :: myNormalizeDomainParts ( $ domainParts ) ; self :: myNormalizeTld ( $ tld ) ; return true ; }
Tries to parse a hostname and returns the result or error text .
20,481
private static function myValidateTld ( ? string $ tld , ? string & $ error ) : bool { if ( $ tld === null ) { return true ; } if ( $ tld === '' ) { $ error = 'Top-level domain "' . $ tld . '" is empty.' ; return false ; } if ( strlen ( $ tld ) > 63 ) { $ error = 'Top-level domain "' . $ tld . '" is too long: Maximum allowed length is 63 characters.' ; return false ; } if ( preg_match ( '/[^a-zA-Z]/' , $ tld , $ matches ) ) { $ error = 'Top-level domain "' . $ tld . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } return true ; }
Validates a top - level domain .
20,482
private static function myValidateDomainParts ( array $ domainParts , ? string & $ error ) : bool { foreach ( $ domainParts as $ part ) { if ( ! is_string ( $ part ) ) { throw new \ InvalidArgumentException ( '$domainParts parameter is not an array of strings.' ) ; } if ( ! self :: myValidateDomainPart ( $ part , $ error ) ) { return false ; } } return true ; }
Validates domain parts .
20,483
private static function myValidateDomainPart ( string $ domainPart , ? string & $ error ) : bool { if ( $ domainPart === '' ) { $ error = 'Part of domain "' . $ domainPart . '" is empty.' ; return false ; } if ( strlen ( $ domainPart ) > 63 ) { $ error = 'Part of domain "' . $ domainPart . '" is too long: Maximum allowed length is 63 characters.' ; return false ; } if ( preg_match ( '/[^a-zA-Z0-9-]/' , $ domainPart , $ matches ) ) { $ error = 'Part of domain "' . $ domainPart . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } if ( substr ( $ domainPart , 0 , 1 ) === '-' ) { $ error = 'Part of domain "' . $ domainPart . '" begins with "-".' ; return false ; } if ( substr ( $ domainPart , - 1 ) === '-' ) { $ error = 'Part of domain "' . $ domainPart . '" ends with "-".' ; return false ; } return true ; }
Validates a domain part .
20,484
private static function myNormalizeTld ( ? string & $ tld = null ) : void { if ( $ tld !== null ) { $ tld = strtolower ( $ tld ) ; } }
Normalizes a top - level domain .
20,485
public function first ( string $ key ) { $ key = $ this -> getKey ( $ key ) ; if ( ! $ this -> exists ( $ key ) ) { throw new ModelNotFoundException ( sprintf ( 'No query results for the redis key [%s]' , $ key ) ) ; } $ value = cache ( $ key ) ; if ( is_array ( $ value ) ) { return Arr :: first ( $ value ) ; } return $ value ; }
Grab the first bit of data of whatever is saved to the key .
20,486
public function save ( string $ key , callable $ callback ) { $ key = $ this -> getKey ( $ key ) ; return cache ( ) -> rememberForever ( $ key , $ callback ) ; }
Save the results of the callback to the cache .
20,487
public function exists ( string $ key ) : bool { $ key = $ this -> getKey ( $ key ) ; return cache ( ) -> has ( $ key ) ; }
Checks if the thing exists in the store
20,488
public function destroy ( string $ key ) : void { $ key = $ this -> getKey ( $ key ) ; cache ( ) -> forget ( $ key ) ; }
Remove an item from the store
20,489
public function fireReflected ( string $ event , array $ arguments = null ) { return $ this -> getEventManager ( ) -> fireReflected ( $ event , $ arguments ) ; }
Fire events and reflect on the handler to pass named arguments
20,490
private static function setDefaultAttributes ( array $ attributes , array $ default ) : array { foreach ( $ default as $ name => $ value ) { if ( ! \ array_key_exists ( $ name , $ attributes ) ) { $ attributes [ $ name ] = $ value ; } } return $ attributes ; }
Sets default attributes
20,491
private static function extractAttributes ( array $ attributes = [ ] ) : string { $ extracted = [ ] ; if ( \ count ( $ attributes ) > 0 ) { foreach ( $ attributes as $ name => $ value ) { if ( $ name != 'id' || ( $ name == 'id' && $ value != '' ) ) { $ extracted [ ] = sprintf ( '%s="%s"' , \ strtolower ( $ name ) , \ htmlspecialchars ( ( string ) $ value , ENT_COMPAT | ENT_HTML5 ) ) ; } } return \ sprintf ( ' %s' , \ implode ( ' ' , $ extracted ) ) ; } return '' ; }
This method transforms attributes array to string
20,492
private static function buildTag ( string $ name , $ arguments ) : string { $ tagConf = static :: $ tagsData [ $ name ] ; $ hasValue = ( boolean ) $ tagConf [ 'hasValue' ] ; $ clear = \ iterator_to_array ( $ tagConf [ 'clearAttributes' ] , true ) ; $ default = \ iterator_to_array ( $ tagConf [ 'defaultAttributes' ] , true ) ; $ tagName = $ name == 'vartag' ? 'var' : $ name ; $ tagValue = static :: getTagContent ( $ arguments , $ hasValue ) ; $ attributes = static :: getTagAttributes ( $ arguments , $ hasValue ) ; $ attributes = static :: clearAttributes ( $ attributes , $ clear ) ; $ attributes = static :: setDefaultAttributes ( $ attributes , $ default ) ; $ newLine = '' ; if ( \ is_array ( $ tagValue ) ) { $ tagValue = \ implode ( static :: CRLF , $ tagValue ) ; $ newLine = static :: CRLF ; } elseif ( \ in_array ( $ tagName , [ 'body' , 'head' , 'html' ] ) ) { $ newLine = static :: CRLF ; } if ( $ hasValue === true ) { return \ sprintf ( '<%s%s>%s%s%s</%s>%s' , $ tagName , static :: extractAttributes ( $ attributes ) , $ newLine , \ rtrim ( \ str_replace ( static :: CRLF . static :: CRLF , static :: CRLF , $ tagValue ) , static :: CRLF ) , $ newLine , $ tagName , $ newLine ) ; } if ( \ in_array ( $ tagName , [ 'iframe' ] ) ) { return \ sprintf ( '<%s%s></%s>' , $ tagName , static :: extractAttributes ( $ attributes ) , $ tagName ) ; } return \ sprintf ( '<%s%s/>' , $ tagName , static :: extractAttributes ( $ attributes ) ) ; }
Builds html tag
20,493
public static function comment ( string $ text = '' , bool $ addSpaces = false ) : string { $ space = $ addSpaces === true ? ' ' : '' ; return \ sprintf ( '<!--%s%s%s , $ space , $ text , $ space ) ; }
This method returns html comment
20,494
public function getRules ( ) { if ( ! isset ( $ this -> ruleSet ) ) { $ this -> ruleSet = new PriorityList ( RuleInterface :: class ) ; } return $ this -> ruleSet ; }
Get the standards rule set .
20,495
public function getFirstErrors ( ) { $ errors = array ( ) ; foreach ( array_keys ( $ this -> errors ) as $ name ) { $ errors [ $ name ] = current ( $ this -> errors [ $ name ] ) ; } return $ errors ; }
Get the first error for each value .
20,496
public function onlyForCommandLine ( $ onlyForCommandLine = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> onlyForCommandLine ; } $ this -> onlyForCommandLine = ( bool ) $ onlyForCommandLine ; }
Restrict error handling to command line calls .
20,497
public function outputOnlyIfCommandLine ( $ outputOnlyIfCommandLine = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> outputOnlyIfCommandLine ; } $ this -> outputOnlyIfCommandLine = ( bool ) $ outputOnlyIfCommandLine ; }
Output the error message only if using command line . else output to logger if available . Allow to safely add this handler to web pages .
20,498
protected function root ( ) { if ( isset ( $ _GET [ '_framework_url_' ] ) ) { $ url = $ _GET [ '_framework_url_' ] ; } else return false ; $ parts = explode ( '/' , $ url ) ; $ count = count ( $ parts ) - 2 ; $ path = $ parts > 1 ? '../' : '' ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ path .= '../' ; } \ Vinala \ Kernel \ Foundation \ Application :: $ path = $ path ; return $ path ; }
Set the app root
20,499
protected function loadConfig ( ) { $ app_root = Registry :: getInstance ( ) -> app_root ; if ( file_exists ( $ app_root . '/Application/config.php' ) ) { require_once $ app_root . '/Application/config.php' ; } if ( file_exists ( $ app_root . '/Application/localconfig.php' ) ) { require_once $ app_root . '/Application/localconfig.php' ; } if ( isset ( $ config ) ) { Registry :: getInstance ( ) -> config = $ config ; } else { Registry :: getInstance ( ) -> config = [ ] ; } }
Load application config