idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
51,100 | public function formatTaxRate ( $ rate ) { return $ rate != intval ( $ rate ) ? self :: formatAsDecimal ( $ rate , 1 ) : self :: formatAsDecimal ( $ rate , 0 ) ; } | shows decimals only if necessary |
51,101 | public function getNetPriceAfterTaxUpdate ( $ productId , $ oldNetPrice , $ oldTaxRate ) { if ( is_null ( $ oldTaxRate ) ) { $ oldTaxRate = 0 ; } $ sql = 'SELECT ROUND(:oldNetPrice / ((100 + t.rate) / 100) * (1 + :oldTaxRate / 100), 6) as new_net_price ' ; $ sql .= $ this -> getTaxJoins ( ) ; $ params = [ 'oldNetPrice'... | needs to be called AFTER taxId of product was updated |
51,102 | public function findNeighbors ( Query $ query , array $ options ) { $ previous = $ this -> find ( ) -> orderAsc ( $ this -> getAlias ( ) . '.modified' ) -> where ( $ this -> getAlias ( ) . '.modified > \'' . $ options [ 'modified' ] . '\'' ) ; $ next = $ this -> find ( ) -> orderDesc ( $ this -> getAlias ( ) . '.modifi... | Find neighbors method |
51,103 | public function initInstantOrder ( $ customerId ) { if ( ! $ customerId ) { throw new RecordNotFoundException ( 'customerId not passed' ) ; } $ this -> Customer = TableRegistry :: getTableLocator ( ) -> get ( 'Customers' ) ; $ instantOrderCustomer = $ this -> Customer -> find ( 'all' , [ 'conditions' => [ 'Customers.id... | this url is called if instant order is initialized saves the desired user in session |
51,104 | public function middleware ( $ middlewareQueue ) { $ middlewareQueue -> add ( ErrorHandlerMiddleware :: class ) -> add ( AssetMiddleware :: class ) -> add ( new RoutingMiddleware ( $ this ) ) ; return $ middlewareQueue ; } | Setup the middleware queue your application will use . |
51,105 | private function getFile ( $ filenameWithPath ) { $ explodedString = explode ( '\\' , $ filenameWithPath ) ; header ( 'Content-Type: application/pdf' ) ; header ( 'Content-Disposition: inline; filename="' . $ explodedString [ count ( $ explodedString ) - 1 ] . '"' ) ; readfile ( ROOT . $ filenameWithPath ) ; exit ; } | invoices and order lists are not stored in webroot |
51,106 | private function markProductsAsSynced ( $ products , $ syncDomainsCount ) { $ syncProducts = $ this -> SyncProduct -> findAllSyncProducts ( $ this -> AppAuth -> getManufacturerId ( ) ) ; foreach ( $ products as $ product ) { $ syncCount = 0 ; $ preparedSyncProducts = [ ] ; foreach ( $ syncProducts as $ syncProduct ) { ... | check if already synced with local products |
51,107 | public function getManufacturerRecord ( $ customer ) { $ mm = TableRegistry :: getTableLocator ( ) -> get ( 'Manufacturers' ) ; $ manufacturer = $ mm -> find ( 'all' , [ 'conditions' => [ 'AddressManufacturers.email' => $ customer -> email ] , 'contain' => [ 'AddressManufacturers' ] ] ) -> first ( ) ; return $ manufact... | bindings with email as foreign key was tricky ... |
51,108 | private function validateAuthentication ( ) { if ( $ this -> AppAuth -> user ( ) ) { $ this -> Customer = TableRegistry :: getTableLocator ( ) -> get ( 'Customers' ) ; $ query = $ this -> Customer -> find ( 'all' , [ 'conditions' => [ 'Customers.email' => $ this -> AppAuth -> getEmail ( ) ] ] ) ; $ query = $ this -> Cu... | check valid login on each request logged in user should be logged out if deleted or deactivated by admin |
51,109 | private static function paddingString ( int $ inputsize , int $ blocksize ) : string { $ pad = $ blocksize - ( $ inputsize % $ blocksize ) ; return \ str_repeat ( \ chr ( $ pad ) , $ pad ) ; } | Create the padding string that will be appended to the input . |
51,110 | protected static function initializeState ( string $ key ) : array { $ s = \ range ( 0 , 255 ) ; $ j = 0 ; foreach ( \ range ( 0 , 255 ) as $ i ) { $ j = ( $ j + $ s [ $ i ] + \ ord ( $ key [ $ i % Str :: strlen ( $ key ) ] ) ) % 256 ; $ x = $ s [ $ i ] ; $ s [ $ i ] = $ s [ $ j ] ; $ s [ $ j ] = $ x ; } return $ s ; } | Create the initial byte matrix that will be used for swaps . This code is identical between RC4 and Spritz . |
51,111 | public static function equal ( string $ known , string $ given ) : bool { $ nonce = \ random_bytes ( 32 ) ; $ known = \ hash_hmac ( 'sha256' , $ known , $ nonce , true ) ; $ given = \ hash_hmac ( 'sha256' , $ given , $ nonce , true ) ; return \ hash_equals ( $ known , $ given ) ; } | Compares two strings in constant time . Strings are hashed before comparison so information is not leaked when strings are not of equal length . |
51,112 | public static function tagRequired ( string $ cipher ) : bool { $ cipher = strtolower ( $ cipher ) ; $ needle_tips = [ '-gcm' , '-ccm' , ] ; foreach ( $ needle_tips as $ needle ) { if ( strpos ( $ cipher , $ needle ) ) { return true ; } } return false ; } | Determines if the provided cipher requires a tag |
51,113 | public static function crypt ( string $ input , string $ password , string $ algo = 'sha512' ) : string { $ chunks = \ str_split ( $ input , Str :: hashSize ( $ algo ) ) ; $ length = Str :: strlen ( $ input ) ; foreach ( $ chunks as $ i => & $ chunk ) { $ chunk = $ chunk ^ \ hash_hmac ( $ algo , $ password . $ length ,... | Encrypt or decrypt a binary input string . |
51,114 | private static function build ( string $ data , string $ pass , int $ cost , string $ salt = null ) : string { $ salt = $ salt ?? \ random_bytes ( 16 ) ; $ pkey = \ hash_pbkdf2 ( self :: ALGO , $ pass , $ salt , $ cost , 0 , true ) ; $ hash = \ hash_hmac ( self :: ALGO , $ data , $ pkey , true ) ; $ cost = self :: cost... | Internal function used to build the actual hash . |
51,115 | private static function costEncrypt ( int $ cost , string $ salt , string $ pass ) : string { $ packed = pack ( 'N' , $ cost ) ; return Otp :: crypt ( $ packed , ( $ pass . $ salt ) , self :: ALGO ) ; } | Encrypts the cost value so that it can be added to the output hash discretely |
51,116 | private static function costDecrypt ( string $ pack , string $ salt , string $ pass ) : int { $ pack = Otp :: crypt ( $ pack , ( $ pass . $ salt ) , self :: ALGO ) ; return unpack ( 'N' , $ pack ) [ 1 ] ; } | Decrypts the cost string back into an int |
51,117 | public static function make ( string $ data , string $ pass , int $ cost = 250000 ) : string { return self :: build ( $ data , $ pass , $ cost , null ) ; } | Hash an input string into a salted 52 bit hash . |
51,118 | public static function verify ( string $ data , string $ hash , string $ pass ) : bool { $ salt = Str :: substr ( $ hash , 0 , 16 ) ; $ chsh = Str :: substr ( $ hash , 16 , 8 ) ; $ cost = Str :: substr ( $ hash , 24 , 4 ) ; if ( $ chsh !== self :: costHash ( $ cost , $ pass ) ) { return false ; } $ cost = self :: costD... | Check the validity of a hash . |
51,119 | private static function costHash ( string $ cost , string $ pass ) : string { return Str :: substr ( \ hash_hmac ( self :: ALGO , $ cost , $ pass , true ) , 0 , 8 ) ; } | Returns the correct hash for an encrypted cost value . |
51,120 | public static function encrypt ( string $ input , string $ method , string $ key , string $ iv , string & $ tag ) : string { if ( OpensslStatic :: tagRequired ( $ method ) ) { $ ret = \ openssl_encrypt ( $ input , $ method , $ key , OPENSSL_RAW_DATA , $ iv , $ tag , '' , 4 ) ; } else { $ ret = \ openssl_encrypt ( $ inp... | OpenSSL encrypt wrapper function |
51,121 | public static function decrypt ( string $ input , string $ method , string $ key , string $ iv , string $ tag ) : string { if ( OpensslStatic :: tagRequired ( $ method ) ) { $ ret = \ openssl_decrypt ( $ input , $ method , $ key , OPENSSL_RAW_DATA , $ iv , $ tag , '' ) ; } else { $ ret = \ openssl_decrypt ( $ input , $... | OpenSSL decrypt wrapper function |
51,122 | public static function ivsize ( string $ cipher ) : int { $ ret = \ openssl_cipher_iv_length ( $ cipher ) ; if ( $ ret === false ) { throw new \ Exception ( "Failed to determine correct IV size." ) ; } return $ ret ; } | Get IV size for specified CIPHER . |
51,123 | protected function formatDateTime ( DateTimeInterface $ date ) : string { return ( new DateTime ) -> setTimestamp ( $ date -> getTimestamp ( ) ) -> setTimezone ( new DateTimeZone ( 'UTC' ) ) -> format ( 'Y-m-d\TH:i:s\Z' ) ; } | Use UTC time zone and return ISO - 8601 format . |
51,124 | protected function toDateTime ( string $ representation ) : DateTimeImmutable { if ( is_numeric ( $ representation ) ) { $ representation = '@' . substr ( $ representation , 0 , 10 ) ; } return new DateTimeImmutable ( $ representation ) ; } | Convert an ISO - 8601 formatted string to DateTimeImmutable . |
51,125 | private static function processUriParams ( & $ path , & $ params ) { if ( preg_match_all ( static :: REGEX_PATH_PARAMS , $ path , $ matches , PREG_SET_ORDER | PREG_OFFSET_CAPTURE ) ) { $ previousMatchEnd = 0 ; $ regexParts = [ ] ; foreach ( $ matches as $ match ) { $ matchStart = $ match [ 0 ] [ 1 ] ; $ matchEnd = $ ma... | Extracts parameters from a path |
51,126 | public function normalize ( ) { $ this -> str = ltrim ( $ this -> str ) ; $ this -> str = '/' . ltrim ( $ this -> str , '/' ) ; $ this -> str = rtrim ( $ this -> str ) ; return $ this ; } | Normalizes the path |
51,127 | public function index ( ) { $ test = new \ core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'uri' ) ) ; $ model = $ this -> getServiceManager ( ) -> get ( TestModel :: SERVICE_ID ) ; $ itemSequence = array ( ) ; $ itemUris = array ( ) ; $ counter = 1 ; foreach ( $ model -> getItems ( $ test ) as $ item ) ... | Renders the auhtoring for simple tests |
51,128 | public function saveItems ( ) { $ test = new \ core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'uri' ) ) ; if ( ! tao_helpers_Request :: isAjax ( ) ) { throw new common_exception_BadRequest ( 'wrong request mode' ) ; } $ itemUris = tao_helpers_form_GenerisTreeForm :: getSelectedInstancesFromPost ( ) ; fo... | save the related items from the checkbox tree or from the sequence box |
51,129 | protected function getMergedConfigurationForSitePackage ( $ sitePackageKey ) { if ( array_key_exists ( $ sitePackageKey , $ this -> mergedConfigurationCache ) ) { return $ this -> mergedConfigurationCache [ $ sitePackageKey ] ; } $ configuration = $ this -> configuration ; $ siteConfiguration = Arrays :: getValueByPath... | Get the merged configuration for a specific site - package |
51,130 | public function configurationAction ( $ sitePackageKey = null ) { $ sitePackageKey = $ sitePackageKey ? : $ this -> getDefaultSitePackageKey ( ) ; $ value = [ ] ; $ value [ 'sitePackage' ] = $ sitePackageKey ; $ value [ 'ui' ] = [ 'sitePackages' => $ this -> getSitePackages ( ) , 'viewportPresets' => $ this -> configur... | Get all configurations for this site package |
51,131 | public function prototypeDetailsAction ( $ sitePackageKey , $ prototypeName ) { $ sitePackageKey = $ sitePackageKey ? : $ this -> getDefaultSitePackageKey ( ) ; $ prototypePreviewRenderPath = FusionService :: RENDERPATH_DISCRIMINATOR . str_replace ( [ '.' , ':' ] , [ '_' , '__' ] , $ prototypeName ) ; $ fusionView = ne... | Render informations about the given prototype |
51,132 | protected function getStructureForPrototypeName ( $ prototypeStructures , $ prototypeName ) { foreach ( $ prototypeStructures as $ structure ) { if ( preg_match ( sprintf ( '!%s!' , $ structure [ 'match' ] ) , $ prototypeName ) ) { return $ structure ; } } return [ 'label' => 'Other' , 'icon' => 'icon-question' , 'colo... | Find the matching structure for a prototype |
51,133 | public function getMergedFusionObjectTreeForSitePackage ( $ siteResourcesPackageKey ) { $ siteRootFusionPathAndFilename = sprintf ( $ this -> siteRootFusionPattern , $ siteResourcesPackageKey ) ; $ mergedFusionCode = '' ; $ mergedFusionCode .= $ this -> generateNodeTypeDefinitions ( ) ; $ mergedFusionCode .= $ this -> ... | Returns a merged fusion object tree in the context of the given site - package |
51,134 | public function getStyleguideObjectsFromFusionAst ( $ fusionAst ) { $ styleguideObjects = [ ] ; if ( $ fusionAst && $ fusionAst [ '__prototypes' ] ) { foreach ( $ fusionAst [ '__prototypes' ] as $ prototypeFullName => $ prototypeObject ) { if ( array_key_exists ( '__meta' , $ prototypeObject ) && is_array ( $ prototype... | Get all styleguide objects for the given fusion - ast |
51,135 | public function getAnatomicalPrototypeTreeFromAstExcerpt ( $ fusionAstExcerpt ) { $ result = [ ] ; if ( ! is_array ( $ fusionAstExcerpt ) ) { return $ result ; } foreach ( $ fusionAstExcerpt as $ key => $ value ) { if ( substr ( $ key , 0 , 2 ) === '__' ) { continue ; } $ anatomy = $ this -> getAnatomicalPrototypeTreeF... | Get anatomical prototype tree from fusion AST excerpt |
51,136 | public function viewportsCommand ( $ format = 'json' , $ packageKey = null ) { $ sitePackageKey = $ packageKey ? : $ this -> getDefaultSitePackageKey ( ) ; $ viewportPresets = $ this -> configurationService -> getSiteConfiguration ( $ sitePackageKey , 'ui.viewportPresets' ) ; $ this -> outputData ( $ viewportPresets , ... | Get a list of all configured default styleguide viewports |
51,137 | public function itemsCommand ( $ format = 'json' , $ packageKey = null ) { $ sitePackageKey = $ packageKey ? : $ this -> getDefaultSitePackageKey ( ) ; $ fusionAst = $ this -> fusionService -> getMergedFusionObjectTreeForSitePackage ( $ sitePackageKey ) ; $ styleguideObjects = $ this -> fusionService -> getStyleguideOb... | Get all styleguide items currently available |
51,138 | public function renderCommand ( $ prototypeName , $ packageKey = null , $ propSet = '__default' , $ props = '' , $ locales = '' ) { $ sitePackageKey = $ packageKey ? : $ this -> getDefaultSitePackageKey ( ) ; $ convertedProps = json_decode ( $ props , true ) ?? [ ] ; $ convertedLocales = json_decode ( $ locales , true ... | Render a given fusion component to HTML |
51,139 | public function staticAction ( $ key ) { if ( $ key && is_array ( $ this -> staticUriMocks ) && array_key_exists ( $ key , $ this -> staticUriMocks ) ) { $ config = $ this -> staticUriMocks [ $ key ] ; $ this -> response -> setHeader ( 'Content-Type' , $ config [ 'contentType' ] ) ; return file_get_contents ( $ config ... | Return the given static content as defined in the configuration |
51,140 | public static function restorePrototypeCode ( $ prototypeName , $ abstractSyntaxTree , $ indentation = '' ) { $ result = '' ; if ( array_key_exists ( '__prototypeObjectName' , $ abstractSyntaxTree ) ) { $ result .= sprintf ( 'prototype(%s) < prototype(%s) {' , $ prototypeName , $ abstractSyntaxTree [ '__prototypeObject... | Get PrototypeName and AST and restore the original Code representation |
51,141 | protected function getActiveSitePackageKeys ( ) { $ sitePackages = $ this -> packageManager -> getFilteredPackages ( 'available' , null , 'neos-site' ) ; $ result = [ ] ; foreach ( $ sitePackages as $ sitePackage ) { $ packageKey = $ sitePackage -> getPackageKey ( ) ; $ result [ ] = $ packageKey ; } return $ result ; } | Get a list of all active site package keys |
51,142 | public function evaluate ( ) { $ type = $ this -> getType ( ) ; $ content = $ this -> getContent ( ) ; if ( $ type && $ content ) { return 'data:' . $ type . ';base64,' . base64_encode ( $ content ) ; } } | Render a prototype |
51,143 | protected function createDummyControllerContext ( ) { $ httpRequest = Request :: create ( new Uri ( 'http://neos.io' ) ) ; $ request = new ActionRequest ( $ httpRequest ) ; $ response = new Response ( ) ; $ arguments = new Arguments ( [ ] ) ; $ uriBuilder = new UriBuilder ( ) ; $ uriBuilder -> setRequest ( $ request ) ... | Create a dummy controller context |
51,144 | private function minifyHTML ( $ html ) { $ search = array ( '/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\'|\")\/\/.*))/' , '/\n/' , '/\>[^\S ]+/s' , '/[^\S ]+\</s' , '/(\s)+/s' , '/<!--.*? ) ; $ replace = array ( ' ' , ' ' , '>' , '<' , '\\1' , '' ) ; $ squeezedHTML = preg_replace ( $ search , $ replace , $... | minify html content |
51,145 | public function attempt ( $ password ) { if ( ! Hash :: check ( $ password , Auth :: user ( ) -> getAuthPassword ( ) ) ) { return false ; } $ this -> request -> session ( ) -> put ( $ this -> key . '.life' , Carbon :: now ( ) -> timestamp ) ; $ this -> request -> session ( ) -> put ( $ this -> key . '.authenticated' , ... | Attempt to Reauthenticate the user . |
51,146 | public function check ( ) { $ session = $ this -> request -> session ( ) ; $ validationTime = Carbon :: createFromTimestamp ( $ session -> get ( $ this -> key . '.life' , 0 ) ) ; return $ session -> get ( $ this -> key . '.authenticated' , false ) && ( $ validationTime -> diffInMinutes ( ) <= $ this -> reauthTime ) ; } | Validate a reauthenticated Session data . |
51,147 | public function createConnection ( string $ dsn , string $ driverClass = 'com.mysql.jdbc.Driver' ) : Interfaces \ JavaObject { if ( ! is_string ( $ dsn ) || trim ( $ dsn ) == '' ) { $ message = 'DSN param must be a valid (on-empty) string' ; throw new Exception \ InvalidArgumentException ( __METHOD__ . ' ' . $ message ... | Create an sql connection to database . |
51,148 | public function getDriverManager ( ) : Interfaces \ JavaObject { if ( $ this -> driverManager === null ) { $ this -> driverManager = $ this -> ba -> javaClass ( 'java.sql.DriverManager' ) ; } return $ this -> driverManager ; } | Return underlying java driver manager . |
51,149 | public static function getJdbcDsn ( string $ driver , string $ db , string $ host , string $ user , string $ password , array $ options = [ ] ) : string { $ extras = '' ; if ( count ( $ options ) > 0 ) { $ tmp = [ ] ; foreach ( $ options as $ key => $ value ) { $ tmp [ ] = urlencode ( $ key ) . '=' . urlencode ( $ valu... | Return a JDBC DSN formatted string from options . |
51,150 | protected function loadClient ( ) : void { if ( self :: $ client === null ) { $ options = $ this -> options ; if ( ! isset ( $ options [ 'servlet_address' ] ) ) { throw new Exception \ InvalidArgumentException ( __METHOD__ . ' Missing required parameter servlet_address' ) ; } $ connection = static :: parseServletUrl ( ... | Load pjb client with options . |
51,151 | public function getJavaClass ( $ name ) : Interfaces \ JavaClass { if ( ! array_key_exists ( $ name , $ this -> classMapCache ) ) { $ this -> classMapCache [ $ name ] = new JavaClass ( $ name ) ; } return $ this -> classMapCache [ $ name ] ; } | Return a Java class . |
51,152 | public function invokeMethod ( ? Interfaces \ JavaType $ object = null , string $ method , array $ args = [ ] ) { $ id = ( $ object === null ) ? 0 : $ object -> __getJavaInternalObjectId ( ) ; return self :: getClient ( ) -> invokeMethod ( $ id , $ method , $ args ) ; } | Invoke a method dynamically . |
51,153 | public function isInstanceOf ( Interfaces \ JavaObject $ object , $ class ) : bool { if ( is_string ( $ class ) ) { $ name = $ class ; $ class = $ this -> getJavaClass ( $ name ) ; } elseif ( ! $ class instanceof Interfaces \ JavaObject ) { throw new Exception \ InvalidArgumentException ( __METHOD__ . 'Class $class par... | Test whether an object is an instance of java class or interface . |
51,154 | public function getOption ( string $ name ) { if ( ! $ this -> options -> offsetExists ( $ name ) ) { throw new Exception \ InvalidArgumentException ( "Option '$name' does not exists'" ) ; } return $ this -> options [ $ name ] ; } | Return specific option . |
51,155 | public static function unregisterInstance ( ) : void { if ( ! self :: $ unregistering && self :: $ client !== null ) { self :: $ unregistering = true ; if ( ( self :: $ client -> preparedToSendBuffer ? : '' ) !== '' ) { self :: $ client -> sendBuffer .= self :: $ client -> preparedToSendBuffer ; } try { self :: $ clien... | Clean up PjbProxyClient instance . |
51,156 | public function invokeMethod ( int $ object_id , string $ method , array $ args = [ ] ) { $ this -> protocol -> invokeBegin ( $ object_id , $ method ) ; $ this -> writeArgs ( $ args ) ; $ this -> protocol -> invokeEnd ( ) ; $ val = $ this -> getResult ( ) ; return $ val ; } | Invoke a method on java object . |
51,157 | public function setExitCode ( int $ code ) : void { if ( isset ( $ this -> protocol ) ) { $ this -> protocol -> writeExitCode ( $ code ) ; } } | Write exit code . |
51,158 | public function cast ( JavaProxy $ object , $ type ) { $ code = strtoupper ( $ type [ 0 ] ) ; switch ( $ code ) { case 'S' : return $ this -> invokeMethod ( 0 , 'castToString' , [ $ object ] ) ; case 'B' : return $ this -> invokeMethod ( 0 , 'castToBoolean' , [ $ object ] ) ; case 'L' : case 'I' : return $ this -> invo... | Cast an object to a certain type . |
51,159 | public function getAvailableIDs ( ) : array { if ( $ this -> availableTz === null ) { $ this -> availableTz = [ ] ; $ available = $ this -> timeZoneClass -> getAvailableIDs ( ) ; foreach ( $ available as $ id ) { $ this -> availableTz [ ] = $ id ; } } return $ this -> availableTz ; } | Return java available timezone ids . |
51,160 | public function getDefault ( $ enableTzCache = true ) : Interfaces \ JavaObject { $ enableCache = $ enableTzCache && self :: $ enableTzCache ; if ( ! $ enableCache || self :: $ defaultTz === null ) { self :: $ defaultTz = $ this -> timeZoneClass -> getDefault ( ) ; } return self :: $ defaultTz ; } | Return default jvm TimeZone . |
51,161 | public function isInstanceOf ( Interfaces \ JavaObject $ javaObject , $ className ) : bool { return $ this -> driver -> isInstanceOf ( $ javaObject , $ className ) ; } | Checks whether object is an instance of a class or interface . |
51,162 | public function isNull ( Interfaces \ JavaObject $ javaObject = null ) : bool { return $ this -> driver -> isNull ( $ javaObject ) ; } | Whether a java internal value is null . |
51,163 | public function getSystem ( ) : Adapter \ System { if ( $ this -> system === null ) { $ this -> system = new Adapter \ System ( $ this ) ; } return $ this -> system ; } | Return system properties . |
51,164 | public static function getJavaBridgeHeader ( string $ name , array $ array ) : string { if ( array_key_exists ( $ name , $ array ) ) { return $ array [ $ name ] ; } $ name = "HTTP_$name" ; if ( array_key_exists ( $ name , $ array ) ) { return $ array [ $ name ] ; } return '' ; } | Return java bridge header or empty string if nothing . |
51,165 | public static function castPjbInternal ( $ javaObject , string $ cast_type ) { if ( $ javaObject instanceof JavaType ) { return $ javaObject -> __cast ( $ cast_type ) ; } $ first_char = strtoupper ( $ cast_type [ 0 ] ) ; switch ( $ first_char ) { case 'S' : return ( string ) $ javaObject ; case 'B' : return ( bool ) $ ... | Cast internal objects to a new type . |
51,166 | public function getClassName ( Interfaces \ JavaObject $ javaObject ) : string { $ inspect = $ this -> inspect ( $ javaObject ) ; $ matches = [ ] ; preg_match ( '/^\[class (.+)\:/' , $ inspect , $ matches ) ; if ( ! isset ( $ matches [ 1 ] ) || $ matches [ 1 ] == '' ) { throw new Exception \ UnexpectedException ( __MET... | Return object java class name . |
51,167 | public static function all ( $ routes ) { foreach ( self :: $ beforeFuncs as $ beforeFunc ) { if ( $ beforeFunc [ 1 ] ) { call_user_func_array ( $ beforeFunc [ 0 ] , $ beforeFunc [ 1 ] ) ; } else { call_user_func ( $ beforeFunc [ 0 ] ) ; } } self :: $ routes = $ routes ; $ method = strtolower ( $ _SERVER [ 'REQUEST_MET... | Static function of the class Link that deploys the route according to the passed handler and path |
51,168 | public static function route ( $ name , $ params = array ( ) ) { $ href = null ; foreach ( self :: $ routes as $ routePath => $ routeDesc ) { if ( is_array ( $ routeDesc ) ) { if ( $ name == $ routeDesc [ 1 ] ) { $ href = $ routePath ; for ( $ i = 0 ; $ i < count ( $ params ) ; $ i ++ ) { $ href = preg_replace ( '#{(.*... | Static function that helps you generate links effortlessly and pass parameters to them thus enabling to generate dynamic links |
51,169 | public static function callFunction ( $ handler , $ matched , $ method ) { if ( $ handler ) { if ( is_callable ( $ handler ) ) { $ newParams = call_user_func_array ( $ handler , $ matched ) ; } else { if ( class_exists ( $ handler ) ) { $ instanceOfHandler = new $ handler ( ) ; } else { print_r ( 'Class or function ' .... | Static function to handle both middlewares call and main handler s call . |
51,170 | protected function determineLineEnding ( ) { if ( isset ( $ this -> content [ 0 ] ) && strpos ( $ this -> content [ 0 ] , "\r\n" ) !== false ) { $ this -> lineEnding = "\r\n" ; } return $ this ; } | Default line ending is set to LF . |
51,171 | protected static function useCustomGrammar ( $ connection ) { if ( get_class ( $ connection ) === 'Illuminate\Database\MySqlConnection' ) { $ MySqlGrammar = $ connection -> withTablePrefix ( new MySqlGrammar ) ; $ connection -> setSchemaGrammar ( $ MySqlGrammar ) ; } return $ connection -> getSchemaBuilder ( ) ; } | lead the system to load custom Grammar |
51,172 | public function enter ( RequestInterface $ request = null ) { $ this -> starts = [ 'wt' => microtime ( true ) , 'mu' => memory_get_usage ( ) , 'pmu' => memory_get_peak_usage ( ) , ] ; if ( $ request ) { $ this -> request = [ 'method' => $ request -> getMethod ( ) , 'url' => ( string ) $ request -> getUri ( ) , 'headers... | Starts the profiling . |
51,173 | protected function findOrCreateMember ( AccessToken $ token , AbstractProvider $ provider ) { $ user = $ provider -> getResourceOwner ( $ token ) ; $ passport = Passport :: get ( ) -> filter ( [ 'Identifier' => $ user -> getId ( ) ] ) -> first ( ) ; if ( ! $ passport ) { $ member = $ this -> createMember ( $ token , $ ... | Find or create a member from the given access token |
51,174 | protected function createMember ( AccessToken $ token , AbstractProvider $ provider ) { $ session = $ this -> getSession ( ) ; $ providerName = $ session -> get ( 'oauth2.provider' ) ; $ user = $ provider -> getResourceOwner ( $ token ) ; $ member = Member :: create ( ) ; $ member = $ this -> getMapper ( $ providerName... | Create a member from the given token |
51,175 | public function link ( $ action = null ) { if ( $ action ) { return Controller :: join_links ( $ this -> link , $ action ) ; } return $ this -> link ; } | Return a link to this request handler . The link returned is supplied in the constructor |
51,176 | public function handleProvider ( $ name ) { $ this -> extend ( 'onBeforeHandleProvider' , $ name ) ; $ providers = Config :: inst ( ) -> get ( $ this -> authenticator_class , 'providers' ) ; $ config = $ providers [ $ name ] ; $ scope = isset ( $ config [ 'scopes' ] ) ? $ config [ 'scopes' ] : [ 'email' ] ; $ url = Hel... | Handle a submission for a given provider - build redirection |
51,177 | public function pushDecorator ( Decorator $ decorator ) { $ decorator -> setInnerBus ( $ this -> bus ) ; $ this -> bus = $ decorator ; } | Push a new Decorator on to the stack |
51,178 | public function resolve ( Command $ command ) { $ commandName = get_class ( $ command ) ; foreach ( $ this -> handlers as $ handlerCommand => $ handler ) { if ( $ handlerCommand == $ commandName ) { return $ handler ; } } if ( $ command instanceof CommandHandler ) { return $ command ; } $ class = $ commandName . 'Handl... | Retrieve a CommandHandler for a given Command |
51,179 | public function bindHandler ( $ commandName , $ handler ) { if ( $ handler instanceof CommandHandler ) { $ this -> handlers [ $ commandName ] = $ handler ; return ; } if ( is_callable ( $ handler ) ) { return $ this -> bindHandler ( $ commandName , new CallableCommandHandler ( $ handler ) ) ; } if ( is_string ( $ handl... | Bind a handler to a command . These bindings should overrule the default resolution behaviour for this resolver |
51,180 | public function handle ( Command $ command ) { $ handler = $ this -> container -> make ( $ this -> handlerName ) ; return $ handler -> handle ( $ command ) ; } | Handle a command execution |
51,181 | public function execute ( Command $ command ) { if ( ! $ this -> innerCommandBus ) { throw new Exception ( 'No inner bus defined for this decorator. Set an inner bus with setInnerBus()' ) ; } $ response = $ this -> innerCommandBus -> execute ( $ command ) ; $ eventName = $ this -> getEventName ( $ command ) ; $ this ->... | Execute a command and dispatch and event |
51,182 | private function createCacheItem ( CacheableCommand $ command , $ value ) { return $ this -> cache -> getItem ( $ this -> getCacheKey ( $ command ) ) -> expiresAfter ( $ this -> getCacheExpiry ( $ command ) ) -> set ( $ value ) ; } | Create a new cache item to be persisted . |
51,183 | private function getCacheKey ( CacheableCommand $ command ) { if ( $ command instanceof HasCacheOptions && $ command -> getCacheKey ( ) ) { return $ command -> getCacheKey ( ) ; } return md5 ( serialize ( $ command ) ) ; } | Create the key to be used when saving this item to the cache pool . |
51,184 | private function getCacheExpiry ( CacheableCommand $ command ) { if ( $ command instanceof HasCacheOptions && $ command -> getCacheExpiry ( ) > 0 ) { return $ command -> getCacheExpiry ( ) ; } return $ this -> expiresAfter ; } | Determine when this CachableCommand should expire in terms of seconds from now . |
51,185 | public function addTags ( array $ tags , Taggable $ resource ) { foreach ( $ tags as $ tag ) { if ( $ tag instanceof Tag ) { $ this -> addTag ( $ tag , $ resource ) ; } } } | Adds multiple tags on the given taggable resource |
51,186 | public function replaceTags ( array $ tags , Taggable $ resource ) { $ resource -> getTags ( ) -> clear ( ) ; $ this -> addTags ( $ tags , $ resource ) ; } | Replaces all current tags on the given taggable resource |
51,187 | public function loadOrCreateTags ( array $ names ) { if ( empty ( $ names ) ) { return array ( ) ; } $ names = array_unique ( $ names ) ; $ builder = $ this -> em -> createQueryBuilder ( ) ; $ tags = $ builder -> select ( 't' ) -> from ( $ this -> tagClass , 't' ) -> where ( $ builder -> expr ( ) -> in ( 't.name' , $ n... | Loads or creates multiples tags from a list of tag names |
51,188 | public function saveTagging ( Taggable $ resource ) { $ oldTags = $ this -> getTagging ( $ resource ) ; $ newTags = $ resource -> getTags ( ) ; $ tagsToAdd = $ newTags ; if ( $ oldTags !== null and is_array ( $ oldTags ) and ! empty ( $ oldTags ) ) { $ tagsToRemove = array ( ) ; foreach ( $ oldTags as $ oldTag ) { if (... | Saves tags for the given taggable resource |
51,189 | public function loadTagging ( Taggable $ resource ) { $ tags = $ this -> getTagging ( $ resource ) ; $ this -> replaceTags ( $ tags , $ resource ) ; } | Loads all tags for the given taggable resource |
51,190 | public function deleteTagging ( Taggable $ resource ) { $ taggingList = $ this -> em -> createQueryBuilder ( ) -> select ( 't' ) -> from ( $ this -> taggingClass , 't' ) -> where ( 't.resourceType = :type' ) -> setParameter ( 'type' , $ resource -> getTaggableType ( ) ) -> andWhere ( 't.resourceId = :id' ) -> setParame... | Deletes all tagging records for the given taggable resource |
51,191 | public function splitTagNames ( $ names , $ separator = ',' ) { $ tags = explode ( $ separator , $ names ) ; $ tags = array_map ( 'trim' , $ tags ) ; $ tags = array_filter ( $ tags , function ( $ value ) { return ! empty ( $ value ) ; } ) ; return array_values ( $ tags ) ; } | Splits an string into an array of valid tag names |
51,192 | public function getTagNames ( Taggable $ resource ) { $ names = array ( ) ; if ( sizeof ( $ resource -> getTags ( ) ) > 0 ) { foreach ( $ resource -> getTags ( ) as $ tag ) { $ names [ ] = $ tag -> getName ( ) ; } } return $ names ; } | Returns an array of tag names for the given Taggable resource . |
51,193 | public function get ( $ class , $ connexion , array $ exchangeOptions , array $ queueOptions , $ lazy = false , array $ qosOptions = [ ] ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( "Consumer class '%s' doesn't exist" , $ class ) ) ; } if ( $ lazy ) { if ( ! $ connexion -> is... | build the consumer class . |
51,194 | public function setResource ( Taggable $ resource ) { $ this -> resourceType = $ resource -> getTaggableType ( ) ; $ this -> resourceId = $ resource -> getTaggableId ( ) ; } | Sets the resource |
51,195 | public function purge ( ) { if ( $ this -> eventDispatcher ) { $ purgeEvent = new PurgeEvent ( $ this -> queue ) ; $ this -> eventDispatcher -> dispatch ( PurgeEvent :: NAME , $ purgeEvent ) ; } return $ this -> call ( $ this -> queue , 'purge' ) ; } | Purge the contents of the queue . |
51,196 | public function getCurrentMessageCount ( ) { $ flags = $ this -> queue -> getFlags ( ) ; $ this -> queue -> setFlags ( $ flags | AMQP_PASSIVE ) ; $ messagesCount = $ this -> queue -> declareQueue ( ) ; $ this -> queue -> setFlags ( $ flags ) ; return $ messagesCount ; } | Get the current message count . |
51,197 | public function getTagsWithCountArray ( $ taggableType , $ limit = null ) { $ qb = $ this -> getTagsWithCountArrayQueryBuilder ( $ taggableType ) ; if ( null !== $ limit ) { $ qb -> setMaxResults ( $ limit ) ; } $ tags = $ qb -> getQuery ( ) -> getResult ( AbstractQuery :: HYDRATE_SCALAR ) ; $ arr = array ( ) ; foreach... | For a specific taggable type this returns an array where they key is the tag and the value is the number of times that tag is used |
51,198 | public function getTagsWithCountArrayQueryBuilder ( $ taggableType ) { $ qb = $ this -> getTagsQueryBuilder ( $ taggableType ) -> groupBy ( 'tagging.tag' ) -> select ( 'tag.' . $ this -> tagQueryField . ', COUNT(tagging.tag) as tag_count' ) -> orderBy ( 'tag_count' , 'DESC' ) ; return $ qb ; } | Returns a query builder built to return tag counts for a given type |
51,199 | public function onCommand ( $ event ) { $ this -> data [ 'commands' ] [ ] = array ( 'command' => $ event -> getCommand ( ) , 'arguments' => $ event -> getArguments ( ) , 'executiontime' => $ event -> getExecutionTime ( ) , ) ; } | Listen for command event . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.