idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
24,300 | function partition ( callable $ closure ) { $ collection1 = new self ( ) ; $ collection2 = new self ( ) ; foreach ( $ this -> data as $ key => $ val ) { if ( $ closure ( $ val , $ key ) ) { $ collection1 -> set ( $ key , $ val ) ; } else { $ collection2 -> set ( $ key , $ val ) ; } } return array ( $ collection1 , $ collection2 ) ; } | Partitions the collection into two collections where the first collection contains the items that passed and the second contains the items that failed . |
24,301 | function pluck ( $ key , $ index = null ) { $ data = array ( ) ; $ i = 0 ; foreach ( $ this -> data as $ v ) { $ k = ( $ index ? ( \ is_array ( $ v ) ? ( \ array_key_exists ( $ index , $ v ) ? $ v [ $ index ] : $ i ) : ( \ is_object ( $ v ) ? ( \ property_exists ( $ v , $ index ) ? $ v -> $ index : $ i ) : $ i ) ) : $ i ) ; if ( \ is_array ( $ v ) && \ array_key_exists ( $ key , $ v ) ) { $ data [ $ k ] = $ v [ $ key ] ; } elseif ( \ is_object ( $ v ) && \ property_exists ( $ v , $ key ) ) { $ data [ $ k ] = $ v -> $ key ; } $ i ++ ; } return ( new self ( $ data ) ) ; } | Return the values from a single column in the input array . Returns a new Collection . |
24,302 | function random ( int $ num = 1 ) { $ rand = \ array_rand ( $ this -> data , $ num ) ; if ( ! \ is_array ( $ rand ) ) { $ rand = array ( $ rand ) ; } $ col = new self ( ) ; foreach ( $ rand as $ key ) { $ col -> set ( $ key , $ this -> data [ $ key ] ) ; } return $ col ; } | Returns one random item or multiple random items inside a Collection from the Collection . Returns a new Collection . |
24,303 | function reduce ( callable $ closure , $ carry = null ) { foreach ( $ this -> data as $ val ) { $ carry = $ closure ( $ carry , $ val ) ; } return $ carry ; } | Reduces the collection to a single value passing the result of each iteration into the subsequent iteration . |
24,304 | function search ( $ needle , bool $ strict = true ) { return \ array_search ( $ needle , $ this -> data , $ strict ) ; } | Searches the collection for the given value and returns its key if found . If the item is not found false is returned . |
24,305 | function slice ( int $ offset , int $ limit = null , bool $ preserve_keys = false ) { $ data = $ this -> data ; return ( new self ( \ array_slice ( $ data , $ offset , $ limit , $ preserve_keys ) ) ) ; } | Returns a slice of the collection starting at the given index . Returns a new Collection . |
24,306 | function some ( callable $ closure ) { foreach ( $ this -> data as $ key => $ val ) { if ( $ closure ( $ val , $ key ) ) { return true ; } } return false ; } | Returns true if at least one element passes the given truth test . |
24,307 | function sort ( bool $ descending = false , int $ options = \ SORT_REGULAR ) { $ data = $ this -> data ; if ( $ descending ) { \ arsort ( $ data , $ options ) ; } else { \ asort ( $ data , $ options ) ; } return ( new self ( $ data ) ) ; } | Sorts the collection using sort behaviour flags . Returns a new Collection . |
24,308 | function sortKey ( bool $ descending = false , int $ options = \ SORT_REGULAR ) { $ data = $ this -> data ; if ( $ descending ) { \ krsort ( $ data , $ options ) ; } else { \ ksort ( $ data , $ options ) ; } return ( new self ( $ data ) ) ; } | Sorts the collection by key using sort behaviour flags . Returns a new Collection . |
24,309 | function sortCustom ( callable $ closure ) { $ data = $ this -> data ; \ uasort ( $ data , $ closure ) ; return ( new self ( $ data ) ) ; } | Sorts the collection using a custom sorting function . Returns a new Collection . |
24,310 | function sortCustomKey ( callable $ closure ) { $ data = $ this -> data ; \ uksort ( $ data , $ closure ) ; return ( new self ( $ data ) ) ; } | Sorts the collection by key using a custom sorting function . Returns a new Collection . |
24,311 | function unique ( $ key , $ options = \ SORT_REGULAR ) { if ( $ key === null ) { return ( new self ( \ array_unique ( $ this -> data , $ options ) ) ) ; } $ exists = array ( ) ; return $ this -> filter ( function ( $ item ) use ( $ key , & $ exists ) { if ( \ is_array ( $ item ) ) { if ( ! isset ( $ item [ $ key ] ) ) { throw new \ BadMethodCallException ( 'Specified key "' . $ key . '" does not exist on array' ) ; } $ id = $ item [ $ key ] ; } elseif ( \ is_object ( $ item ) ) { if ( ! isset ( $ item -> $ key ) ) { throw new \ BadMethodCallException ( 'Specified key "' . $ key . '" does not exist on object' ) ; } $ id = $ item -> $ key ; } else { $ id = $ item ; } if ( \ in_array ( $ id , $ exists , true ) ) { return false ; } $ exists [ ] = $ id ; return true ; } ) ; } | Returns all of the unique items in the collection . Returns a new Collection . |
24,312 | public function resolveClass ( FoundClass $ found ) { Logger :: trace ( "Resolving class %s" , $ found -> name ) ; if ( $ found -> name [ 0 ] === '\\' ) { return new Classname ( $ found -> name ) ; } $ classParts = explode ( '\\' , $ found -> name ) ; if ( count ( $ classParts ) >= 2 ) { $ b = array_shift ( $ classParts ) ; $ baseClass = $ this -> originalUse -> get ( $ b ) ; if ( $ baseClass ) { return new Classname ( $ baseClass . '\\' . implode ( '\\' , $ classParts ) ) ; } } if ( $ c = $ this -> originalUse -> get ( $ found -> name ) ) { Logger :: trace ( "Found a use statement for class" ) ; Logger :: trace ( "Resolved to %s" , $ c ) ; return $ c ; } else { $ class = Classname :: build ( $ this -> getOriginalNamespace ( ) , $ found -> name ) ; Logger :: trace ( "Resolved to %s" , $ class -> classname ) ; return $ class ; } } | Resolves a class to it s fully - qualified using a few different mechanisms . If the class begins with a slash we assume that it is already qualified . If the class exists in the list of use - statements then we resolve the fully qualified name using the uses . Lastly if the class doesn t begin with a slash or exist as a use - statement we resolve the name using the namespace of the current class . |
24,313 | public function shortenClasses ( $ classesToFix , Configuration $ config ) { $ cumulativeOffset = 0 ; foreach ( $ classesToFix as $ c ) { $ replacement = [ ] ; if ( in_array ( $ c -> name , $ this -> ignoredClassNames ) ) { if ( $ c -> name == $ this -> originalClassname ) { $ replacement = [ [ T_STATIC , "static" , 2 ] ] ; } else { continue ; } } if ( ! $ replacement ) { $ resolvedClass = $ this -> resolveClass ( $ c ) ; $ alias = $ config -> replace ( $ this -> originalUse -> getAliasForClassname ( $ resolvedClass ) ) ; Logger :: trace ( "Resolved class %s to %s" , array ( $ resolvedClass -> classname , $ alias ) ) ; $ replacement = array ( array ( 308 , $ alias , 2 ) ) ; } $ offset = $ c -> from ; $ length = $ c -> to - $ c -> from + 1 ; array_splice ( $ this -> tokens , $ offset + $ cumulativeOffset , $ length , $ replacement ) ; $ cumulativeOffset -= $ length - 1 ; } } | fixClasses replaces all classnames with the shortest version of a class name possible |
24,314 | public function getSrc ( ) { $ content = "" ; foreach ( $ this -> tokens as $ token ) { $ content .= is_string ( $ token ) ? $ token : $ token [ 1 ] ; ; } return $ content ; } | Returns the rebuilt source code by processing each token back as it was |
24,315 | public function save ( $ directory ) { $ parts = explode ( '_' , $ this -> getClass ( ) ) ; array_unshift ( $ parts , $ directory ) ; $ path = join ( DIRECTORY_SEPARATOR , $ parts ) . '.php' ; self :: saveToFile ( $ path , $ this -> getSrc ( ) ) ; } | Saves the file to the location complying with the Magento classloader s file placement structure |
24,316 | private static function saveToFile ( $ path , $ contents ) { $ directory = pathinfo ( $ path , PATHINFO_DIRNAME ) ; if ( ! file_exists ( $ directory ) ) { mkdir ( $ directory , 0777 , true ) ; } file_put_contents ( $ path , $ contents ) ; } | Extended version of file put contents that also creates the directory tree if it doesn t exist . |
24,317 | public function saveLastProcessedVersion ( $ version ) { $ this -> lastProcessedVersion = $ version ; $ this -> myCreateColumn = null ; $ this -> deleteFromSQL ( [ 'serverurl' => constant ( 'FLEXIBEE_URL' ) ] ) ; if ( is_null ( $ this -> insertToSQL ( [ 'serverurl' => constant ( 'FLEXIBEE_URL' ) , 'changeid' => $ version ] ) ) ) { $ this -> addStatusMessage ( _ ( "Last Processed Change ID Saving Failed" ) , 'error' ) ; } else { if ( $ this -> debug === true ) { $ this -> addStatusMessage ( sprintf ( _ ( 'Last Processed Change ID #%s Saved' ) , $ version ) ) ; } } } | Ulozi posledni zpracovanou verzi |
24,318 | private function putFile ( MountManager $ mountManager , string $ from , string $ to , array $ config ) : bool { $ this -> logger -> debug ( "Copying file $from to $to" ) ; list ( $ prefixFrom , $ from ) = $ mountManager -> getPrefixAndPath ( $ from ) ; $ buffer = $ mountManager -> getFilesystem ( $ prefixFrom ) -> readStream ( $ from ) ; if ( $ buffer === false ) { return false ; } list ( $ prefixTo , $ to ) = $ mountManager -> getPrefixAndPath ( $ to ) ; $ result = $ mountManager -> getFilesystem ( $ prefixTo ) -> putStream ( $ to , $ buffer , $ config ) ; if ( is_resource ( $ buffer ) ) { fclose ( $ buffer ) ; } return $ result ; } | This method is the same as copy except that it does a putStream rather than writeStream allowing it to write even if the file exists . |
24,319 | public static function generateSessionId ( $ length = 40 ) { if ( $ length < 1 ) { throw new \ InvalidArgumentException ( 'Length should be >= 1' ) ; } $ chars = '0123456789abcdefghijklmnopqrstuvwxyz' ; $ numChars = 36 ; $ bytes = random_bytes ( $ length ) ; $ pos = 0 ; $ result = '' ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ pos = ( $ pos + ord ( $ bytes [ $ i ] ) ) % $ numChars ; $ result .= $ chars [ $ pos ] ; } return $ result ; } | Create a base 36 random alphanumeric string . No uppercase because these would collide with lowercase chars on Windows . |
24,320 | public function createPlayer ( PlayerInfo $ playerInfo , PlayerDetailedInfo $ playerDetailedInfo ) { $ class = $ this -> class ; $ player = new $ class ( ) ; $ player -> merge ( $ playerInfo ) ; $ player -> merge ( $ playerDetailedInfo ) ; return $ player ; } | Create a player obhect . |
24,321 | public function getRenderData ( $ useLabel = false ) { if ( ( $ this -> jsWriter -> getType ( $ this -> series -> getTitle ( ) ) instanceof \ Altamira \ Type \ Flot \ Donut ) ) { $ value = array ( 1 , $ this [ 'y' ] ) ; } else { $ value = array ( $ this [ 'x' ] , $ this [ 'y' ] ) ; if ( $ useLabel ) { $ value [ ] = $ this -> getLabel ( ) ; } } return $ value ; } | Provides the data prepared for json encoding |
24,322 | public function checkIP ( $ UserIP = false ) { if ( $ UserIP === false ) { $ tempIP = $ this -> dlstatsGetUserIP ( ) ; if ( $ tempIP !== false ) { $ this -> IP = $ tempIP ; } else { return false ; } } else { $ this -> IP = $ UserIP ; } switch ( $ this -> checkIPVersion ( $ this -> IP ) ) { case "IPv4" : if ( $ this -> checkIPv4 ( $ this -> IP ) === true ) { $ this -> IP_Filter = true ; return $ this -> IP_Filter ; } break ; case "IPv6" : if ( $ this -> checkIPv6 ( $ this -> IP ) === true ) { $ this -> IP_Filter = true ; return $ this -> IP_Filter ; } break ; default : $ this -> IP_Filter = false ; return $ this -> IP_Filter ; break ; } $ this -> IP_Filter = false ; return $ this -> IP_Filter ; } | IP Check Set IP detect the IP version and calls the method CheckIPv4 respectively CheckIPv6 . |
24,323 | protected function checkIPVersion ( $ UserIP = false ) { if ( ip2long ( $ UserIP ) !== false ) { $ this -> IP_Version = "IPv4" ; return $ this -> IP_Version ; } if ( substr_count ( $ UserIP , ":" ) < 2 ) { $ this -> IP_Version = false ; return false ; } if ( substr_count ( $ UserIP , "::" ) > 1 ) { $ this -> IP_Version = false ; return false ; } $ groups = explode ( ':' , $ UserIP ) ; $ num_groups = count ( $ groups ) ; if ( ( $ num_groups > 8 ) || ( $ num_groups < 3 ) ) { $ this -> IP_Version = false ; return false ; } $ empty_groups = 0 ; foreach ( $ groups as $ group ) { $ group = trim ( $ group ) ; if ( ! empty ( $ group ) && ! ( is_numeric ( $ group ) && ( $ group == 0 ) ) ) { if ( ! preg_match ( '#([a-fA-F0-9]{0,4})#' , $ group ) ) { $ this -> IP_Version = false ; return false ; } } else { ++ $ empty_groups ; } } if ( $ empty_groups < $ num_groups ) { $ this -> IP_Version = "IPv6" ; return $ this -> IP_Version ; } $ this -> IP_Version = false ; return false ; } | IP = IPv4 or IPv6 ? |
24,324 | protected function checkIPv6 ( $ UserIP = false ) { if ( $ UserIP === false ) { return false ; } if ( isset ( $ GLOBALS [ 'DLSTATS' ] [ 'BOT_IPV6' ] ) ) { foreach ( $ GLOBALS [ 'DLSTATS' ] [ 'BOT_IPV6' ] as $ lineleft ) { $ network = explode ( "/" , trim ( $ lineleft ) ) ; if ( ! isset ( $ network [ 1 ] ) ) { $ network [ 1 ] = 128 ; } if ( $ this -> dlstatsIPv6InNetwork ( $ UserIP , $ network [ 0 ] , $ network [ 1 ] ) ) { return true ; } } } return false ; } | IP Check for IPv6 |
24,325 | protected function checkIPv4 ( $ UserIP = false ) { if ( $ UserIP === false ) { return false ; } if ( isset ( $ GLOBALS [ 'DLSTATS' ] [ 'BOT_IPV4' ] ) ) { foreach ( $ GLOBALS [ 'DLSTATS' ] [ 'BOT_IPV4' ] as $ lineleft ) { $ network = explode ( "/" , trim ( $ lineleft ) ) ; if ( ! isset ( $ network [ 1 ] ) ) { $ network [ 1 ] = 32 ; } if ( $ this -> dlstatsIPv4InNetwork ( $ UserIP , $ network [ 0 ] , $ network [ 1 ] ) ) { return true ; } } } return false ; } | IP Check for IPv4 |
24,326 | protected function dlstatsAnonymizeDomain ( ) { if ( $ this -> IP_Version === false || $ this -> IP === '0.0.0.0' ) { return '' ; } if ( isset ( $ GLOBALS [ 'TL_CONFIG' ] [ 'privacyAnonymizeIp' ] ) && ( bool ) $ GLOBALS [ 'TL_CONFIG' ] [ 'privacyAnonymizeIp' ] === false ) { $ domain = gethostbyaddr ( $ this -> IP ) ; return ( $ domain == $ this -> IP ) ? '' : $ domain ; } $ domain = gethostbyaddr ( $ this -> IP ) ; if ( $ domain != $ this -> IP ) { $ arrURL = explode ( '.' , $ domain ) ; $ tld = array_pop ( $ arrURL ) ; $ host = array_pop ( $ arrURL ) ; return ( strlen ( $ host ) ) ? $ host . '.' . $ tld : $ tld ; } else { return '' ; } } | dlstatsAnonymizeDomain - Anonymize the Domain of visitors if enabled |
24,327 | public function add ( $ element ) { $ currentValue = $ this -> getRawValue ( ) ; if ( ! in_array ( $ element , $ currentValue ) ) { $ currentValue [ ] = $ element ; $ this -> setRawValue ( $ currentValue ) ; } return $ this ; } | Add a new value to the list . |
24,328 | public function remove ( $ element ) { $ currentValue = $ this -> getRawValue ( ) ; if ( ( $ key = array_search ( $ element , $ currentValue ) ) !== false ) { unset ( $ currentValue [ $ key ] ) ; $ this -> setRawValue ( $ currentValue ) ; } } | Remove an element from the list . |
24,329 | public function useCursor ( ) { $ this -> files = array_merge_recursive ( array ( 'jqplot.cursor.js' ) , $ this -> files ) ; $ this -> setNestedOptVal ( $ this -> options , 'cursor' , 'show' , true ) ; $ this -> setNestedOptVal ( $ this -> options , 'cursor' , 'showTooltip' , true ) ; return $ this ; } | Implemented from \ Altamira \ JsWriter \ Ability \ Cursorable |
24,330 | public function setAxisOptions ( $ axis , $ name , $ value ) { if ( strtolower ( $ axis ) === 'x' || strtolower ( $ axis ) === 'y' ) { $ axis = strtolower ( $ axis ) . 'axis' ; if ( in_array ( $ name , array ( 'min' , 'max' , 'numberTicks' , 'tickInterval' , 'numberTicks' ) ) ) { $ this -> setNestedOptVal ( $ this -> options , 'axes' , $ axis , $ name , $ value ) ; } elseif ( in_array ( $ name , array ( 'showGridline' , 'formatString' ) ) ) { $ this -> setNestedOptVal ( $ this -> options , 'axes' , $ axis , 'tickOptions' , $ name , $ value ) ; } } return $ this ; } | Used to format the axis of the registered chart |
24,331 | public function setType ( $ type , $ options = array ( ) , $ series = 'default' ) { parent :: setType ( $ type , $ options , $ series ) ; if ( $ series == 'default' ) { $ rendererOptions = $ this -> types [ 'default' ] -> getRendererOptions ( ) ; if ( $ renderer = $ this -> types [ 'default' ] -> getRenderer ( ) ) { $ this -> options [ 'seriesDefaults' ] [ 'renderer' ] = $ renderer ; } if ( ! empty ( $ rendererOptions ) ) { $ this -> options [ 'seriesDefaults' ] [ 'rendererOptions' ] = $ rendererOptions ; } } return $ this ; } | Registers a type for a series or entire chart |
24,332 | protected function getOptionsJS ( ) { $ opts = $ this -> options ; foreach ( $ opts [ 'seriesStorage' ] as $ label => $ options ) { $ options [ 'label' ] = $ label ; $ opts [ 'series' ] [ ] = $ options ; } if ( $ this -> chart -> titleHidden ( ) ) { unset ( $ opts [ 'title' ] ) ; } unset ( $ opts [ 'seriesStorage' ] ) ; return $ this -> makeJSArray ( $ opts ) ; } | Prepares options and returns JSON |
24,333 | public function setSeriesLabelSetting ( $ series , $ name , $ value ) { if ( ( $ name === 'location' && in_array ( $ value , array ( 'n' , 'ne' , 'e' , 'se' , 's' , 'sw' , 'w' , 'nw' ) ) ) || ( in_array ( $ name , array ( 'xpadding' , 'ypadding' , 'edgeTolerance' , 'stackValue' ) ) ) ) { return $ this -> setNestedOptVal ( $ this -> options , 'seriesStorage' , $ this -> getSeriesTitle ( $ series ) , 'pointLabels' , $ name , $ value ) ; } return $ this ; } | Sets label setting option values |
24,334 | public static function preRender ( \ Altamira \ Chart $ chart , array $ styleOptions = array ( ) ) { if ( $ chart -> titleHidden ( ) ) { return '' ; } $ tagType = isset ( $ styleOptions [ 'titleTag' ] ) ? $ styleOptions [ 'titleTag' ] : 'h3' ; $ title = $ chart -> getTitle ( ) ; $ output = <<<ENDDIV<div class="altamira-chart-title"> <{$tagType}>{$title}</{$tagType}>ENDDIV ; return $ output ; } | Adds open wrapping div and puts title in h3 tags by default but configurable with titleTag key in style If the chart has been set to hide its title then it will not display |
24,335 | public function getUserGroups ( ) { $ groups = [ ] ; foreach ( $ this -> adminGroupConfiguration -> getGroups ( ) as $ groupName ) { $ groups [ ] = $ this -> getUserGroup ( "$groupName" ) ; } $ groups [ ] = $ this -> getUserGroup ( 'guest' ) ; return $ groups ; } | Get list of all user groups . Can be useful for creating group based GUI widgets . |
24,336 | public function getLoginUserGroups ( $ login ) { $ groupName = $ this -> adminGroupConfiguration -> getLoginGroupName ( $ login ) ; if ( empty ( $ groupName ) ) { $ groupName = 'guest' ; } return $ this -> getUserGroup ( "$groupName" ) ; } | Get the group in which a user is . This is useful for gui actions . |
24,337 | public function hasPermission ( $ recipient , $ permission ) { if ( $ recipient instanceof Group ) { $ check = true ; foreach ( $ recipient -> getLogins ( ) as $ login ) { if ( $ this -> hasLoginPermission ( $ login , $ permission ) === false ) { $ check = false ; } } return $ check ; } else { return $ this -> hasLoginPermission ( $ recipient , $ permission ) ; } } | Checks if group a login or a player has a certain permission or not . |
24,338 | public function hasGroupPermission ( $ groupName , $ permission ) { if ( strpos ( $ groupName , 'admin:' ) === 0 ) { $ groupName = str_replace ( "admin:" , '' , $ groupName ) ; } $ logins = $ this -> adminGroupConfiguration -> getGroupLogins ( $ groupName ) ; if ( ! empty ( $ logins ) ) { return $ this -> hasPermission ( $ logins [ 0 ] , $ permission ) ; } if ( $ groupName == 'guest' && is_null ( $ logins ) ) { return false ; } if ( is_null ( $ logins ) ) { throw new UnknownGroupException ( "'$groupName' admin group does not exist." ) ; } return false ; } | Check if a group has a certain permission or not . |
24,339 | public function render ( $ uri , $ maxWidth = 0 , $ maxHeight = 0 , $ objectName = null ) { $ consumer = new Consumer ( ) ; $ this -> prepareRequestParameters ( $ maxWidth , $ maxHeight , $ consumer ) ; $ resourceObject = $ consumer -> consume ( $ uri ) ; if ( $ resourceObject !== null ) { if ( $ objectName !== null ) { if ( $ this -> templateVariableContainer -> exists ( $ objectName ) ) { throw new Exception ( 'Object name for EmbedViewHelper given as: ' . htmlentities ( $ objectName ) . '. This variable name is already in use, choose another.' , 1359969229 ) ; } $ this -> templateVariableContainer -> add ( $ objectName , $ resourceObject ) ; $ html = $ this -> renderChildren ( ) ; $ this -> templateVariableContainer -> remove ( $ objectName ) ; } else { $ html = $ resourceObject -> getAsString ( ) ; } } else { $ html = 'Invalid oEmbed Resource' ; } return $ html ; } | Renders a representation of a oEmbed resource |
24,340 | public final function removeAll ( $ whereParams ) : int { $ whereParams = [ $ whereParams ] ; if ( $ whereParams [ 0 ] === null || $ whereParams [ 0 ] === '' ) { throw new InvalidValueException ( 'You need to pass a parameter for delete action!' ) ; } $ return = $ this -> db -> getLink ( ) -> getAgent ( ) -> deleteAll ( $ this -> table , "{$this->tablePrimary} IN(?)" , $ whereParams ) ; if ( method_exists ( $ this , 'onRemove' ) ) { $ this -> onRemove ( $ return ) ; } return $ return ; } | Remove all . |
24,341 | public function end ( ) { if ( $ this -> isStarted ( ) ) { if ( is_callable ( $ this -> getCleanupCallback ( ) ) ) { call_user_func ( $ this -> getCleanupCallback ( ) ) ; } session_write_close ( ) ; } return $ this ; } | End session . |
24,342 | public function setCleanupCallback ( $ callback ) { if ( ! is_null ( $ callback ) && ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( "No callable function provided" ) ; } $ this -> cleanupCallback = $ callback ; return $ this ; } | Set session cleanup callback function . |
24,343 | public function setCookieLifetime ( $ ttl ) { if ( ! is_null ( $ ttl ) && ! is_numeric ( $ ttl ) ) { throw new InvalidArgumentException ( "No valid ttl provided" ) ; } $ this -> cookieLifetime = ( int ) $ ttl ; return $ this ; } | Set cookie time - to - live . |
24,344 | public static function fixSforceId ( $ shortId ) { $ shortId = ( string ) $ shortId ; if ( strlen ( $ shortId ) !== 15 ) { return new self ( $ shortId ) ; } $ suffix = '' ; for ( $ i = 0 ; $ i < 3 ; $ i ++ ) { $ flags = 0 ; for ( $ j = 0 ; $ j < 5 ; $ j ++ ) { $ c = substr ( $ shortId , $ i * 5 + $ j , 1 ) ; if ( false !== strpos ( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' , $ c ) ) { $ flags += ( 1 << $ j ) ; } } if ( $ flags <= 25 ) { $ suffix .= substr ( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' , $ flags , 1 ) ; } else { $ suffix .= substr ( '012345' , $ flags - 26 , 1 ) ; } } return new self ( $ shortId . $ suffix ) ; } | Create the 18 char ID from a 15 char ID |
24,345 | public function getRoot ( ) { $ tmp_parent = $ this -> getParent ( ) ; $ root = $ tmp_parent ; while ( $ tmp_parent ) { $ root = $ tmp_parent ; $ tmp_parent = $ tmp_parent -> getParent ( ) ; } return $ root ; } | Returns the entity s root if it has one . |
24,346 | public function setValue ( $ attribute_name , $ attribute_value ) { $ value_holder = $ this -> getValueHolderFor ( $ attribute_name ) ; $ this -> validation_results -> setItem ( $ attribute_name , $ value_holder -> setValue ( $ attribute_value , $ this ) ) ; return $ this -> isValid ( ) ; } | Sets a specific value by attribute_name . |
24,347 | public function setValues ( array $ values ) { foreach ( $ this -> type -> getAttributes ( ) -> getKeys ( ) as $ attribute_name ) { if ( array_key_exists ( $ attribute_name , $ values ) ) { $ this -> setValue ( $ attribute_name , $ values [ $ attribute_name ] ) ; } } return $ this -> isValid ( ) ; } | Batch set a given list of attribute values . |
24,348 | public function toArray ( ) { $ attribute_values = [ self :: OBJECT_TYPE => $ this -> getType ( ) -> getPrefix ( ) ] ; foreach ( $ this -> value_holder_map as $ attribute_name => $ value_holder ) { $ attribute_value = $ value_holder -> getValue ( ) ; if ( is_object ( $ attribute_value ) && is_callable ( [ $ attribute_value , 'toArray' ] ) ) { $ attribute_values [ $ attribute_name ] = $ attribute_value -> toArray ( ) ; } else { $ attribute_values [ $ attribute_name ] = $ value_holder -> toNative ( ) ; } } return $ attribute_values ; } | Returns an array representation of a entity s current value state . |
24,349 | public function isEqualTo ( EntityInterface $ entity ) { if ( $ entity -> getType ( ) !== $ this -> getType ( ) ) { return false ; } if ( $ this -> getType ( ) -> getAttributes ( ) -> getSize ( ) !== $ this -> value_holder_map -> getSize ( ) ) { return false ; } foreach ( $ this -> getType ( ) -> getAttributes ( ) -> getKeys ( ) as $ attribute_name ) { $ value_holder = $ this -> value_holder_map -> getItem ( $ attribute_name ) ; if ( ! $ value_holder -> sameValueAs ( $ entity -> getValue ( $ attribute_name ) ) ) { return false ; } } return true ; } | Tells whether this entity is considered equal to another given entity . Entities are equal when they have the same type and values . |
24,350 | public function addEntityChangedListener ( EntityChangedListenerInterface $ listener ) { if ( ! $ this -> listeners -> hasItem ( $ listener ) ) { $ this -> listeners -> push ( $ listener ) ; } } | Attaches the given entity - changed listener . |
24,351 | public function removeEntityChangedListener ( EntityChangedListenerInterface $ listener ) { if ( $ this -> listeners -> hasItem ( $ listener ) ) { $ this -> listeners -> removeItem ( $ listener ) ; } } | Removes the given entity - changed listener . |
24,352 | public function onValueChanged ( ValueChangedEvent $ event ) { $ this -> changes -> push ( $ event ) ; $ this -> propagateEntityChangedEvent ( $ event ) ; } | Handles value - changed events that are received from the entity s value holders . |
24,353 | public function collateChildren ( Closure $ criteria , $ recursive = true ) { $ entity_map = new EntityMap ; $ nested_attribute_types = [ EmbeddedEntityListAttribute :: CLASS , EntityReferenceListAttribute :: CLASS ] ; foreach ( $ this -> getType ( ) -> getAttributes ( [ ] , $ nested_attribute_types ) as $ attribute ) { foreach ( $ this -> getValue ( $ attribute -> getName ( ) ) as $ child_entity ) { if ( $ criteria ( $ child_entity ) ) { $ entity_map -> setItem ( $ child_entity -> asEmbedPath ( ) , $ child_entity ) ; } if ( $ recursive ) { $ entity_map -> append ( $ child_entity -> collateChildren ( $ criteria ) ) ; } } } return $ entity_map ; } | Collate nested entities according to the given predicate and index by embed path |
24,354 | protected function getChatCommands ( ManialinkInterface $ manialink ) { $ login = $ manialink -> getUserGroup ( ) -> getLogins ( ) [ 0 ] ; return array_map ( function ( $ command ) { return [ 'command' => $ command -> getCommand ( ) , 'description' => $ command -> getDescription ( ) , 'help' => $ command -> getHelp ( ) , 'aliases' => $ command -> getAliases ( ) , ] ; } , array_filter ( $ this -> chatCommands -> getChatCommands ( ) , function ( $ command ) use ( $ login ) { if ( $ command instanceof AbstractAdminChatCommand ) { return $ command -> hasPermission ( $ login ) ; } return true ; } ) ) ; } | Get chat commands to display the admin . |
24,355 | public function callbackCallCommand ( ManialinkInterface $ manialink , $ login , $ params , $ arguments ) { $ this -> chatCommandDataProvider -> onPlayerChat ( - 1 , $ login , '/' . $ arguments [ 'command' ] , true ) ; } | Callback called when help button is pressed . |
24,356 | public function callbackDescription ( ManialinkInterface $ manialink , $ login , $ params , $ arguments ) { $ chatCommands = $ this -> chatCommands -> getChatCommands ( ) ; $ this -> windowHelpDetailsFactory -> setCurrentCommand ( $ chatCommands [ $ arguments [ 'command' ] ] ) ; $ this -> windowHelpDetailsFactory -> create ( $ login ) ; } | Callbacked called when description button is pressed . |
24,357 | public function addError ( string $ msg , string ... $ args ) : void { $ this -> errors [ ] = sprintf ( $ msg , ... $ args ) ; } | Add error message to store |
24,358 | public static function build ( string $ connectionName = null ) : Connection { $ configs = Application :: current ( ) -> config ( 'database' ) ; $ connectionName = $ connectionName ? : $ configs [ 'default' ] ; if ( ! isset ( $ configs [ $ connectionName ] ) ) { throw new \ Exception ( "Unknown database connection: '$connectionName'" ) ; } if ( ! isset ( self :: $ connections [ $ connectionName ] ) ) { $ connectionClass = $ configs [ $ connectionName ] [ 'driver' ] ; $ options = $ configs [ $ connectionName ] [ 'options' ] ; self :: $ connections [ $ connectionName ] = new $ connectionClass ( $ options ) ; } return self :: $ connections [ $ connectionName ] ; } | Creates a connection instance by its name . |
24,359 | public function call ( $ url , $ callback , $ additionalData = null , $ options = [ ] ) { $ curlJob = $ this -> factory -> createCurlJob ( $ url , $ callback , $ additionalData , $ options ) ; $ this -> factory -> startJob ( $ curlJob ) ; } | Make a http query . |
24,360 | public function get ( $ url , callable $ callback , $ additionalData = null , $ options = [ ] ) { $ defaultOptions = [ CURLOPT_FOLLOWLOCATION => true , CURLOPT_USERAGENT => "eXpansionPluginPack v " . AbstractApplication :: EXPANSION_VERSION , ] ; $ options = $ options + $ defaultOptions ; $ additionalData [ 'callback' ] = $ callback ; $ this -> call ( $ url , [ $ this , 'process' ] , $ additionalData , $ options ) ; } | Make a get http query . |
24,361 | public function post ( $ url , $ fields , callable $ callback , $ additionalData = null , $ options = [ ] ) { $ this -> doCall ( "POST" , $ url , $ fields , $ callback , $ additionalData , $ options ) ; } | Make a post http query . |
24,362 | public function process ( HttpRequest $ curl ) { $ data = $ curl -> getData ( ) ; $ additionalData = $ curl -> getAdditionalData ( ) ; $ callback = $ additionalData [ 'callback' ] ; unset ( $ additionalData [ 'callback' ] ) ; $ obj = new HttpResult ( $ data [ 'response' ] , $ data [ 'curlInfo' ] , $ curl -> getCurlError ( ) , $ additionalData ) ; call_user_func ( $ callback , $ obj ) ; } | processes the request return value |
24,363 | public function addContext ( array $ context ) { if ( $ context ) { $ this -> context = array_merge ( $ this -> context , $ context ) ; } return $ this ; } | Add log context . |
24,364 | public function newTokenAction ( Request $ request , $ userClass ) { try { $ this -> get ( 'bengor_user.' . $ userClass . '.api_command_bus' ) -> handle ( new LogInUserCommand ( $ request -> getUser ( ) , $ request -> getPassword ( ) ) ) ; } catch ( UserDoesNotExistException $ exception ) { return new JsonResponse ( '' , 400 ) ; } catch ( UserEmailInvalidException $ exception ) { return new JsonResponse ( '' , 400 ) ; } catch ( UserInactiveException $ exception ) { return new JsonResponse ( 'Inactive user' , 400 ) ; } catch ( UserPasswordInvalidException $ exception ) { return new JsonResponse ( '' , 400 ) ; } $ token = $ this -> get ( 'lexik_jwt_authentication.encoder.default' ) -> encode ( [ 'email' => $ request -> getUser ( ) ] ) ; return new JsonResponse ( [ 'token' => $ token ] ) ; } | Generates new token action . |
24,365 | protected function getDocument ( $ record ) { $ document = new Document ( ) ; $ document -> setData ( $ record ) ; $ document -> setType ( $ this -> type ) ; $ document -> setIndex ( $ this -> index ) ; return $ document ; } | Convert a log message into an Elastica Document |
24,366 | public function init ( ) { if ( ! in_array ( $ this -> step , CheckoutSteps :: getSteps ( ) ) ) { $ this -> redirect ( $ this -> Link ( '/' ) ) ; } elseif ( empty ( ReservationSession :: get ( ) ) ) { $ this -> redirect ( $ this -> Link ( '/' ) ) ; } elseif ( ReservationSession :: get ( ) -> Status === 'PAID' && $ this -> step != 'success' ) { ReservationSession :: end ( ) ; $ this -> redirect ( $ this -> Link ( '/' ) ) ; } else { $ this -> reservation = ReservationSession :: get ( ) ; parent :: init ( ) ; } } | Init the controller and check if the current step is allowed |
24,367 | public function Link ( $ action = null ) { if ( ! $ action ) { $ action = $ this -> step ; } return $ this -> dataRecord -> RelativeLink ( $ action ) ; } | Get a relative link to the current controller |
24,368 | public static function Validate ( $ date , $ format = DATEFORMAT :: YMD , $ separator = "/" ) { $ timestamp = DateUtil :: TimeStampFromStr ( $ date , $ format ) ; $ dateCheck = DateUtil :: FormatDate ( $ timestamp , $ format , $ separator , true ) ; $ date = $ date . substr ( '--/--/---- 00:00:00' , strlen ( $ date ) ) ; $ timestamp2 = DateUtil :: TimeStampFromStr ( $ dateCheck , $ format ) ; return ( $ timestamp == $ timestamp2 ) && ( $ date == $ dateCheck ) ; } | Check if a date is Valid |
24,369 | public function get ( $ withScript = false ) { $ retVal = '' ; if ( $ withScript ) { $ retVal .= "<script type='text/javascript'>\n" ; } $ retVal .= $ this -> current ( ) ; if ( $ withScript ) { $ retVal .= "\n</script>\n" ; } return $ retVal ; } | Returns the current script value . |
24,370 | public function getValue ( ) { if ( $ option = $ this -> Options ( ) -> byID ( $ this -> getField ( 'Value' ) ) ) { return $ option -> Title ; } return null ; } | Get the value by set option |
24,371 | public function setPrice ( $ price , $ format = self :: EURO ) { $ this -> validatePriceFormat ( $ format ) ; if ( preg_match ( '/^\-?\d+\.\d+E(\+|\-)\d+$/u' , ( string ) $ price ) ) { $ this -> price = 0 ; return $ this ; } if ( $ format == self :: EURO ) { $ price = preg_replace ( '/[^0-9,\-\.\+]/' , '' , $ price ) ; $ price = preg_replace ( '/^(.*)(\-|\+)$/' , '$2$1' , $ price ) ; if ( mb_strpos ( $ price , ',' ) !== false ) { if ( preg_match ( '/,\./' , $ price ) ) { $ price = str_replace ( ',' , '' , $ price ) ; } else { $ price = str_replace ( '.' , '' , $ price ) ; $ price = str_replace ( ',' , '.' , $ price ) ; } } $ price = ( float ) $ price ; $ price = $ price * 100 ; } else { $ price = ( float ) $ price ; } $ this -> price = ( int ) round ( $ price ) ; return $ this ; } | Set price after cutting out all unwanted chars . |
24,372 | public function sanitize ( $ price , $ format = self :: EURO ) { return $ this -> setPrice ( $ price , $ format ) -> getPrice ( $ format ) ; } | Set price and return sanitized value at once . |
24,373 | public function initMxmaps ( $ overrideExisting = true ) { if ( null !== $ this -> collMxmaps && ! $ overrideExisting ) { return ; } $ collectionClassName = MxmapTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collMxmaps = new $ collectionClassName ; $ this -> collMxmaps -> setModel ( '\eXpansion\Bundle\Maps\Model\Mxmap' ) ; } | Initializes the collMxmaps collection . |
24,374 | public function getMxmaps ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collMxmapsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMxmaps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMxmaps ) { $ this -> initMxmaps ( ) ; } else { $ collMxmaps = ChildMxmapQuery :: create ( null , $ criteria ) -> filterByMap ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collMxmapsPartial && count ( $ collMxmaps ) ) { $ this -> initMxmaps ( false ) ; foreach ( $ collMxmaps as $ obj ) { if ( false == $ this -> collMxmaps -> contains ( $ obj ) ) { $ this -> collMxmaps -> append ( $ obj ) ; } } $ this -> collMxmapsPartial = true ; } return $ collMxmaps ; } if ( $ partial && $ this -> collMxmaps ) { foreach ( $ this -> collMxmaps as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collMxmaps [ ] = $ obj ; } } } $ this -> collMxmaps = $ collMxmaps ; $ this -> collMxmapsPartial = false ; } } return $ this -> collMxmaps ; } | Gets an array of ChildMxmap objects which contain a foreign key that references this object . |
24,375 | public function countMxmaps ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collMxmapsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMxmaps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMxmaps ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getMxmaps ( ) ) ; } $ query = ChildMxmapQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByMap ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collMxmaps ) ; } | Returns the number of related Mxmap objects . |
24,376 | public function addMxmap ( ChildMxmap $ l ) { if ( $ this -> collMxmaps === null ) { $ this -> initMxmaps ( ) ; $ this -> collMxmapsPartial = true ; } if ( ! $ this -> collMxmaps -> contains ( $ l ) ) { $ this -> doAddMxmap ( $ l ) ; if ( $ this -> mxmapsScheduledForDeletion and $ this -> mxmapsScheduledForDeletion -> contains ( $ l ) ) { $ this -> mxmapsScheduledForDeletion -> remove ( $ this -> mxmapsScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; } | Method called to associate a ChildMxmap object to this object through the ChildMxmap foreign key attribute . |
24,377 | private function createServer ( ) { $ server = new SoapServer ( null , $ this -> soapServerOptions ) ; $ server -> SetClass ( $ this -> wsdlclassname ) ; $ server -> handle ( ) ; } | create the soap - server |
24,378 | protected function intoStruct ( ) { $ class = new ReflectionObject ( $ this ) ; $ this -> classname = $ class -> getName ( ) ; $ this -> wsdlclassname = str_replace ( '\\' , '.' , $ class -> getName ( ) ) ; $ this -> classMethodsIntoStruct ( ) ; $ this -> classStructDispatch ( ) ; } | parse classes into struct |
24,379 | protected function classPropertiesIntoStruct ( $ className ) { if ( ! isset ( $ this -> wsdlStruct [ $ className ] ) ) { $ class = new ReflectionClass ( $ className ) ; $ properties = $ class -> getProperties ( ) ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] = array ( ) ; for ( $ i = 0 ; $ i < count ( $ properties ) ; ++ $ i ) { if ( $ properties [ $ i ] -> isPublic ( ) ) { preg_match_all ( '~@var\s(\S+)~' , $ properties [ $ i ] -> getDocComment ( ) , $ var ) ; $ _cleanType = str_replace ( '[]' , '' , $ var [ 1 ] [ 0 ] , $ _length ) ; $ _typens = str_repeat ( 'ArrayOf' , $ _length ) ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] [ $ properties [ $ i ] -> getName ( ) ] [ 'type' ] = $ _cleanType ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] [ $ properties [ $ i ] -> getName ( ) ] [ 'wsdltype' ] = $ _typens . $ _cleanType ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] [ $ properties [ $ i ] -> getName ( ) ] [ 'length' ] = $ _length ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] [ $ properties [ $ i ] -> getName ( ) ] [ 'array' ] = ( $ _length > 0 && in_array ( $ _cleanType , $ this -> simpleTypes ) ) ? true : false ; $ isObject = ( ! in_array ( $ _cleanType , $ this -> simpleTypes ) && new ReflectionClass ( $ _cleanType ) ) ? true : false ; $ this -> wsdlStruct [ 'class' ] [ $ className ] [ 'property' ] [ $ properties [ $ i ] -> getName ( ) ] [ 'class' ] = $ isObject ; if ( $ isObject == true ) { $ this -> classPropertiesIntoStruct ( $ _cleanType ) ; } if ( $ _length > 0 ) { $ _typensSource = '' ; for ( $ j = $ _length ; $ j > 0 ; -- $ j ) { $ _typensSource .= 'ArrayOf' ; $ this -> wsdlStruct [ 'array' ] [ $ _typensSource . $ _cleanType ] = substr ( $ _typensSource , 0 , strlen ( $ _typensSource ) - 7 ) . $ _cleanType ; } } } } } } | parse classes properties into struct |
24,380 | protected function createWSDL_definitions ( ) { $ this -> wsdl_definitions = $ this -> wsdl -> createElement ( 'definitions' ) ; $ this -> wsdl_definitions -> setAttribute ( 'name' , $ this -> wsdlclassname ) ; $ this -> wsdl_definitions -> setAttribute ( 'targetNamespace' , 'urn:' . $ this -> wsdlclassname ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns:typens' , 'urn:' . $ this -> wsdlclassname ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns:xsd' , self :: SOAP_XML_SCHEMA_VERSION ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns:soap' , self :: SCHEMA_SOAP ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns:soapenc' , self :: SOAP_SCHEMA_ENCODING ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns:wsdl' , self :: SCHEMA_WSDL ) ; $ this -> wsdl_definitions -> setAttribute ( 'xmlns' , self :: SCHEMA_WSDL ) ; $ this -> wsdl -> appendChild ( $ this -> wsdl_definitions ) ; } | Create the definition node |
24,381 | protected function createWSDL_types ( ) { $ types = $ this -> wsdl -> createElement ( 'types' ) ; $ schema = $ this -> wsdl -> createElement ( 'xsd:schema' ) ; $ schema -> setAttribute ( 'xmlns' , self :: SOAP_XML_SCHEMA_VERSION ) ; $ schema -> setAttribute ( 'targetNamespace' , 'urn:' . $ this -> wsdlclassname ) ; $ types -> appendChild ( $ schema ) ; if ( isset ( $ this -> wsdlStruct [ 'array' ] ) ) { foreach ( $ this -> wsdlStruct [ 'array' ] as $ source => $ target ) { $ complexType = $ this -> wsdl -> createElement ( 'xsd:complexType' ) ; $ complexContent = $ this -> wsdl -> createElement ( 'xsd:complexContent' ) ; $ restriction = $ this -> wsdl -> createElement ( 'xsd:restriction' ) ; $ attribute = $ this -> wsdl -> createElement ( 'xsd:attribute' ) ; $ restriction -> appendChild ( $ attribute ) ; $ complexContent -> appendChild ( $ restriction ) ; $ complexType -> appendChild ( $ complexContent ) ; $ schema -> appendChild ( $ complexType ) ; $ complexType -> setAttribute ( 'name' , $ source ) ; $ restriction -> setAttribute ( 'base' , 'soapenc:Array' ) ; $ attribute -> setAttribute ( 'ref' , 'soapenc:arrayType' ) ; try { $ class = new ReflectionClass ( $ target ) ; } catch ( Exception $ e ) { } if ( in_array ( $ target , $ this -> simpleTypes ) ) { $ attribute -> setAttribute ( 'wsdl:arrayType' , 'xsd:' . $ target . '[]' ) ; } elseif ( isset ( $ class ) ) { $ attribute -> setAttribute ( 'wsdl:arrayType' , 'typens:' . $ target . '[]' ) ; } else { $ attribute -> setAttribute ( 'wsdl:arrayType' , 'typens:' . $ target . '[]' ) ; } unset ( $ class ) ; } } if ( isset ( $ this -> wsdlStruct [ 'class' ] ) ) { foreach ( $ this -> wsdlStruct [ 'class' ] as $ className => $ classProperty ) { $ complextype = $ this -> wsdl -> createElement ( 'xsd:complexType' ) ; $ complextype -> setAttribute ( 'name' , $ className ) ; $ sequence = $ this -> wsdl -> createElement ( 'xsd:all' ) ; $ complextype -> appendChild ( $ sequence ) ; $ schema -> appendChild ( $ complextype ) ; foreach ( $ classProperty [ 'property' ] as $ cpname => $ cpValue ) { $ element = $ this -> wsdl -> createElement ( 'xsd:element' ) ; $ element -> setAttribute ( 'name' , $ cpname ) ; $ element -> setAttribute ( 'type' , ( in_array ( $ cpValue [ 'wsdltype' ] , $ this -> simpleTypes ) ? 'xsd:' : 'typens:' ) . $ cpValue [ 'wsdltype' ] ) ; $ sequence -> appendChild ( $ element ) ; } } } $ this -> wsdl_definitions -> appendChild ( $ types ) ; } | Create the types node |
24,382 | protected function createWSDL_messages ( ) { foreach ( $ this -> wsdlStruct [ $ this -> wsdlclassname ] [ 'method' ] as $ name => $ method ) { $ messageInput = $ this -> wsdl -> createElement ( 'message' ) ; $ messageInput -> setAttribute ( 'name' , $ name ) ; $ messageOutput = $ this -> wsdl -> createElement ( 'message' ) ; $ messageOutput -> setAttribute ( 'name' , $ name . 'Response' ) ; $ this -> wsdl_definitions -> appendChild ( $ messageInput ) ; $ this -> wsdl_definitions -> appendChild ( $ messageOutput ) ; foreach ( $ method [ 'var' ] as $ methodVars ) { if ( isset ( $ methodVars [ 'param' ] ) ) { $ part = $ this -> wsdl -> createElement ( 'part' ) ; $ part -> setAttribute ( 'name' , $ methodVars [ 'name' ] ) ; $ part -> setAttribute ( 'type' , ( ( $ methodVars [ 'array' ] != 1 && $ methodVars [ 'class' ] != 1 ) ? 'xsd:' : 'typens:' ) . $ methodVars [ 'wsdltype' ] ) ; $ messageInput -> appendChild ( $ part ) ; } if ( isset ( $ methodVars [ 'return' ] ) ) { $ part = $ this -> wsdl -> createElement ( 'part' ) ; $ part -> setAttribute ( 'name' , $ name . 'Response' ) ; $ part -> setAttribute ( 'type' , ( ( $ methodVars [ 'array' ] != 1 && $ methodVars [ 'class' ] != 1 ) ? 'xsd:' : 'typens:' ) . $ methodVars [ 'wsdltype' ] ) ; $ messageOutput -> appendChild ( $ part ) ; } } } } | Create the messages node |
24,383 | protected function createWSDL_binding ( ) { $ binding = $ this -> wsdl -> createElement ( 'binding' ) ; $ binding -> setAttribute ( 'name' , $ this -> wsdlclassname . 'Binding' ) ; $ binding -> setAttribute ( 'type' , 'typens:' . $ this -> wsdlclassname . 'Port' ) ; $ soap_binding = $ this -> wsdl -> createElement ( 'soap:binding' ) ; $ soap_binding -> setAttribute ( 'style' , 'rpc' ) ; $ soap_binding -> setAttribute ( 'transport' , self :: SCHEMA_SOAP_HTTP ) ; $ binding -> appendChild ( $ soap_binding ) ; foreach ( $ this -> wsdlStruct [ $ this -> wsdlclassname ] [ 'method' ] as $ name => $ vars ) { $ operation = $ this -> wsdl -> createElement ( 'operation' ) ; $ operation -> setAttribute ( 'name' , $ name ) ; $ binding -> appendChild ( $ operation ) ; $ soap_operation = $ this -> wsdl -> createElement ( 'soap:operation' ) ; $ soap_operation -> setAttribute ( 'soapAction' , 'urn:' . $ this -> wsdlclassname . 'Action' ) ; $ operation -> appendChild ( $ soap_operation ) ; $ input = $ this -> wsdl -> createElement ( 'input' ) ; $ output = $ this -> wsdl -> createElement ( 'output' ) ; $ operation -> appendChild ( $ input ) ; $ operation -> appendChild ( $ output ) ; $ soap_body = $ this -> wsdl -> createElement ( 'soap:body' ) ; $ soap_body -> setAttribute ( 'use' , 'encoded' ) ; $ soap_body -> setAttribute ( 'namespace' , 'urn:' . $ this -> namespace ) ; $ soap_body -> setAttribute ( 'encodingStyle' , self :: SOAP_SCHEMA_ENCODING ) ; $ input -> appendChild ( $ soap_body ) ; $ soap_body = $ this -> wsdl -> createElement ( 'soap:body' ) ; $ soap_body -> setAttribute ( 'use' , 'encoded' ) ; $ soap_body -> setAttribute ( 'namespace' , 'urn:' . $ this -> namespace ) ; $ soap_body -> setAttribute ( 'encodingStyle' , self :: SOAP_SCHEMA_ENCODING ) ; $ output -> appendChild ( $ soap_body ) ; } $ this -> wsdl_definitions -> appendChild ( $ binding ) ; } | Create the binding node |
24,384 | protected function createWSDL_portType ( ) { $ portType = $ this -> wsdl -> createElement ( 'portType' ) ; $ portType -> setAttribute ( 'name' , $ this -> wsdlclassname . 'Port' ) ; foreach ( $ this -> wsdlStruct [ $ this -> wsdlclassname ] [ 'method' ] as $ methodName => $ methodVars ) { $ operation = $ this -> wsdl -> createElement ( 'operation' ) ; $ operation -> setAttribute ( 'name' , $ methodName ) ; $ portType -> appendChild ( $ operation ) ; $ documentation = $ this -> wsdl -> createElement ( 'documentation' ) ; $ documentation -> appendChild ( $ this -> wsdl -> createTextNode ( $ methodVars [ 'description' ] ) ) ; $ operation -> appendChild ( $ documentation ) ; $ input = $ this -> wsdl -> createElement ( 'input' ) ; $ output = $ this -> wsdl -> createElement ( 'output' ) ; $ input -> setAttribute ( 'message' , 'typens:' . $ methodName ) ; $ output -> setAttribute ( 'message' , 'typens:' . $ methodName . 'Response' ) ; $ operation -> appendChild ( $ input ) ; $ operation -> appendChild ( $ output ) ; } $ this -> wsdl_definitions -> appendChild ( $ portType ) ; } | Create the portType node |
24,385 | protected function createWSDL_service ( ) { $ service = $ this -> wsdl -> createElement ( 'service' ) ; $ service -> setAttribute ( 'name' , $ this -> wsdlclassname ) ; $ port = $ this -> wsdl -> createElement ( 'port' ) ; $ port -> setAttribute ( 'name' , $ this -> wsdlclassname . 'Port' ) ; $ port -> setAttribute ( 'binding' , 'typens:' . $ this -> wsdlclassname . 'Binding' ) ; $ adress = $ this -> wsdl -> createElement ( 'soap:address' ) ; $ adress -> setAttribute ( 'location' , $ this -> protocol . '://' . $ _SERVER [ 'HTTP_HOST' ] . $ this -> getSelfUrl ( ) ) ; $ port -> appendChild ( $ adress ) ; $ service -> appendChild ( $ port ) ; $ this -> wsdl_definitions -> appendChild ( $ service ) ; } | Create the service node |
24,386 | protected function registerTokenParser ( ) { $ this -> app -> singleton ( 'tymon.jwt.parser' , function ( $ app ) { $ parser = new Parser ( $ app [ 'request' ] , [ new AuthHeaders , new QueryString , new InputSource , new RouteParams , new Cookies , ] ) ; $ app -> refresh ( 'request' , $ parser , 'setRequest' ) ; return $ parser ; } ) ; } | Register the bindings for the Token Parser . |
24,387 | public function setSelectedByValue ( $ value ) { $ x = 0 ; foreach ( $ this -> options as $ idx => $ data ) { if ( $ value == $ data ) { $ this -> setSelectedIndex ( $ x ) ; return ; } $ x ++ ; } $ this -> setSelectedIndex ( - 1 ) ; } | Sets selected index by entry return value |
24,388 | protected function writePaymentSlipLines ( $ elementName , $ element ) { echo sprintf ( 'Write the element "%s"<br>' , $ elementName ) ; parent :: writePaymentSlipLines ( $ elementName , $ element ) ; echo '<br>' ; return $ this ; } | Normally it is not necessary to overwrite this method |
24,389 | public function getCostCenterChildrenIds ( $ id ) { $ ids = array ( ) ; $ this -> CostCenter -> byParent ( $ id ) -> each ( function ( $ CostCenter ) use ( & $ ids ) { if ( $ CostCenter -> is_group ) { $ ids = array_merge ( $ ids , $ this -> getCostCenterChildrenIds ( $ CostCenter -> id ) ) ; } array_push ( $ ids , $ CostCenter -> id ) ; } ) ; return $ ids ; } | Get cost center children |
24,390 | public function getCostCenterChildren ( $ input ) { $ CostCenter = $ this -> CostCenter -> byId ( $ input [ 'id' ] ) ; $ costCenterTree = array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'state' => array ( 'opened' => true ) , 'icon' => 'fa fa-sitemap' , 'children' => array ( ) ) ; $ this -> CostCenter -> byParent ( $ input [ 'id' ] ) -> each ( function ( $ CostCenter ) use ( & $ costCenterTree ) { if ( $ CostCenter -> is_group ) { array_push ( $ costCenterTree [ 'children' ] , array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'icon' => 'fa fa-sitemap' ) ) ; } else { array_push ( $ costCenterTree [ 'children' ] , array ( 'text' => $ CostCenter -> key . ' ' . $ CostCenter -> name , 'icon' => 'fa fa-leaf' ) ) ; } } ) ; return json_encode ( array ( $ costCenterTree ) ) ; } | Get cost centers children |
24,391 | protected function _getModelInfoFromField ( $ field = null , $ plugin = null ) { $ result = false ; if ( empty ( $ field ) || ! is_string ( $ field ) ) { return $ result ; } if ( strpos ( $ field , '.' ) === false ) { return $ result ; } list ( $ modelName , $ fieldName ) = pluginSplit ( $ field ) ; if ( ! empty ( $ plugin ) ) { $ modelName = $ plugin . '.' . $ modelName ; } $ modelObj = ClassRegistry :: init ( $ modelName , true ) ; if ( $ modelObj === false ) { return false ; } $ fieldFullName = $ modelObj -> alias . '.' . $ fieldName ; $ result = compact ( 'modelName' , 'fieldName' , 'fieldFullName' ) ; return $ result ; } | Return information of model from field name |
24,392 | protected function _parseConditionSign ( $ conditionSign = null ) { $ result = '' ; if ( empty ( $ conditionSign ) ) { return $ result ; } $ conditionSign = ( string ) mb_convert_case ( $ conditionSign , MB_CASE_LOWER ) ; switch ( $ conditionSign ) { case 'gt' : $ result = '>' ; break ; case 'ge' : $ result = '>=' ; break ; case 'lt' : $ result = '<' ; break ; case 'le' : $ result = '<=' ; break ; case 'ne' : $ result = '<>' ; break ; case 'eq' : default : $ result = '' ; } return $ result ; } | Return condition sign in SQL format from 2 char format . |
24,393 | protected function _parseConditionGroup ( $ condition = null ) { $ result = 'AND' ; if ( empty ( $ condition ) ) { return $ result ; } $ condition = ( string ) mb_convert_case ( $ condition , MB_CASE_UPPER ) ; if ( in_array ( $ condition , [ 'AND' , 'OR' , 'NOT' ] ) ) { $ result = $ condition ; } return $ result ; } | Return string of logical group condition . |
24,394 | public function buildConditions ( $ filterData = null , $ filterConditions = null , $ plugin = null , $ limit = CAKE_THEME_FILTER_ROW_LIMIT ) { $ result = [ ] ; if ( empty ( $ filterData ) || ! is_array ( $ filterData ) ) { return $ result ; } if ( ! is_array ( $ filterConditions ) ) { $ filterConditions = [ ] ; } $ conditionsGroup = null ; if ( isset ( $ filterConditions [ 'group' ] ) ) { $ conditionsGroup = $ filterConditions [ 'group' ] ; } $ conditionSignGroup = $ this -> _parseConditionGroup ( $ conditionsGroup ) ; $ conditionsCache = [ ] ; $ filterRowCount = 0 ; $ limit = ( int ) $ limit ; if ( $ limit <= 0 ) { $ limit = CAKE_THEME_FILTER_ROW_LIMIT ; } foreach ( $ filterData as $ index => $ modelInfo ) { if ( ! is_int ( $ index ) || ! is_array ( $ modelInfo ) ) { continue ; } $ filterRowCount ++ ; if ( $ filterRowCount > $ limit ) { break ; } foreach ( $ modelInfo as $ filterModel => $ filterField ) { if ( ! is_array ( $ filterField ) ) { continue ; } foreach ( $ filterField as $ filterFieldName => $ filterFieldValue ) { if ( $ filterFieldValue === '' ) { continue ; } $ condSign = null ; if ( isset ( $ filterConditions [ $ index ] [ $ filterModel ] [ $ filterFieldName ] ) ) { $ condSign = $ filterConditions [ $ index ] [ $ filterModel ] [ $ filterFieldName ] ; } $ condition = $ this -> getCondition ( $ filterModel . '.' . $ filterFieldName , $ filterFieldValue , $ condSign , $ plugin ) ; if ( $ condition === false ) { continue ; } $ cacheKey = md5 ( serialize ( $ condition ) ) ; if ( in_array ( $ cacheKey , $ conditionsCache ) ) { continue ; } $ result [ $ conditionSignGroup ] [ ] = $ condition ; $ conditionsCache [ ] = $ cacheKey ; } } } if ( isset ( $ result [ $ conditionSignGroup ] ) && ( count ( $ result [ $ conditionSignGroup ] ) == 1 ) ) { $ result = array_shift ( $ result [ $ conditionSignGroup ] ) ; } return $ result ; } | Return condition for filter data and filter condition . |
24,395 | public function getOptions ( ) { $ opts = array ( ) ; $ first = array ( ) ; $ second = array ( ) ; if ( $ this -> axisRenderer ) { $ first [ 'renderer' ] = '#' . $ this -> axisRenderer . '#' ; } if ( isset ( $ this -> options [ 'ticks' ] ) ) { $ first [ 'ticks' ] = $ this -> options [ 'ticks' ] ; } $ second [ 'min' ] = isset ( $ this -> options [ 'min' ] ) ? $ this -> options [ 'min' ] : 0 ; if ( isset ( $ this -> options [ 'horizontal' ] ) && $ this -> options [ 'horizontal' ] ) { $ opts [ 'xaxis' ] = $ second ; $ opts [ 'yaxis' ] = $ first ; } else { $ opts [ 'xaxis' ] = $ first ; $ opts [ 'yaxis' ] = $ second ; } $ opts = array ( 'axes' => $ opts ) ; if ( isset ( $ this -> options [ 'stackSeries' ] ) ) { $ opts [ 'stackSeries' ] = $ this -> options [ 'stackSeries' ] ; } if ( isset ( $ this -> options [ 'seriesColors' ] ) ) { $ opts [ 'seriesColors' ] = $ this -> options [ 'seriesColors' ] ; } return $ opts ; } | This provides a limited set of options based on how it has been configured |
24,396 | public function getGroupPermissions ( $ groupName ) { if ( ! isset ( $ this -> config [ $ groupName ] ) ) { return [ ] ; } return array_keys ( $ this -> config [ $ groupName ] [ 'permissions' ] ) ; } | Get list of all permissions given to a group . |
24,397 | public function getGroupLabel ( $ groupName ) { if ( ! isset ( $ this -> config [ $ groupName ] ) ) { return "" ; } return $ this -> config [ $ groupName ] [ 'label' ] -> get ( ) ; } | Get admin group label |
24,398 | public function makeMaintenanceFile ( ) { $ filePath = $ this -> downClass -> getFilePath ( ) ; $ template = __DIR__ . '/.maintenance' ; return exec ( 'cat ' . $ template . ' > ' . $ filePath ) ; } | Create maintenance mode file |
24,399 | public function updateWithScores ( $ scores ) { if ( isset ( $ scores [ 'winnerplayer' ] ) ) { $ player = $ this -> getPlayer ( $ scores [ 'winnerplayer' ] ) ; if ( $ player ) { $ this -> playerQueryBuilder -> save ( $ player ) ; } } foreach ( $ this -> loggedInPlayers as $ player ) { $ this -> updatePlayer ( $ player ) ; } $ this -> playerQueryBuilder -> saveAll ( $ this -> loggedInPlayers ) ; } | Update when scores is available . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.