idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
17,100 | public function override ( $ key = - 1 , $ options = [ ] ) { if ( $ key >= 0 ) { $ notification = $ this -> notifications -> get ( $ key ) ; } else { $ notification = $ this -> notifications -> last ( ) ; } $ notification -> setOptions ( $ options , false ) ; return $ this -> flash ( ) ; } | Override a notification with a new one instantiates new notification and sets it equal to options |
17,101 | public function bindValue ( $ param , $ value , $ type = null ) { $ ok = false ; try { $ param = $ this -> _getBindVar ( $ param ) ; if ( PDO :: PARAM_LOB == $ type ) { $ lob = \ oci_new_descriptor ( $ this -> _con , \ OCI_D_LOB ) ; $ ok = \ oci_bind_by_name ( $ this -> _stmt , $ param , $ lob , - 1 , \ OCI_B_BLOB ) ; ... | Binds a value |
17,102 | public function bindParam ( $ param , & $ value , $ type = null , $ leng = null , $ driver = null ) { $ ok = false ; try { $ param = $ this -> _getBindVar ( $ param ) ; if ( $ type && $ leng ) { $ ok = \ oci_bind_by_name ( $ this -> _stmt , $ param , $ value , $ leng , $ this -> _pdoToOciType ( $ type ) ) ; } else { $ ... | Binds a param |
17,103 | public function rowCount ( ) { set_error_handler ( array ( $ this -> _pdooci , "errorHandler" ) ) ; $ rows = null ; try { $ rows = \ oci_num_rows ( $ this -> _stmt ) ; } catch ( \ Exception $ e ) { throw new \ PDOException ( $ e -> getMessage ( ) ) ; } restore_error_handler ( ) ; return $ rows ; } | Get the number of affected rows |
17,104 | public function closeCursor ( ) { set_error_handler ( array ( $ this -> _pdooci , "errorHandler" ) ) ; try { \ oci_free_statement ( $ this -> _stmt ) ; } catch ( \ Exception $ e ) { throw new \ PDOException ( $ e -> getMessage ( ) ) ; } restore_error_handler ( ) ; $ this -> _stmt = null ; } | Close the current cursor |
17,105 | public function fetch ( $ style = null , $ orientation = null , $ offset = null ) { set_error_handler ( array ( $ this -> _pdooci , "errorHandler" ) ) ; try { $ style = is_null ( $ style ) ? $ this -> _fetch_sty : $ style ; $ this -> _fetch_sty = $ style ; $ rst = null ; switch ( $ style ) { case \ PDO :: FETCH_BOTH : ... | Fetch a value |
17,106 | public function fetchObject ( $ name = 'stdClass' , $ ctor_args = null ) { try { $ data = $ this -> fetch ( \ PDO :: FETCH_ASSOC ) ; return $ this -> _createObjectFromData ( $ name , $ data ) ; } catch ( \ Exception $ e ) { return null ; } } | Fetch data and create an object |
17,107 | private function _createObjectFromData ( $ name , $ data ) { try { $ cls = new $ name ( ) ; foreach ( $ data as $ key => $ value ) { if ( $ name !== 'stdClass' && ! array_key_exists ( strtolower ( $ key ) , get_object_vars ( $ cls ) ) ) { var_dump ( get_object_vars ( $ cls ) ) ; continue ; } $ key = strtolower ( $ key ... | Create a new object from data |
17,108 | public static function insertMarks ( $ query ) { $ pos = - 1 ; $ regex = '/(?<!\')\?(?!\')/' ; return preg_replace_callback ( $ regex , function ( $ matches ) use ( & $ pos ) { $ pos ++ ; return ":pdooci_m$pos" ; } , $ query ) ; } | Convert a query to use bind marks |
17,109 | private function _checkBinds ( ) { if ( $ this -> _fetch_sty != \ PDO :: FETCH_BOUND ) { return ; } foreach ( $ this -> _binds as $ key => & $ value ) { if ( is_numeric ( $ key ) ) { $ key -- ; } else { $ key = strtoupper ( $ key ) ; } if ( ! array_key_exists ( $ key , $ this -> _current ) ) { continue ; } $ value = $ ... | Check what binds are needed |
17,110 | public function debugDumpParams ( ) { $ str = "SQL: [" . strlen ( $ this -> _statement ) . "] " . $ this -> _statement . "\n" ; $ str .= "Params: " . sizeof ( $ this -> _binds ) . "\n" ; foreach ( $ this -> _binds as $ key => $ value ) { $ str .= "Key: Name: [" . strlen ( $ key ) . "] $key\n" ; $ str .= "name=[" . strl... | Debug dump params |
17,111 | public function getColumnMeta ( $ colnum = 0 ) { if ( ! $ this -> _stmt ) { return null ; } $ name = \ oci_field_name ( $ this -> _stmt , $ colnum + 1 ) ; $ len = \ oci_field_size ( $ this -> _stmt , $ colnum + 1 ) ; $ prec = \ oci_field_scale ( $ this -> _stmt , $ colnum + 1 ) ; $ type = \ oci_field_type ( $ this -> _... | Get column meta data |
17,112 | private function _fixResultKeys ( $ result ) { if ( ! $ this -> _case || $ this -> _case === \ PDO :: CASE_NATURAL ) { return $ result ; } switch ( $ this -> _case ) { case \ PDO :: CASE_LOWER : $ case = CASE_LOWER ; break ; case \ PDO :: CASE_UPPER : $ case = CASE_UPPER ; break ; default : throw new \ PDOException ( '... | Fix the result keys |
17,113 | private function _pdoToOciType ( $ pdotype ) { $ ocitype = SQLT_CHR ; $ pdotype = $ pdotype & ~ PDO :: PARAM_INPUT_OUTPUT ; switch ( $ pdotype ) { case PDO :: PARAM_STR : case PDO :: PARAM_NULL : $ ocitype = SQLT_CHR ; break ; case PDO :: PARAM_INT : $ ocitype = SQLT_INT ; break ; case PDO :: PARAM_BOOL : $ ocitype = S... | Return the correct OCI type |
17,114 | public function getAttribute ( $ attr ) { switch ( $ attr ) { case \ PDO :: ATTR_AUTOCOMMIT : return $ this -> _autocommit ; case \ PDO :: ATTR_DRIVER_NAME : return 'oci' ; case \ PDO :: ATTR_CASE : return $ this -> _case ; } return null ; } | Return an attribute |
17,115 | public function setError ( $ obj = null ) { $ obj = $ obj ? $ obj : $ this -> _con ; if ( ! is_resource ( $ obj ) ) { return ; } $ error = \ oci_error ( $ obj ) ; if ( ! $ error ) { return null ; } $ this -> _last_error = $ error ; } | Sets the last error found |
17,116 | public function errorInfo ( ) { if ( ! $ this -> _last_error ) { return null ; } return array ( $ this -> _last_error [ "code" ] , $ this -> _last_error [ "code" ] , $ this -> _last_error [ "message" ] ) ; } | Returns the last error info |
17,117 | public function errorHandler ( $ errno , $ errstr , $ errfile , $ errline ) { preg_match ( '/(ORA-)(\d+)/' , $ errstr , $ ora_error ) ; if ( $ ora_error ) { $ this -> _last_error = intval ( $ ora_error [ 2 ] ) ; } else { $ this -> setError ( $ this -> _con ) ; } } | Trigger stupid errors who should be exceptions |
17,118 | public function lastInsertId ( $ sequence = null ) { if ( ! $ sequence ) { throw new \ PDOException ( "SQLSTATE[IM001]: Driver does not support this function: driver does not support getting attributes in system_requirements" ) ; } $ id = 0 ; try { $ stmt = $ this -> query ( "select $sequence.currval from dual" ) ; $ d... | Return the last inserted id If the sequence name is not sent throws an exception |
17,119 | protected function getBitrixCommands ( ) { return array_merge ( [ new OnCronCommand ( ) , new ExecuteCommand ( ) , new ClearCommand ( ) , new InitCommand ( ) , new ReIndexCommand ( ) , new ExportCommand ( ) , new ImportCommand ( ) , new ReIndexCommand ( ) , ] , Module \ ModuleCommand :: getCommands ( ) ) ; } | Gets Bitrix console commands from this package . |
17,120 | protected function getModulesCommands ( ) { $ commands = [ ] ; foreach ( ModuleManager :: getInstalledModules ( ) as $ module ) { $ cliFile = getLocalPath ( 'modules/' . $ module [ 'ID' ] . '/cli.php' ) ; if ( $ cliFile === false ) { continue ; } elseif ( ! Loader :: includeModule ( $ module [ 'ID' ] ) ) { continue ; }... | Gets console commands from modules . |
17,121 | public function loadConfiguration ( $ path = self :: CONFIG_DEFAULT_FILE ) { if ( ! is_file ( $ path ) ) { return false ; } $ this -> configuration = include $ path ; if ( ! is_array ( $ this -> configuration ) ) { throw new ConfigurationException ( 'Configuration file ' . $ path . ' must return an array' ) ; } $ files... | Loading application configuration . |
17,122 | public function initializeBitrix ( ) { if ( $ this -> bitrixStatus === static :: BITRIX_STATUS_COMPLETE ) { return static :: BITRIX_STATUS_COMPLETE ; } elseif ( ! $ this -> checkBitrix ( ) ) { return static :: BITRIX_STATUS_UNAVAILABLE ; } define ( 'NO_KEEP_STATISTIC' , true ) ; define ( 'NOT_CHECK_PERMISSIONS' , true ... | Initialize kernel of Bitrix . |
17,123 | protected function hasNecessaryVerifier ( ) { $ query = $ this -> request -> getQueryParams ( ) ; $ hasToken = A :: get ( $ query , 'oauth_token' ) !== null ; $ hasVerifier = A :: get ( $ query , 'oauth_verifier' ) !== null ; return $ hasToken && $ hasVerifier ; } | Determine if the request has the necessary OAuth verifier . |
17,124 | public function get ( string $ uri , array $ params = [ ] , array $ options = [ ] ) : ResponseContract { return $ this -> request ( 'GET' , $ uri , $ params , $ options ) ; } | Create and send an GET HTTP request . |
17,125 | public function post ( string $ uri , array $ params = [ ] , array $ options = [ ] ) : ResponseContract { return $ this -> request ( 'POST' , $ uri , $ params , $ options ) ; } | Create and send an POST HTTP request . |
17,126 | public function put ( string $ uri , array $ params = [ ] , array $ options = [ ] ) : ResponseContract { return $ this -> request ( 'PUT' , $ uri , $ params , $ options ) ; } | Create and send an PUT HTTP request . |
17,127 | public function delete ( string $ uri , array $ params = [ ] , array $ options = [ ] ) : ResponseContract { return $ this -> request ( 'DELETE' , $ uri , $ params , $ options ) ; } | Create and send an DELETE HTTP request . |
17,128 | public function withHeader ( string $ key , string $ value ) : void { $ this -> headers [ $ key ] = $ value ; } | Write header value . |
17,129 | protected function buildOptions ( array $ params = [ ] , array $ options = [ ] ) : array { $ defaultOptions = [ 'form_params' => $ params , 'headers' => $ this -> buildHeaders ( ) , ] ; if ( isset ( $ options [ 'multipart' ] ) ) { unset ( $ defaultOptions [ 'form_params' ] ) ; foreach ( $ params as $ key => $ value ) {... | Build request options . |
17,130 | protected function buildHeaders ( ) : array { $ this -> headers = [ 'User-Agent' => 'Cog-YouTrack-REST-PHP/' . self :: VERSION , 'Accept' => 'application/json' , ] ; $ this -> authorizer -> appendHeadersTo ( $ this ) ; return $ this -> headers ; } | Build request headers . |
17,131 | protected function createEnvironmentsDir ( InputInterface $ input , OutputInterface $ output ) { $ targetDir = getcwd ( ) . '/' . $ this -> envDir ; $ tmplDir = $ this -> tmplDir . '/environments' ; $ output -> writeln ( ' - Environment settings' ) ; if ( file_exists ( $ targetDir ) ) { $ question = new ConfirmationQu... | Creates directory with environments settings . |
17,132 | protected function createConfiguration ( InputInterface $ input , OutputInterface $ output ) { $ path = $ this -> getApplication ( ) -> getRoot ( ) . '/.jedi.php' ; $ output -> writeln ( ' - Configuration' ) ; if ( file_exists ( $ path ) ) { $ question = new ConfirmationQuestion ( ' <error>Configuration file ' . $ ... | Creates configuration file of application . |
17,133 | public static function generate ( $ message = null , \ CMain $ APPLICATION = null ) { if ( null === $ APPLICATION ) { $ APPLICATION = $ GLOBALS [ 'APPLICATION' ] ; } if ( $ ex = $ APPLICATION -> GetException ( ) ) { throw new static ( $ message ? $ message . ': ' . $ ex -> GetString ( ) : $ ex -> GetString ( ) ) ; } el... | Check for legacy bitrix exception throws new self if any |
17,134 | protected function copyFiles ( InputInterface $ input , OutputInterface $ output ) { $ output -> writeln ( '<comment>Copy files from the environment directory</comment>' ) ; $ fs = new Filesystem ( ) ; $ directoryIterator = new \ RecursiveDirectoryIterator ( $ this -> dir , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ;... | Copy files and directories from the environment directory to application . |
17,135 | protected function configureLicenseKey ( InputInterface $ input , OutputInterface $ output , $ licenseKey ) { if ( ! is_string ( $ licenseKey ) ) { throw new \ InvalidArgumentException ( 'Config "licenseKey" must be string type.' ) ; } $ licenseFileContent = "<" . "? $" . "LICENSE_KEY = \"" . EscapePHPString ( $ licens... | Sets license key Bitrix CMS . |
17,136 | protected function configureModules ( InputInterface $ input , OutputInterface $ output , array $ modules ) { $ app = $ this -> getApplication ( ) ; if ( $ app -> getConfiguration ( ) ) { $ app -> addCommands ( ModuleCommand :: getCommands ( ) ) ; if ( $ app -> getBitrixStatus ( ) != \ Notamedia \ ConsoleJedi \ Applica... | Installation modules . |
17,137 | protected function configureSettings ( InputInterface $ input , OutputInterface $ output , array $ settings ) { $ configuration = Configuration :: getInstance ( ) ; foreach ( $ settings as $ name => $ value ) { $ configuration -> setValue ( $ name , $ value ) ; } } | Sets configs to . settings . php . |
17,138 | protected function configureCluster ( InputInterface $ input , OutputInterface $ output , array $ cluster ) { global $ APPLICATION ; if ( ! Loader :: includeModule ( 'cluster' ) ) { throw new \ Exception ( 'Failed to load module "cluster"' ) ; } $ memcache = new \ CClusterMemcache ; if ( isset ( $ cluster [ 'memcache' ... | Installation config to module cluster . |
17,139 | protected function configureOptions ( InputInterface $ input , OutputInterface $ output , array $ options ) { if ( empty ( $ options ) ) { return ; } foreach ( $ options as $ module => $ moduleOptions ) { if ( ! is_array ( $ moduleOptions ) || empty ( $ moduleOptions ) ) { continue ; } foreach ( $ moduleOptions as $ co... | Installation of option modules . |
17,140 | private function appendUserAgent ( array $ options ) : array { $ defaultAgent = 'GuzzleHttp/' . Client :: VERSION ; if ( extension_loaded ( 'curl' ) && function_exists ( 'curl_version' ) ) { $ defaultAgent .= ' curl/' . \ curl_version ( ) [ 'version' ] ; } $ defaultAgent .= ' PHP/' . PHP_VERSION ; if ( ! isset ( $ opti... | Append User - Agent header to Request options . |
17,141 | protected function convertation ( ) { if ( $ this -> executionTime instanceof DateTime ) { $ this -> executionTime = $ this -> executionTime -> toString ( ) ; } elseif ( $ this -> executionTime === null ) { $ time = new DateTime ( ) ; $ this -> executionTime = $ time -> toString ( ) ; } foreach ( [ 'periodically' , 'ac... | Convertation property for creation agent in queue through the old and dirty Bitrix API . |
17,142 | public function create ( $ checkExist = false ) { $ this -> convertation ( ) ; $ model = new \ CAgent ; return $ model -> AddAgent ( AgentHelper :: createName ( $ this -> class , $ this -> constructorArgs , $ this -> callChain ) , $ this -> module , $ this -> periodically , $ this -> interval , null , $ this -> active ... | Create agent in Bitrix queue . |
17,143 | protected function setSessionData ( string $ key , $ val ) { if ( method_exists ( $ this -> getSession ( ) , 'put' ) ) { return $ this -> getSession ( ) -> put ( $ key , $ val ) ; } elseif ( method_exists ( $ this -> getSession ( ) , 'set' ) ) { return $ this -> getSession ( ) -> set ( $ key , $ val ) ; } elseif ( meth... | Set Session data |
17,144 | protected function getSessionData ( string $ key ) { if ( method_exists ( $ this -> getSession ( ) , 'get' ) ) { return $ this -> getSession ( ) -> get ( $ key ) ; } elseif ( method_exists ( $ this -> getSession ( ) , 'read' ) ) { return $ this -> getSession ( ) -> read ( $ key ) ; } return false ; } | Get Session data |
17,145 | public function appendHeadersTo ( ClientContract $ client ) : void { $ this -> authenticator -> authenticate ( $ client ) ; $ client -> withHeader ( 'Cookie' , $ this -> authenticator -> token ( ) ) ; } | Append authorization headers to REST client . |
17,146 | public static function createName ( $ className , array $ args = [ ] , array $ callChain = [ ] ) { $ chain = '' ; if ( ! empty ( $ callChain ) ) { foreach ( $ callChain as $ method => $ methodArgs ) { if ( ! is_array ( $ methodArgs ) ) { throw new ArgumentTypeException ( 'callChain' , 'array' ) ; } $ chain .= '->' . $ ... | Creates and returns agent name by class name and parameters . Use to return this name from the executed method of agent . |
17,147 | public static function agent ( ) { static :: $ constructorArgs = func_get_args ( ) ; static :: $ agentMode = true ; $ reflection = new \ ReflectionClass ( get_called_class ( ) ) ; return $ reflection -> newInstanceArgs ( static :: $ constructorArgs ) ; } | Factory method for create object of agent class . |
17,148 | protected function pingAgent ( $ interval , array $ callChain ) { if ( ! $ this -> isAgentMode ( ) ) { return ; } $ name = $ this -> getAgentName ( $ callChain ) ; $ model = new \ CAgent ( ) ; $ rsAgent = $ model -> GetList ( [ ] , [ 'NAME' => $ name ] ) ; if ( $ agent = $ rsAgent -> Fetch ( ) ) { $ dateCheck = DateTim... | Ping from the agent to inform that it still works correctly . Use this method if your agent works more 10 minutes otherwise Bitrix will be consider your agent as non - working . |
17,149 | public function register ( ) { if ( ! $ this -> isRegistered ( ) ) { $ moduleObject = & $ this -> getObject ( ) ; if ( ( new \ ReflectionClass ( $ moduleObject ) ) -> getMethod ( 'InstallDB' ) -> class !== get_class ( $ moduleObject ) ) { throw new Exception \ ModuleInstallException ( 'Missing InstallDB method. This mo... | Install module . |
17,150 | public function load ( ) { if ( ! $ this -> isRegistered ( ) ) { if ( ! $ this -> exist ( ) ) { require_once ( $ _SERVER [ "DOCUMENT_ROOT" ] . '/bitrix/modules/main/classes/general/update_client_partner.php' ) ; if ( ! \ CUpdateClientPartner :: LoadModuleNoDemand ( $ this -> getName ( ) , $ strError , $ this -> isBeta ... | Download module from Marketplace . |
17,151 | public function unRegister ( ) { $ moduleObject = $ this -> getObject ( ) ; if ( $ this -> isRegistered ( ) ) { if ( ( new \ ReflectionClass ( $ moduleObject ) ) -> getMethod ( 'UnInstallDB' ) -> class !== get_class ( $ moduleObject ) ) { throw new Exception \ ModuleUninstallException ( 'Missing UnInstallDB method. Thi... | Uninstall module . |
17,152 | public function remove ( ) { if ( $ this -> isRegistered ( ) ) { $ this -> unRegister ( ) ; } $ path = getLocalPath ( 'modules/' . $ this -> getName ( ) ) ; if ( $ path ) { ( new Filesystem ( ) ) -> remove ( $ _SERVER [ 'DOCUMENT_ROOT' ] . $ path ) ; } unset ( $ this -> object ) ; return $ this ; } | Uninstall and remove module directory . |
17,153 | public function update ( & $ modulesUpdated = null ) { require_once ( $ _SERVER [ "DOCUMENT_ROOT" ] . '/bitrix/modules/main/classes/general/update_client_partner.php' ) ; if ( ! $ this -> isThirdParty ( ) ) { throw new Exception \ ModuleUpdateException ( 'Kernel module updates are currently not supported.' , $ this -> ... | Update module . |
17,154 | protected function validateUpdate ( $ updateDir ) { $ errorMessage = null ; if ( ! \ CUpdateClientPartner :: CheckUpdatability ( $ updateDir , $ errorMessage ) ) { throw new Exception \ ModuleUpdateException ( '[CL03] CheckUpdatability failed. ' . $ errorMessage , $ this -> getName ( ) ) ; } if ( isset ( $ updateDescri... | Check update files . |
17,155 | public function userFromToken ( string $ token ) { $ user = $ this -> mapUserToObject ( $ this -> getUserByToken ( $ token ) ) ; return $ user -> setToken ( $ token ) ; } | Get a Social User instance from a known access token . |
17,156 | public function authenticate ( ClientContract $ client ) : void { if ( $ this -> cookie !== '' || $ this -> isAuthenticating ) { return ; } $ this -> isAuthenticating = true ; $ response = $ client -> request ( 'POST' , '/user/login' , [ 'login' => $ this -> username , 'password' => $ this -> password , ] ) ; $ this ->... | Authenticate client and returns cookie on success login . |
17,157 | protected function restartScript ( InputInterface $ input , OutputInterface $ output ) { $ proc = popen ( 'php -f ' . join ( ' ' , $ GLOBALS [ 'argv' ] ) . ' 2>&1' , 'r' ) ; while ( ! feof ( $ proc ) ) { $ output -> write ( fread ( $ proc , 4096 ) ) ; } return pclose ( $ proc ) ; } | Executes another copy of console process to continue updates |
17,158 | public static function isDnsError ( string $ domain ) : bool { if ( \ function_exists ( 'checkdnsrr' ) ) { $ mxFound = \ checkdnsrr ( $ domain . '.' , 'MX' ) ; if ( $ mxFound === true ) { return false ; } $ aFound = \ checkdnsrr ( $ domain . '.' , 'A' ) ; if ( $ aFound === true ) { return false ; } return true ; } thro... | Check if the domain has a MX - or A - record in the DNS . |
17,159 | public static function isExampleDomain ( string $ domain ) : bool { if ( self :: $ domainsExample === null ) { self :: $ domainsExample = self :: getData ( 'domainsExample' ) ; } if ( \ in_array ( $ domain , self :: $ domainsExample , true ) ) { return true ; } return false ; } | Check if the domain is a example domain . |
17,160 | public static function isTemporaryDomain ( string $ domain ) : bool { if ( self :: $ domainsTemporary === null ) { self :: $ domainsTemporary = self :: getData ( 'domainsTemporary' ) ; } if ( \ in_array ( $ domain , self :: $ domainsTemporary , true ) ) { return true ; } if ( \ preg_match ( '/.*\.(?:tk|ml|ga|cf|gq)$/si... | Check if the domain is a temporary domain . |
17,161 | public static function isTypoInDomain ( string $ domain ) : bool { if ( self :: $ domainsTypo === null ) { self :: $ domainsTypo = self :: getData ( 'domainsTypo' ) ; } if ( \ in_array ( $ domain , self :: $ domainsTypo , true ) ) { return true ; } return false ; } | Check if the domain has a typo . |
17,162 | public static function isValid ( string $ email , bool $ useExampleDomainCheck = false , bool $ useTypoInDomainCheck = false , bool $ useTemporaryDomainCheck = false , bool $ useDnsCheck = false ) : bool { if ( ! isset ( $ email [ 0 ] ) ) { return false ; } $ emailStringLength = \ strlen ( $ email ) ; if ( $ emailStrin... | Check if the email is valid . |
17,163 | public function printSuccessMessage ( $ joinString , $ force = true ) : void { if ( $ this -> isPrintable ( $ force ) ) { $ this -> printMessage ( implode ( ': ' , [ 'Success' , $ joinString ] ) , 'info' ) ; } } | Print error message |
17,164 | public function printMessage ( $ string , $ type = 'comment' , $ force = true ) : void { if ( $ this -> isPrintable ( $ force ) ) { echo $ this -> getMessageWithColor ( $ string , $ this -> getMessageBackgroundColor ( $ type ) ) ; echo "\n" ; } } | Pretty print information messages to console |
17,165 | public function saveImage ( $ imagePath , $ saveDirPath , $ separator = '-' ) : string { if ( strpos ( $ image = str_replace ( ' ' , '%20' , $ imagePath ) , DIRECTORY_SEPARATOR ) !== false ) { $ filename = str_replace ( '%20' , $ separator , pathinfo ( $ image , PATHINFO_BASENAME ) ) ; if ( ! empty ( $ filename ) ) { $... | Save image to specified path and return the full path with image name and extension |
17,166 | public function getFlights ( $ onlyFirstAgentPerItinerary = true ) : array { if ( $ this -> init ( ) ) { $ this -> flights = [ ] ; $ this -> addItineraries ( $ onlyFirstAgentPerItinerary ) ; $ this -> beautifyFlights ( $ onlyFirstAgentPerItinerary ) ; } else { $ this -> printErrorMessage ( $ this -> getResponseMessage ... | Get modified data where the each agent and carrier is assigned to each itinerary If you only want to get get the first one it will remove Agents property Whereas Agent property will hold the first agent within the array sorted with given sorttype property |
17,167 | private function beautifyFlights ( $ onlyFirstAgentPerItinerary ) : void { [ $ agents , $ carriers , $ legs ] = $ this -> getMeta ( ) ; foreach ( $ this -> flights as & $ flight ) { foreach ( $ flight [ 'Agents' ] as $ key => & $ flightAgent ) { $ agent = $ agents [ $ this -> arraySearch ( $ flightAgent -> Agents [ 0 ]... | Assign flight specific agents carriers and legs to the each |
17,168 | public function get ( ) { $ data = $ this -> request ( implode ( '/' , [ $ this -> url , 'geo' , 'v1.0' ] ) ) ; if ( empty ( $ data ) ) { throw new RestrictedMethodException ( implode ( ' ' , [ 'You don\'t have the permission to call this method.' , 'For more information, contact with Skyscanner here: https://partners.... | Get the full list of all the places that SkyScanner supports . You need to contact and grant permission from SkyScanner to use this method |
17,169 | public function getList ( $ country , $ currency , $ locale , $ query ) { $ url = implode ( '/' , [ $ this -> url , 'autosuggest' , 'v1.0' , $ country , $ currency , $ locale ] ) ; $ data = $ this -> request ( $ url , compact ( 'query' ) ) ; return $ data -> Places ?? [ ] ; } | Get a list of places that match a query string . |
17,170 | public function getInformation ( $ market , $ currency , $ locale , $ id ) { $ url = implode ( '/' , [ $ this -> url , 'autosuggest' , 'v1.0' , $ market , $ currency , $ locale ] ) ; $ data = $ this -> request ( $ url , compact ( 'id' ) ) ; return $ data -> Places ?? [ ] ; } | Get information about a country city or airport using its ID . |
17,171 | public function get ( $ property = null , $ reset = false ) { if ( empty ( $ this -> data ) || $ reset === true ) { $ this -> makeRequest ( $ this -> getUrl ( ) , 'GET' ) ; $ this -> data = $ this -> getResponseBody ( ) ; } if ( $ property !== null ) { return $ this -> data -> { $ property } ?? [ ] ; } return $ this ->... | Just return data property without doing any modifications to the original one |
17,172 | public function getResponseHeader ( $ key , $ first = true ) : string { $ header = $ this -> response -> getHeader ( $ key ) ; $ headerFirst = $ header [ 0 ] ?? '' ; return $ first ? $ headerFirst : $ header ; } | Returns specific response header defined by key |
17,173 | protected function getSessionId ( $ url , $ method = 'POST' ) { if ( $ this -> makeRequest ( $ url , $ method ) === false ) { $ this -> printErrorMessage ( 'Could not fetch a valid session id.' ) ; return false ; } $ location = $ this -> getResponseHeader ( 'Location' ) ; $ locationParameters = explode ( '/' , $ locati... | If you make too many requests then you will probably have issues on rate limiting . So until a non - empty location is received it will make a request to get a session key . |
17,174 | public function getUri ( ) : string { foreach ( $ this -> getParameterArray ( ) as $ parameter ) { if ( property_exists ( $ this , $ parameter ) ) { if ( isset ( $ this -> $ parameter ) ) { $ this -> uri = str_replace ( '{' . $ parameter . '}' , $ this -> $ parameter , $ this -> uri ) ; } else { $ this -> uri = str_rep... | Create direct query link via replacing uri |
17,175 | public function getParameters ( array $ parameters = [ ] ) : array { foreach ( array_merge ( $ parameters , $ this -> getParameterArray ( ) ) as $ parameter ) { if ( isset ( $ this -> $ parameter ) ) { $ parameters [ $ parameter ] = $ this -> $ parameter ; } } foreach ( $ this -> extraParameters as $ parameter => $ fun... | Get parameter array to create query string from parameters |
17,176 | protected function arraySearch ( $ needle , $ haystack , $ property ) { return array_search ( $ needle , array_map ( function ( $ value ) use ( $ property ) { return \ is_object ( $ value ) ? $ value -> $ property : $ value [ $ property ] ; } , $ haystack ) , true ) ; } | Helper method for array search to locate the property with the given property |
17,177 | protected function addDates ( array $ dates = [ ] ) { foreach ( [ 'OutboundDates' , 'InboundDates' ] as $ date ) { if ( ! empty ( $ this -> data -> Dates -> $ date ) ) { foreach ( $ this -> data -> Dates -> $ date as $ key => $ datum ) { $ dates [ $ key ] = $ this -> syncQuotes ( $ datum , [ ] , 'QuoteIds' ) ; } } } re... | Get the cheapest price from one place to another for each day of a given month Get the cheapest price from one place to another for each month within the next year |
17,178 | public function setClient ( ) { if ( empty ( $ this -> apiKey ) ) { throw new InvalidArgumentException ( 'Api key can not be empty' ) ; } $ this -> client = new Client ( $ this -> apiKey ) ; } | Instantiate QuickEmailVerification Client with api Key |
17,179 | public function verify ( $ emailAddress ) { $ this -> response = $ this -> client -> quickemailverification ( ) -> verify ( $ emailAddress ) ; return $ this ; } | Verifies email Address and returns an API Object response |
17,180 | static public function show ( $ raw_sql , $ parameters ) { $ keys = array ( ) ; $ values = array ( ) ; $ isNamedMarkers = false ; if ( count ( $ parameters ) && is_string ( key ( $ parameters ) ) ) { uksort ( $ parameters , function ( $ k1 , $ k2 ) { return strlen ( $ k2 ) - strlen ( $ k1 ) ; } ) ; $ isNamedMarkers = t... | Returns the emulated SQL string |
17,181 | public function bulkSerialise ( $ model ) { $ class = get_class ( $ model ) ; if ( ! $ model instanceof Model ) { throw new InvalidOperationException ( $ class ) ; } if ( ! isset ( self :: $ metadataCache [ $ class ] ) ) { self :: $ metadataCache [ $ class ] = $ model -> metadata ( ) ; } $ meta = self :: $ metadataCach... | Serialise needed bits of supplied model taking fast path where possible . |
17,182 | protected function registerManager ( ) { $ this -> app -> singleton ( Manager :: class , function ( ) { $ manager = new Manager ( $ this -> driver ( ) ) ; if ( $ manager -> getDriver ( ) instanceof ArrayDriver ) { $ callback = config ( 'lock.permissions' ) ; if ( $ callback !== null ) { call_user_func ( $ callback , $ ... | This method will register the lock manager instance |
17,183 | protected function registerAuthenticatedUserLock ( ) { $ this -> app -> singleton ( Lock :: class , function ( $ app ) { return new UserLock ( $ app [ Manager :: class ] , $ app [ 'auth.driver' ] , config ( 'lock.user_caller_type' ) ) ; } ) ; } | This will register the lock instance for the authenticated user |
17,184 | public function setResourceType ( ResourceType $ resourceType ) { $ this -> iteratorName = '$' . $ resourceType -> getName ( ) ; $ this -> resourceType = $ resourceType ; } | call - back for setting the resource type . |
17,185 | public function onLogicalExpression ( $ expressionType , $ left , $ right ) { $ type = $ this -> unpackExpressionType ( $ expressionType ) ; switch ( $ type ) { case ExpressionType :: AND_LOGICAL : return $ this -> prepareBinaryExpression ( self :: LOGICAL_AND , $ left , $ right ) ; case ExpressionType :: OR_LOGICAL : ... | Call - back for logical expression . |
17,186 | public function onArithmeticExpression ( $ expressionType , $ left , $ right ) { $ type = $ this -> unpackExpressionType ( $ expressionType ) ; switch ( $ type ) { case ExpressionType :: MULTIPLY : return $ this -> prepareBinaryExpression ( self :: MULTIPLY , $ left , $ right ) ; case ExpressionType :: DIVIDE : return ... | Call - back for arithmetic expression . |
17,187 | public function onRelationalExpression ( $ expressionType , $ left , $ right ) { $ type = $ this -> unpackExpressionType ( $ expressionType ) ; switch ( $ type ) { case ExpressionType :: GREATERTHAN : return $ this -> prepareBinaryExpression ( self :: GREATER_THAN , $ left , $ right ) ; case ExpressionType :: GREATERTH... | Call - back for relational expression . |
17,188 | public function onUnaryExpression ( $ expressionType , $ child ) { $ type = $ this -> unpackExpressionType ( $ expressionType ) ; switch ( $ type ) { case ExpressionType :: NEGATE : return $ this -> prepareUnaryExpression ( self :: NEGATE , $ child ) ; case ExpressionType :: NOT_LOGICAL : return $ this -> prepareUnaryE... | Call - back for unary expression . |
17,189 | public function onConstantExpression ( IType $ type , $ value ) { if ( is_bool ( $ value ) ) { return var_export ( $ value , true ) ; } elseif ( null === $ value ) { return var_export ( null , true ) ; } return $ value ; } | Call - back for constant expression . |
17,190 | public function onPropertyAccessExpression ( $ expression ) { $ parent = $ expression ; $ variable = null ; do { $ variable = $ parent -> getResourceProperty ( ) -> getName ( ) . self :: MEMBER_ACCESS . $ variable ; $ parent = $ parent -> getParent ( ) ; } while ( $ parent != null ) ; $ variable = rtrim ( $ variable , ... | Call - back for property access expression . |
17,191 | public function onFunctionCallExpression ( $ functionDescription , $ params ) { if ( ! isset ( $ functionDescription ) ) { throw new \ InvalidArgumentException ( 'onFunctionCallExpression' ) ; } if ( ! array_key_exists ( $ functionDescription -> name , $ this -> functionDescriptionParsers ) ) { throw new \ InvalidArgum... | Call - back for function call expression . |
17,192 | private function prepareBinaryExpression ( $ operator , $ left , $ right ) { return self :: OPEN_BRACKET . $ left . ' ' . $ operator . ' ' . $ right . self :: CLOSE_BRACKET ; } | To format binary expression . |
17,193 | public function unhookSingleModel ( ResourceSet $ sourceResourceSet , $ sourceEntityInstance , ResourceSet $ targetResourceSet , $ targetEntityInstance , $ navPropName ) { $ relation = $ this -> isModelHookInputsOk ( $ sourceEntityInstance , $ targetEntityInstance , $ navPropName ) ; unset ( $ targetEntityInstance -> P... | Removes child model from parent model . |
17,194 | public function metadataMask ( ) { $ attribs = array_keys ( $ this -> getAllAttributes ( ) ) ; $ visible = $ this -> getVisible ( ) ; $ hidden = $ this -> getHidden ( ) ; if ( 0 < count ( $ visible ) ) { $ attribs = array_intersect ( $ visible , $ attribs ) ; } elseif ( 0 < count ( $ hidden ) ) { $ attribs = array_diff... | Return the set of fields that are permitted to be in metadata - following same visible - trumps - hidden guideline as Laravel . |
17,195 | public function getRelationships ( ) { if ( empty ( static :: $ relationHooks ) ) { $ hooks = [ ] ; $ rels = $ this -> getRelationshipsFromMethods ( true ) ; $ this -> getRelationshipsUnknownPolyMorph ( $ rels , $ hooks ) ; $ this -> getRelationshipsKnownPolyMorph ( $ rels , $ hooks ) ; $ this -> getRelationshipsHasOne... | Get model s relationships . |
17,196 | protected function collectGetters ( ) { $ getterz = [ ] ; $ methods = get_class_methods ( $ this ) ; foreach ( $ methods as $ method ) { if ( 12 < strlen ( $ method ) && 'get' == substr ( $ method , 0 , 3 ) ) { if ( 'Attribute' == substr ( $ method , - 9 ) ) { $ getterz [ ] = $ method ; } } } $ methods = [ ] ; foreach ... | Dig up all defined getters on the model . |
17,197 | protected function getTableColumns ( ) { if ( 0 === count ( self :: $ tableColumns ) ) { $ table = $ this -> getTable ( ) ; $ connect = $ this -> getConnection ( ) ; $ builder = $ connect -> getSchemaBuilder ( ) ; $ columns = $ builder -> getColumnListing ( $ table ) ; self :: $ tableColumns = ( array ) $ columns ; } r... | Get columns for selected table . |
17,198 | protected function getTableDoctrineColumns ( ) { if ( 0 === count ( self :: $ tableColumnsDoctrine ) ) { $ table = $ this -> getTable ( ) ; $ connect = $ this -> getConnection ( ) ; $ columns = $ connect -> getDoctrineSchemaManager ( ) -> listTableColumns ( $ table ) ; self :: $ tableColumnsDoctrine = $ columns ; } ret... | Get Doctrine columns for selected table . |
17,199 | public function register ( ) { $ this -> app -> singleton ( 'metadata' , function ( $ app ) { return new SimpleMetadataProvider ( 'Data' , self :: $ metaNAMESPACE ) ; } ) ; $ this -> app -> singleton ( 'objectmap' , function ( $ app ) { return new Map ( ) ; } ) ; } | Register the application services . Boot - time only . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.