idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
25,300
public function dispatch ( $ eventName , $ params ) { $ event = new DedicatedEvent ( ) ; $ event -> setParameters ( $ params ) ; $ this -> symfonyEventDispatcher -> dispatch ( "maniaplanet.game." . $ eventName , $ event ) ; }
Dispatch event as it needs to be .
25,301
public function flashcfg ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = $ this -> ConfigTheme -> getConfigAjaxFlash ( ) ; $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action flashcfg . Is used to get configuration for plugin
25,302
public function flashmsg ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ ] ; $ dataDefault = [ 'result' => false , 'key' => null , 'messages' => [ ] , ] ; $ keys = $ this -> request -> data ( 'keys' ) ; $ delete = ( bool ) $ this -> request -> data ( 'delete' ) ; if ( empty ( $ keys ) ) { $ data [ ] = $ dataDefault ; $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; return ; } $ keys = ( array ) $ keys ; foreach ( $ keys as $ key ) { if ( empty ( $ key ) ) { $ key = 'flash' ; } $ dataItem = $ dataDefault ; $ dataItem [ 'key' ] = $ key ; if ( $ delete ) { $ dataItem [ 'result' ] = $ this -> FlashMessage -> deleteMessage ( $ key ) ; } else { $ messages = $ this -> FlashMessage -> getMessage ( $ key ) ; $ dataItem [ 'messages' ] = $ messages ; $ dataItem [ 'result' ] = ! empty ( $ messages ) ; } $ data [ ] = $ dataItem ; } $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action flashmsg . Is used to get message from session data
25,303
public function postCommand ( $ name , array $ params = null ) { $ uri = 'command' ; $ uriData = [ 'name' => $ name ] ; if ( $ params != null ) { foreach ( $ params as $ key => $ value ) { $ uriData [ $ key ] = $ value ; } } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'post' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; }
Publish a new command for Radarr to run . These commands are executed asynchronously ; use GET to retrieve the current status .
25,304
public function postMovie ( array $ data ) { $ uri = 'movie' ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'post' , 'data' => $ data ] ) ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } return $ response -> getBody ( ) -> getContents ( ) ; }
Adds a new movie to your collection
25,305
public function updateMovie ( array $ data ) { $ uri = 'movie' ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'put' , 'data' => $ data ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; }
Update the given movies currently only monitored is changed all other modifications are ignored .
25,306
public function deleteMovie ( $ id , $ deleteFiles = false ) { $ uri = 'movie' ; try { $ response = $ this -> _request ( [ 'uri' => $ uri . '/' . $ id , 'type' => 'delete' , 'deleteFiles' => $ deleteFiles ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; }
Delete the given movie file
25,307
public static function order ( array $ array , array $ columns ) { $ arrayMultisortParameters = [ ] ; foreach ( $ columns as $ column => $ order ) { $ arrayMultisortParameters [ ] = array_column ( $ array , $ column ) ; $ arrayMultisortParameters [ ] = $ order ; } $ arrayMultisortParameters [ ] = & $ array ; array_multisort ( ... $ arrayMultisortParameters ) ; return $ array ; }
Order an array
25,308
public static function addRank ( $ array , $ key = 'rank' , $ columns = [ 'pointChart' ] , $ boolEqual = false ) { $ rank = 1 ; $ compteur = 0 ; $ nbEqual = 1 ; $ nb = count ( $ array ) ; for ( $ i = 0 ; $ i <= $ nb - 1 ; $ i ++ ) { if ( $ i >= 1 ) { $ row1 = $ array [ $ i - 1 ] ; $ row2 = $ array [ $ i ] ; $ isEqual = true ; foreach ( $ columns as $ column ) { if ( $ row1 [ $ column ] != $ row2 [ $ column ] ) { $ isEqual = false ; break ; } } if ( $ isEqual ) { $ compteur ++ ; ++ $ nbEqual ; } else { $ rank = $ rank + $ compteur + 1 ; $ compteur = 0 ; unset ( $ nbEqual ) ; $ nbEqual = 1 ; } } $ row = $ array [ $ i ] ; $ row [ $ key ] = $ rank ; if ( $ boolEqual ) { $ row [ 'nbEqual' ] = & $ nbEqual ; } $ array [ $ i ] = $ row ; } unset ( $ nbEqual ) ; return $ array ; }
Add a rank column checking one or more columns to a sorted array
25,309
public static function chartPointProvider ( $ iNbPartcipant ) { $ liste = [ ] ; $ pointRecord = 100 * $ iNbPartcipant ; $ nb = 80 ; $ compteur = 0 ; $ liste [ 1 ] = $ pointRecord ; for ( $ i = 2 ; $ i <= $ iNbPartcipant ; $ i ++ ) { $ pointRecord = ( int ) ( $ pointRecord * $ nb / 100 ) ; $ liste [ $ i ] = $ pointRecord ; $ compteur ++ ; if ( $ nb < 85 ) { if ( $ compteur === 2 ) { $ nb ++ ; $ compteur = 0 ; } } elseif ( $ nb < 99 ) { $ nb ++ ; } } return $ liste ; }
Renvoie le tableau des pointsVGR
25,310
public function reInitOptions ( $ options ) { $ this -> setOptions ( [ 'memory_limit' => null , 'execution_max_time' => null , 'enable_profiler' => false , 'profiler' => [ 'display' => false , 'log' => false , ] , ] ) ; $ this -> setOptions ( $ options ) ; $ this -> initDebugOptions ( $ this ) ; }
Reinitialize debug options then set new options .
25,311
public function handleError ( $ error , $ code , $ path , $ source , $ parameters , $ options ) { $ exception = $ options [ 'debug' ] ? $ this -> getDebuggedException ( $ error , $ code , $ source , $ path , $ parameters , $ options ) : $ error ; $ handler = $ options [ 'error_handler' ] ; if ( ! $ handler ) { if ( $ options [ 'debug' ] && $ options [ 'exit_on_error' ] ) { if ( $ options [ 'html_error' ] ) { echo $ exception -> getMessage ( ) ; exit ( 1 ) ; } if ( ! function_exists ( 'xdebug_is_enabled' ) || ! xdebug_is_enabled ( ) ) { echo $ exception -> getMessage ( ) . "\n" . $ exception -> getTraceAsString ( ) ; exit ( 1 ) ; } } throw $ exception ; } $ handler ( $ exception ) ; }
Handle error occurred in compiled PHP .
25,312
public function getRenderData ( $ useLabel = false ) { $ radius = ( $ this -> jsWriter instanceof \ Altamira \ JsWriter \ Flot ) ? $ this [ 'radius' ] * 10 : $ this [ 'radius' ] ; $ data = array ( $ this [ 'x' ] , $ this [ 'y' ] , $ radius ) ; if ( $ useLabel ) { $ data [ ] = $ this [ 'label' ] ; } return $ data ; }
Returns an array that corresponds with the ultimate JSON data needed for this datum
25,313
public function getTranslation ( $ id , $ parameters = [ ] , $ locale = null ) { $ parameters = array_merge ( $ this -> replacementPatterns , $ parameters ) ; return $ this -> translator -> trans ( $ id , $ parameters , null , $ locale ) ; }
Get translated message .
25,314
public function getTranslations ( $ id , $ parameters = [ ] ) { $ messages = [ ] ; foreach ( $ this -> supportedLocales as $ locale ) { $ message = $ this -> getTranslation ( $ id , $ parameters , $ locale ) ; $ messages [ ] = [ "Lang" => lcfirst ( $ locale ) , "Text" => $ message , ] ; } return $ messages ; }
Get list of translations .
25,315
public function setUp ( $ options = [ ] ) { parent :: setUp ( $ options ) ; if ( isset ( $ options [ 'changeid' ] ) ) { $ this -> changeid = $ options [ 'changeid' ] ; } if ( isset ( $ options [ 'operation' ] ) ) { $ this -> setOperation ( $ options [ 'operation' ] ) ; if ( $ options [ 'operation' ] == 'delete' ) { $ this -> ignore404 ( true ) ; } } if ( isset ( $ options [ 'external-ids' ] ) ) { $ this -> extids = $ options [ 'external-ids' ] ; } }
SetUp Object to be ready for connect
25,316
protected static function getResponseFormat ( ) { foreach ( headers_list ( ) as $ header ) { if ( stripos ( $ header , 'content-type:' ) === 0 ) { if ( stripos ( $ header , 'application/javascript' ) !== false || stripos ( $ header , 'text/javascript' ) !== false ) { return 'js' ; } if ( stripos ( $ header , 'text/html' ) === false ) { return 'unknown' ; } break ; } } return 'html' ; }
Checks the format of the response
25,317
public function getCompatibleData ( $ haystack , $ title , $ mode , $ script ) { $ choices = $ this -> getChoicesByPriority ( $ title , $ mode , $ script ) ; foreach ( $ choices as $ choice ) { $ data = AssociativeArray :: getFromKey ( $ haystack , $ choice ) ; if ( ! is_null ( $ data ) ) { return $ data ; } } return null ; }
Get a compatible data .
25,318
public function getChoicesByPriority ( $ titleId , $ mode , $ script ) { $ game = $ this -> getTitleGame ( $ titleId ) ; return [ [ $ titleId , $ mode , $ script ] , [ $ titleId , $ mode , self :: COMPATIBLE_ALL ] , [ $ titleId , self :: COMPATIBLE_ALL , self :: COMPATIBLE_ALL ] , [ $ game , $ mode , $ script ] , [ $ game , $ mode , self :: COMPATIBLE_ALL ] , [ $ game , self :: COMPATIBLE_ALL , self :: COMPATIBLE_ALL ] , [ self :: COMPATIBLE_ALL , $ mode , $ script ] , [ self :: COMPATIBLE_ALL , $ mode , self :: COMPATIBLE_ALL ] , [ self :: COMPATIBLE_ALL , self :: COMPATIBLE_ALL , self :: COMPATIBLE_ALL ] , ] ; }
Get list of choices to test by priority .
25,319
public function getTitleGame ( $ titleId ) { $ game = $ this -> titles -> get ( $ titleId , self :: GAME_UNKNOWN ) ; return $ game ; }
Get the game of the title .
25,320
public function get ( ) { $ players = [ ] ; foreach ( parent :: get ( ) as $ login ) { $ player = $ this -> playerDb -> get ( $ login ) ; if ( is_null ( $ player ) ) { $ player = new Player ( ) ; $ player -> setLogin ( $ login ) ; } $ players [ ] = $ player ; } return $ players ; }
Get list of configured players .
25,321
public function addTabItem ( $ title , $ docobj , $ tabdefault = false ) { if ( is_null ( $ docobj ) || ! ( $ docobj instanceof IXmlnukeDocumentObject ) ) { throw new InvalidArgumentException ( "Object is null or not is IXmlnukeDocumentObject. Found object type: " . get_class ( $ docobj ) , 853 ) ; } $ this -> _tabs [ ] = array ( $ title , "OBJ" , $ docobj ) ; if ( $ tabdefault ) { $ this -> _tabDefault = count ( $ this -> _tabs ) - 1 ; } }
Add a Tab with content .
25,322
public function validate ( $ validator ) { if ( empty ( $ this -> value ) ) { $ validator -> validationError ( $ this -> name , _t ( 'TicketsField.VALIDATION_EMPTY' , 'Select at least one ticket' ) , 'validation' ) ; return false ; } $ available = $ this -> getForm ( ) -> event -> getAvailability ( ) ; $ ticketCount = array_sum ( array_map ( function ( $ item ) { return $ item [ 'Amount' ] ; } , $ this -> value ) ) ; if ( $ ticketCount === 0 ) { $ validator -> validationError ( $ this -> name , _t ( 'TicketsField.VALIDATION_EMPTY' , 'Select at least one ticket' ) , 'validation' ) ; return false ; } if ( $ ticketCount > $ available ) { $ validator -> validationError ( $ this -> name , _t ( 'TicketsField.VALIDATION_TO_MUCH' , 'There are {ticketCount} tickets left' , null , array ( 'ticketCount' => $ available ) ) , 'validation' ) ; return false ; } return false ; }
Make sure a ticket is selected and that the selected amount is available
25,323
public function accountsChartsTypesByCountry ( $ id ) { return $ this -> AccountChartType -> where ( function ( $ query ) use ( $ id ) { $ query -> orWhere ( 'country_id' , '=' , $ id ) ; $ query -> orWhereNull ( 'country_id' ) ; } ) -> get ( ) ; }
Retrieve accounts charts types by country
25,324
public function callbackItemClick ( ManialinkInterface $ manialink , $ login , $ params , $ args ) { $ this -> menuContentFactory -> create ( $ login ) ; $ item = $ args [ 'item' ] ; $ item -> execute ( $ this -> menuContentFactory , $ manialink , $ login , $ params , $ args ) ; }
Callback when an item of the menu is clicked on .
25,325
public function clear ( ) { if ( is_array ( $ this -> temp_properties ) ) { foreach ( $ this -> temp_properties as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = $ value ; } } unset ( $ key , $ value ) ; $ this -> temp_properties = null ; } }
Clear and reset properties to the default values .
25,326
public function createLinks ( $ result_string = 'Displaying page :current_page_number_displaying of :total_pages<br>:pagination' ) { $ pagination_data = $ this -> getPaginationData ( ) ; if ( ! is_array ( $ pagination_data ) ) { return null ; } if ( $ result_string == null ) { $ result_string = 'Displaying page :current_page_number_displaying of :total_pages<br>:pagination' ; } $ pagination_rendered = "\n" ; if ( array_key_exists ( 'overall_tag_open' , $ pagination_data ) ) { $ pagination_rendered .= $ pagination_data [ 'overall_tag_open' ] ; } if ( array_key_exists ( 'generated_pages' , $ pagination_data ) && is_array ( $ pagination_data [ 'generated_pages' ] ) ) { foreach ( $ pagination_data [ 'generated_pages' ] as $ page_key => $ page_item ) { if ( is_array ( $ page_item ) ) { if ( array_key_exists ( 'tag_open' , $ page_item ) ) { $ pagination_rendered .= $ page_item [ 'tag_open' ] ; } if ( array_key_exists ( 'link' , $ page_item ) && $ page_item [ 'link' ] != null ) { $ pagination_rendered .= '<a href="' . $ page_item [ 'link' ] . '">' ; } if ( array_key_exists ( 'text' , $ page_item ) ) { $ pagination_rendered .= $ page_item [ 'text' ] ; } if ( array_key_exists ( 'link' , $ page_item ) && $ page_item [ 'link' ] != null ) { $ pagination_rendered .= '</a>' ; } if ( array_key_exists ( 'tag_close' , $ page_item ) ) { $ pagination_rendered .= $ page_item [ 'tag_close' ] ; } } } unset ( $ page_item , $ page_key ) ; } if ( array_key_exists ( 'overall_tag_close' , $ pagination_data ) ) { $ pagination_rendered .= $ pagination_data [ 'overall_tag_close' ] ; } $ pagination_rendered .= "\n" ; $ output = $ result_string ; if ( array_key_exists ( 'total_pages' , $ pagination_data ) ) { $ output = str_replace ( ':total_pages' , $ pagination_data [ 'total_pages' ] , $ output ) ; } if ( array_key_exists ( 'page_number_type' , $ pagination_data ) ) { $ output = str_replace ( ':page_number_type' , $ pagination_data [ 'total_pages' ] , $ output ) ; } if ( array_key_exists ( 'current_page_number_displaying' , $ pagination_data ) ) { $ output = str_replace ( ':current_page_number_displaying' , $ pagination_data [ 'current_page_number_displaying' ] , $ output ) ; } if ( isset ( $ pagination_rendered ) ) { $ output = str_replace ( ':pagination' , $ pagination_rendered , $ output ) ; } unset ( $ pagination_data , $ pagination_rendered ) ; return $ output ; }
Create pagination links and return the html data .
25,327
private function generateUrl ( $ page_value , $ direction = '' , $ return_value_only = false ) { switch ( $ direction ) { case 'first' : if ( $ this -> page_number_type == 'start_num' ) { $ page_value = 0 ; } elseif ( $ this -> page_number_type == 'page_num' ) { $ page_value = 1 ; } break ; case 'previous' : if ( $ this -> page_number_type == 'start_num' ) { $ page_value = ( $ page_value - $ this -> items_per_page ) ; if ( $ page_value < 0 ) { $ page_value = 0 ; } } elseif ( $ this -> page_number_type == 'page_num' ) { $ page_value = ( $ page_value - 1 ) ; if ( $ page_value <= 0 ) { $ page_value = 1 ; } } break ; case 'next' : if ( $ this -> page_number_type == 'start_num' ) { $ page_value = ( $ page_value + $ this -> items_per_page ) ; if ( $ page_value > ( ( $ this -> total_pages * $ this -> items_per_page ) - $ this -> items_per_page ) ) { $ page_value = ( ( $ this -> total_pages * $ this -> items_per_page ) - $ this -> items_per_page ) ; } } elseif ( $ this -> page_number_type == 'page_num' ) { $ page_value = ( $ page_value + 1 ) ; if ( $ page_value > ( ( $ this -> total_pages * $ this -> items_per_page ) / $ this -> items_per_page ) ) { $ page_value = ( ( $ this -> total_pages * $ this -> items_per_page ) / $ this -> items_per_page ) ; } } break ; case 'last' : if ( $ this -> page_number_type == 'start_num' ) { $ page_value = ( $ page_value - $ this -> items_per_page ) ; } elseif ( $ this -> page_number_type == 'page_num' ) { $ page_value = ( $ page_value / $ this -> items_per_page ) ; } break ; default : if ( $ this -> page_number_type == 'start_num' ) { $ page_value = ( ( $ page_value * $ this -> items_per_page ) - $ this -> items_per_page ) ; } break ; } if ( $ return_value_only === true ) { return $ page_value ; } else { return str_replace ( '%PAGENUMBER%' , $ page_value , $ this -> base_url ) ; } }
Generate pagination URL .
25,328
private function isCurrentlyFirstPage ( ) { if ( $ this -> page_number_type === 'start_num' ) { if ( $ this -> page_number_value === 0 ) { return true ; } return false ; } elseif ( $ this -> page_number_type === 'page_num' ) { if ( $ this -> page_number_value === 1 ) { return true ; } return false ; } return false ; }
Is it currently in the first page?
25,329
private function isCurrentlyLastPage ( ) { if ( $ this -> page_number_type === 'start_num' ) { if ( $ this -> page_number_value >= ( $ this -> total_pages * $ this -> items_per_page ) - $ this -> items_per_page ) { return true ; } return false ; } elseif ( $ this -> page_number_type === 'page_num' ) { if ( $ this -> page_number_value >= $ this -> total_pages ) { return true ; } return false ; } return false ; }
Is it currently in the last page?
25,330
private function validateCorrectProperties ( ) { if ( ! is_bool ( $ this -> current_page_link ) ) { $ this -> current_page_link = false ; } if ( ! is_bool ( $ this -> first_page_always_show ) ) { $ this -> first_page_always_show = false ; } if ( is_numeric ( $ this -> items_per_page ) ) { $ this -> items_per_page = intval ( $ this -> items_per_page ) ; if ( $ this -> items_per_page <= 0 ) { $ this -> items_per_page = 10 ; } } elseif ( ! is_numeric ( $ this -> items_per_page ) ) { $ this -> items_per_page = 10 ; } if ( ! is_bool ( $ this -> last_page_always_show ) ) { $ this -> last_page_always_show = false ; } if ( ! is_bool ( $ this -> next_page_always_show ) ) { $ this -> next_page_always_show = false ; } if ( is_numeric ( $ this -> number_adjacent_pages ) ) { $ this -> number_adjacent_pages = intval ( $ this -> number_adjacent_pages ) ; if ( $ this -> number_adjacent_pages < 0 ) { $ this -> number_adjacent_pages = 5 ; } } else { $ this -> number_adjacent_pages = 5 ; } if ( ! is_bool ( $ this -> number_display ) ) { $ this -> number_display = false ; } if ( $ this -> page_number_type != 'start_num' && $ this -> page_number_type != 'page_num' ) { $ this -> page_number_type = 'start_num' ; } if ( ! is_bool ( $ this -> previous_page_always_show ) ) { $ this -> previous_page_always_show = false ; } if ( is_numeric ( $ this -> unavailable_after ) ) { $ this -> unavailable_after = intval ( $ this -> unavailable_after ) ; if ( $ this -> unavailable_after <= 0 ) { $ this -> unavailable_after = 2 ; } } else { $ this -> unavailable_after = false ; } if ( is_numeric ( $ this -> unavailable_before ) ) { $ this -> unavailable_before = intval ( $ this -> unavailable_before ) ; if ( $ this -> unavailable_before <= 0 ) { $ this -> unavailable_before = 2 ; } } else { $ this -> unavailable_before = false ; } if ( ! is_bool ( $ this -> unavailable_display ) ) { $ this -> unavailable_display = false ; } }
Validate that properties values have correct data and type . It will be set to default if the values are incorrect .
25,331
private function validateRequiredProperties ( ) { if ( $ this -> base_url == null ) { throw new \ Exception ( 'The base_url property was not set.' ) ; } if ( is_numeric ( $ this -> total_records ) ) { $ this -> total_records = intval ( $ this -> total_records ) ; } else { throw new \ Exception ( 'The total_records property was not set.' ) ; } if ( ! is_numeric ( $ this -> page_number_value ) ) { throw new \ Exception ( 'The page_number_value property was not set.' ) ; } }
Validate required properties values .
25,332
public function setSessionStore ( Session $ session ) { $ this -> session = $ session ; $ this -> instance = null ; return $ this ; }
Set the session store .
25,333
public function retrieve ( ) { $ messages = null ; if ( \ is_null ( $ this -> instance ) ) { $ this -> instance = new static ( ) ; $ this -> instance -> setSessionStore ( $ this -> session ) ; if ( $ this -> session -> has ( 'message' ) ) { $ messages = \ unserialize ( $ this -> session -> pull ( 'message' ) , [ 'allowed_classes' => false ] ) ; } if ( \ is_array ( $ messages ) ) { $ this -> instance -> merge ( $ messages ) ; } } return $ this -> instance ; }
Retrieve Message instance from Session the data should be in serialize so we need to unserialize it first .
25,334
public function save ( ) : void { $ this -> session -> flash ( 'message' , $ this -> serialize ( ) ) ; $ this -> instance = null ; }
Store current instance .
25,335
public function addMethod ( string $ methodName , callable $ methodClosure ) : void { $ this -> methods [ strtolower ( $ methodName ) ] = $ methodClosure -> bindTo ( $ this ) ; }
Add method .
25,336
private function passFilterManagerToListener ( ) { $ enableFiltersSubscriberDefinition = $ this -> definitionFinder -> getDefinitionByType ( EnableFiltersSubscriber :: class ) ; $ filterManagerServiceName = $ this -> definitionFinder -> getServiceNameByType ( FilterManagerInterface :: class ) ; $ enableFiltersSubscriberDefinition -> addSetup ( 'setFilterManager' , [ '@' . $ filterManagerServiceName ] ) ; }
Prevents circular reference .
25,337
private function formLoginAuthenticator ( ContainerBuilder $ container , $ routes , $ user ) { $ container -> setDefinition ( 'bengor.user_bundle.security.authenticator.form_login_' . $ user . '_authenticator' , new Definition ( FormLoginAuthenticator :: class , [ $ container -> getDefinition ( 'router.default' ) , $ container -> getDefinition ( 'bengor_user.' . $ user . '.command_bus' ) , [ 'login' => $ routes [ $ user ] [ 'login' ] [ 'name' ] , 'login_check' => $ routes [ $ user ] [ 'login_check' ] [ 'name' ] , 'success_redirection_route' => $ routes [ $ user ] [ 'success_redirection_route' ] , ] , ] ) ) -> setPublic ( false ) ; $ container -> setAlias ( 'bengor_user.' . $ user . '.form_login_authenticator' , 'bengor.user_bundle.security.authenticator.form_login_' . $ user . '_authenticator' ) ; }
Registers service of the form login authenticator and its alias .
25,338
private function userSymfonyDataTransformer ( ContainerBuilder $ container , $ user ) { $ container -> setDefinition ( 'bengor.user_bundle.security.' . $ user . '_symfony_data_transformer' , new Definition ( UserSymfonyDataTransformer :: class ) ) -> setPublic ( false ) ; $ container -> setAlias ( 'bengor_user.' . $ user . '.symfony_data_transformer' , 'bengor.user_bundle.security.' . $ user . '_symfony_data_transformer' ) ; }
Registers service of the user Symfony data transformer and its alias .
25,339
private function userProvider ( ContainerBuilder $ container , $ user ) { $ container -> setDefinition ( 'bengor.user_bundle.security.' . $ user . '_provider' , new Definition ( UserProvider :: class , [ $ container -> getDefinition ( 'bengor.user.application.query.' . $ user . '_of_email' ) , $ container -> getDefinition ( 'bengor.user_bundle.security.' . $ user . '_symfony_data_transformer' ) , ] ) ) -> setPublic ( false ) ; $ container -> setAlias ( 'bengor_user.' . $ user . '.provider' , 'bengor.user_bundle.security.' . $ user . '_provider' ) ; }
Registers service of the user provider and its alias .
25,340
public static function getNowDateTime ( ) { if ( PHP_VERSION_ID < 70100 ) { $ now = \ DateTime :: createFromFormat ( 'U.u' , \ sprintf ( '%.6F' , microtime ( true ) ) ) ; } else { $ now = new \ DateTime ( null ) ; } return $ now ; }
Using the same strategy as Monolog does for creating time stamps with micro seconds .
25,341
public function getPlayerInfo ( $ login , $ forceNew = false ) { if ( ! isset ( $ this -> online [ $ login ] ) || $ forceNew ) { $ playerInformation = new PlayerInfo ( ) ; $ playerInformation -> login = $ login ; $ playerDetails = new PlayerDetailedInfo ( ) ; $ playerDetails -> nickName = $ login ; try { $ playerInformation = $ this -> factory -> getConnection ( ) -> getPlayerInfo ( $ login ) ; $ playerDetails = $ this -> factory -> getConnection ( ) -> getDetailedPlayerInfo ( $ login ) ; } catch ( InvalidArgumentException $ e ) { $ this -> logger -> error ( "Login unknown: $login" , [ "exception" => $ e ] ) ; $ this -> console -> writeln ( '$f00Login Unknown: ' . $ login . ' dedicated server said: $fff' . $ e -> getMessage ( ) ) ; } catch ( FaultException $ ex ) { $ this -> logger -> error ( "Login unknown: $login" , [ "exception" => $ ex ] ) ; $ this -> console -> writeln ( '$f00Login Unknown: ' . $ login . ' dedicated server said: $fff' . $ ex -> getMessage ( ) ) ; } return $ this -> playerFactory -> createPlayer ( $ playerInformation , $ playerDetails ) ; } return $ this -> online [ $ login ] ; }
Get information about a player .
25,342
public function onPlayerConnect ( Player $ playerData ) { $ login = $ playerData -> getLogin ( ) ; $ this -> online [ $ login ] = $ playerData ; if ( $ playerData -> isSpectator ( ) ) { $ this -> spectators [ $ login ] = $ playerData ; } else { $ this -> players [ $ login ] = $ playerData ; } }
Fetch player data & store it when player connects .
25,343
public function onPlayerInfoChanged ( Player $ oldPlayer , Player $ player ) { unset ( $ this -> players [ $ player -> getLogin ( ) ] ) ; unset ( $ this -> spectators [ $ player -> getLogin ( ) ] ) ; $ this -> onPlayerConnect ( $ player ) ; }
Change the status of the players .
25,344
public function installFile ( $ sSourcePath , $ sInstallPath ) { if ( ! file_exists ( $ sSourcePath ) ) throw new NoSuchFileException ( $ sSourcePath , 1 ) ; try { $ sInstallDir = dirname ( $ sInstallPath ) ; $ this -> installDir ( $ sInstallDir ) ; } catch ( Exception $ e ) { throw new Exception ( "Cannot install file, no such directory no perms to create it: $sInstallPath" , 11 , $ e ) ; } $ sTempInstallPath = $ this -> findTempSafeInstallPath ( $ sInstallPath ) ; $ success = true ; $ originalUmask = umask ( 0377 ) ; if ( ! @ copy ( $ sSourcePath , $ sTempInstallPath ) ) $ success = false ; umask ( $ originalUmask ) ; if ( ! $ success ) throw new Exception ( "Unable to copy file to temp install path: $sTempInstallPath" , 17 ) ; clearstatcache ( ) ; $ hSrcStat = stat ( $ sSourcePath ) ; $ sSrcOwner = $ hSrcStat [ 'uid' ] ; $ sSrcGroup = $ hSrcStat [ 'gid' ] ; $ sSrcMode = $ hSrcStat [ 'mode' ] ; $ hDstStat = stat ( $ sTempInstallPath ) ; $ sDstOwner = $ hDstStat [ 'uid' ] ; $ sDstGroup = $ hDstStat [ 'gid' ] ; $ sDstMode = $ hDstStat [ 'mode' ] ; if ( $ sSrcOwner !== $ sDstOwner ) @ chown ( $ sTempInstallPath , $ sSrcOwner ) ; if ( $ sSrcGroup !== $ sDstGroup ) @ chgrp ( $ sTempInstallPath , $ sSrcGroup ) ; if ( $ sSrcMode !== $ sDstMode ) @ chmod ( $ sTempInstallPath , $ sSrcMode ) ; if ( ! @ rename ( $ sTempInstallPath , $ sInstallPath ) ) throw new Exception ( "Unable to rename temp file to $sInstallPath" , 21 ) ; }
Safely install a file
25,345
public function findTempSafeInstallPath ( $ sInstallPath ) { try { $ sTemp = $ this -> appendTempExtension ( $ sInstallPath ) ; while ( file_exists ( $ sTemp ) ) { $ sTemp = $ this -> appendTempExtension ( $ sTemp ) ; } } catch ( Exception $ e ) { throw new Exception ( "No available temp file found for: $sInstallPath" , 0 , $ e ) ; } return $ sTemp ; }
Find an unused temporary safe install path
25,346
protected function displayResume ( OutputInterface $ output ) { $ output -> write ( "Creation of a new stack [<info>{$this->collectedData['name']}</info>]" , true ) ; foreach ( $ this -> collectedData [ 'operations' ] as $ name => $ operation ) { $ output -> write ( " * Operation [<info>$name</info>] with " . json_encode ( $ operation -> options ) , true ) ; } }
Display a summary of the stack that will be created .
25,347
public function addMapFirst ( Map $ map , $ login = null , $ force = false ) { return $ this -> addMap ( $ map , $ login , $ force , true ) ; }
Adds map as first item
25,348
public function addMapLast ( Map $ map , $ login = null , $ force = false ) { return $ this -> addMap ( $ map , $ login , $ force , false ) ; }
Adds map as last item
25,349
public function addMap ( Map $ map , $ login = null , $ force = false , $ addFirst = false ) { if ( ! $ login ) { return false ; } $ player = $ this -> playerStorage -> getPlayerInfo ( $ login ) ; $ jbMap = new JukeboxMap ( $ map , $ player ) ; if ( $ force ) { $ this -> add ( $ jbMap , $ addFirst ) ; return true ; } if ( $ this -> adminGroups -> hasPermission ( $ login , "jukebox" ) ) { if ( $ this -> checkMap ( $ map ) === false ) { $ this -> add ( $ jbMap , $ addFirst ) ; return true ; } } else { if ( $ this -> checkLogin ( $ login ) === false && $ this -> checkMap ( $ map ) === false ) { $ this -> add ( $ jbMap , $ addFirst ) ; return true ; } } return false ; }
Adds map as last or first item
25,350
private function checkLogin ( $ login ) { foreach ( $ this -> mapQueue as $ jukeboxMap ) { if ( $ jukeboxMap -> getPlayer ( ) -> getLogin ( ) == $ login ) { return true ; } } return false ; }
checks if login exists on queue
25,351
private function removeFiles ( ) { foreach ( $ this -> files as $ filename ) { if ( file_exists ( $ filename ) ) { @ unlink ( $ filename ) ; } } $ this -> files = array ( ) ; }
Removes temporary files .
25,352
protected function _getSchemaCache ( $ model = null ) { if ( empty ( $ model ) || ! isset ( $ this -> _schemaCache [ $ model ] ) ) { return null ; } return $ this -> _schemaCache [ $ model ] ; }
Return schema for model from cache .
25,353
protected function _setSchemaCache ( $ model = null , $ schema = null ) { if ( empty ( $ model ) ) { return ; } $ this -> _schemaCache [ $ model ] = $ schema ; }
Add schema for model to cache .
25,354
protected function _getSchema ( $ model = null ) { $ result = null ; if ( empty ( $ model ) ) { return $ result ; } $ modelObj = ClassRegistry :: init ( $ model , true ) ; if ( $ modelObj === false ) { return $ result ; } $ result = $ modelObj -> schema ( ) ; if ( empty ( $ modelObj -> virtualFields ) ) { return $ result ; } foreach ( $ modelObj -> virtualFields as $ virtualFieldName => $ virtualFieldVal ) { $ result [ $ virtualFieldName ] = [ 'type' => 'string' ] ; } return $ result ; }
Return schema for model .
25,355
public function openFilterForm ( $ usePost = false ) { $ this -> _setFlagUsePost ( $ usePost ) ; $ type = 'get' ; $ dataToggle = 'pjax-form' ; if ( $ this -> _getFlagUsePost ( ) ) { $ type = 'post' ; $ dataToggle = 'ajax-form' ; } else { $ filterData = $ this -> getFilterData ( ) ; if ( ! empty ( $ filterData ) ) { $ this -> setFilterInputData ( $ filterData ) ; } $ conditions = $ this -> getFilterConditions ( ) ; if ( ! empty ( $ conditions ) ) { $ this -> setFilterInputConditions ( $ conditions ) ; } } $ options = [ 'data-toggle' => $ dataToggle , 'type' => $ type , ] ; $ optionsDefault = $ this -> _getOptionsForElem ( 'openFilterForm' ) ; $ result = $ this -> ExtBs3Form -> create ( null , $ options + $ optionsDefault ) ; return $ result ; }
Return HTML open tag of filter form .
25,356
public function closeFilterForm ( ) { $ type = 'get' ; if ( $ this -> _getFlagUsePost ( ) ) { $ type = 'post' ; } $ this -> ExtBs3Form -> requestType = $ type ; $ result = $ this -> ExtBs3Form -> end ( ) ; return $ result ; }
Return HTML close tag of filter form .
25,357
protected function _createPaginationTableRow ( $ paginationFields = null ) { $ result = '' ; if ( empty ( $ paginationFields ) || ! is_array ( $ paginationFields ) ) { return $ result ; } $ tableHeader = [ ] ; $ includeOptions = [ 'class' => null , 'escape' => null , ] ; foreach ( $ paginationFields as $ paginationField => $ paginationOptions ) { if ( is_int ( $ paginationField ) ) { if ( ! is_string ( $ paginationOptions ) ) { continue ; } $ paginationField = $ paginationOptions ; $ paginationOptions = [ ] ; } if ( strpos ( $ paginationField , '.' ) === false ) { continue ; } if ( ! is_array ( $ paginationOptions ) ) { $ paginationOptions = [ $ paginationOptions ] ; } $ paginationFieldUse = $ paginationField ; if ( isset ( $ paginationOptions [ 'pagination-field' ] ) && ! empty ( $ paginationOptions [ 'pagination-field' ] ) ) { $ paginationFieldUse = $ paginationOptions [ 'pagination-field' ] ; } $ label = $ paginationFieldUse ; if ( isset ( $ paginationOptions [ 'label' ] ) && ! empty ( $ paginationOptions [ 'label' ] ) ) { $ label = $ paginationOptions [ 'label' ] ; } $ paginationSortLink = $ label ; $ paginationOptionsUse = array_intersect_key ( $ paginationOptions , $ includeOptions ) ; if ( ! isset ( $ paginationOptions [ 'disabled' ] ) || ! $ paginationOptions [ 'disabled' ] ) { $ paginationSortLink = $ this -> ViewExtension -> paginationSortPjax ( $ paginationFieldUse , $ label , $ paginationOptionsUse ) ; } if ( isset ( $ paginationOptions [ 'class-header' ] ) && ! empty ( $ paginationOptions [ 'class-header' ] ) ) { $ paginationSortLink = [ $ paginationSortLink => [ 'class' => $ paginationOptions [ 'class-header' ] ] ] ; } $ tableHeader [ ] = $ paginationSortLink ; } $ tableHeader [ ] = [ $ this -> _getOptionsForElem ( 'paginTableRowHeaderActTitle' ) => [ 'class' => 'action hide-popup' ] ] ; $ result = $ this -> Html -> tableHeaders ( $ tableHeader ) ; return $ result ; }
Returns a row of table headers with pagination links
25,358
public function createFilterForm ( $ formInputs = null , $ plugin = null , $ usePrint = true , $ exportType = null ) { $ result = '' ; if ( empty ( $ formInputs ) || ! is_array ( $ formInputs ) ) { return $ result ; } if ( $ usePrint ) { $ urlOptions = $ this -> _getExtendOptionsPaginationUrl ( ) ; if ( ! isset ( $ this -> Paginator -> options [ 'url' ] ) ) { $ this -> Paginator -> options [ 'url' ] = [ ] ; } $ this -> Paginator -> options [ 'url' ] = Hash :: merge ( $ this -> Paginator -> options [ 'url' ] , $ urlOptions ) ; } $ result .= $ this -> _createPaginationTableRow ( $ formInputs ) ; $ result .= $ this -> _createFilterTableRow ( $ formInputs , $ plugin , $ usePrint , $ exportType ) ; return $ result ; }
Returns a row of table header with pagination links and filter form .
25,359
public function createGroupActionControls ( $ formInputs = null , $ groupActions = null , $ useSelectAll = false ) { $ result = '' ; if ( empty ( $ formInputs ) || ! is_array ( $ formInputs ) || ( ! empty ( $ groupActions ) && ! is_array ( $ groupActions ) ) || ( empty ( $ groupActions ) && ! $ useSelectAll ) ) { return $ result ; } if ( empty ( $ groupActions ) ) { $ groupActions = [ ] ; } $ colspan = null ; $ countFormInputs = count ( $ formInputs ) ; if ( $ countFormInputs > 2 ) { $ colspan = $ countFormInputs ; } $ selectOptions = [ ] ; foreach ( $ groupActions as $ value => $ text ) { $ selectOptions [ ] = compact ( 'text' , 'value' ) ; } $ tableFoother = [ ] ; if ( $ useSelectAll ) { if ( ! empty ( $ colspan ) ) { $ colspan -- ; } $ tableFoother [ ] = $ this -> _getOptionsForElem ( 'createGroupActionControls.selectAllBtn' ) ; } $ inputField = '' ; if ( ! empty ( $ selectOptions ) ) { $ this -> ExtBs3Form -> unlockField ( 'FilterGroup.action' ) ; $ tableFoother [ ] = [ $ this -> ExtBs3Form -> hidden ( 'FilterGroup.action' ) . $ this -> _getOptionsForElem ( 'createGroupActionControls.groupDataProcTitle' ) , [ 'colspan' => $ colspan , 'class' => 'text-center' ] ] ; $ btnOptions = [ 'data-dialog-sel-options' => htmlentities ( json_encode ( $ selectOptions ) ) ] ; $ optionsDefault = $ this -> _getOptionsForElem ( 'createGroupActionControls.performActionBtn' ) ; $ tableFoother [ ] = [ $ this -> ViewExtension -> button ( 'fas fa-cog' , 'btn-warning' , $ btnOptions + $ optionsDefault ) , [ 'class' => 'action text-center' ] ] ; } else { if ( ! empty ( $ colspan ) ) { $ colspan ++ ; } $ tableFoother [ ] = [ '' , [ 'colspan' => $ colspan ] ] ; } $ result = $ this -> Html -> tableCells ( [ $ tableFoother ] , [ 'class' => 'active' ] , [ 'class' => 'active' ] ) ; return $ result ; }
Returns a row of table foother with group actions controls .
25,360
public function createFilterRowCheckbox ( $ inputField = null , $ value = null ) { $ result = '' ; if ( is_array ( $ inputField ) ) { $ inputField = array_keys ( $ inputField ) ; $ inputField = ( string ) array_shift ( $ inputField ) ; } if ( empty ( $ inputField ) || ( strpos ( $ inputField , '.' ) === false ) ) { return $ result ; } $ uniqid = uniqid ( ) ; $ dataPath = 'FilterData.0.' . $ inputField ; $ inputFieldName = $ dataPath . '.' ; $ data = ( array ) $ this -> request -> data ( $ dataPath ) ; $ options = [ 'value' => $ value , 'checked ' => in_array ( $ value , $ data ) , 'hiddenField' => false , 'required' => false , 'secure' => false , ] ; $ this -> setEntity ( $ inputFieldName . $ uniqid ) ; $ options = $ this -> domId ( $ options ) ; $ options = $ this -> _initInputField ( $ inputFieldName , $ options ) ; $ result = $ this -> ExtBs3Form -> checkbox ( $ inputFieldName , $ options ) . $ this -> ExtBs3Form -> label ( $ inputFieldName . $ uniqid , '' ) ; $ result = $ this -> Html -> div ( 'checkbox' , $ result ) ; return $ result ; }
Returns control checkbox for select row of table .
25,361
public function getBtnConditionGroup ( $ inputCondField = null ) { $ options = $ this -> _getOptionsForElem ( 'getBtnConditionGroup.options' ) ; $ title = $ this -> _getOptionsForElem ( 'getBtnConditionGroup.title' ) ; return $ this -> _getBtnCondition ( $ inputCondField , $ options , $ title , false ) ; }
Return button with dropdown list of group conditions for form filter input field .
25,362
protected function _getFilterRequestData ( $ baseKey = null , $ key = null ) { $ filterData = [ ] ; if ( empty ( $ baseKey ) ) { return $ filterData ; } if ( $ this -> _getFlagUsePost ( ) ) { $ requestData = $ this -> request -> data ( $ baseKey ) ; if ( ! empty ( $ requestData ) ) { $ filterData = $ requestData ; } } else { $ requestData = $ this -> request -> query ( 'data.' . $ baseKey ) ; if ( ! empty ( $ requestData ) ) { $ filterData = array_map ( 'unserialize' , array_unique ( array_map ( 'serialize' , $ requestData ) ) ) ; } } if ( ! empty ( $ key ) ) { return Hash :: get ( $ filterData , $ key ) ; } return $ filterData ; }
Return request data for filter from GET or POST request .
25,363
protected function _getExtendOptionsPaginationUrl ( ) { $ options = [ ] ; $ ext = ( string ) $ this -> request -> param ( 'ext' ) ; $ ext = mb_strtolower ( $ ext ) ; if ( empty ( $ ext ) || ( $ ext !== 'prt' ) ) { return $ options ; } $ options = compact ( 'ext' ) ; return $ options ; }
Return extended options for pagination URL . If request extension equal prt return ext option .
25,364
public function destroy ( ) { if ( ! empty ( $ this -> data ) ) { foreach ( $ this -> data as $ data ) { if ( $ data instanceof DestroyableObject ) { $ data -> destroy ( ) ; } } } $ this -> data = [ ] ; $ this -> manialinkFactory = null ; }
Destroys a manialink .
25,365
private function getView ( string $ name , array $ data = [ ] ) { $ filesystemLoader = new FilesystemLoader ( __DIR__ . '/views/%name%' ) ; $ templating = new PhpEngine ( new TemplateNameParser ( ) , $ filesystemLoader ) ; return $ templating -> render ( $ name . '.phtml' , $ data ) ; }
Get a view from the views directory
25,366
public function getFiles ( ) { $ files = $ this -> files ; foreach ( $ this -> types as $ type ) { $ files = array_merge ( $ files , $ type -> getFiles ( ) ) ; } $ path = \ Altamira \ Config :: getInstance ( ) -> getPluginPath ( $ this -> getLibrary ( ) ) ; array_walk ( $ files , function ( & $ val ) use ( $ path ) { $ val = $ path . $ val ; } ) ; return $ files ; }
Returns an array of files required to render the chart Includes the default files as well as any files registered by type It s important to note that some methods in concrete classes will add additional files to this instance
25,367
public function getOptionsForSeries ( $ series ) { $ seriesTitle = $ this -> getSeriesTitle ( $ series ) ; if ( ! isset ( $ this -> options [ 'seriesStorage' ] [ $ seriesTitle ] ) ) { throw new \ Exception ( 'Series not registered with JsWriter' ) ; } return $ this -> options [ 'seriesStorage' ] [ $ seriesTitle ] ; }
Returns the options for a series
25,368
public function getSeriesOption ( $ series , $ option , $ default = null ) { $ seriesTitle = $ this -> getSeriesTitle ( $ series ) ; return ( isset ( $ this -> options [ 'seriesStorage' ] [ $ seriesTitle ] ) && isset ( $ this -> options [ 'seriesStorage' ] [ $ seriesTitle ] [ $ option ] ) ) ? $ this -> options [ 'seriesStorage' ] [ $ seriesTitle ] [ $ option ] : $ default ; }
Returns an option for a specific series . Accepts title or instance .
25,369
public function setSeriesOption ( $ series , $ name , $ value ) { $ this -> setNestedOptVal ( $ this -> options , 'seriesStorage' , $ this -> getSeriesTitle ( $ series ) , $ name , $ value ) ; return $ this ; }
Set a series - specific value for rendering JS
25,370
public function setType ( $ type , $ options = array ( ) , $ series = 'default' ) { $ options = $ options ? : array ( ) ; $ className = $ this -> typeNamespace . ucwords ( $ type ) ; if ( class_exists ( $ className ) ) { $ type = new $ className ( $ this ) ; } else { throw new \ Exception ( "Type {$type} does not exist" ) ; } $ type -> setOptions ( $ options ) ; $ series = $ this -> getSeriesTitle ( $ series ) ; $ this -> types [ $ series ] = $ type ; if ( isset ( $ this -> options [ 'seriesStorage' ] [ $ series ] ) ) { $ this -> options [ 'seriesStorage' ] [ $ series ] = array_merge_recursive ( $ this -> options [ 'seriesStorage' ] [ $ series ] , $ type -> getSeriesOptions ( ) ) ; if ( $ renderer = $ type -> getRenderer ( ) ) { $ this -> options [ 'seriesStorage' ] [ $ series ] [ 'renderer' ] = $ renderer ; } } $ this -> options = array_merge_recursive ( $ this -> options , $ type -> getOptions ( ) ) ; return $ this ; }
Returns an type that has not yet been registered .
25,371
public function getType ( $ series = null ) { $ series = $ series ? : 'default' ; $ seriesTitle = $ this -> getSeriesTitle ( $ series ) ; return isset ( $ this -> types [ $ seriesTitle ] ) ? $ this -> types [ $ seriesTitle ] : null ; }
Returns the type instance for the provided key
25,372
protected function setNestedOptVal ( array & $ options , $ arg ) { $ args = func_get_args ( ) ; if ( count ( $ args ) == 2 && is_array ( $ args [ 1 ] ) ) { $ args = $ args [ 1 ] ; } else if ( count ( $ args ) < 3 ) { throw new \ BadMethodCallException ( '\Altamira\JsWriterAbstract::setNestedOptVal requires at least three arguments' ) ; } else { array_shift ( $ args ) ; } do { $ arg = array_shift ( $ args ) ; if ( ! isset ( $ options [ $ arg ] ) ) { $ options [ $ arg ] = array ( ) ; } $ options = & $ options [ $ arg ] ; } while ( count ( $ args ) > 2 ) ; $ options [ array_shift ( $ args ) ] = array_shift ( $ args ) ; return $ this ; }
Allows you to set discretely infinite nesting without notices by creating an empty array for key values that don t already exist
25,373
protected function getNestedOptVal ( array $ options , $ arg ) { $ args = func_get_args ( ) ; if ( count ( $ args ) == 2 && is_array ( $ args [ 1 ] ) ) { $ args = $ args [ 1 ] ; } else if ( count ( $ args ) < 3 ) { throw new \ BadMethodCallException ( '\Altamira\JsWriterAbstract::getNestedOptVal requires at least three arguments' ) ; } else { array_shift ( $ args ) ; } do { $ arg = array_shift ( $ args ) ; if ( ! isset ( $ options [ $ arg ] ) ) { return null ; } $ options = & $ options [ $ arg ] ; } while ( count ( $ args ) > 1 ) ; $ finalArg = array_shift ( $ args ) ; return isset ( $ options [ $ finalArg ] ) ? $ options [ $ finalArg ] : null ; }
Allows you to get the value for discretely infinite nesting without notices by returning null without a warning if it doesn t exist
25,374
public function onMainMenuBuild ( MenuBuilderEvent $ event ) : void { if ( ! $ this -> authorizationChecker -> isGranted ( 'ROLE_NGBM_ADMIN' ) ) { return ; } $ this -> addLayoutsSubMenu ( $ event -> getMenu ( ) ) ; }
This method adds Netgen Layouts menu items to Sylius admin interface .
25,375
public function setOption ( $ name , $ value ) { switch ( $ name ) { case 'horizontal' : $ this -> options [ 'bars' ] [ 'horizontal' ] = $ value ; break ; case 'stackSeries' : $ this -> pluginFiles [ ] = 'jquery.flot.stack.js' ; $ this -> options [ 'series' ] [ 'stack' ] = true ; break ; case 'fillColor' : $ this -> options [ 'series' ] [ 'bars' ] [ 'fillColor' ] [ 'colors' ] = $ value ; break ; default : parent :: setOption ( $ name , $ value ) ; } return $ this ; }
Abstracts out option setting and registers the required options based on what s provided .
25,376
protected function prepareContentData ( $ record ) { $ dataArray = array ( 'token' => $ this -> token , 'channel' => $ this -> channel , 'username' => $ this -> username , 'text' => '' , 'attachments' => array ( ) , ) ; if ( $ this -> formatter ) { $ message = $ this -> formatter -> format ( $ record ) ; } else { $ message = $ record [ 'message' ] ; } if ( $ this -> useAttachment ) { $ attachment = array ( 'fallback' => $ message , 'color' => $ this -> getAttachmentColor ( $ record [ 'level' ] ) , 'fields' => array ( ) , ) ; if ( $ this -> useShortAttachment ) { $ attachment [ 'title' ] = $ record [ 'level_name' ] ; $ attachment [ 'text' ] = $ message ; } else { $ attachment [ 'title' ] = 'Message' ; $ attachment [ 'text' ] = $ message ; $ attachment [ 'fields' ] [ ] = array ( 'title' => 'Level' , 'value' => $ record [ 'level_name' ] , 'short' => true , ) ; } if ( $ this -> includeContextAndExtra ) { if ( ! empty ( $ record [ 'extra' ] ) ) { if ( $ this -> useShortAttachment ) { $ attachment [ 'fields' ] [ ] = array ( 'title' => "Extra" , 'value' => $ this -> stringify ( $ record [ 'extra' ] ) , 'short' => $ this -> useShortAttachment , ) ; } else { foreach ( $ record [ 'extra' ] as $ var => $ val ) { $ attachment [ 'fields' ] [ ] = array ( 'title' => $ var , 'value' => $ val , 'short' => $ this -> useShortAttachment , ) ; } } } if ( ! empty ( $ record [ 'context' ] ) ) { if ( $ this -> useShortAttachment ) { $ attachment [ 'fields' ] [ ] = array ( 'title' => "Context" , 'value' => $ this -> stringify ( $ record [ 'context' ] ) , 'short' => $ this -> useShortAttachment , ) ; } else { foreach ( $ record [ 'context' ] as $ var => $ val ) { $ attachment [ 'fields' ] [ ] = array ( 'title' => $ var , 'value' => $ val , 'short' => $ this -> useShortAttachment , ) ; } } } } $ dataArray [ 'attachments' ] = json_encode ( array ( $ attachment ) ) ; } else { $ dataArray [ 'text' ] = $ message ; } if ( $ this -> iconEmoji ) { $ dataArray [ 'icon_emoji' ] = ":{$this->iconEmoji}:" ; } return $ dataArray ; }
Prepares content data
25,377
public function getCache ( string $ name = '' ) { $ cache = $ this -> findCache ( $ name ) ; if ( \ is_null ( $ cache ) ) { $ cache = $ this -> createCache ( $ name ) ; if ( ! \ is_null ( $ cache ) ) { $ this -> addCache ( $ cache ) ; } } return $ cache ; }
Get or Create a Cache
25,378
public function findCache ( string $ name = '' ) { if ( empty ( $ name ) ) { $ cache = \ reset ( $ this -> caches ) ; if ( $ cache === false ) return null ; } else { $ cache = ( $ this -> caches [ \ strtolower ( $ name ) ] ?? null ) ; } return $ cache ; }
Find a Cache based on name
25,379
public function addCache ( AbstractCacheAdapterInterface $ cache ) { $ this -> caches [ \ strtolower ( $ cache -> getDriver ( ) ) ] = $ cache ; return $ this ; }
Adds the Cache to the Pool
25,380
public function removeCache ( string $ name ) { if ( empty ( $ name ) ) return false ; $ cache = $ this -> findCache ( $ name ) ; if ( $ cache ) { unset ( $ this -> caches [ \ strtolower ( $ cache -> getDriver ( ) ) ] ) ; unset ( $ cache ) ; $ cache = null ; } return $ this ; }
Remove a cache from the pool
25,381
protected function registerConfigItems ( ParentItem $ root , $ parentId , $ configItems ) { foreach ( $ configItems as $ configId => $ configItem ) { $ subItems = reset ( $ configItem ) ; $ path = $ parentId . '/' . $ configId ; $ configPath = str_replace ( "admin/server/config/" , '' , $ path ) ; $ translationKey = 'expansion_config.menu.' . implode ( '.' , explode ( '/' , $ configPath ) ) . '.label' ; if ( is_array ( $ subItems ) ) { $ root -> addChild ( ParentItem :: class , $ path , $ translationKey , null ) ; $ this -> registerConfigItems ( $ root , $ path , $ configItem ) ; } else { $ root -> addChild ( ChatCommandItem :: class , $ path , $ translationKey , 'admin_config' , [ 'cmd' => '/admin config "' . $ configPath . '"' ] ) ; } } }
Register config items
25,382
public function createStreamFromFile ( string $ filename , string $ mode = 'r' ) : StreamInterface { $ resource = \ fopen ( $ filename , $ mode ) ; return \ GuzzleHttp \ Psr7 \ stream_for ( $ resource ) ; }
Create a stream from an existing file .
25,383
public function apply ( Injector $ injector ) : void { $ dependencies = $ this -> config [ 'dependencies' ] ?? [ ] ; $ dependencies [ 'services' ] [ 'config' ] = new ArrayObject ( $ this -> config , ArrayObject :: ARRAY_AS_PROPS ) ; $ this -> injectServices ( $ injector , $ dependencies ) ; $ this -> injectFactories ( $ injector , $ dependencies ) ; $ this -> injectInvokables ( $ injector , $ dependencies ) ; $ this -> injectAliases ( $ injector , $ dependencies ) ; }
Configure the injector using Zend Service Manager format
25,384
function & getSuggestions ( $ lang , $ word ) { $ r = enchant_broker_init ( ) ; $ suggs = array ( ) ; if ( enchant_broker_dict_exists ( $ r , $ lang ) ) { $ d = enchant_broker_request_dict ( $ r , $ lang ) ; $ suggs = enchant_dict_suggest ( $ d , $ word ) ; enchant_broker_free_dict ( $ d ) ; } else { } enchant_broker_free ( $ r ) ; return $ suggs ; }
Returns suggestions for a specific word .
25,385
public function generate ( array $ parameters = array ( ) , array $ options = array ( ) ) { $ parametersResolver = new OptionsResolver ( ) ; $ this -> setDefaultParameters ( $ parametersResolver ) ; $ parameters = $ parametersResolver -> resolve ( $ parameters ) ; $ optionsResolver = new OptionsResolver ( ) ; $ this -> setDefaultOptions ( $ optionsResolver ) ; $ options = $ optionsResolver -> resolve ( $ options ) ; return $ this -> doGenerate ( $ parameters , $ options ) ; }
Generates a new PDF
25,386
public static function finish ( ) { if ( empty ( self :: $ profiler ) === false ) { self :: $ profiler = array_merge ( [ 'elapsed' => self :: getTime ( time ( ) - self :: $ profiler [ 'start' ] ) , 'memory' => self :: getMemoryUsage ( ) , 'cpu' => self :: getUsageCPU ( ) , 'stack' => self :: getStackCalls ( ) ] , self :: $ profiler ) ; unset ( self :: $ profiler [ 'start' ] ) ; } }
Finish collect profiling data
25,387
public function getTime ( $ seconds ) { $ dtF = new \ DateTime ( "@0" ) ; $ dtT = new \ DateTime ( "@$seconds" ) ; return $ dtF -> diff ( $ dtT ) -> format ( '%h hours, %i minutes %s sec.' ) ; }
Get elapsled time
25,388
private static function getStackCalls ( ) { $ i = 1 ; $ result = [ ] ; foreach ( xdebug_get_function_stack ( ) as $ node ) { if ( isset ( $ node [ 'line' ] ) === true ) { $ result [ ] = "$i. " . basename ( $ node [ 'file' ] ) . ":" . $ node [ 'function' ] . "(" . $ node [ 'line' ] . ")" ; } $ i ++ ; } return $ result ; }
Get stack calls
25,389
private static function getMemoryUsage ( ) { $ memory = memory_get_peak_usage ( ) ; $ floor = floor ( ( strlen ( $ memory ) - 1 ) / 3 ) ; return sprintf ( "%.2f" , $ memory / pow ( 1024 , $ floor ) ) . ' ' . @ 'BKMGTPEZY' [ $ floor ] . 'B' ; }
Get stack of memory usage
25,390
private static function pretty ( array $ data ) { $ color = new Color ( ) ; $ output = $ color -> getColoredString ( self :: VERBOSE_TITLE , 'blue' , 'light-gray' ) . PHP_EOL ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) === false ) { $ output .= $ color -> getColoredString ( sprintf ( self :: VERBOSE_ROW , $ key , $ value ) , 'dark_gray' ) . PHP_EOL ; } else { $ output .= $ color -> getColoredString ( sprintf ( self :: VERBOSE_ROW , $ key , '' ) , 'dark_gray' ) . PHP_EOL ; foreach ( $ value as $ line => $ string ) { $ output .= $ color -> getColoredString ( sprintf ( "\t" . self :: VERBOSE_ROW , '' , $ string ) , 'dark_gray' ) . PHP_EOL ; } } } $ output .= $ color -> getColoredString ( '-----------------' , 'blue' , 'light-gray' ) . PHP_EOL ; return $ output ; }
Pretty print profile data
25,391
public function _block_filter_oembed_result ( $ response , $ handler , $ request ) { if ( 'GET' !== $ request -> get_method ( ) ) { return $ response ; } if ( is_wp_error ( $ response ) && 'oembed_invalid_url' !== $ response -> get_error_code ( ) ) { return $ response ; } if ( '/oembed/1.0/proxy' !== $ request -> get_route ( ) ) { return $ response ; } $ provider_name = 'wp-oembed-blog-card handler' ; if ( isset ( $ response -> provider_name ) && $ response -> provider_name === $ provider_name ) { return $ response ; } global $ wp_embed ; $ html = $ wp_embed -> shortcode ( [ ] , $ request -> get_param ( 'url' ) ) ; if ( ! $ html ) { return $ response ; } return [ 'provider_name' => $ provider_name , 'html' => $ html , ] ; }
Make sure oEmbed REST Requests apply the WP Embed security mechanism for WordPress embeds .
25,392
protected function _maybe_refresh_cache ( $ url ) { $ cache = Cache :: get ( $ url ) ; if ( ! $ cache || is_admin ( ) ) { Cache :: refresh ( $ url ) ; } }
Refresh cache if the cache is expired or is_admin
25,393
protected function _render ( $ url ) { $ this -> _maybe_refresh_cache ( $ url ) ; if ( ! is_admin ( ) ) { return $ this -> _is_block_embed_rendering_request ( ) ? View :: get_block_template ( $ url ) : View :: get_pre_blog_card_template ( $ url ) ; } return View :: get_template ( $ url ) ; }
Rendering bloc card on editor
25,394
protected function _is_admin_request ( ) { if ( ! isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { return false ; } $ request_uri = wp_unslash ( $ _SERVER [ 'REQUEST_URI' ] ) ; if ( false !== strpos ( $ request_uri , '/wp-admin/admin-ajax.php' ) ) { return false === strpos ( $ request_uri , 'action=wp_oembed_blog_card_render' ) ; } if ( false !== strpos ( $ request_uri , '/wp-json/' ) ) { return false === strpos ( $ request_uri , '/wp-json/oembed/' ) ; } if ( false !== strpos ( $ request_uri , '/wp-cron.php' ) ) { return true ; } return false ; }
Return true when requested from admin - ajax . php wp - cron . php wp - json
25,395
public function setAutosuggest ( $ context , $ url , $ paramReq , $ jsCallback = "" , $ jsonArray = "select.option" , $ jsonObjKey = "value" , $ jsonObjValue = "_text" , $ jsonObjInfo = "_text" ) { $ this -> _context = $ context ; $ this -> _autosuggestUrl = $ url ; $ this -> _autosuggestParamReq = $ paramReq ; $ this -> _autosuggestCallback = $ jsCallback ; $ this -> _autosuggestJsonArray = $ jsonArray ; $ this -> _autosuggestJsonObjKey = $ jsonObjKey ; $ this -> _autosuggestJsonObjValue = $ jsonObjValue ; $ this -> _autosuggestJsonObjInfo = $ jsonObjInfo ; }
Configure an basic Autosuggest based on a JSON request .
25,396
public function getEncoding ( $ direction ) { if ( ! isset ( $ this -> encoding [ $ direction ] ) ) { throw new Exception ( "Encoding direction invalid" ) ; } return $ this -> encoding [ $ direction ] ; }
Get decoding for CSV .
25,397
public function setEncoding ( $ direction , $ encoding ) { if ( ! isset ( $ this -> encoding [ $ direction ] ) ) { throw new Exception ( "Encoding direction invalid" ) ; } if ( ! $ encoding ) { throw new Exception ( "Encoding value invalid" ) ; } elseif ( preg_match ( '/utf.?8/ui' , $ encoding ) ) { $ encoding = 'UTF-8' ; } else { $ encoding = mb_strtoupper ( $ encoding ) ; } $ this -> encoding [ $ direction ] = $ encoding ; return $ this ; }
Set encoding for CSV .
25,398
public function SearchAndReplace ( $ buffer ) { $ context = Context :: getInstance ( ) ; $ posi = 0 ; $ i = strpos ( $ buffer , "<param-" , $ posi ) ; while ( $ i !== false ) { echo substr ( $ buffer , $ posi , $ i - $ posi ) ; $ if = strpos ( $ buffer , "</param-" , $ i ) ; $ tamparam = $ if - $ i - 8 ; $ var = substr ( $ buffer , $ i + 7 , $ tamparam ) ; echo $ context -> get ( $ var ) ; $ posi = $ if + $ tamparam + 9 ; $ i = strpos ( $ buffer , "<param-" , $ posi ) ; } echo substr ( $ buffer , $ posi ) ; }
This method is used only in the Wrappers So it can echo string directly
25,399
public function addJavaScript ( $ javascript , $ location = 'up' ) { $ nodeWorking = XmlUtil :: CreateChild ( $ this -> _nodePage , "script" , "" ) ; XmlUtil :: AddAttribute ( $ nodeWorking , "language" , "javascript" ) ; XmlUtil :: AddAttribute ( $ nodeWorking , "location" , $ location ) ; XmlUtil :: AddTextNode ( $ nodeWorking , $ javascript ) ; }
= - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -