idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
34,400 | public function registerDynamicType ( $ typeName ) { if ( isset ( $ this -> bindings [ $ typeName ] ) ) { throw new \ InvalidArgumentException ( "`$typeName` is already registerd." ) ; } $ type = new \ ReflectionClass ( $ typeName ) ; $ this -> bindings [ $ typeName ] = new DynamicService ( $ type ) ; return $ this ; } | Registers the type to use dynamic binding . |
34,401 | public function registerNamedType ( $ typeName ) { if ( isset ( $ this -> namedTypes [ $ typeName ] ) ) { throw new \ InvalidArgumentException ( "`$typeName` is already registerd." ) ; } $ type = new \ ReflectionClass ( $ typeName ) ; $ this -> namedTypes [ $ typeName ] = $ type ; return $ this ; } | Registers the type to use name - based binding . |
34,402 | public function registerNamedValue ( $ valueName ) { if ( isset ( $ this -> namedValues [ $ valueName ] ) ) { throw new \ InvalidArgumentException ( "`$valueName` is already registerd." ) ; } $ this -> namedValues [ $ valueName ] = true ; return $ this ; } | Registers the value name to use name - based binding . |
34,403 | public function onMode ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; $ params = $ msg [ 'params' ] ; $ isValidMessage = isset ( $ params [ 'channel' ] , $ params [ 'params' ] ) && preg_match ( '/(?:\+|-)[hovaq+-]+/i' , $ params [ 'mode' ] ) ; if ( ! $ isValidMessage ) { return ; } $ chan = $ params [ 'channel' ] ; $ nicks = explode ( ' ' , $ params [ 'params' ] ) ; $ modes = str_split ( $ params [ 'mode' ] , 1 ) ; $ operation = array_shift ( $ modes ) ; while ( $ char = array_shift ( $ modes ) ) { $ nick = array_shift ( $ nicks ) ; $ mode = self :: $ modesNum [ $ char ] ; $ userMode = $ this -> storage -> getUserMode ( $ nick , $ chan ) ; if ( ! $ userMode ) { $ userMode = self :: REGULAR ; } switch ( $ operation ) { case '+' : $ userMode |= $ mode ; break ; case '-' : $ userMode ^= $ mode ; break ; } $ this -> storage -> setUserMode ( $ nick , $ chan , $ userMode ) ; } } | Tracks user mode changes |
34,404 | public function onJoin ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; if ( ! isset ( $ msg [ 'nick' ] ) ) { return ; } $ chan = $ msg [ 'params' ] [ 'channels' ] ; $ nick = $ msg [ 'nick' ] ; $ this -> storage -> setUserMode ( $ nick , $ chan , self :: REGULAR ) ; } | Tracks users joining a channel |
34,405 | public function onPart ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; if ( ! isset ( $ msg [ 'nick' ] ) ) { return ; } $ nick = $ msg [ 'nick' ] ; $ chan = $ msg [ 'params' ] [ 'channels' ] ; $ this -> storage -> removeUser ( $ nick , $ chan ) ; } | Tracks users leaving a channel |
34,406 | public function onQuit ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; if ( ! isset ( $ msg [ 'nick' ] ) ) { return ; } $ nick = $ msg [ 'nick' ] ; $ this -> storage -> removeUser ( $ nick ) ; } | Tracks users quitting a server |
34,407 | public function onNick ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; $ oldNick = $ msg [ 'nick' ] ; $ newNick = $ msg [ 'params' ] [ 'nickname' ] ; $ this -> storage -> updateNickname ( $ oldNick , $ newNick ) ; } | Tracks users changing nicks |
34,408 | public function onNameReply ( Event $ event ) { $ msg = $ event -> getMessage ( ) ; $ chan = $ msg [ 'params' ] [ 2 ] ; $ names = explode ( ' ' , $ msg [ 'params' ] [ 3 ] ) ; foreach ( $ names as $ nick ) { $ mode = self :: REGULAR ; $ prefix = $ nick [ 0 ] ; if ( isset ( self :: $ modesPrefix [ $ prefix ] ) ) { $ mode |= self :: $ modesNum [ self :: $ modesPrefix [ $ prefix ] ] ; $ nick = substr ( $ nick , 1 ) ; } $ this -> storage -> setUserMode ( $ nick , $ chan , $ mode ) ; } } | Populates the internal user listing for a channel when the bot joins it . |
34,409 | public function is ( $ mode , $ nick , $ chan ) { $ userMode = $ this -> storage -> getUserMode ( $ nick , $ chan ) ; if ( $ userMode ) { return ( $ userMode & $ mode ) != 0 ; } else { return false ; } } | Checks whether or not a given user has a mode |
34,410 | protected function getBaseUrl ( $ withAuthentication = false ) { $ config = $ this -> getConfig ( ) ; $ baseUrl = $ config [ 'scheme' ] . '://' . rtrim ( $ config [ 'host' ] , '/' ) . '/' ; if ( isset ( $ config [ 'path' ] ) ) { $ baseUrl .= trim ( $ config [ 'path' ] , '/' ) . '/' ; } if ( $ withAuthentication === true && $ this -> getConnector ( ) -> getListener ( ) instanceof \ Buzz \ Listener \ BasicAuthListener ) { $ baseUrl .= 'a/' ; } return $ baseUrl ; } | Gets the base url for all HTTP requests . |
34,411 | protected function verifyResult ( \ Buzz \ Message \ Response $ response , $ url ) { if ( $ response -> getStatusCode ( ) !== 200 ) { throw new \ Exception ( 'Request to "' . $ url . '" failed' , 1364061673 ) ; } return $ response ; } | Verifies the last request . If the last request was not successful it will be throw an exception . |
34,412 | public function transformJsonResponse ( $ json ) { if ( substr ( $ json , 0 , 4 ) === ')]}\'' ) { $ json = substr ( $ json , 5 ) ; } return json_decode ( $ json , true ) ; } | Transforms a JSON string into an array . Regular the json is the content from the response . |
34,413 | protected function initQueryLimit ( ) { $ url = $ this -> getBaseUrl ( true ) . 'accounts/self/capabilities?format=JSON' ; $ response = $ this -> getConnector ( ) -> get ( $ url ) ; $ response = $ this -> verifyResult ( $ response , $ url ) ; $ content = $ this -> transformJsonResponse ( $ response -> getContent ( ) ) ; return $ content [ 'queryLimit' ] [ 'max' ] ; } | Initiales the query limit |
34,414 | public function add ( Container $ container , $ startOnCreate = true ) { $ this -> client -> post ( $ this -> getUri ( ) , $ container , array ( 'startOnCreate' => $ startOnCreate ) ) ; return $ this -> reload ( ) ; } | Add a new container . |
34,415 | public function findAllTemplates ( ) { if ( null !== $ this -> templates ) { return $ this -> templates ; } $ templates = array ( ) ; foreach ( $ this -> paths as $ dir ) { $ templates = array_merge ( $ templates , $ this -> findTemplatesInFolder ( $ dir ) ) ; } return $ this -> templates = $ templates ; } | Find all the templates in the bundle and in the kernel Resources folder . |
34,416 | public function update ( $ NodeID , $ Label = null , $ Address = null , $ Weight = null , $ Mode = null ) { return $ this -> call ( 'nodebalancer.node.update' , [ 'NodeID' => $ NodeID , 'Label' => $ Label , 'Address' => $ Address , 'Weight' => $ Weight , 'Mode' => $ Mode , ] ) ; } | Updates a Node s properties . |
34,417 | public function onBefore ( BeforeEvent $ event , $ name ) { $ request = $ event -> getRequest ( ) ; if ( $ request -> getMethod ( ) == 'GET' && $ this -> lifetime ) { $ response_key = $ this -> getCacheResponseKey ( $ request -> getUrl ( ) ) ; $ body_key = $ this -> getCacheBodyKey ( $ request -> getUrl ( ) ) ; if ( $ this -> cache -> has ( $ response_key ) && $ this -> cache -> has ( $ body_key ) ) { $ response = $ this -> cache -> get ( $ response_key ) ; $ body = $ this -> cache -> get ( $ body_key ) ; $ response -> setBody ( Stream :: factory ( $ body ) ) ; $ event -> intercept ( $ response ) ; } } } | Intercept any request if cached |
34,418 | public function onComplete ( CompleteEvent $ event , $ name ) { $ request = $ event -> getRequest ( ) ; $ response = $ event -> getResponse ( ) ; if ( $ request -> getMethod ( ) == 'GET' && $ response -> getStatusCode ( ) == 200 && $ this -> lifetime ) { $ response_key = $ this -> getCacheResponseKey ( $ request -> getUrl ( ) ) ; $ body_key = $ this -> getCacheBodyKey ( $ request -> getUrl ( ) ) ; if ( ! $ this -> cache -> has ( $ response_key ) || ! $ this -> cache -> has ( $ body_key ) ) { $ body = ( string ) $ response -> getBody ( ) ; $ this -> cache -> put ( $ response_key , $ response , $ this -> lifetime ) ; $ this -> cache -> put ( $ body_key , $ body , $ this -> lifetime ) ; } } } | Store completed request in the cache |
34,419 | public function client ( array $ config = array ( ) , $ lifetime = null ) { if ( is_null ( $ lifetime ) ) { $ lifetime = $ this -> lifetime ; } $ client = new Client ( $ config ) ; $ emitter = $ client -> getEmitter ( ) ; $ subscriber = new CacheSubscriber ( $ this -> cache , $ lifetime , $ this -> cachePrefix ) ; $ emitter -> attach ( $ subscriber ) ; return $ client ; } | Get the cached guzzle client |
34,420 | public function getTypeValue ( ) { return function ( $ row ) { $ name = is_null ( $ row -> component_name ) ? 'core' : $ row -> component_name ; return '<span class="label-circle" data-color="' . component_color ( $ name ) . '" >' . ucfirst ( Str :: humanize ( $ name ) ) . '</span>' ; } ; } | Gets type value |
34,421 | public function translate ( Proxy $ proxy ) { $ this -> proxy = $ proxy ; $ laravelPhpbu = $ this -> proxy -> get ( 'phpbu' ) ; $ configuration = new Configuration ( ) ; $ configuration -> setFilename ( $ this -> proxy -> get ( 'phpbu.config' ) ) ; $ this -> addBackups ( $ configuration , $ laravelPhpbu ) ; return $ configuration ; } | Translates the laravel configuration to a phpbu configuration . |
34,422 | protected function addBackups ( Configuration $ configuration , array $ laravelPhpbu ) { foreach ( array_keys ( $ this -> types ) as $ type ) { foreach ( $ laravelPhpbu [ $ type ] as $ conf ) { $ configuration -> addBackup ( $ this -> translateBackup ( $ type , $ conf ) ) ; } } } | Translate and add all configured backups . |
34,423 | public function translateBackup ( $ type , array $ conf ) { $ backup = $ this -> { $ this -> types [ $ type ] } ( $ conf ) ; $ backup -> setTarget ( $ this -> translateTarget ( $ conf [ 'target' ] ) ) ; $ this -> addChecksIfConfigured ( $ backup , $ conf ) ; $ this -> addSyncIfConfigured ( $ backup , $ conf ) ; $ this -> addCleanupIfConfigured ( $ backup , $ conf ) ; $ this -> addCryptIfConfigured ( $ backup , $ conf ) ; return $ backup ; } | Translates a given laravel config type to a phpbu backup configuration . |
34,424 | protected function directoryConfigToBackup ( array $ dir ) { $ backup = new Configuration \ Backup ( $ dir [ 'source' ] [ 'path' ] , false ) ; $ options = [ 'path' => $ dir [ 'source' ] [ 'path' ] , ] ; if ( isset ( $ dir [ 'source' ] [ 'options' ] ) ) { $ options = array_merge ( $ options , $ dir [ 'source' ] [ 'options' ] ) ; } $ backup -> setSource ( new Configuration \ Backup \ Source ( 'tar' , $ options ) ) ; return $ backup ; } | Translate a laravel directory config to phpbu backup configuration . |
34,425 | protected function databaseConfigToBackup ( array $ db ) { $ connection = $ this -> getDatabaseConnectionConfig ( $ db [ 'source' ] [ 'connection' ] ) ; $ options = [ 'host' => $ connection [ 'host' ] , 'user' => $ connection [ 'username' ] , 'password' => $ connection [ 'password' ] , 'databases' => $ connection [ 'database' ] , ] ; if ( isset ( $ db [ 'source' ] [ 'options' ] ) ) { $ options = array_merge ( $ options , $ db [ 'source' ] [ 'options' ] ) ; } $ backup = new Configuration \ Backup ( 'db-' . $ db [ 'source' ] [ 'connection' ] , false ) ; $ type = $ this -> getDatabaseSourceType ( $ connection [ 'driver' ] ) ; $ backup -> setSource ( new Configuration \ Backup \ Source ( $ type , $ options ) ) ; return $ backup ; } | Translate a laravel db config to phpbu backup configuration . |
34,426 | protected function getDatabaseConnectionConfig ( $ connection ) { $ connections = $ this -> proxy -> get ( 'database.connections' ) ; if ( ! isset ( $ connections [ $ connection ] ) ) { throw new Exception ( 'Unknown database connection: ' . $ connection ) ; } $ config = $ connections [ $ connection ] ; if ( ! in_array ( $ config [ 'driver' ] , [ 'mysql' , 'pgsql' ] ) ) { throw new Exception ( 'Currently only MySQL and PostgreSQL databases are supported using the laravel config' ) ; } return $ config ; } | Get a database connection configuration . |
34,427 | protected function translateTarget ( array $ config ) { if ( empty ( $ config [ 'dirname' ] ) ) { throw new Exception ( 'invalid target: dirname has to be configured' ) ; } if ( empty ( $ config [ 'filename' ] ) ) { throw new Exception ( 'invalid target: filename has to be configured' ) ; } $ dirname = $ config [ 'dirname' ] ; $ filename = $ config [ 'filename' ] ; $ compression = ! empty ( $ config [ 'compression' ] ) ? $ config [ 'compression' ] : null ; return new Target ( $ dirname , $ filename , $ compression ) ; } | Translate the target configuration . |
34,428 | protected function addChecksIfConfigured ( Configuration \ Backup $ backup , array $ conf ) { if ( isset ( $ conf [ 'check' ] ) ) { $ backup -> addCheck ( new Configuration \ Backup \ Check ( $ conf [ 'check' ] [ 'type' ] , $ conf [ 'check' ] [ 'value' ] ) ) ; } } | Adds a check configuration to the given backup configuration . |
34,429 | protected function addSyncIfConfigured ( Configuration \ Backup $ backup , array $ conf ) { if ( isset ( $ conf [ 'sync' ] ) ) { $ backup -> addSync ( new Configuration \ Backup \ Sync ( 'laravel-storage' , false , [ 'filesystem' => $ conf [ 'sync' ] [ 'filesystem' ] , 'path' => $ conf [ 'sync' ] [ 'path' ] ] ) ) ; } } | Adds a sync configuration to the given backup configuration . |
34,430 | protected function addCleanupIfConfigured ( Configuration \ Backup $ backup , array $ conf ) { if ( isset ( $ conf [ 'cleanup' ] ) ) { $ backup -> setCleanup ( new Configuration \ Backup \ Cleanup ( $ conf [ 'cleanup' ] [ 'type' ] , false , $ conf [ 'cleanup' ] [ 'options' ] ) ) ; } } | Adds a cleanup configuration to the given backup configuration . |
34,431 | protected function addCryptIfConfigured ( Configuration \ Backup $ backup , array $ conf ) { if ( isset ( $ conf [ 'crypt' ] ) ) { $ backup -> setCrypt ( new Configuration \ Backup \ Crypt ( $ conf [ 'crypt' ] [ 'type' ] , false , $ conf [ 'crypt' ] [ 'options' ] ) ) ; } } | Adds a encryption configuration to the given encryption configuration . |
34,432 | public function update ( ConfigurationUpdaterListener $ listener , array $ input ) { try { foreach ( array_get ( $ input , 'drivers' , [ ] ) as $ driver => $ config ) { $ this -> authProviderService -> updateDriver ( $ driver , $ config ) ; event ( 'api.driver.' . $ driver . '.update' , [ $ input , $ this -> authProviderService ] ) ; } $ this -> authProviderService -> save ( ) ; } catch ( Exception $ e ) { Log :: emergency ( $ e ) ; return $ listener -> updateAuthFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> authUpdated ( ) ; } | Updates api providers configuration |
34,433 | public function system ( Request $ request , Builder $ htmlBuilder ) { return $ this -> processor -> system ( $ request , $ htmlBuilder ) ; } | list of system logs |
34,434 | protected function writeQueuedCookies ( Response $ response ) { foreach ( $ this -> queue -> getQueuedCookies ( ) as $ cookie ) { $ response -> headers -> setCookie ( $ cookie ) ; } } | Append all queued cookies to the response . |
34,435 | private function getFiles ( $ pattern , $ extension = '.log' ) { $ pattern = $ this -> storagePath . DS . $ pattern . $ extension ; $ files = array_map ( 'realpath' , glob ( $ pattern , GLOB_BRACE ) ) ; return array_filter ( $ files ) ; } | Get all files . |
34,436 | private function getLogPath ( $ date ) { $ path = "{$this->storagePath}/http-{$date}.log" ; if ( ! $ this -> filesystem -> exists ( $ path ) ) { throw new Exception ( 'The log(s) could not be located at : ' . $ path ) ; } return realpath ( $ path ) ; } | Get the log file path . |
34,437 | protected function isValid ( $ response ) { if ( is_null ( $ response ) ) { return true ; } if ( app ( 'request' ) instanceof Request ) { return $ response -> getStatusCode ( ) !== 401 ; } return true ; } | Verify request and response status code |
34,438 | protected function callController ( $ callable , Request $ request ) { list ( $ class , $ action ) = explode ( '@' , $ callable [ 0 ] , 2 ) ; $ request -> query -> add ( $ callable [ 1 ] ) ; $ controller = $ this -> factory -> make ( $ class ) ; $ controller -> setRequest ( $ request ) ; return $ controller -> call ( $ action ) ; } | Instantiate the controller and run the given action . |
34,439 | protected function getCallable ( Request $ request ) { $ method = $ request -> getMethod ( ) ; $ uri = $ request -> getPathInfo ( ) ; return $ this -> router -> getCallable ( $ method , $ uri ) ; } | Get the class of the controller to be executed . |
34,440 | private static function decideEncode ( $ object , & $ serialized ) { switch ( $ type = gettype ( $ object ) ) { case 'integer' : $ serialized .= "i{$object}e" ; break ; case 'string' : self :: encodeString ( $ object , $ serialized ) ; break ; case 'array' : $ function = self :: getArraySerializer ( $ object ) ; self :: $ function ( $ object , $ serialized ) ; break ; case 'boolean' : $ serialized .= $ object === true ? 'i1e' : 'i0e' ; break ; default : throw new EncodingException ( "Invalid type for encoding: $type" , $ object ) ; } } | Handles the serialization of one of the supported object types . |
34,441 | private static function encodeList ( $ list , & $ serialized ) { if ( empty ( $ list ) ) { $ serialized .= "le" ; return ; } $ serialized .= "l" ; for ( $ i = 0 ; isset ( $ list [ $ i ] ) ; $ i ++ ) { self :: decideEncode ( $ list [ $ i ] , $ serialized ) ; } $ serialized .= "e" ; } | Handles the serialization of an array object . |
34,442 | private static function encodeDictionary ( $ dictionary , & $ serialized ) { if ( empty ( $ dictionary ) ) { $ serialized .= "de" ; return ; } $ serialized .= "d" ; foreach ( self :: sortDictionary ( $ dictionary ) as $ key => $ value ) { self :: encodeString ( $ key , $ serialized ) ; self :: decideEncode ( $ value , $ serialized ) ; } $ serialized .= "e" ; } | Handles the serialization of a named array object . |
34,443 | public static function decodeFromFile ( $ path ) { if ( ! file_exists ( $ path ) ) { throw new \ RuntimeException ( "File $path does not exist" ) ; } $ buffer = file_get_contents ( $ path ) ; $ object = self :: decode ( $ buffer ) ; return $ object ; } | Handles the deserialization of the Bencode representation of an object from a file . |
34,444 | private static function decodeEntry ( $ buffer , & $ offset ) { $ offsetMarker = $ offset ; switch ( $ byte = $ buffer [ $ offset ++ ] ) { case 'd' : $ dictionary = array ( ) ; for ( ; ; ) { if ( $ buffer [ $ offset ] === 'e' ) { $ offset ++ ; break ; } $ key = self :: decodeEntry ( $ buffer , $ offset ) ; if ( ! is_string ( $ key ) && ! is_numeric ( $ key ) ) { throw new DecodingException ( "One of the dictionary keys is not a string or an integer: " . gettype ( $ key ) , $ offset ) ; } $ dictionary [ $ key ] = self :: decodeEntry ( $ buffer , $ offset ) ; } return $ dictionary ; case 'l' : $ list = array ( ) ; for ( ; ; ) { if ( $ buffer [ $ offset ] === 'e' ) { $ offset ++ ; break ; } $ list [ ] = self :: decodeEntry ( $ buffer , $ offset ) ; } return $ list ; case 'e' : case 'i' : return self :: getIntegerFromBuffer ( $ buffer , $ offset ) ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : $ number = self :: getStringFromBuffer ( $ buffer , $ offsetMarker ) ; $ offset = $ offsetMarker ; return $ number ; default : throw new DecodingException ( "Unknown prefix: $byte" , $ offset ) ; } } | Decodes the next Bencode entry from the buffer . |
34,445 | private static function getStringFromBuffer ( $ buffer , & $ offset ) { if ( ( $ length = self :: getIntegerFromBuffer ( $ buffer , $ offset , ':' ) ) < 0 ) { throw new DecodingException ( "Invalid string length: $length" , $ offset ) ; } if ( $ length == 0 ) { return '' ; } $ string = substr ( $ buffer , $ offset , $ length ) ; $ offset += $ length ; return $ string ; } | Decodes a string from the buffer . |
34,446 | private static function getIntegerFromBuffer ( $ buffer , & $ offset , $ delimiter = 'e' ) { $ numeric = '' ; $ offsetMarker = $ offset ; while ( ( $ byte = $ buffer [ $ offset ++ ] ) !== $ delimiter ) { $ numeric .= $ byte ; } $ integer = ( int ) $ numeric ; if ( $ numeric != $ integer ) { throw new DecodingException ( "Invalid integer: $numeric" , $ offsetMarker ) ; } return $ integer ; } | Decodes an integer from the buffer . |
34,447 | public static function convertToJSON ( $ bencode , $ options = 0 ) { $ object = self :: decode ( $ bencode ) ; $ json = json_encode ( $ object , $ options ) ; return $ json ; } | Converts Bencode representation to JSON representation . |
34,448 | public static function convertFromJSON ( $ json ) { $ object = json_decode ( $ json , true ) ; $ bencode = self :: encode ( $ object ) ; return $ bencode ; } | Converts JSON representation to Bencode representation . |
34,449 | public function setVersion ( string $ version ) : bool { $ supportedVersions = $ this -> getSupportedVersions ( ) ; if ( in_array ( $ version , $ supportedVersions , true ) ) { $ this -> _version = $ version ; return true ; } else { throw new NotSupportedException ( "Version `$version` is not supported in " . __CLASS__ . "! Supported versions: " . implode ( ' - ' , $ supportedVersions ) ) ; } } | This method support set version of gateway . |
34,450 | public function requestCommands ( ) : array { if ( $ this -> _requestCommands === null ) { $ reflection = new ReflectionClass ( $ this ) ; $ commands = [ ] ; foreach ( $ reflection -> getConstants ( ) as $ name => $ value ) { if ( strpos ( $ name , 'RC_' ) === 0 ) { $ commands [ ] = $ value ; } } return $ this -> _requestCommands = $ commands ; } else { return $ this -> _requestCommands ; } } | This method automatically detect request commands supported via constants name prefix with RC_ . RC meaning Request Command . |
34,451 | function loadStandsData ( ) { $ array = $ fields = array ( ) ; $ i = 0 ; $ handle = @ fopen ( $ this -> airportStandsFile , "r" ) ; if ( $ handle ) { while ( ( $ row = fgetcsv ( $ handle , 4096 ) ) !== false ) { if ( empty ( $ fields ) ) { $ fields = $ row ; continue ; } $ y = 0 ; foreach ( $ row as $ k => $ value ) { if ( $ y == 1 ) { $ array [ $ row [ 0 ] ] [ $ fields [ $ k ] ] = $ this -> convertCAALatCoord ( $ value ) ; } else if ( $ y == 2 ) { $ array [ $ row [ 0 ] ] [ $ fields [ $ k ] ] = $ this -> convertCAALongCoord ( $ value ) ; } else { $ array [ $ row [ 0 ] ] [ $ fields [ $ k ] ] = $ value ; } $ y ++ ; } $ i ++ ; } if ( ! feof ( $ handle ) ) { echo "Error: unexpected fgets() fail\n" ; return false ; } fclose ( $ handle ) ; } else { return false ; } $ this -> stands = $ array ; return true ; } | Load the stand data |
34,452 | public function api ( $ path , array $ parameters = array ( ) , $ method = 'GET' ) { return $ this -> getRequest ( ) -> api ( $ path , $ method , $ parameters ) ; } | Make an API call |
34,453 | public function authenticate ( $ publicKey , $ privateKey , $ secure = true ) { $ this -> options -> set ( 'publicKey' , $ publicKey ) ; $ this -> options -> set ( 'privateKey' , $ privateKey ) ; if ( $ secure ) { $ this -> options -> set ( 'protocol' , 'https' ) ; } } | Authenticate the application . If secure is true use SSL |
34,454 | public function setRegion ( $ region , $ locale = null ) { $ region = strtolower ( $ region ) ; $ locales = $ this -> getSupportedLocales ( $ region ) ; if ( in_array ( $ region , $ this -> getSupportedRegions ( ) ) && $ locales !== false ) { $ this -> options -> set ( 'region' , $ region ) ; } else { throw new \ InvalidArgumentException ( sprintf ( 'The region `%s` is not supported.' , $ region ) ) ; } if ( $ locale === null ) { $ this -> options -> set ( 'locale' , $ locales [ 0 ] ) ; } else { if ( $ locales !== false && in_array ( $ locale , $ locales ) ) { $ this -> options -> set ( 'locale' , $ locale ) ; } else { throw new \ InvalidArgumentException ( sprintf ( 'The locale `%s` for region `%s` is not supported.' , $ locale , $ region ) ) ; } } } | Set the region |
34,455 | public function setRequest ( \ WowApi \ Request \ RequestInterface $ request ) { $ request -> setClient ( $ this ) ; $ this -> request = $ request ; } | Set the request object |
34,456 | public function getAchievementsApi ( ) { if ( ! $ this -> apis -> has ( 'achievements' ) ) { $ this -> apis -> set ( 'achievements' , new Achievements ( $ this ) ) ; ; } return $ this -> apis -> get ( 'achievements' ) ; } | Returns the achievements API |
34,457 | public function getArenaApi ( ) { if ( ! $ this -> apis -> get ( 'arena' ) ) { $ this -> apis -> set ( 'arena' , new Arena ( $ this ) ) ; } return $ this -> apis -> get ( 'arena' ) ; } | Returns the arena API |
34,458 | public function getAuctionApi ( ) { if ( ! $ this -> apis -> has ( 'auction' ) ) { $ this -> apis -> set ( 'auction' , new Auction ( $ this ) ) ; } return $ this -> apis -> get ( 'auction' ) ; } | Returns the auction API |
34,459 | public function getChallengeApi ( ) { if ( ! $ this -> apis -> has ( 'challenge' ) ) { $ this -> apis -> set ( 'challenge' , new Challenge ( $ this ) ) ; } return $ this -> apis -> get ( 'challenge' ) ; } | Returns the challenge API |
34,460 | public function getCharacterApi ( ) { if ( ! $ this -> apis -> has ( 'character' ) ) { $ this -> apis -> set ( 'character' , new Character ( $ this ) ) ; } return $ this -> apis -> get ( 'character' ) ; } | Returns the character API |
34,461 | public function getClassesApi ( ) { if ( ! $ this -> apis -> has ( 'classes' ) ) { $ this -> apis -> set ( 'classes' , new Classes ( $ this ) ) ; } return $ this -> apis -> get ( 'classes' ) ; } | Returns the classes API |
34,462 | public function getGuildApi ( ) { if ( ! $ this -> apis -> has ( 'guild' ) ) { $ this -> apis -> set ( 'guild' , new Guild ( $ this ) ) ; } return $ this -> apis -> get ( 'guild' ) ; } | Returns the guild API |
34,463 | public function getGuildPerksApi ( ) { if ( ! $ this -> apis -> has ( 'guildPerks' ) ) { $ this -> apis -> set ( 'guildPerks' , new GuildPerks ( $ this ) ) ; } return $ this -> apis -> get ( 'guildPerks' ) ; } | Returns the guildPerks API |
34,464 | public function getGuildRewardsApi ( ) { if ( ! $ this -> apis -> has ( 'guildRewards' ) ) { $ this -> apis -> set ( 'guildRewards' , new GuildRewards ( $ this ) ) ; } return $ this -> apis -> get ( 'guildRewards' ) ; } | Returns the guildRewards API |
34,465 | public function getRacesApi ( ) { if ( ! $ this -> apis -> has ( 'races' ) ) { $ this -> apis -> set ( 'races' , new Races ( $ this ) ) ; } return $ this -> apis -> get ( 'races' ) ; } | Returns the races API |
34,466 | public function getRealmApi ( ) { if ( ! $ this -> apis -> has ( 'realm' ) ) { $ this -> apis -> set ( 'realm' , new Realm ( $ this ) ) ; } return $ this -> apis -> get ( 'realm' ) ; } | Returns the realm API |
34,467 | public function generate ( GeneratorListener $ listener ) { $ today = date ( 'Y-m-d H:i:s' ) ; $ model = new Report ( [ 'name' => "System Analyzer Report {$today}" , 'html' => Input :: get ( 'src' ) , 'user_id' => auth ( ) -> user ( ) -> id , 'brand_id' => app ( 'antares.memory' ) -> make ( 'primary' ) -> get ( 'brand.default' ) , 'type_id' => ReportType :: where ( 'name' , Input :: get ( 'type' , "analyzer" ) ) -> first ( ) -> id ] ) ; if ( $ model -> save ( ) ) { return $ listener -> generateSuccess ( $ model -> id ) ; } return $ listener -> generateFailed ( ) ; } | default generate action |
34,468 | public function view ( $ id , GeneratorListener $ listener ) { $ model = Report :: where ( 'id' , $ id ) -> first ( ) ; if ( is_null ( $ model ) ) { return $ listener -> viewFailed ( ) ; } return $ this -> presenter -> publishHtml ( $ model ) ; } | preview report content |
34,469 | public function download ( $ type , $ id , GeneratorListener $ listener ) { $ model = Report :: where ( 'id' , $ id ) -> first ( ) ; if ( is_null ( $ model ) ) { return $ listener -> downloadFailed ( ) ; } $ filename = snake_case ( str_replace ( [ '-' , ':' , ' ' ] , '_' , $ model -> name ) ) ; switch ( $ type ) { case 'pdf' : $ snappy = app ( 'snappy.pdf.wrapper' ) ; $ appKey = config ( 'app.key' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , handles ( 'antares::logger/view/' . $ id . '/html' ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ "generator: {$appKey}" ] ) ; $ html = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ snappy -> loadHTML ( $ html ) ; $ return = $ snappy -> download ( $ filename . '.pdf' ) ; break ; default : $ return = Response :: make ( $ model -> html , '200' , array ( 'Content-Type' => 'application/octet-stream' , 'Content-Disposition' => 'attachment; filename="' . $ filename . '.html' ) ) ; break ; } return $ return ; } | download report content |
34,470 | public function html ( $ id ) { $ model = Report :: query ( ) -> find ( $ id ) -> first ( ) ; $ html = preg_replace ( '#<script(.*?)>(.*?)</script>#is' , '' , $ model -> html ) ; $ html = preg_replace ( '#<link(.*?)>#is' , '' , $ html ) ; return $ this -> presenter -> html ( $ html ) ; } | preview report as html content |
34,471 | public function generateStandalone ( GeneratorListener $ listener ) { $ response = $ this -> consoleKernel -> call ( 'report:analyzer' ) ; $ splFileInfo = new SplFileInfo ( $ this -> consoleKernel -> output ( ) ) ; return new JsonResponse ( [ 'redirect' => handles ( 'antares::logger/generate/download/' . trim ( $ splFileInfo -> getFilename ( ) ) ) ] , 200 ) ; } | response when generates standalone system report |
34,472 | public function downloadReportByFilename ( GeneratorListener $ listener , $ filename ) { if ( ! $ filename ) { return $ listener -> downloadFailed ( ) ; } $ file = storage_path ( 'temp' . DIRECTORY_SEPARATOR . $ filename ) ; $ filesystem = app ( Filesystem :: class ) ; if ( ! $ filesystem -> exists ( $ file ) ) { return $ listener -> downloadFailed ( ) ; } return Response :: download ( $ file ) ; } | downloads system report by filename |
34,473 | protected function createConfiguration ( ) { $ phpbuConfigFile = $ this -> configProxy -> get ( 'phpbu.phpbu' ) ; if ( ! empty ( $ phpbuConfigFile ) ) { $ configLoader = PhpbuConfigLoaderFactory :: createLoader ( $ phpbuConfigFile ) ; $ configuration = $ configLoader -> getConfiguration ( $ this -> runner -> getFactory ( ) ) ; } else { $ this -> validateConfig ( ) ; $ translator = new Translator ( ) ; $ configuration = $ translator -> translate ( $ this -> configProxy ) ; $ configuration -> setSimulate ( ( bool ) $ this -> option ( 'phpbu-simulate' ) ) ; PhpbuFactory :: register ( 'sync' , 'laravel-storage' , '\\phpbu\\Laravel\\Backup\\Sync\\LaravelStorage' ) ; } return $ configuration ; } | Creates a phpbu configuration . |
34,474 | public function create ( $ DomainID , $ Type , $ Name = null , $ Target = null , $ Priority = null , $ Weight = null , $ Port = null , $ Protocol = null , $ Tag = null , $ TTL_sec = null ) { return $ this -> call ( 'domain.resource.create' , [ 'DomainID' => $ DomainID , 'Type' => $ Type , 'Name' => $ Name , 'Target' => $ Target , 'Priority' => $ Priority , 'Weight' => $ Weight , 'Port' => $ Port , 'Protocol' => $ Protocol , 'Tag' => $ Tag , 'TTL_sec' => $ TTL_sec , ] ) ; } | Create a domain record . |
34,475 | protected function registerRouterAdapter ( ) { $ this -> app -> singleton ( 'api.router.adapter' , function ( $ app ) { return new DingoRoutingLaravelAdapter ( $ this -> cloneLaravelRouter ( ) , $ app [ 'router' ] -> getRoutes ( ) ) ; } ) ; } | Register the router adapter . |
34,476 | protected function cloneLaravelRouter ( ) { $ router = clone $ this -> app [ 'router' ] ; $ router -> aliasMiddleware ( 'api.auth' , NodesHttpMiddlewareAuth :: class ) ; $ router -> aliasMiddleware ( 'api.controllers' , NodesHttpMiddlewarePrepareController :: class ) ; $ router -> aliasMiddleware ( 'api.throttle' , NodesHttpMiddlewareRateLimit :: class ) ; $ router -> aliasMiddleware ( 'api.useragent' , NodesHttpMiddlewareUserAgent :: class ) ; $ router -> aliasMiddleware ( 'api.meta' , NodesHttpMiddleware :: class ) ; return $ router ; } | Clone the Laravel router and set the middleware on the cloned router . |
34,477 | public function download ( $ path , DownloadListener $ listener ) { $ decoded = Urlcrypt :: decode ( $ path ) ; $ file = new File ( $ decoded ) ; if ( $ this -> isImage ( $ file ) ) { $ path = $ file -> getRealPath ( ) ; $ imgData = base64_encode ( file_get_contents ( $ path ) ) ; $ src = 'data: ' . mime_content_type ( $ path ) . ';base64,' . $ imgData ; return $ this -> presenter -> show ( $ src ) ; } } | default download action |
34,478 | protected function checkProperty ( OutputInterface $ output , CheckInterface $ property ) { $ result = $ property -> check ( ) ; if ( $ result === false ) { $ outputLevel = 'error' ; $ sign = self :: EMOJI_FAILURE ; if ( $ property -> isOptional ( ) === true ) { $ outputLevel = 'comment' ; $ sign = self :: EMOJI_OPTIONAL ; } $ message = $ property -> getFailureMessage ( ) ; $ this -> overallResult = false ; } elseif ( $ result === true ) { $ outputLevel = 'info' ; $ sign = self :: EMOJI_OK ; $ message = $ property -> getSuccessMessage ( ) ; } $ outputMessage = " <info>%s</info> <%s>%s</%s>" ; $ outputMessage = sprintf ( $ outputMessage , $ sign , $ outputLevel , $ message , $ outputLevel ) ; $ output -> writeln ( $ outputMessage ) ; return $ result ; } | Checks a single property |
34,479 | protected function outputEverythingIsFineAndIWantABeerMessage ( OutputInterface $ output ) { $ output -> writeln ( '' ) ; $ output -> writeln ( "<info>Wow! Everything works fine. Gratulations \xF0\x9F\x8E\x81</info>" ) ; $ output -> writeln ( '' ) ; $ output -> writeln ( '<info>Now you are ready to use Gerrie with the full featureset. Awesome!</info>' ) ; $ message = "<info>Grab a \xF0\x9F\x8D\xBA (better \xF0\x9F\x8D\xBB ) or a \xF0\x9F\x8D\xB7 " ; $ message .= "and start crawling your Gerrit instances.</info>" ; $ output -> writeln ( $ message ) ; $ output -> writeln ( "<info>Have fun \xF0\x9F\x98\x83</info>" ) ; $ output -> writeln ( '' ) ; } | If everything is fine and all checks went good this message will be outputted . |
34,480 | public function authenticate ( array $ providers = [ ] ) { $ exceptionStack = [ ] ; foreach ( $ this -> filterProviders ( $ providers ) as $ provider ) { try { $ user = $ provider -> authenticate ( $ this -> router -> getCurrentRequest ( ) , $ this -> router -> getCurrentRoute ( ) ) ; $ this -> providerUsed = $ provider ; return $ this -> user = $ user ; } catch ( NodesException $ exception ) { $ exceptionStack [ ] = $ exception ; } catch ( UnauthorizedHttpException $ exception ) { $ exceptionStack [ ] = $ exception ; } catch ( BadRequestHttpException $ exception ) { } } $ this -> throwUnauthorizedException ( $ exceptionStack ) ; } | Authenticate request . |
34,481 | public function index ( $ token ) { $ resetToken = $ this -> resetPasswordRepository -> getByToken ( $ token ) ; if ( empty ( $ resetToken ) || $ resetToken -> isUsed ( ) ) { return view ( 'nodes.api::reset-password.invalid' ) ; } if ( $ resetToken -> isExpired ( ) ) { return view ( 'nodes.api::reset-password.expired' ) ; } return view ( 'nodes.api::reset-password.form' , compact ( 'token' ) ) ; } | Reset password form . |
34,482 | public function generateResetToken ( ) { $ email = $ email = Input :: get ( 'email' ) ; if ( empty ( config ( 'nodes.api.auth.model' ) ) ) { throw new MissingUserModelException ( 'No API auth model has been specified' ) ; } if ( empty ( $ email ) || ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw ( new Exception ( 'Missing or invalid e-mail address' , 412 ) ) -> setStatusCode ( 412 ) ; } $ this -> resetPasswordRepository -> sendResetPasswordEmail ( [ 'email' => $ email ] ) ; return $ this -> response -> content ( [ 'email' => 'sent' , ] ) ; } | Generate reset password token and send it on e - mail . |
34,483 | public function initActionGet ( ) : array { $ rem = $ this -> di -> get ( "remserver" ) ; $ rem -> init ( ) ; $ json = [ "message" => "The session is initiated with the default dataset(s)." , "dataset" => $ rem -> getDefaultDataset ( ) , ] ; return [ $ json ] ; } | Init or re - init the REM Server . |
34,484 | public function getItem ( string $ dataset , int $ itemId ) : array { $ item = $ this -> di -> get ( "remserver" ) -> getItem ( $ dataset , $ itemId ) ; if ( ! $ item ) { return [ [ "message" => "The item is not found." ] ] ; } return [ $ item ] ; } | Get one item from the dataset . |
34,485 | public function postItem ( string $ dataset ) : array { try { $ entry = $ this -> di -> get ( "request" ) -> getBodyAsJson ( ) ; } catch ( \ Anax \ Request \ Exception $ e ) { return [ [ "message" => "500. HTTP request body is not an object/array or valid JSON." ] , 500 ] ; } $ item = $ this -> di -> get ( "remserver" ) -> addItem ( $ dataset , $ entry ) ; return [ $ item ] ; } | Create a new item by getting the entry from the request body and add to the dataset . |
34,486 | public static function bootLogRecorder ( ) { static :: saving ( function ( $ model ) { $ model -> prepareAudit ( ) ; } ) ; static :: created ( function ( $ model ) { if ( $ model -> isTypeAuditable ( 'created' ) ) { $ model -> auditCreation ( ) ; } } ) ; static :: saved ( function ( $ model ) { if ( $ model -> isTypeAuditable ( 'saved' ) ) { $ model -> auditUpdate ( ) ; } } ) ; static :: deleted ( function ( $ model ) { if ( $ model -> isTypeAuditable ( 'deleted' ) ) { $ model -> prepareAudit ( ) ; $ model -> auditDeletion ( ) ; } } ) ; } | Init auditing . |
34,487 | public function prepareAudit ( ) { if ( ! isset ( $ this -> auditEnabled ) || $ this -> auditEnabled ) { $ this -> originalData = $ this -> original ; $ this -> updatedData = $ this -> attributes ; foreach ( $ this -> updatedData as $ key => $ val ) { if ( gettype ( $ val ) == 'object' && ! method_exists ( $ val , '__toString' ) ) { unset ( $ this -> originalData [ $ key ] ) ; unset ( $ this -> updatedData [ $ key ] ) ; array_push ( $ this -> dontKeep , $ key ) ; } } $ this -> dontKeep = isset ( $ this -> dontKeepLogOf ) ? $ this -> dontKeepLogOf + $ this -> dontKeep : $ this -> dontKeep ; $ this -> doKeep = isset ( $ this -> keepLogOf ) ? $ this -> keepLogOf + $ this -> doKeep : $ this -> doKeep ; unset ( $ this -> attributes [ 'dontKeepLogOf' ] ) ; unset ( $ this -> attributes [ 'keepLogOf' ] ) ; $ this -> dirtyData = $ this -> getDirty ( ) ; $ this -> updating = $ this -> exists ; } } | Prepare audit model . |
34,488 | public function auditCreation ( ) { if ( ( ! isset ( $ this -> auditEnabled ) || $ this -> auditEnabled ) ) { $ insert = array_merge ( [ 'old_value' => null , 'author_id' => auth ( ) -> guest ( ) ? null : auth ( ) -> user ( ) -> id , 'new_value' => $ this -> getAttributes ( ) , 'related_data' => $ this -> getRelatedData ( ) , 'type' => 'created' , ] , $ this -> values ( ) ) ; return $ this -> audit ( $ insert ) ; } } | Audit creation . |
34,489 | public function auditUpdate ( ) { try { $ history = $ this -> logHistory ( ) ; if ( is_null ( $ history ) ) { return false ; } if ( isset ( $ this -> historyLimit ) && $ this -> logHistory ( ) -> count ( ) >= $ this -> historyLimit ) { $ LimitReached = true ; } else { $ LimitReached = false ; } if ( isset ( $ this -> logCleanup ) ) { $ LogCleanup = $ this -> LogCleanup ; } else { $ LogCleanup = false ; } if ( ( ( ! isset ( $ this -> auditEnabled ) || $ this -> auditEnabled ) && $ this -> updating ) && ( ! $ LimitReached || $ LogCleanup ) ) { $ changes_to_record = $ this -> changedAuditingFields ( ) ; if ( count ( $ changes_to_record ) ) { $ log = [ 'type' => 'updated' ] ; foreach ( $ changes_to_record as $ key => $ change ) { $ log [ 'old_value' ] [ $ key ] = array_get ( $ this -> originalData , $ key ) ; $ log [ 'new_value' ] [ $ key ] = array_get ( $ this -> updatedData , $ key ) ; } $ log [ 'related_data' ] = $ this -> getRelatedData ( ) ; $ this -> audit ( $ log ) ; } } } catch ( Exception $ ex ) { Log :: emergency ( $ ex ) ; return false ; } } | Audit updated . |
34,490 | protected function values ( ) { try { return [ 'type_id' => $ this -> resolveTypeIdByOwner ( ) , 'priority_id' => $ this -> getPriorityId ( ) , 'brand_id' => brand_id ( ) , 'owner_type' => get_class ( $ this ) , 'owner_id' => $ this -> getKey ( ) , 'user_id' => $ this -> getUserId ( ) , 'route' => str_replace ( app ( 'url' ) -> to ( '/' ) , '' , Request :: url ( ) ) , 'ip_address' => Request :: getClientIp ( ) , 'user_agent' => isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : 'No UserAgent' , 'created_at' => new DateTime ( ) , 'updated_at' => new DateTime ( ) , ] ; } catch ( Exception $ ex ) { return [ ] ; } } | get constantiable values |
34,491 | protected function getPriorityId ( ) { $ name = ! $ this -> priority ? 'medium' : $ this -> priority ; $ priority = LogPriorities :: where ( 'name' , $ name ) -> first ( ) ; if ( is_null ( $ priority ) ) { throw new Exception ( sprintf ( "Unable to find log priority %s." , $ name ) ) ; } return $ priority -> id ; } | priority id getter |
34,492 | protected function getLoggerModuleNameForType ( ) { $ reflection = new ReflectionClass ( $ this ) ; $ filename = $ reflection -> getFileName ( ) ; $ match = str_contains ( $ filename , 'app' ) ? [ 1 => 'core' ] : null ; if ( ! isset ( $ match [ 1 ] ) and ! preg_match ( "'src(.*?)src'si" , $ filename , $ match ) ) { throw new Exception ( 'Unable to resolve current module name.' ) ; } if ( ! isset ( $ match [ 1 ] ) ) { throw new Exception ( 'Unable to resolve current module namespace.' ) ; } $ reserved = [ 'components' , 'modules' ] ; return str_contains ( $ match [ 1 ] , 'core' ) ? 'core' : trim ( str_replace ( $ reserved , '' , $ match [ 1 ] ) , DIRECTORY_SEPARATOR ) ; } | Returns a name of the type . In the default the module name based on class namespace will be returned . |
34,493 | protected function resolveTypeIdByOwner ( ) { try { if ( method_exists ( $ this , 'getLogTypeId' ) ) { return self :: getLogTypeId ( ) ; } $ module = $ this -> getLoggerModuleNameForType ( ) ; $ type = LogTypes :: where ( 'name' , $ module ) -> first ( ) ; if ( is_null ( $ type ) ) { $ type = new LogTypes ( [ 'name' => $ module ] ) ; $ type -> save ( ) ; } return $ type -> id ; } catch ( Exception $ ex ) { Log :: emergency ( $ ex ) ; } } | current component name resolver |
34,494 | public function auditDeletion ( ) { if ( ( ! isset ( $ this -> auditEnabled ) || $ this -> auditEnabled ) ) { $ type = 'deleted' ; $ delete = array_merge ( [ 'old_value' => $ this -> getAttributes ( ) , 'new_value' => null , 'related_data' => $ this -> getRelatedData ( ) , 'type' => $ type ] , $ this -> values ( ) ) ; return $ this -> audit ( $ delete ) ; } } | Audit deletion . |
34,495 | public function audit ( array $ log ) { try { $ type = $ log [ 'type' ] ; $ values = $ this -> values ( ) ; $ authorId = array_get ( $ log , 'author_id' ) ; if ( is_null ( $ authorId ) && isset ( $ values [ 'owner_type' ] ) ) { $ created = Logs :: withoutGlobalScopes ( ) -> where ( [ 'owner_type' => $ values [ 'owner_type' ] , 'type' => 'created' , 'owner_id' => $ values [ 'owner_id' ] ] ) -> whereNotNull ( 'author_id' ) -> first ( ) ; if ( ! is_null ( $ created ) ) { $ authorId = $ created -> author_id ; } } $ logAuditing = array_merge ( [ 'author_id' => $ authorId , 'old_value' => $ log [ 'old_value' ] , 'new_value' => $ log [ 'new_value' ] , 'related_data' => $ log [ 'related_data' ] , 'name' => $ this -> resolveOperationName ( $ type ) , 'is_api_request' => is_api_request ( ) , 'type' => $ type ] , $ values ) ; $ log = new Logs ( $ logAuditing ) ; $ log -> created_at = ( method_exists ( $ this , 'createdAt' ) ) ? $ this -> createdAt ( ) : new DateTime ( ) ; if ( ! $ log -> save ( ) ) { throw new Exception ( 'Unable to save log entity.' ) ; } } catch ( Exception $ ex ) { Log :: emergency ( $ ex ) ; return false ; } return true ; } | Audit model . |
34,496 | protected function getUserId ( ) { try { if ( Auth :: check ( ) ) { return Auth :: user ( ) -> getAuthIdentifier ( ) ; } } catch ( Exception $ e ) { Log :: emergency ( $ e ) ; return ; } return ; } | Get user id . |
34,497 | private function changedAuditingFields ( ) { $ changes_to_record = [ ] ; $ attributes = $ this -> getAttributes ( ) ; foreach ( $ attributes as $ key => $ value ) { if ( $ this -> isAuditing ( $ key ) && ! is_array ( $ value ) ) { $ changes_to_record [ $ key ] = $ value ; } else { unset ( $ this -> updatedData [ $ key ] ) ; unset ( $ this -> originalData [ $ key ] ) ; } } return $ changes_to_record ; } | Fields Changed . |
34,498 | public function isTypeAuditable ( $ key ) { $ auditableTypes = isset ( $ this -> auditableTypes ) ? $ this -> auditableTypes : [ 'created' , 'saved' , 'deleted' ] ; if ( in_array ( $ key , $ auditableTypes ) ) { return true ; } return ; } | Verify is type auditable . |
34,499 | private function populateDetail ( \ stdClass $ locationDetail ) { if ( ! property_exists ( $ locationDetail , 'results' ) ) { $ this -> isValid = false ; return false ; } $ this -> latitude = $ locationDetail -> results [ 0 ] -> geometry -> location -> lat ; $ this -> longitude = $ locationDetail -> results [ 0 ] -> geometry -> location -> lng ; foreach ( $ locationDetail -> results [ 0 ] -> address_components as $ component ) { if ( in_array ( 'street_number' , $ component -> types ) ) { $ this -> streetNumber = $ component -> long_name ; } elseif ( in_array ( 'locality' , $ component -> types ) ) { $ this -> locality = $ component -> long_name ; $ this -> shortLocality = $ component -> short_name ; } elseif ( in_array ( 'postal_town' , $ component -> types ) ) { $ this -> town = $ component -> long_name ; $ this -> shortTown = $ component -> short_name ; } elseif ( in_array ( 'administrative_area_level_2' , $ component -> types ) ) { $ this -> country = $ component -> long_name ; $ this -> shortCountry = $ component -> short_name ; } elseif ( in_array ( 'country' , $ component -> types ) ) { $ this -> country = $ component -> long_name ; $ this -> shortCountry = $ component -> short_name ; } elseif ( in_array ( 'administrative_area_level_1' , $ component -> types ) ) { $ this -> district = $ component -> long_name ; $ this -> shortDistrict = $ component -> short_name ; } elseif ( in_array ( 'postal_code' , $ component -> types ) ) { $ this -> postcode = $ component -> long_name ; } elseif ( in_array ( 'route' , $ component -> types ) ) { $ this -> streetAddress = $ component -> long_name ; $ this -> shortStreetAddress = $ component -> short_name ; } elseif ( in_array ( 'political' , $ component -> types ) ) { $ this -> neighborhood = $ component -> long_name ; $ this -> shortNeighborhood = $ component -> short_name ; } } return true ; } | Populates the object with the detail from the service |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.