idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
47,900
public function compileDelete ( Builder $ query ) { $ match = $ this -> compileComponents ( $ query , array ( 'from' ) ) ; $ match = $ match [ 'from' ] ; $ where = is_array ( $ query -> wheres ) ? $ this -> compileWheres ( $ query ) : '' ; return "$match $where OPTIONAL $match-[r]-() $where DELETE " . $ query -> mode...
Compile a delete statement into Cypher .
47,901
public function compileInsert ( Builder $ query , array $ values ) { if ( ! is_array ( $ query -> from ) ) { $ query -> from = array ( $ query -> from ) ; } $ label = $ this -> prepareLabels ( $ query -> from ) ; if ( ! is_array ( reset ( $ values ) ) ) { $ values = array ( $ values ) ; } $ values = array_map ( functio...
Compile an insert statement into Cypher .
47,902
public function compileUpdateLabels ( Builder $ query , $ labels , $ operation = 'add' ) { if ( trim ( strtolower ( $ operation ) ) == 'add' ) { $ updateType = 'SET' ; } else { $ updateType = 'REMOVE' ; } $ labels = $ query -> modelAsNode ( ) . $ this -> prepareLabels ( $ labels ) ; $ where = $ this -> compileWheres ( ...
Compile an statement to add or drop node labels
47,903
public function getSQLType ( ) { $ class = get_class ( $ this ) ; $ start = strrpos ( $ class , '\\' ) + 1 ; $ len = strlen ( $ class ) - $ start - 4 ; return substr ( $ class , strrpos ( $ class , '\\' ) + 1 , $ len ) ; }
Gets the SQL name of this type .
47,904
public function walkSelectExpression ( $ selectExpression ) { $ expr = $ selectExpression -> expression ; $ sql = parent :: walkSelectExpression ( $ selectExpression ) ; if ( $ expr instanceof ReturnsGeometryInterface && ! $ selectExpression -> hiddenAliasResultVariable ) { $ alias = trim ( strrchr ( $ sql , ' ' ) ) ; ...
Walks down a SelectExpression AST node and generates the corresponding SQL .
47,905
public function getMappedDatabaseTypes ( AbstractSpatialType $ type ) { $ sqlType = strtolower ( $ type -> getSQLType ( ) ) ; if ( $ type instanceof GeographyType && $ sqlType !== 'geography' ) { $ sqlType = sprintf ( 'geography(%s)' , $ sqlType ) ; } return array ( $ sqlType ) ; }
Get an array of database types that map to this Doctrine type .
47,906
private function newObjectFromValue ( AbstractSpatialType $ type , $ value ) { $ typeFamily = $ type -> getTypeFamily ( ) ; $ typeName = strtoupper ( $ value [ 'type' ] ) ; $ constName = sprintf ( 'CrEOF\Spatial\PHP\Types\Geometry\GeometryInterface::%s' , $ typeName ) ; if ( ! defined ( $ constName ) ) { throw new Inva...
Create spatial object from parsed value
47,907
public function send ( string $ str ) : void { if ( $ this -> need_headers ) { $ this -> sendHttpHeaders ( ) ; } $ this -> need_headers = false ; fwrite ( $ this -> opt -> getOutputStream ( ) , $ str ) ; }
Send string sending HTTP headers if necessary .
47,908
protected function sendHttpHeaders ( ) : void { $ disposition = $ this -> opt -> getContentDisposition ( ) ; if ( $ this -> output_name ) { $ safe_output = trim ( str_replace ( [ '"' , "'" , '\\' , ';' , "\n" , "\r" ] , '' , $ this -> output_name ) ) ; $ urlencoded = rawurlencode ( $ safe_output ) ; $ disposition .= ";...
Send HTTP headers for this stream .
47,909
protected function clear ( ) : void { $ this -> files = [ ] ; $ this -> ofs = new Bigint ( ) ; $ this -> cdr_ofs = new Bigint ( ) ; $ this -> opt = new ArchiveOptions ( ) ; }
Clear all internal variables . Note that the stream object is not usable after this .
47,910
public function isLargeFile ( string $ path ) : bool { if ( ! $ this -> opt -> isStatFiles ( ) ) { return false ; } $ stat = stat ( $ path ) ; return $ stat [ 'size' ] > $ this -> opt -> getLargeFileSize ( ) ; }
Is this file larger than large_file_size?
47,911
public function addToCdr ( File $ file ) : void { $ file -> ofs = $ this -> ofs ; $ this -> ofs = $ this -> ofs -> add ( $ file -> getTotalLength ( ) ) ; $ this -> files [ ] = $ file -> getCdrFile ( ) ; }
Save file attributes for trailing CDR record .
47,912
public function addFileHeader ( ) : void { $ name = static :: filterFilename ( $ this -> name ) ; $ nameLength = strlen ( $ name ) ; $ time = static :: dosTime ( $ this -> opt -> getTime ( ) -> getTimestamp ( ) ) ; $ comment = $ this -> opt -> getComment ( ) ; if ( ! mb_check_encoding ( $ name , 'ASCII' ) || ! mb_check...
Create and send zip header for this file .
47,913
final protected static function dosTime ( int $ when ) : int { $ d = getdate ( $ when ) ; if ( $ d [ 'year' ] < 1980 ) { $ d = array ( 'year' => 1980 , 'mon' => 1 , 'mday' => 1 , 'hours' => 0 , 'minutes' => 0 , 'seconds' => 0 ) ; } $ d [ 'year' ] -= 1980 ; return ( $ d [ 'year' ] << 25 ) | ( $ d [ 'mon' ] << 21 ) | ( $...
Convert a UNIX timestamp to a DOS timestamp .
47,914
public function addFileFooter ( ) : void { if ( $ this -> bits & self :: BIT_ZERO_HEADER ) { $ fields = [ [ 'V' , ZipStream :: DATA_DESCRIPTOR_SIGNATURE ] , [ 'V' , $ this -> crc ] , [ 'V' , $ this -> zlen ] , [ 'V' , $ this -> len ] , ] ; if ( $ this -> zip -> opt -> isEnableZip64 ( ) ) { $ fields = [ [ 'V' , ZipStrea...
Create and send data descriptor footer for this file .
47,915
public function getCdrFile ( ) : string { $ name = static :: filterFilename ( $ this -> name ) ; $ comment = $ this -> opt -> getComment ( ) ; $ time = static :: dosTime ( $ this -> opt -> getTime ( ) -> getTimestamp ( ) ) ; $ footer = $ this -> buildZip64ExtraBlock ( ) ; $ fields = [ [ 'V' , ZipStream :: CDR_FILE_SIGN...
Send CDR record for specified file .
47,916
protected function fillBytes ( int $ value , int $ start , int $ count ) : void { for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ this -> bytes [ $ start + $ i ] = $ i >= PHP_INT_SIZE ? 0 : $ value & 0xFF ; $ value >>= 8 ; } }
Fill the bytes field with int
47,917
public static function fromLowHigh ( int $ low , int $ high ) : self { $ bigint = new Bigint ( ) ; $ bigint -> fillBytes ( $ low , 0 , 4 ) ; $ bigint -> fillBytes ( $ high , 4 , 4 ) ; return $ bigint ; }
Fill bytes from low to high
47,918
public function getValue ( int $ end = 0 , int $ length = 8 ) : int { $ result = 0 ; for ( $ i = $ end + $ length - 1 ; $ i >= $ end ; $ i -- ) { $ result <<= 8 ; $ result |= $ this -> bytes [ $ i ] ; } return $ result ; }
Get value from bytes array
47,919
public function getLowFF ( bool $ force = false ) : int { if ( $ force || $ this -> isOver32 ( ) ) { return 0xFFFFFFFF ; } return $ this -> getLow32 ( ) ; }
Get low FF
47,920
public function isOver32 ( bool $ force = false ) : bool { return $ force || max ( array_slice ( $ this -> bytes , 4 , 4 ) ) > 0 || min ( array_slice ( $ this -> bytes , 0 , 4 ) ) === 0xFF ; }
Check if is over 32
47,921
public static function convert ( $ html , $ options = array ( ) ) { if ( $ options === false || $ options === true ) { $ options = array ( 'ignore_errors' => $ options ) ; } $ options = array_merge ( static :: defaultOptions ( ) , $ options ) ; foreach ( $ options as $ key => $ value ) { if ( ! in_array ( $ key , array...
Tries to convert the given HTML into a plain text format - best suited for e - mail display etc .
47,922
static function processWhitespaceNewlines ( $ text ) { $ text = preg_replace ( "/ *\t */im" , "\t" , $ text ) ; $ text = ltrim ( $ text ) ; $ text = preg_replace ( "/\n[ \t]*/im" , "\n" , $ text ) ; $ text = static :: renderText ( $ text ) ; $ text = rtrim ( $ text ) ; $ text = preg_replace ( "/[ \t]*\n/im" , "\n" , $ ...
Remove leading or trailing spaces and excess empty lines from provided multiline text
47,923
static function getDocument ( $ html , $ ignore_error = false ) { $ doc = new \ DOMDocument ( ) ; $ html = trim ( $ html ) ; if ( ! $ html ) { return $ doc ; } if ( $ html [ 0 ] !== '<' ) { $ html = '<body>' . $ html . '</body>' ; } if ( $ ignore_error ) { $ doc -> strictErrorChecking = false ; $ doc -> recover = true ...
Parse HTML into a DOMDocument
47,924
public function setFields ( array $ fields ) { $ this -> clearFields ( ) ; foreach ( $ fields as $ field ) { $ this -> addField ( $ field ) ; } return $ this ; }
Set the fields for the attachment .
47,925
protected function getFieldsAsArrays ( ) { $ fields = [ ] ; foreach ( $ this -> getFields ( ) as $ field ) { $ fields [ ] = $ field -> toArray ( ) ; } return $ fields ; }
Iterates over all fields in this attachment and returns them in their array form .
47,926
protected function getActionsAsArrays ( ) { $ actions = [ ] ; foreach ( $ this -> getActions ( ) as $ action ) { $ actions [ ] = $ action -> toArray ( ) ; } return $ actions ; }
Iterates over all actions in this attachment and returns them in their array form .
47,927
public function query ( $ query ) { if ( ! $ this -> ready ) { if ( isset ( $ this -> check_current_query ) ) { $ this -> check_current_query = true ; } return false ; } if ( $ this -> show_errors ) { $ this -> hide_errors ( ) ; } $ result = parent :: query ( $ query ) ; if ( ! SAVEQUERIES ) { return $ result ; } $ i =...
Perform a MySQL database query using current database connection .
47,928
public function filter_http_request_args ( array $ args , $ url ) { $ trace = new QM_Backtrace ( ) ; if ( isset ( $ args [ '_qm_key' ] ) ) { $ args [ '_qm_original_key' ] = $ args [ '_qm_key' ] ; $ start = $ this -> data [ 'http' ] [ $ args [ '_qm_key' ] ] [ 'start' ] ; } else { $ start = microtime ( true ) ; } $ key =...
Filter the arguments used in an HTTP request .
47,929
public function action_http_api_debug ( $ response , $ action , $ class , $ args , $ url ) { switch ( $ action ) { case 'response' : if ( ! empty ( $ class ) ) { $ this -> data [ 'http' ] [ $ args [ '_qm_key' ] ] [ 'transport' ] = str_replace ( 'wp_http_' , '' , strtolower ( $ class ) ) ; } else { $ this -> data [ 'htt...
Debugging action for the HTTP API .
47,930
public function log_http_response ( $ response , array $ args , $ url ) { $ this -> data [ 'http' ] [ $ args [ '_qm_key' ] ] [ 'end' ] = microtime ( true ) ; $ this -> data [ 'http' ] [ $ args [ '_qm_key' ] ] [ 'response' ] = $ response ; $ this -> data [ 'http' ] [ $ args [ '_qm_key' ] ] [ 'args' ] = $ args ; if ( iss...
Log an HTTP response .
47,931
public function filter_rest_post_dispatch ( WP_HTTP_Response $ result , WP_REST_Server $ server , WP_REST_Request $ request ) { if ( ! $ this -> should_dispatch ( ) ) { return $ result ; } $ this -> before_output ( ) ; foreach ( $ this -> get_outputters ( 'headers' ) as $ id => $ output ) { $ output -> output ( ) ; } $...
Filters a REST API response in order to add QM s headers .
47,932
public function log_file_load ( $ override , $ domain , $ mofile ) { if ( 'query-monitor' === $ domain && self :: hide_qm ( ) ) { return $ override ; } $ trace = new QM_Backtrace ( ) ; $ filtered = $ trace -> get_filtered_trace ( ) ; $ caller = array ( ) ; foreach ( $ filtered as $ i => $ item ) { if ( in_array ( $ ite...
Store log data .
47,933
public function log_script_file_load ( $ file , $ handle , $ domain ) { $ trace = new QM_Backtrace ( ) ; $ filtered = $ trace -> get_filtered_trace ( ) ; $ caller = $ filtered [ 0 ] ; $ this -> data [ 'languages' ] [ $ domain ] [ ] = array ( 'caller' => $ caller , 'domain' => $ domain , 'file' => $ file , 'found' => ( ...
Filters the file path for loading script translations for the given script handle and textdomain .
47,934
public function filter_wp_redirect ( $ location , $ status ) { if ( ! $ this -> should_dispatch ( ) ) { return $ location ; } $ this -> before_output ( ) ; foreach ( $ this -> get_outputters ( 'headers' ) as $ id => $ output ) { $ output -> output ( ) ; } $ this -> after_output ( ) ; return $ location ; }
Filters a redirect location in order to output QM s headers .
47,935
protected function build_filter ( $ name , array $ values , $ label , $ args = array ( ) ) { if ( empty ( $ values ) ) { return esc_html ( $ label ) ; } if ( ! is_array ( $ args ) ) { $ args = array ( 'highlight' => $ args , ) ; } $ args = array_merge ( array ( 'highlight' => '' , 'prepend' => array ( ) , 'append' => a...
Returns the table filter controls . Safe for output .
47,936
protected function build_sorter ( $ heading = '' ) { $ out = '' ; $ out .= '<label class="qm-th">' ; $ out .= '<span class="qm-sort-heading">' ; if ( '#' === $ heading ) { $ out .= '<span class="qm-screen-reader-text">' . esc_html__ ( 'Sequence' , 'query-monitor' ) . '</span>' ; } elseif ( $ heading ) { $ out .= esc_ht...
Returns the column sorter controls . Safe for output .
47,937
public static function format_sql ( $ sql ) { $ sql = str_replace ( array ( "\r\n" , "\r" , "\n" , "\t" ) , ' ' , $ sql ) ; $ sql = esc_html ( $ sql ) ; $ sql = trim ( $ sql ) ; $ regex = 'ADD|AFTER|ALTER|AND|BEGIN|COMMIT|CREATE|DELETE|DESCRIBE|DO|DROP|ELSE|END|EXCEPT|EXPLAIN|FROM|GROUP|HAVING|INNER|INSERT|INTERSECT|LE...
Returns the given SQL string in a nicely presented format . Safe for output .
47,938
public static function output_filename ( $ text , $ file , $ line = 0 , $ is_filename = false ) { if ( empty ( $ file ) ) { if ( $ is_filename ) { return esc_html ( $ text ) ; } else { return '<code>' . esc_html ( $ text ) . '</code>' ; } } $ link_line = ( $ line ) ? $ line : 1 ; if ( ! self :: has_clickable_links ( ) ...
Returns a file path name and line number or a clickable link to the file . Safe for output .
47,939
public function filter_user_has_cap ( array $ user_caps , array $ required_caps , array $ args , WP_User $ user ) { if ( 'view_query_monitor' !== $ args [ 0 ] ) { return $ user_caps ; } if ( array_key_exists ( 'view_query_monitor' , $ user_caps ) ) { return $ user_caps ; } if ( ! is_multisite ( ) && user_can ( $ args [...
Filter a user s capabilities so they can be altered at runtime .
47,940
public function process ( ) { $ this -> types = array ( 'errors' => array ( 'warning' => _x ( 'Warning' , 'PHP error level' , 'query-monitor' ) , 'notice' => _x ( 'Notice' , 'PHP error level' , 'query-monitor' ) , 'strict' => _x ( 'Strict' , 'PHP error level' , 'query-monitor' ) , 'deprecated' => _x ( 'Deprecated' , 'P...
Runs post - processing on the collected errors and updates the errors collected in the data - > errors property .
47,941
public function is_affected_component ( $ component , $ component_type , $ component_context ) { if ( empty ( $ component ) ) { return false ; } return ( $ component -> type === $ component_type && $ component -> context === $ component_context ) ; }
Checks if the component is of the given type and has the given context . This is used to scope an error to a plugin or theme .
47,942
public function is_reportable_error ( $ error_no , $ flags ) { if ( ! is_null ( $ flags ) ) { $ result = $ error_no & $ flags ; } else { $ result = 1 ; } return ( bool ) $ result ; }
Checks if the error number specified is viewable based on the flags specified .
47,943
public function filter_user_has_cap ( array $ user_caps , array $ caps , array $ args ) { $ trace = new QM_Backtrace ( ) ; $ result = true ; foreach ( $ caps as $ cap ) { if ( empty ( $ user_caps [ $ cap ] ) ) { $ result = false ; break ; } } $ this -> data [ 'caps' ] [ ] = array ( 'args' => $ args , 'trace' => $ trace...
Logs user capability checks .
47,944
public function filter_map_meta_cap ( array $ required_caps , $ cap , $ user_id , array $ args ) { if ( ! is_multisite ( ) ) { return $ required_caps ; } if ( ! is_super_admin ( $ user_id ) ) { return $ required_caps ; } $ trace = new QM_Backtrace ( ) ; $ result = ( ! in_array ( 'do_not_allow' , $ required_caps , true ...
Logs user capability checks for Super Admins on Multisite .
47,945
public function register ( ) { parent :: register ( ) ; if ( class_exists ( 'Laravel\Lumen\Application' ) && ! defined ( 'SOCIALITEPROVIDERS_STATELESS' ) ) { define ( 'SOCIALITEPROVIDERS_STATELESS' , true ) ; } $ this -> app -> singleton ( ConfigRetrieverInterface :: class , function ( ) { return new ConfigRetriever ( ...
Register the provider services .
47,946
public function getTokenCredentials ( TemporaryCredentials $ temporaryCredentials , $ temporaryIdentifier , $ verifier ) { if ( $ temporaryIdentifier !== $ temporaryCredentials -> getIdentifier ( ) ) { throw new \ InvalidArgumentException ( 'Temporary identifier passed back by server does not match that of stored tempo...
Retrieves token credentials by passing in the temporary credentials the temporary credentials identifier as passed back by the server and finally the verifier code .
47,947
protected function buildOAuth1Provider ( SocialiteManager $ socialite , $ providerClass , $ providerName , $ oauth1Server ) { $ this -> classExtends ( $ oauth1Server , OAuth1Server :: class ) ; $ config = $ this -> getConfig ( $ providerClass , $ providerName ) ; $ configServer = $ socialite -> formatConfig ( $ config ...
Build an OAuth 1 provider instance .
47,948
private function getIdsWithAttributes ( $ id , $ attributes = [ ] ) { $ ids = [ ] ; if ( $ id instanceof Model ) { $ ids [ $ id -> getKey ( ) ] = $ attributes ; } elseif ( $ id instanceof Collection ) { foreach ( $ id as $ model ) { $ ids [ $ model -> getKey ( ) ] = $ attributes ; } } elseif ( is_array ( $ id ) ) { for...
Cleans the ids and ids with attributes Returns an array with and array of ids and array of id = > attributes .
47,949
function version ( $ version ) { $ this -> version = ( int ) $ version ; if ( $ version == 2 ) { $ this -> url_base = $ this -> url_base . "/2" ; } }
Set the version on the url
47,950
function api ( $ path , $ post_data = array ( ) ) { $ components = explode ( "/" , $ path ) ; $ component = $ components [ 0 ] ; if ( count ( $ components ) > 2 ) { array_shift ( $ components ) ; $ method_str = implode ( "_" , $ components ) ; $ components = array ( $ component , $ method_str ) ; } if ( preg_match ( "/...
Make api calls
47,951
public function dbg ( $ var , $ continue = 0 , $ element = "pre" , $ extra = "" ) { echo "<" . $ element . ">" ; echo "Vartype: " . gettype ( $ var ) . "\n" ; if ( is_array ( $ var ) ) echo "Elements: " . count ( $ var ) . "\n" ; elseif ( is_string ( $ var ) ) echo "Length: " . strlen ( $ var ) . "\n" ; if ( $ extra ) ...
Debug helper function
47,952
public function make ( $ file , $ content ) { if ( $ this -> exists ( $ file ) ) { throw new FileAlreadyExists ( ) ; } return file_put_contents ( $ file , $ content ) ; }
Make a file .
47,953
public function tableNames ( ) { return collect ( DB :: select ( $ this -> getQuery ( ) ) ) -> pluck ( 'name' ) -> reject ( function ( $ name ) { return $ this -> skips ( ) -> contains ( $ name ) ; } ) ; }
retrieve table names from database .
47,954
private function getAttributes ( ) { collect ( $ this -> foreignKeys ) -> each ( function ( $ key , $ value ) { $ Schema = collect ( Schema :: getColumnListing ( $ key ) ) ; $ Schema = $ Schema -> reject ( function ( $ value , $ key ) { return str_contains ( $ value , 'id' ) ; } ) ; $ this -> relationAttributes [ $ key...
Deduce relational arttributes .
47,955
private function relationData ( ) { $ onData = collect ( $ this -> data ) -> reject ( function ( $ value , $ key ) { return ! str_contains ( $ key , 'on' ) ; } ) ; $ foreignKeys = collect ( $ this -> data ) -> reject ( function ( $ value , $ key ) { return ! str_contains ( $ key , 'tbl' ) ; } ) ; $ this -> onData = arr...
Deduce onData and foreingKeys .
47,956
public function dataScaffold ( $ spec = null ) { $ data = collect ( $ this -> data ) -> reject ( function ( $ value , $ key ) use ( $ spec ) { if ( $ spec == 'migration' ) { return ! str_contains ( $ key , 'opt' ) ; } return ! str_contains ( $ key , 'atr' ) ; } ) ; return array_values ( $ data -> toArray ( ) ) ; }
Data for migration and views .
47,957
public static function make ( ) { $ class = str_replace ( 'DatabaseManager' , ucfirst ( config ( 'database.default' ) ) . 'Database' , self :: class ) ; try { return new self ( new $ class ( ) ) ; } catch ( \ Exception $ e ) { return new self ( new MysqlDatabase ( ) ) ; } }
New instance based on app s database driver .
47,958
public function getTablesNames ( ) { return $ this -> database -> tableNames ( ) -> filter ( function ( $ name ) { return ! in_array ( $ name , $ this -> exclude ) ; } ) ; }
Get all tables names .
47,959
public function deleteMsg ( $ id ) { $ scaffold = Scaffoldinterface :: FindOrFail ( $ id ) ; if ( Schema :: hasTable ( $ scaffold -> tablename ) ) { $ table = $ scaffold -> tablename ; return view ( 'scaffold-interface::template.DeleteMessage.delete' , compact ( 'table' ) ) -> render ( ) ; } $ msg = Ajaxis :: Mtdeletin...
Delete confirmation message by ajaxis .
47,960
public function migrate ( ) { try { Artisan :: call ( 'migrate' , [ '--path' => config ( 'amranidev.config.database' ) ] ) ; exec ( 'cd ' . base_path ( ) . ' && composer dump-autoload' ) ; } catch ( \ Exception $ e ) { Session :: flash ( 'status' , $ e -> getMessage ( ) ) ; return redirect ( 'scaffold' ) ; } $ Msg = st...
Migrate schema .
47,961
public function rollback ( ) { if ( ! Scaffoldinterface :: all ( ) -> count ( ) ) { Session :: flash ( 'status' , 'Nothing To Rollback' ) ; return redirect ( 'scaffold' ) ; } try { Artisan :: call ( 'migrate:rollback' ) ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } $ Msg = str_replace ( "\n" , '' , A...
Rollback schema .
47,962
public function manyToManyForm ( Request $ request ) { $ dummyData = DatabaseManager :: tableNames ( ) ; $ elements = Ajaxis :: MtcreateFormModal ( [ [ 'type' => 'select' , 'name' => 'table1' , 'key' => 'table1' , 'value' => $ dummyData ] , [ 'type' => 'select' , 'name' => 'table2' , 'key' => 'table2' , 'value' => $ du...
ManyToMany form .
47,963
public function manyToMany ( Request $ request ) { if ( $ this -> check ( $ request -> toArray ( ) ) ) { Session :: flash ( 'status' , 'Error! could not be related' ) ; return redirect ( 'scaffold' ) ; } $ table1 = DB :: table ( 'scaffoldinterfaces' ) -> where ( 'tablename' , $ request -> toArray ( ) [ 'table1' ] ) -> ...
ManyToMany generate .
47,964
public function graph ( ) { $ nodes = Scaffoldinterface :: all ( ) -> map ( function ( Scaffoldinterface $ entity ) { return [ 'id' => $ entity -> id , 'label' => $ entity -> tablename ] ; } ) -> toJson ( ) ; $ edges = Relation :: all ( ) -> map ( function ( Relation $ relation ) { return [ 'from' => $ relation -> scaf...
Transform entities into a grahp .
47,965
private function order ( ) { $ result = [ ] ; $ data = $ this -> request ; if ( $ data [ 'table1' ] > $ data [ 'table2' ] ) { $ result [ 'first' ] = $ data [ 'table2' ] ; $ result [ 'second' ] = $ data [ 'table1' ] ; } else { $ result [ 'first' ] = $ data [ 'table1' ] ; $ result [ 'second' ] = $ data [ 'table2' ] ; } r...
Determine which table is ordered alphabetically .
47,966
private function model ( ) { $ this -> relationship ( config ( 'amranidev.config.model' ) . DIRECTORY_SEPARATOR . ucfirst ( str_singular ( $ this -> tables [ 'first' ] ) ) . '.php' , $ this -> tables [ 'second' ] ) ; $ this -> relationship ( config ( 'amranidev.config.model' ) . DIRECTORY_SEPARATOR . ucfirst ( str_sing...
Add relationships methods to models .
47,967
private function migration ( ) { $ migrationContent = "<?php\n\n" . view ( 'scaffold-interface::template.ManyToMany.migration' , $ this -> tables ) -> render ( ) ; $ migrationFileName = date ( 'Y' ) . '_' . date ( 'm' ) . '_' . date ( 'd' ) . '_' . date ( 'his' ) . '_' . ucfirst ( $ this -> tables [ 'first' ] ) . ucfir...
Make migration file .
47,968
private function relationship ( $ path , $ model ) { $ lines = file ( $ path , FILE_IGNORE_NEW_LINES ) ; $ last = count ( $ lines ) - 1 ; unset ( $ lines [ $ last ] ) ; $ result = implode ( "\n" , array_values ( $ lines ) ) ; $ model = view ( 'scaffold-interface::template.ManyToMany.model' , [ 'model' => $ model ] ) ->...
Generate relationships methods .
47,969
private function migrationPath ( ) { $ FileName = date ( 'Y' ) . '_' . date ( 'm' ) . '_' . date ( 'd' ) . '_' . date ( 'his' ) . '_' . $ this -> parser -> plural ( ) . '.php' ; return config ( 'amranidev.config.migration' ) . '/' . $ FileName ; }
Get migration file path .
47,970
private function generateView ( $ view ) { return $ this -> indenter -> indent ( view ( 'scaffold-interface::template.views.' . $ this -> parser -> getTemplate ( ) . '.' . $ view , [ 'parser' => $ this -> parser , 'dataSystem' => $ this -> dataSystem ] ) -> render ( ) ) ; }
Generate View .
47,971
public function generate ( ) { $ views = new \ StdClass ( ) ; foreach ( $ this -> views as $ view ) { $ views -> { $ view } = $ this -> generateView ( $ view ) ; } return $ views ; }
Generate Views .
47,972
public function getAttributes ( ) { return collect ( Schema :: getColumnListing ( $ this -> table ) ) -> filter ( function ( $ column ) { return ! in_array ( $ column , $ this -> exclude ) ; } ) ; }
Get attributes from an existing table .
47,973
public function addRole ( Request $ request ) { $ user = \ App \ User :: findOrfail ( $ request -> user_id ) ; $ user -> assignRole ( $ request -> role_name ) ; return redirect ( 'scaffold-users/edit/' . $ request -> user_id ) ; }
Assign Role to user .
47,974
public function addPermission ( Request $ request ) { $ user = \ App \ User :: findorfail ( $ request -> user_id ) ; $ user -> givePermissionTo ( $ request -> permission_name ) ; return redirect ( 'scaffold-users/edit/' . $ request -> user_id ) ; }
Assign Permission to a user .
47,975
public function revokePermission ( $ permission , $ user_id ) { $ user = \ App \ User :: findorfail ( $ user_id ) ; $ user -> revokePermissionTo ( str_slug ( $ permission , ' ' ) ) ; return redirect ( 'scaffold-users/edit/' . $ user_id ) ; }
revoke Permission to a user .
47,976
public function revokeRole ( $ role , $ user_id ) { $ user = \ App \ User :: findorfail ( $ user_id ) ; $ user -> removeRole ( str_slug ( $ role , ' ' ) ) ; return redirect ( 'scaffold-users/edit/' . $ user_id ) ; }
revoke Role to a a user .
47,977
private function clearRoutes ( $ remove ) { $ path = config ( 'amranidev.config.routes' ) ; $ lines = file ( $ path , FILE_IGNORE_NEW_LINES ) ; foreach ( array_filter ( $ lines , function ( $ line ) use ( $ remove ) { return strstr ( $ line , $ remove ) ; } ) as $ key => $ line ) { unset ( $ lines [ $ key ] ) ; } retur...
Clear routes .
47,978
public function setHttpClient ( $ httpClient ) : void { if ( ! $ httpClient instanceof ClientInterface && ! $ httpClient instanceof HttpClient ) { throw new \ LogicException ( 'Client must be an instance of Http\\Client\\HttpClient or Psr\\Http\\Client\\ClientInterface' ) ; } $ this -> httpClient = $ httpClient ; }
Sets the http client .
47,979
public function create ( string $ serviceName , array $ args = [ ] ) { if ( ! $ this -> registry -> has ( $ serviceName ) ) { throw new \ LogicException ( sprintf ( 'The service "%s" is not registered.' , $ serviceName ) ) ; } $ classOrCallable = $ this -> registry -> get ( $ serviceName ) ; if ( is_callable ( $ classO...
Creates a new service .
47,980
public function useHttpClient ( $ httpClient ) : self { if ( ! $ httpClient instanceof ClientInterface && ! $ httpClient instanceof HttpClient ) { throw new \ LogicException ( 'Client must be an instance of Http\\Client\\HttpClient or Psr\\Http\\Client\\ClientInterface' ) ; } $ this -> httpClient = $ httpClient ; retur...
Uses the given http client .
47,981
public function build ( ) : Swap { $ serviceFactory = new Factory ( $ this -> httpClient , $ this -> requestFactory ) ; $ services = [ ] ; foreach ( $ this -> services as $ name => $ options ) { $ services [ ] = $ serviceFactory -> create ( $ name , $ options ) ; } $ service = new Chain ( $ services ) ; $ exchanger = n...
Builds Swap .
47,982
private function registerServices ( ) : void { $ services = ExchangerRegistry :: getServices ( ) ; foreach ( $ services as $ name => $ class ) { self :: register ( $ name , $ class ) ; } }
Registers the core services .
47,983
protected function parseServerParameters ( Buffer & $ buffer ) { $ parsed = [ ] ; $ parameterSize = $ buffer -> readInt32Signed ( ) ; for ( $ i = 0 ; $ i < $ parameterSize ; $ i ++ ) { $ dataType = $ buffer -> readInt8Signed ( ) ; switch ( $ dataType ) { case 1 : $ parsed [ $ i ] = $ buffer -> readInt32Signed ( ) ; bre...
Parse the server response parameters
47,984
protected function processDetails ( Buffer & $ buffer , Result & $ result ) { parent :: processDetails ( $ buffer , $ result ) ; $ result -> add ( 'mapname' , 'Panau' ) ; $ result -> add ( 'dedicated' , 'true' ) ; }
Overload so we can add in some static data points
47,985
protected function processPlayersAndTeams ( Buffer & $ buffer , Result & $ result ) { while ( $ buffer -> getLength ( ) ) { $ result -> addPlayer ( 'name' , $ buffer -> readString ( ) ) ; $ result -> addPlayer ( 'steamid' , $ buffer -> readString ( ) ) ; $ result -> addPlayer ( 'ping' , $ buffer -> readInt16 ( ) ) ; } ...
Override the parent this protocol is returned differently
47,986
public function write ( $ data ) { try { if ( is_null ( $ this -> socket ) ) { $ this -> create ( ) ; } return fwrite ( $ this -> socket , $ data ) ; } catch ( \ Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Write data to the socket
47,987
protected function create ( ) { $ remote_addr = sprintf ( "%s://%s:%d" , $ this -> transport , $ this -> ip , $ this -> port ) ; $ context = stream_context_create ( [ 'socket' => [ 'bindto' => '0:0' , ] , ] ) ; $ errno = null ; $ errstr = null ; if ( ( $ this -> socket = @ stream_socket_client ( $ remote_addr , $ errno...
Create a new socket for this query
47,988
public function getResponses ( array $ sockets , $ timeout , $ stream_timeout ) { $ loop_active = true ; $ responses = [ ] ; $ sockets_tmp = [ ] ; foreach ( $ sockets as $ socket_id => $ socket_data ) { $ socket = $ socket_data [ 'socket' ] ; $ sockets_tmp [ $ socket_id ] = $ socket -> get ( ) ; unset ( $ socket ) ; } ...
Pull the responses out of the stream
47,989
public function beforeSend ( Server $ server ) { if ( ! isset ( $ this -> options [ Server :: SERVER_OPTIONS_QUERY_PORT ] ) || empty ( $ this -> options [ Server :: SERVER_OPTIONS_QUERY_PORT ] ) ) { throw new Exception ( __METHOD__ . " Missing required setting '" . Server :: SERVER_OPTIONS_QUERY_PORT . "'." ) ; } forea...
Before we send off the queries we need to update the packets
47,990
protected function processProperties ( $ data ) { $ properties = [ ] ; $ items = explode ( ' ' , $ data ) ; foreach ( $ items as $ item ) { list ( $ key , $ value ) = array_pad ( explode ( '=' , $ item , 2 ) , 2 , '' ) ; $ properties [ $ key ] = utf8_encode ( str_replace ( [ '\\s' , ] , [ ' ' , ] , $ value ) ) ; } retu...
Process the properties of the data .
47,991
protected function processPlayers ( Buffer $ buffer ) { $ result = new Result ( ) ; $ num_players = $ buffer -> readInt8 ( ) ; $ result -> add ( 'num_players' , $ num_players ) ; if ( $ num_players == 0 ) { return $ result -> fetch ( ) ; } for ( $ player = 0 ; $ player < $ num_players ; $ player ++ ) { $ result -> addP...
Specific player parse for The Ship
47,992
public function beforeSend ( Server $ server ) { $ this -> server_code = implode ( '' , array_map ( 'chr' , explode ( '.' , $ server -> ip ( ) ) ) ) . pack ( "S" , $ server -> portClient ( ) ) ; foreach ( $ this -> packets as $ packetType => $ packet ) { $ this -> packets [ $ packetType ] = sprintf ( $ packet , $ this ...
Handle some work before sending the packets out to the server
47,993
protected function processStatus ( Buffer $ buffer ) { $ result = new Result ( ) ; $ result -> add ( 'dedicated' , 1 ) ; $ result -> add ( 'password' , $ buffer -> readInt8 ( ) ) ; $ result -> add ( 'num_players' , $ buffer -> readInt16 ( ) ) ; $ result -> add ( 'max_players' , $ buffer -> readInt16 ( ) ) ; $ result ->...
Handles processing the server status data
47,994
protected function checkAndSetIpPort ( $ ip_address ) { if ( substr_count ( $ ip_address , ':' ) > 1 ) { if ( strstr ( $ ip_address , ']:' ) ) { $ server_addr = explode ( ':' , $ ip_address ) ; $ this -> port_client = ( int ) array_pop ( $ server_addr ) ; $ this -> ip = implode ( ':' , $ server_addr ) ; unset ( $ serve...
Check and set the ip address for this server
47,995
protected function checkAndSetServerOptions ( ) { if ( array_key_exists ( self :: SERVER_OPTIONS_QUERY_PORT , $ this -> options ) ) { $ this -> port_query = ( int ) $ this -> options [ self :: SERVER_OPTIONS_QUERY_PORT ] ; } else { $ this -> port_query = $ this -> protocol -> findQueryPort ( $ this -> port_client ) ; }...
Check and set any server specific options
47,996
public function socketGet ( ) { $ socket = null ; if ( count ( $ this -> sockets ) > 0 ) { $ socket = array_pop ( $ this -> sockets ) ; } return $ socket ; }
Get a socket from the list to reuse if any are available
47,997
protected function processPackets ( $ packet_id , array $ packets = [ ] ) { $ packs = [ ] ; foreach ( $ packets as $ i => $ packet ) { $ buffer = new Buffer ( $ packet ) ; if ( $ this -> source_engine == self :: GOLDSOURCE_ENGINE ) { $ packet_number = $ buffer -> readInt8 ( ) ; if ( $ i == 0 ) { $ buffer -> read ( 4 ) ...
Process the split packets and decompress if necessary
47,998
protected function processDetailsGoldSource ( Buffer $ buffer ) { $ result = new Result ( ) ; $ result -> add ( 'address' , $ buffer -> readString ( ) ) ; $ result -> add ( 'hostname' , $ buffer -> readString ( ) ) ; $ result -> add ( 'map' , $ buffer -> readString ( ) ) ; $ result -> add ( 'game_dir' , $ buffer -> rea...
Handles processing the server details from goldsource response
47,999
public function challengeParseAndApply ( Buffer $ challenge_buffer ) { $ challenge = substr ( preg_replace ( "/[^0-9\-]/si" , "" , $ challenge_buffer -> getBuffer ( ) ) , 1 ) ; $ challenge_result = '' ; if ( $ challenge ) { $ challenge_result = sprintf ( "%c%c%c%c" , ( $ challenge >> 24 ) , ( $ challenge >> 16 ) , ( $ ...
Parse the challenge response and apply it to all the packet types