idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
22,900 | protected function setError ( int $ errorType = 0 , string $ className = '' ) : void { $ errorMessage = '' ; if ( $ errorType == self :: E_NO_CONNECTION ) { $ errorMessage = \ sprintf ( 'FATAL ERROR (%s): Cannot establish connection to database server.' , $ this -> currentLink -> connect_errno ) ; } elseif ( $ errorType == self :: E_NO_DB_SELECTED ) { $ errorMessage = \ sprintf ( 'FATAL ERROR (%s): Cannot select database \'%s\'.' , $ this -> currentLink -> errno , $ this -> selectedDB ) ; } elseif ( $ errorType == self :: E_NO_SQL ) { $ errorMessage = \ sprintf ( 'FATAL ERROR (%s): Query was empty.' , $ this -> currentLink -> errno ) ; } elseif ( $ errorType == self :: E_ENGINE_ERROR ) { $ errorMessage = \ sprintf ( 'FATAL ERROR (%s): %s: %s' , $ this -> currentLink -> errno , $ this -> currentLink -> error , $ this -> currentQuery ) ; } if ( $ this -> logHandler !== null ) { $ this -> logHandler -> logError ( $ errorMessage , $ className ) ; } if ( $ this -> errorLevel == 'print' ) { $ errorText = \ sprintf ( '%s%s%s%s' , $ errorMessage , Tags :: CRLF , Tags :: br ( ) , Tags :: CRLF ) ; echo filter_var ( $ errorText , FILTER_DEFAULT ) ; } if ( $ this -> errorLevel == 'exception' ) { $ this -> closeConnection ( ) ; throw new RuntimeException ( $ errorMessage ) ; } } | Handles class errors . |
22,901 | public function toArray ( ) { return array ( 'id' => $ this -> getId ( ) , 'nome' => $ this -> getNome ( ) , 'logo' => $ this -> getLogo ( ) , 'intro' => $ this -> getIntro ( ) , 'copyright' => $ this -> getCopyright ( ) ) ; } | Obtem a estrutura da entity Site em formato array |
22,902 | public function invoke ( ) { $ args = func_get_args ( ) ; $ retries = 0 ; $ exception = null ; $ return = null ; $ sc = SmartCallable :: factory ( "restore_error_handler" ) ; set_error_handler ( function ( $ type , $ message , $ file , $ line ) { throw PHPException :: factory ( $ message , $ type , $ file , $ line ) ; } ) ; do { try { $ exception = null ; $ return = call_user_func_array ( $ this -> callback , $ args ) ; } catch ( Exception $ exception ) { $ this -> logger -> error ( $ exception -> getMessage ( ) ) ; } $ action = $ this -> matchesCondition ( $ return , $ exception ) ; if ( "retry" == $ action ) { $ retries ++ ; } } while ( "retry" == $ action && ( $ retries < $ this -> max_retries || - 1 === $ this -> max_retries ) ) ; if ( $ exception && "return" !== $ action ) { throw $ exception ; } if ( $ this -> filter ) { $ return = call_user_func ( $ this -> filter , $ return ) ; } return $ return ; } | Calls the function |
22,903 | protected function matchesCondition ( $ return , $ exception = null ) { $ matched = false ; foreach ( $ this -> conditions as $ expression ) { if ( "isExceptionOf" === $ expression [ "compare" ] ) { $ matched = Comparator :: isInstanceOf ( $ exception , $ expression [ "value" ] ) ; } else { $ matched = Comparator :: $ expression [ "compare" ] ( $ return , $ expression [ "value" ] ) ; } if ( $ matched ) { $ matched = $ expression [ "action" ] ; break ; } } return $ matched ; } | Returns which condition the value matches |
22,904 | private function getRegionZonesByTypeName ( $ typeName ) { return $ this -> getRegionZones ( ) -> filter ( function ( $ regionZone ) use ( $ typeName ) { return $ regionZone -> getType ( ) -> getName ( ) === $ typeName ; } ) ; } | Returns all the RegionZones of given type that the Region is attached to |
22,905 | public function hydrate ( $ data ) { parent :: hydrate ( $ data ) ; $ this -> values = ValueAs :: arr ( $ this -> values ) ; } | Hydrate the public properties |
22,906 | protected function call ( Container $ container , $ id , ... $ args ) { $ ret = $ container -> resolve ( $ id ) ; if ( is_array ( $ ret ) && $ ret [ 0 ] instanceof \ Closure && is_bool ( $ ret [ 1 ] ) ) { return ( $ ret [ 1 ] ) ? $ ret [ 0 ] ( $ container , ... $ args ) : $ ret [ 0 ] ( ... $ args ) ; } return null ; } | Small helper for calling declared methods with arguments . |
22,907 | public static function forge ( $ fieldset = 'default' ) { if ( is_string ( $ fieldset ) ) { ( $ set = \ Fieldset :: instance ( $ fieldset ) ) and $ fieldset = $ set ; } if ( $ fieldset instanceof Fieldset ) { if ( $ fieldset -> validation ( false ) != null ) { throw new \ DomainException ( 'Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.' ) ; } } return new static ( $ fieldset ) ; } | Gets a new instance of the Validation class . |
22,908 | public function set_message ( $ rule , $ message ) { if ( $ message !== null ) { $ this -> error_messages [ $ rule ] = $ message ; } else { unset ( $ this -> error_messages [ $ rule ] ) ; } return $ this ; } | This will overwrite lang file messages for this validation instance |
22,909 | public function get_message ( $ rule ) { if ( ! array_key_exists ( $ rule , $ this -> error_messages ) ) { return false ; } return $ this -> error_messages [ $ rule ] ; } | Fetches a specific error message for this validation instance |
22,910 | protected function _find_rule ( $ callback ) { if ( is_string ( $ callback ) ) { $ callback_method = '_validation_' . $ callback ; foreach ( $ this -> callables as $ callback_class ) { if ( method_exists ( $ callback_class , $ callback_method ) ) { return array ( $ callback => array ( $ callback_class , $ callback_method ) ) ; } } } if ( is_callable ( $ callback ) ) { if ( $ callback instanceof \ Closure ) { $ callback_name = 'closure' ; } elseif ( is_array ( $ callback ) ) { $ callback_name = preg_replace ( '#^([a-z_]*\\\\)*#i' , '' , is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] ) . ':' . $ callback [ 1 ] ; } else { $ callback_name = preg_replace ( '#^([a-z_]*\\\\)*#i' , '' , str_replace ( '::' , ':' , $ callback ) ) ; } return array ( $ callback_name => $ callback ) ; } elseif ( is_array ( $ callback ) and is_callable ( reset ( $ callback ) ) ) { return $ callback ; } else { $ string = ! is_array ( $ callback ) ? $ callback : ( is_object ( @ $ callback [ 0 ] ) ? get_class ( @ $ callback [ 0 ] ) . '->' . @ $ callback [ 1 ] : @ $ callback [ 0 ] . '::' . @ $ callback [ 1 ] ) ; \ Error :: notice ( 'Invalid rule "' . $ string . '" passed to Validation, not used.' ) ; return false ; } } | Takes the rule input and formats it into a name & callback |
22,911 | public function input ( $ key = null , $ default = null ) { if ( $ key === null ) { return $ this -> input ; } if ( strpos ( $ key , '[' ) !== false ) { $ key = str_replace ( array ( '[' , ']' ) , array ( '.' , '' ) , $ key ) ; } if ( ! array_key_exists ( $ key , $ this -> input ) ) { if ( strpos ( $ key , '.' ) !== false ) { if ( ( $ result = \ Arr :: get ( $ this -> input , $ key , null ) ) !== null ) { $ this -> input [ $ key ] = $ result ; } else { $ this -> input [ $ key ] = $ this -> global_input_fallback ? \ Arr :: get ( \ Input :: param ( ) , $ key , $ default ) : $ default ; } } else { $ this -> input [ $ key ] = $ this -> global_input_fallback ? \ Input :: param ( $ key , $ default ) : $ default ; } } return $ this -> input [ $ key ] ; } | Fetches the input value from either post or given input |
22,912 | public function error_message ( $ field = null , $ default = false ) { if ( $ field === null ) { $ messages = array ( ) ; foreach ( $ this -> error ( ) as $ field => $ e ) { $ messages [ $ field ] = $ e -> get_message ( ) ; } return $ messages ; } return array_key_exists ( $ field , $ this -> errors ) ? $ this -> errors [ $ field ] -> get_message ( ) : $ default ; } | Return error message |
22,913 | public function _validation_match_value ( $ val , $ compare , $ strict = false ) { if ( $ this -> _empty ( $ val ) || $ val === $ compare || ( ! $ strict && $ val == $ compare ) ) { return true ; } if ( is_array ( $ compare ) ) { foreach ( $ compare as $ c ) { if ( $ val === $ c || ( ! $ strict && $ val == $ c ) ) { return true ; } } } return false ; } | Match value against comparison input |
22,914 | public function _validation_match_collection ( $ val , $ collection = array ( ) ) { if ( ! is_array ( $ collection ) ) { $ collection = func_get_args ( ) ; array_shift ( $ collection ) ; } return in_array ( $ val , $ collection ) ; } | Match against an array of values |
22,915 | public function _validation_min_length ( $ val , $ length ) { return $ this -> _empty ( $ val ) || \ Str :: length ( $ val ) >= $ length ; } | Minimum string length |
22,916 | public function _validation_max_length ( $ val , $ length ) { return $ this -> _empty ( $ val ) || \ Str :: length ( $ val ) <= $ length ; } | Maximum string length |
22,917 | public function _validation_exact_length ( $ val , $ length ) { return $ this -> _empty ( $ val ) || \ Str :: length ( $ val ) == $ length ; } | Exact string length |
22,918 | public function _validation_numeric_min ( $ val , $ min_val ) { return $ this -> _empty ( $ val ) || floatval ( $ val ) >= floatval ( $ min_val ) ; } | Checks whether numeric input has a minimum value |
22,919 | public function _validation_numeric_max ( $ val , $ max_val ) { return $ this -> _empty ( $ val ) || floatval ( $ val ) <= floatval ( $ max_val ) ; } | Checks whether numeric input has a maximum value |
22,920 | public function _validation_numeric_between ( $ val , $ min_val , $ max_val ) { return $ this -> _empty ( $ val ) or ( floatval ( $ val ) >= floatval ( $ min_val ) and floatval ( $ val ) <= floatval ( $ max_val ) ) ; } | Checks whether numeric input is between a minimum and a maximum value |
22,921 | public function _validation_required_with ( $ val , $ field ) { if ( ! $ this -> _empty ( $ this -> input ( $ field ) ) and $ this -> _empty ( $ val ) ) { $ validating = $ this -> active_field ( ) ; throw new \ Validation_Error ( $ validating , $ val , array ( 'required_with' => array ( $ this -> field ( $ field ) ) ) , array ( $ this -> field ( $ field ) -> label ) ) ; } return true ; } | Conditionally requires completion of current field based on completion of another field |
22,922 | public function _validation_valid_date ( $ val , $ format = null , $ strict = true ) { if ( $ this -> _empty ( $ val ) ) { return true ; } if ( $ format ) { $ parsed = date_parse_from_format ( $ format , $ val ) ; } else { $ parsed = date_parse ( $ val ) ; } if ( \ Arr :: get ( $ parsed , 'error_count' , 1 ) + ( $ strict ? \ Arr :: get ( $ parsed , 'warning_count' , 1 ) : 0 ) === 0 ) { if ( $ format ) { return date ( $ format , mktime ( $ parsed [ 'hour' ] , $ parsed [ 'minute' ] , $ parsed [ 'second' ] , $ parsed [ 'month' ] , $ parsed [ 'day' ] , $ parsed [ 'year' ] ) ) ; } else { return true ; } } else { return false ; } } | Checks whether string input is valid date format . When a format is passed it will make sure the date will be in that specific format if validated |
22,923 | protected function storeToStash ( $ key , $ value ) { $ this -> items [ $ key ] = $ this -> sanitizeStashStorageItem ( $ value , $ key ) ; } | stores the provided value to the provided key at the stash storage . |
22,924 | protected function storeToStashFromArray ( array $ items ) { $ items = $ this -> mapStashStorageItems ( $ items , null ) ; $ this -> items = array_replace ( $ this -> items , $ items ) ; } | stores the provided items to the stash storage replaces existing items . |
22,925 | private function mapStashStorageItems ( $ item , $ key ) { if ( is_array ( $ item ) ) { foreach ( $ item as $ currentKey => $ currentValue ) { $ item [ $ currentKey ] = $ this -> { __FUNCTION__ } ( $ currentValue , $ currentKey ) ; } return $ item ; } return $ this -> sanitizeStashStorageItem ( $ item , $ key ) ; } | stash storage item mapper . |
22,926 | private function sanitizeStashStorageItem ( $ item , $ key ) { if ( is_object ( $ item ) && ! ( $ item instanceof \ JsonSerializable ) ) { throw new StashException ( 'Can not stash value of key `' . $ key . '`, provided object does not implement JsonSerializable' ) ; } return $ item ; } | value sanitizer for stash items . |
22,927 | public function generate ( $ defClass ) { list ( $ className , $ refClass ) = $ this -> getClassInfo ( $ defClass ) ; $ companionName = $ this -> getCompanionName ( $ className ) ; $ companionNameParts = explode ( '\\' , $ companionName ) ; $ companionClass = array_pop ( $ companionNameParts ) ; $ companionNs = implode ( '\\' , $ companionNameParts ) ; $ companionNsPath = $ this -> nsToPath ( $ companionNs ) ; $ outDir = $ this -> target -> getPath ( ) -> pathJoin ( $ companionNsPath ) ; $ outPath = $ outDir -> pathJoin ( $ companionClass . '.php' ) ; $ psr4Prefix = $ this -> target -> getPrefix ( ) -> rtrim ( '\\' ) ; if ( ! empty ( $ psr4Prefix ) ) { $ companionNs = $ psr4Prefix -> join ( $ companionNs , '\\' ) ; } $ values = $ this -> director -> getValuesFor ( $ refClass ) ; $ values [ 'companionNs' ] = $ companionNs ; $ values [ 'companionClass' ] = $ companionClass ; $ values [ 'model' ] = $ className ; $ values [ 'modelStr' ] = str_replace ( '\\' , '\\\\' , $ className ) ; $ resolved = $ this -> template -> forValues ( $ values ) ; if ( ! file_exists ( $ outDir ) ) { mkdir ( $ outDir , 0755 , true ) ; } $ file = new SplFileObject ( $ outPath , 'w' ) ; $ file -> fwrite ( $ resolved ) ; return $ companionNs -> join ( $ companionClass , '\\' ) -> __toString ( ) ; } | Generate a companion for the given class . |
22,928 | public function hasIntersections ( array $ array , $ strict = false , $ returnIntersection = false ) { foreach ( $ this -> target as $ element ) { if ( in_array ( $ element , $ array , $ strict ) ) { return $ returnIntersection ? $ element : true ; } } return false ; } | Determine if two arrays have at least a single matching element |
22,929 | public function find ( $ defaultResult = null ) { foreach ( $ this -> target as $ value ) { if ( $ value ) { return $ value ; } } return $ defaultResult ; } | Return the first truthy element of the target array . If none of them is truthy return a defaultResult . |
22,930 | public function pregKeys ( $ pattern , $ defaultResult = null , $ flags = 0 ) { $ result = preg_grep ( $ pattern , array_keys ( $ this -> target ) , $ flags ) ; return $ result ? array_values ( $ result ) : $ defaultResult ; } | Get an array of target array s keys matching a regular expression If nothing found return a defaultResult |
22,931 | public function pregValues ( $ pattern , $ defaultResult = null , $ flags = 0 ) { $ result = preg_grep ( $ pattern , array_values ( $ this -> target ) , $ flags ) ; return $ result ? array_values ( $ result ) : $ defaultResult ; } | Get values from an array by a key matching a regular expression If nothing found return a defaultResult |
22,932 | public function except ( array $ keys ) { return $ keys ? array_diff_key ( $ this -> target , array_flip ( $ keys ) ) : $ this -> target ; } | Exclude specified keys form a given array |
22,933 | public function excludeByRule ( Closure $ rule ) { $ result = $ this -> target ; foreach ( $ result as $ key => $ value ) { if ( $ rule ( $ key , $ value ) ) { unset ( $ result [ $ key ] ) ; } } return $ result ; } | Exclude an item from an array if its value meets a rule |
22,934 | public function offsetGet ( $ offset ) { return isset ( $ this -> target [ $ offset ] ) ? $ this -> target [ $ offset ] : null ; } | Implementation of the offsetGet method of the ArrayAccess interface |
22,935 | public function endpoint_title ( $ title ) { global $ wp_query ; if ( isset ( $ wp_query -> query_vars [ $ this -> endpoint ] ) && ! is_admin ( ) && is_main_query ( ) && in_the_loop ( ) && is_account_page ( ) ) { $ title = apply_filters ( 'hametwoo_tab_title' , $ this -> get_title ( ) , $ this -> endpoint , get_called_class ( ) ) ; } return $ title ; } | Change title for tab |
22,936 | protected function build_rcpt ( $ list = 'to' ) { return array_map ( function ( $ item ) use ( $ list ) { $ item [ 'type' ] = $ list ; return $ item ; } , $ this -> { $ list } ) ; } | Add type to recipient list |
22,937 | public function get_merge_vars ( $ key = null , $ rcpt = null ) { if ( is_null ( $ rcpt ) ) { return \ Arr :: get ( $ this -> merge_vars , $ key ) ; } elseif ( isset ( $ this -> rcpt_merge_vars [ $ rcpt ] ) ) { return \ Arr :: get ( $ this -> rcpt_merge_vars [ $ rcpt ] , $ key ) ; } } | Get merge vars |
22,938 | public function add_merge_vars ( array $ merge_vars , $ rcpt = null ) { if ( is_null ( $ rcpt ) ) { $ this -> merge_vars = $ merge_vars ; } else { $ this -> rcpt_merge_vars [ $ rcpt ] = $ merge_vars ; } return $ this ; } | Add merge vars |
22,939 | public function set_merge_var ( $ key , $ value = null , $ rcpt = null ) { is_array ( $ key ) or $ key = array ( $ key => $ value ) ; if ( is_null ( $ rcpt ) ) { $ this -> merge_vars = \ Arr :: merge ( $ this -> merge_vars , $ key ) ; } else { $ merge_vars = \ Arr :: get ( $ this -> rcpt_merge_vars , $ rcpt , array ( ) ) ; $ this -> rcpt_merge_vars [ $ rcpt ] = \ Arr :: merge ( $ merge_vars , $ key ) ; } return $ this ; } | Set one or several merge vars |
22,940 | public function set_metadata ( $ key , $ value = null , $ rcpt = null ) { is_array ( $ key ) or $ key = array ( $ key => $ value ) ; if ( is_null ( $ rcpt ) ) { $ this -> metadata = \ Arr :: merge ( $ this -> metadata , $ key ) ; } else { $ metadata = \ Arr :: get ( $ this -> rcpt_metadata , $ rcpt , array ( ) ) ; $ this -> rcpt_metadata [ $ rcpt ] = \ Arr :: merge ( $ metadata , $ key ) ; } return $ this ; } | Set one or several metadata |
22,941 | private function parseMenuItems ( $ title , string $ url , array $ children , array $ fields ) : Item { $ urlGenerator = $ this -> instantiateUrlGenerator ( ) ; if ( is_array ( $ title ) ) { extract ( $ title ) ; } if ( $ children ) { $ childItems = [ ] ; foreach ( $ children as $ child ) { $ this -> checkFormat ( $ child ) ; if ( isset ( $ child [ 'children' ] ) && $ child [ 'children' ] ) { $ childItems [ ] = $ this -> parseMenuItems ( $ child [ 'title' ] , $ child [ 'url' ] , $ child [ 'children' ] , $ child [ 'fields' ] ?? [ ] ) ; } else { $ childItems [ ] = new Item ( $ child [ 'title' ] , $ child [ 'url' ] , [ ] , $ child [ 'fields' ] ?? [ ] , new Config , $ urlGenerator ) ; } } } return new Item ( $ title , $ url , $ childItems ?? $ children , $ fields , new Config , $ urlGenerator ) ; } | Parse menu items by converting them into instances of Item . |
22,942 | protected function _renderMessages ( array $ messages ) { if ( count ( $ messages ) == 1 ) { return reset ( $ messages ) ; } $ output = '<ul>' ; foreach ( $ messages as $ message ) { $ output .= '<li>' . $ message . '</li>' ; } $ output .= '</ul>' ; return $ output ; } | Render message array |
22,943 | public function addBulkUploader ( $ fileRelationName = null , $ folderName = null ) { $ gridFieldBulkUpload = Injector :: inst ( ) -> create ( "GridFieldBulkUpload" , $ fileRelationName ) ; if ( $ folderName ) { $ gridFieldBulkUpload -> setUfSetup ( "setFolderName" , $ folderName ) ; } $ this -> gridConfig -> addComponent ( $ gridFieldBulkUpload ) ; return $ this ; } | Enables bulk uploaded of files and images |
22,944 | private function sendRequest ( string $ method , string $ uri , array $ query = [ ] , array $ body = [ ] ) : array { $ uri = sprintf ( '%s%s' , $ this -> baseUrl , ltrim ( $ uri , '/' ) ) ; $ options = [ 'headers' => [ 'Authorization' => ( string ) $ this -> authentication ] , 'http_errors' => false ] ; if ( ! empty ( $ query ) ) { $ options [ 'query' ] = $ query ; } if ( ! empty ( $ body ) ) { $ options [ 'json' ] = $ body ; } $ response = $ this -> client -> request ( $ method , $ uri , $ options ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) , true ) ; if ( $ json === null ) { if ( $ this -> throwsExceptions ) { throw new SDKError ( ) ; } return [ ( string ) $ response -> getBody ( ) ] ; } if ( ( $ json [ 'status' ] === false ) && ( $ this -> throwsExceptions ) ) { throw new SDKException ( $ json [ 'error' ] [ 'message' ] , $ json [ 'error' ] [ 'type' ] , $ json [ 'error' ] [ 'link' ] ) ; } return $ json ; } | Sends the request to the api . |
22,945 | protected function sendPost ( string $ uri , array $ query = [ ] , array $ body = [ ] ) : array { return $ this -> sendRequest ( 'POST' , $ uri , $ query , $ body ) ; } | Sends a POST request . |
22,946 | protected function sendPatch ( string $ uri , array $ query = [ ] , array $ body = [ ] ) : array { return $ this -> sendRequest ( 'PATCH' , $ uri , $ query , $ body ) ; } | Sends a PATCH request . |
22,947 | protected function sendPut ( string $ uri , array $ query = [ ] , array $ body = [ ] ) : array { return $ this -> sendRequest ( 'PUT' , $ uri , $ query , $ body ) ; } | Sends a PUT request . |
22,948 | public function getFilters ( ) { return array ( 'num_format' => new \ Twig_Filter_Function ( 'num::format' ) , 'limit_words' => new \ Twig_Filter_Function ( 'Text::limit_words' ) , 'limit_chars' => new \ Twig_Filter_Function ( 'Text::limit_chars' ) , 'auto_link' => new \ Twig_Filter_Function ( 'Text::auto_link' ) , 'auto_p' => new \ Twig_Filter_Function ( 'Text::auto_p' ) , 'bytes' => new \ Twig_Filter_Function ( 'Text::bytes' ) , 'lower' => new \ Twig_Filter_Function ( 'mb_strtolower' ) , 'upper' => new \ Twig_Filter_Function ( 'mb_strtoupper' ) , 'ucfirst' => new \ Twig_Filter_Function ( 'ucfirst' ) , 'ucwords' => new \ Twig_Filter_Function ( 'ucwords' ) , 'strip_tags' => new \ Twig_Filter_Function ( 'strip_tags' ) , 'trim' => new \ Twig_Filter_Function ( 'trim' ) , 'int' => new \ Twig_Filter_Function ( 'intval' ) , 'xss_clean' => new \ Twig_Filter_Function ( 'Security::xss_clean' ) , 'urlencode' => new \ Twig_Filter_Function ( 'urlencode' ) , 'highlight' => new \ Twig_Filter_Function ( '\Meerkat\Twig\Twig_Extension::f_highlight' ) , ) ; } | Returns the added filters |
22,949 | public function logSignedRequestPatternFailures ( \ TYPO3 \ Flow \ Aop \ JoinPointInterface $ joinPoint ) { $ request = $ joinPoint -> getMethodArgument ( 'request' ) ; if ( $ request instanceof \ TYPO3 \ Flow \ Mvc \ RequestInterface ) { if ( $ request -> getControllerObjectName ( ) === 'Flowpack\SingleSignOn\Client\Controller\SessionController' ) { $ this -> securityLogger -> log ( 'Signature for call to Session service could not be verified' , LOG_NOTICE , array ( 'identifier' => $ joinPoint -> getMethodArgument ( 'identifier' ) , 'publicKeyFingerprint' => $ joinPoint -> getMethodArgument ( 'publicKeyFingerprint' ) , 'signature' => base64_encode ( $ joinPoint -> getMethodArgument ( 'signature' ) ) , 'signData' => $ joinPoint -> getMethodArgument ( 'signData' ) , 'content' => $ joinPoint -> getMethodArgument ( 'request' ) -> getHttpRequest ( ) -> getContent ( ) , ) ) ; } } } | Log signed request pattern failures |
22,950 | public function filterByDescendantClass ( $ descendantClass = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ descendantClass ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ descendantClass ) ) { $ descendantClass = str_replace ( '*' , '%' , $ descendantClass ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( StructureNodeTableMap :: COL_DESCENDANT_CLASS , $ descendantClass , $ comparison ) ; } | Filter the query on the descendant_class column |
22,951 | public function useStructureNodeParentRelatedByStructureNodeIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinStructureNodeParentRelatedByStructureNodeId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'StructureNodeParentRelatedByStructureNodeId' , '\gossi\trixionary\model\StructureNodeParentQuery' ) ; } | Use the StructureNodeParentRelatedByStructureNodeId relation StructureNodeParent object |
22,952 | public function useStructureNodeParentRelatedByParentIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinStructureNodeParentRelatedByParentId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'StructureNodeParentRelatedByParentId' , '\gossi\trixionary\model\StructureNodeParentQuery' ) ; } | Use the StructureNodeParentRelatedByParentId relation StructureNodeParent object |
22,953 | public function useKstrukturQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinKstruktur ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Kstruktur' , '\gossi\trixionary\model\KstrukturQuery' ) ; } | Use the Kstruktur relation Kstruktur object |
22,954 | public function useFunctionPhaseQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinFunctionPhase ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'FunctionPhase' , '\gossi\trixionary\model\FunctionPhaseQuery' ) ; } | Use the FunctionPhase relation FunctionPhase object |
22,955 | public function getProperty ( string $ strKey ) { $ mReturn = null ; switch ( $ strKey ) { case 'weekdays' : $ mReturn = array_keys ( array_intersect_key ( $ this -> aProperties , array_flip ( self :: WEEKDAYS ) ) , 1 ) ; break ; case 'lead_time_num' : case 'lead_time_unit' : $ mReturn = $ this -> getLeadTimeFactor ( $ strKey ) ; break ; default : $ mReturn = $ this -> aProperties [ $ strKey ] ?? null ; break ; } return $ mReturn ; } | Get an event property by key . |
22,956 | public function setProperty ( string $ strKey , $ mValue ) { if ( '' === $ mValue ) $ mValue = null ; switch ( $ strKey ) { case 'weekdays' : $ this -> setWeekdays ( ( array ) $ mValue ) ; break ; case 'tags' : $ this -> setTags ( $ mValue ) ; break ; case 'timezone' : $ this -> strTimezone = $ mValue ; break ; case 'starts_at' : case 'ends_at' : $ strProperty = 'starts_at' === $ strKey ? 'strStartsAt' : 'strEndsAt' ; $ this -> $ strProperty = $ mValue ; default : $ this -> aProperties [ $ strKey ] = $ mValue ; break ; } } | Set an event property by key . |
22,957 | public function setProperties ( array $ aProperties ) { foreach ( $ aProperties as $ strKey => $ mValue ) $ this -> setProperty ( $ strKey , $ mValue ) ; $ this -> adjustDependentFields ( ) ; } | Set properties from array . |
22,958 | protected function setWeekdays ( array $ aValues = [ ] ) { foreach ( self :: WEEKDAYS as $ strDay ) $ this -> setProperty ( $ strDay , ( int ) in_array ( $ strDay , $ aValues ) ) ; } | Set each weekday property based on an array of weekday abbreviations . |
22,959 | protected function adjustDependentFields ( ) { if ( array_key_exists ( 'repeats' , $ this -> aProperties ) && ! $ this -> repeats ) { $ this -> frequency = null ; $ this -> interval = self :: INTERVAL_ONCE ; $ this -> setWeekdays ( ) ; $ this -> ends_at = null ; } if ( ! is_null ( $ this -> strStartsAt ) ) { $ this -> aProperties [ 'starts_at' ] = Carbon :: parse ( $ this -> strStartsAt , $ this -> strTimezone ) -> setTimezone ( 'UTC' ) -> toDateTimeString ( ) ; } if ( ! is_null ( $ this -> strEndsAt ) ) { $ this -> aProperties [ 'ends_at' ] = Carbon :: parse ( $ this -> strEndsAt , $ this -> strTimezone ) -> setTimezone ( 'UTC' ) -> toDateTimeString ( ) ; } } | Adjust fields that are dependent upon other fields . |
22,960 | public static function getLeadTimeFactor ( string $ strFactor , int $ iLeadTime ) { if ( $ iLeadTime < 60 || $ iLeadTime % 60 !== 0 ) { $ iNum = $ iLeadTime ; $ iUnit = 1 ; } elseif ( $ iLeadTime % ( 24 * 60 ) !== 0 ) { $ iNum = $ iLeadTime / 60 ; $ iUnit = 60 ; } else { $ iNum = $ iLeadTime / ( 24 * 60 ) ; $ iUnit = 24 * 60 ; } return $ { 'i' . ucfirst ( strtolower ( str_replace ( 'lead_time_' , '' , $ strFactor ) ) ) } ; } | Get the num or unit factor from the lead time . |
22,961 | public function getMembers ( ) { if ( empty ( $ this -> aMembers ) ) { $ this -> aMembers = [ ] ; if ( $ this -> id ) { foreach ( Sked :: getEventMembers ( $ this -> id ) as $ aEventMember ) $ this -> aMembers [ $ aEventMember [ 'member_id' ] ] = $ aEventMember ; } } return $ this -> aMembers ; } | Get associated sked_event_members . |
22,962 | public function setMembers ( array $ aEventMembers ) { $ this -> aMembers = [ ] ; foreach ( $ aEventMembers as $ iMemberId => $ skeVentMember ) $ this -> aMembers [ $ iMemberId ] = $ skeVentMember + [ 'member_id' => $ iMemberId ] ; return $ this ; } | Set associated sked_event_members . |
22,963 | public function owner ( ) { $ iReturn = 0 ; foreach ( $ this -> getMembers ( ) as $ iId => $ aMember ) { if ( 1 == $ aMember [ 'owner' ] ) { $ iReturn = $ iId ; break ; } } return $ iReturn ; } | Get the event owner ID . |
22,964 | public function getTags ( ) { if ( ! is_array ( $ this -> aTags ) && $ this -> id ) { $ this -> aTags = [ ] ; foreach ( Sked :: getEventTags ( $ this -> id ) as $ aEventTag ) $ this -> aTags [ $ aEventTag [ 'tag_id' ] ] = new SkeVentTag ( $ aEventTag ) ; } return $ this -> aTags ; } | Get associated sked_event_tags . |
22,965 | public function setTags ( array $ aEventTags ) { $ this -> aTags = [ ] ; foreach ( $ aEventTags as $ iTagId => $ skeVentTag ) { if ( ! $ skeVentTag instanceof SkeVentTag ) { $ skeVentTag = new SkeVentTag ( [ 'tag_id' => $ iTagId , 'value' => $ skeVentTag , ] ) ; } $ this -> aTags [ $ skeVentTag -> tag_id ] = $ skeVentTag ; } return $ this ; } | Set associated sked_event_tags . |
22,966 | public function time ( string $ strFormat = 'g:ia' , string $ strTimezone = 'UTC' ) { return Carbon :: parse ( $ this -> session_at ?? $ this -> starts_at ) -> setTimezone ( $ strTimezone ) -> format ( $ strFormat ) ; } | Format the time using the given pattern . |
22,967 | public function toArray ( bool $ bIncludeExtras = true ) { $ this -> adjustDependentFields ( ) ; $ aReturn = array_filter ( $ this -> aProperties , function ( $ mValue , $ strKey ) { return ! empty ( $ mValue ) && '-' !== $ mValue && ( in_array ( $ strKey , [ 'created_at' , 'updated_at' ] ) || in_array ( $ strKey , self :: WEEKDAYS ) || array_key_exists ( $ strKey , Sked :: form ( ) -> getFieldDefinitions ( ) ) ) ; } , ARRAY_FILTER_USE_BOTH ) ; if ( isset ( $ aReturn [ 'starts_at' ] ) ) $ aReturn [ 'starts_at' ] = date ( 'Y-m-d H:i:s' , strtotime ( $ aReturn [ 'starts_at' ] ) ) ; if ( isset ( $ aReturn [ 'ends_at' ] ) ) $ aReturn [ 'ends_at' ] = date ( 'Y-m-d H:i:s' , strtotime ( $ aReturn [ 'ends_at' ] ) ) ; if ( $ bIncludeExtras ) { $ aReturn [ 'tags' ] = $ this -> getTags ( ) ; $ aReturn [ 'repeats' ] = self :: INTERVAL_ONCE !== $ aReturn [ 'interval' ] ? '1' : null ; } else { unset ( $ aReturn [ 'repeats' ] ) ; } return $ aReturn ; } | Convert to an array of database properties . |
22,968 | public function get ( $ path ) { $ localPath = $ this -> createUri ( $ path ) ; if ( ! file_exists ( $ localPath ) ) { return null ; } elseif ( ! is_readable ( $ localPath ) ) { throw new Exception \ OperationFailureException ( 'File reading error.' ) ; } else { return new FileDescriptor ( $ localPath , filesize ( $ localPath ) ) ; } } | Fetch file from storage |
22,969 | public function put ( $ path , FileDescriptor $ file ) { $ localPath = $ this -> createUri ( $ path ) ; if ( false === copy ( $ file -> getUri ( ) , $ localPath ) ) { throw new Exception \ OperationFailureException ( 'Can\'t create file ' . $ path . '.' ) ; } } | Put file into storage |
22,970 | protected function update_last_message ( $ overrides = [ ] ) { if ( $ this -> messages -> isNotEmpty ( ) ) { $ this -> messages -> last ( ) -> update ( $ overrides ) ; } return $ this ; } | Modify the most recently added message . |
22,971 | private function updateNodes ( $ key , StreamInterface $ stream ) { $ this -> nodeUrls = array_map ( function ( NodeInfo $ element ) { return $ element -> getServer ( ) ; } , ( new Node ( $ stream , $ this -> log ) ) -> hello ( ) ) ; $ this -> log -> notice ( 'caching connection info from HELLO' , [ 'key' => $ key , 'nodes' => $ this -> nodeUrls , 'ttl' => $ this -> getCacheTtl ( ) , ] ) ; $ this -> cache -> set ( $ key , $ this -> nodeUrls , $ this -> getCacheTtl ( ) ) ; } | Update the node list using the HELLO command . |
22,972 | public function install ( InstalledRepositoryInterface $ repo , PackageInterface $ package ) { $ this -> bootstrap ( ) ; echo 'add ' . $ package -> getName ( ) . ' to wambo modules' ; echo PHP_EOL ; $ wamboInstallerService = new WamboInstallerService ( $ package ) ; $ className = $ wamboInstallerService -> getBootstrapClassName ( ) ; $ name = $ package -> getName ( ) ; $ version = $ package -> getVersion ( ) ; $ module = new Module ( $ name , $ version , $ className ) ; $ this -> moduleRepository -> add ( $ module ) ; parent :: install ( $ repo , $ package ) ; } | Add a json node to the modules . json file . |
22,973 | public static function forCollection ( MapsProperty $ mapping , Throwable $ exception ) : UnmappableInput { return new self ( sprintf ( 'Failed to map the %s collection of the `%s` property: %s' , The :: shortNameOfThe ( $ mapping ) , $ mapping -> name ( ) , $ exception -> getMessage ( ) ) , 0 , $ exception ) ; } | Notifies the client code when a collection class could not be hydrated . |
22,974 | protected function response ( $ type = "json" ) { $ content = $ this -> simple_data ( $ this -> endpoint , $ this -> options -> toArray ( ) ) ; $ response = new Response ; $ response -> setPublic ( ) ; if ( $ this -> options -> get ( 'allow_origin' ) ) $ response -> header ( 'Access-Control-Allow-Origin' , $ this -> options -> get ( 'allow_origin' ) ) ; $ response -> setContent ( $ content ) -> send ( ) ; } | Returns a full response using the result of a call to simple_data by default an instance of Collection otherwise an array or JSON |
22,975 | public function newSheet ( ) { $ position = $ this -> engine -> getSheetCount ( ) ; $ this -> engine -> createSheet ( $ position ) ; $ this -> engine -> setActiveSheetIndex ( $ position ) ; } | Create a new Sheet |
22,976 | public function setValue ( $ cell , $ row , $ value , $ border = false ) { $ this -> engine -> getActiveSheet ( ) -> setCellValueByColumnAndRow ( $ cell , $ row , $ value ) ; $ this -> x = $ this -> getColumnName ( $ cell ) ; $ this -> y = $ row ; if ( $ border ) { $ this -> engine -> getActiveSheet ( ) -> getStyle ( "{$this->x}{$this->y}" ) -> applyFromArray ( $ this -> style ) ; } return $ this ; } | Set value in a cell |
22,977 | public function backgroundCell ( $ color , $ cell = null , $ row = null ) { $ color = str_replace ( "#" , "" , $ color ) ; if ( ! is_null ( $ cell ) ) { $ this -> x = $ this -> getColumnName ( $ cell ) ; $ this -> y = $ row ; } $ style = array ( 'fill' => array ( 'type' => PHPExcel_Style_Fill :: FILL_SOLID , 'color' => array ( 'rgb' => "$color" ) ) ) ; $ this -> engine -> getActiveSheet ( ) -> getStyle ( "{$this->x}{$this->y}" ) -> applyFromArray ( $ style ) ; } | Set background color for a cell |
22,978 | public function bold ( ) { $ style = array ( 'font' => array ( 'bold' => true ) ) ; $ this -> engine -> getActiveSheet ( ) -> getStyle ( "$this->x$this->y" ) -> applyFromArray ( $ style ) ; return $ this ; } | Make the cell text in a cell Bold |
22,979 | public function color ( $ color ) { $ style = array ( 'font' => array ( 'color' => array ( 'rgb' => $ color ) ) ) ; $ this -> engine -> getActiveSheet ( ) -> getStyle ( "$this->x$this->y" ) -> applyFromArray ( $ style ) ; return $ this ; } | Make set color on text |
22,980 | private function findPosition ( $ index ) { if ( $ index < $ this -> total ) { $ this -> letter [ ] = $ this -> alphabet [ $ index ] ; } else { $ mod = $ index % $ this -> total ; $ div = ( int ) $ index / $ this -> total ; $ this -> letter [ ] = $ this -> alphabet [ $ mod ] ; $ this -> findPosition ( $ div - 1 ) ; } } | Find a position for a letter |
22,981 | public function insert ( $ table , array $ data ) { $ columnPart = "" ; $ valuePart = "" ; foreach ( $ data as $ column => $ value ) { $ columnPart .= "`$column`, " ; $ valuePart .= "?, " ; } $ columnPart = substr ( $ columnPart , 0 , - 2 ) ; $ valuePart = substr ( $ valuePart , 0 , - 2 ) ; $ query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)" ; $ statement = $ this -> prepare ( $ query ) ; $ idx = 0 ; foreach ( $ data as $ key => $ value ) { $ statement -> bindValue ( ( $ idx + 1 ) , $ value , Database :: typeOfValue ( $ value ) ) ; $ idx ++ ; } return $ statement -> execute ( ) ; } | Insert data into the table . Will make a query for you and prepare the statement with the data . |
22,982 | public function raw ( $ query , $ return = false , $ fetchMode = null , $ fetchClass = null ) { if ( ! $ return ) { return $ this -> exec ( $ query ) ; } $ fetchMode = Database :: normalizeFetchType ( $ fetchMode ) ; $ statement = $ this -> query ( $ query ) ; if ( $ fetchMode === Database :: FETCH_CLASS ) { $ statement -> setFetchMode ( $ fetchMode , $ fetchClass ) ; } else { $ statement -> setFetchMode ( $ fetchMode ) ; } return $ statement -> fetchAll ( ) ; } | Execute query . Warning! No escaping! |
22,983 | public function getDbalConnection ( ) { $ dbalDriver = '' ; $ driverCode = $ this -> getDriver ( ) -> getCode ( ) ; if ( $ driverCode === 'MySQL' ) $ dbalDriver = 'pdo_mysql' ; if ( $ dbalDriver == '' ) return null ; $ config = new Configuration ( ) ; $ loggerChain = new LoggerChain ( ) ; if ( \ Arvici \ Heart \ Config \ Configuration :: get ( 'app.env' ) == 'development' ) { $ loggerChain -> addLogger ( new DoctrineLogBridge ( \ Logger :: getInstance ( ) -> getMonologInstance ( ) ) ) ; $ loggerChain -> addLogger ( DebugBarHelper :: getInstance ( ) -> getDebugStack ( ) ) ; } $ config -> setSQLLogger ( $ loggerChain ) ; return DriverManager :: getConnection ( [ 'driver' => $ dbalDriver , 'pdo' => $ this ] , $ config ) ; } | Get DBAL Connection |
22,984 | function getContents ( int $ maxLength = - 1 , int $ offset = 0 ) : string { $ contents = stream_get_contents ( $ this -> handle , $ maxLength , $ offset ) ; if ( $ contents === false ) { throw new IOException ( __METHOD__ . ' failed' ) ; } return $ contents ; } | Reads remainder of a stream into a string |
22,985 | protected function getScheme ( $ secured = null ) { if ( is_null ( $ secured ) ) { if ( is_null ( $ this -> cacheScheme ) ) { $ this -> cacheScheme = request ( 'REQUEST_SCHEME' , 'http' , 'server' ) . '://' ; return $ this -> cacheScheme ; } else { $ this -> cacheScheme ; } } return $ secured ? 'http://' : 'https://' ; } | Get the scheme . |
22,986 | protected function setParams ( array $ args ) { if ( ! empty ( $ args ) ) { $ request = '?' ; } else { $ request = '' ; } foreach ( $ args as $ key => $ value ) { if ( is_numeric ( $ key ) ) { if ( $ request != '?' ) { $ request .= '&' ; } $ request .= $ value ; } elseif ( is_string ( $ key ) ) { if ( $ request != '?' ) { $ request .= '&' ; } $ request .= $ key . '=' . $ value ; } } return $ request ; } | To set get parameters . |
22,987 | public function route ( $ route , $ secure = null ) { $ path = Url :: root ( ) ; if ( $ route == '/' ) { $ route = $ path ; } else { $ route = $ path . $ route ; } return self :: locate ( $ route , $ secure ) ; } | Redirect to route . |
22,988 | protected function _getService ( $ key ) { $ cache = $ this -> _getServiceCache ( ) ; $ notFoundException = null ; try { return $ cache -> get ( $ key , function ( $ key ) use ( & $ notFoundException ) { try { $ definition = $ this -> _get ( $ key ) ; } catch ( NotFoundExceptionInterface $ e ) { $ notFoundException = $ e ; throw $ e ; } return $ this -> _resolveDefinition ( $ definition ) ; } ) ; } catch ( RootException $ e ) { if ( $ notFoundException instanceof NotFoundExceptionInterface ) { throw $ notFoundException ; } throw $ this -> _throwContainerException ( $ this -> __ ( 'Could not retrieve service' ) , null , $ e , true ) ; } } | Retrieves a service by key . |
22,989 | private function resolveBody ( Message $ part ) { $ body = $ part -> getBody ( ) ; foreach ( $ part -> getParameters ( ) as $ search => $ replace ) { $ body = str_replace ( $ search , $ replace , $ body ) ; } return $ body ; } | Resolve the body of the message . |
22,990 | public function open ( $ url , array $ attributes = [ ] ) { $ tag = new Tag ( 'form' , $ attributes ) ; $ tag -> action = $ url ; $ tag -> method = 'POST' ; return $ tag ; } | open form tag . |
22,991 | public function model ( Entity $ model , $ url , array $ attributes = [ ] ) { $ this -> model = $ model ; $ tag = $ this -> open ( $ url , $ attributes ) ; return $ tag ; } | open form tag using model |
22,992 | public function close ( ) { $ tag = new Tag ( 'form' ) ; $ tag -> closeMode = Tag :: CLOSE_ONLY ; $ this -> model = null ; return $ tag ; } | close form tag . |
22,993 | public function text ( $ name , $ value = null , array $ attributes = [ ] ) { $ value = $ this -> getDefaultValue ( $ name , $ value ) ; return $ this -> input ( 'text' , $ name , $ value , $ attributes ) ; } | text input tag |
22,994 | public function date ( $ name , $ value = null , array $ attributes = [ ] ) { $ value = $ this -> getDefaultValue ( $ name , $ value ) ; return $ this -> input ( 'date' , $ name , $ value , $ attributes ) ; } | date input tag |
22,995 | protected function getDefaultValue ( $ name , $ value = null ) { if ( $ value !== null ) return $ value ; if ( $ this -> model && $ this -> model -> has ( $ name ) ) return $ this -> model -> get ( $ name ) ; return $ value ; } | get default value |
22,996 | protected function _terminate ( $ timeout = 10 , $ signal = 15 ) { foreach ( $ this -> _getPidRecursive ( $ this -> getPid ( ) ) as $ pid ) { posix_kill ( $ pid , $ signal ) ; } parent :: stop ( $ timeout , $ signal ) ; } | Terminate current process |
22,997 | protected function _getPidRecursive ( $ ppid ) { if ( ! $ ppid ) { return array ( ) ; } $ allPids = $ pids = array_filter ( preg_split ( '/\s+/' , `ps -o pid --no-heading --ppid $ppid` ) ) ; foreach ( $ pids as $ pid ) { $ allPids = array_merge ( $ allPids , $ this -> _getPidRecursive ( $ pid ) ) ; } return $ allPids ; } | Collect all childrens pids recursively |
22,998 | public function makeLogin ( $ vData , $ bKeepAlive = false , & $ sCkString = '' ) { if ( UCProLib :: isValidXTArray ( $ vData ) ) { return $ this -> m_cUCProMain -> makeLoginByXTArray ( $ vData , $ bKeepAlive , $ sCkString ) ; } else if ( CLib :: IsExistingString ( $ vData ) ) { return $ this -> m_cUCProMain -> makeLoginByCookieString ( $ vData , $ bKeepAlive , true ) ; } else { return UCProError :: UCLIENTPRO_MAKELOGIN_FAILURE ; } } | make user login |
22,999 | public function isCookieAlive ( ) { $ bRet = false ; if ( $ this -> isKeepAlive ( ) ) { $ bRet = true ; } else { $ nLoginTime = $ this -> m_cUCProMain -> getXTInstance ( ) -> getTValue ( UCProConst :: CKT_LOGIN_TM ) ; if ( is_numeric ( $ nLoginTime ) ) { $ fTerm = floatval ( time ( ) - floatval ( $ nLoginTime ) ) ; $ bRet = ( $ fTerm <= $ this -> m_cUCProMain -> getConfig_nCookieTimeout ( ) ) ; } else { $ bRet = false ; } } return $ bRet ; } | check if cookie alive |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.