idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
47,400
public function transaction ( \ Closure $ callback ) { try { $ this -> pdo -> beginTransaction ( ) ; $ transaction = $ this -> container -> build ( '\\Pixie\\QueryBuilder\\Transaction' , array ( $ this -> connection ) ) ; $ callback ( $ transaction ) ; $ this -> pdo -> commit ( ) ; return $ this ; } catch ( Transaction...
Runs a transaction
47,401
private function getUpdateStatement ( $ data ) { $ bindings = array ( ) ; $ statement = '' ; foreach ( $ data as $ key => $ value ) { if ( $ value instanceof Raw ) { $ statement .= $ this -> wrapSanitizer ( $ key ) . '=' . $ value . ',' ; } else { $ statement .= $ this -> wrapSanitizer ( $ key ) . '=?,' ; $ bindings [ ...
Build fields assignment part of SET ... or ON DUBLICATE KEY UPDATE ... statements
47,402
protected function buildCriteriaWithType ( $ statements , $ key , $ type , $ bindValues = true ) { $ criteria = '' ; $ bindings = array ( ) ; if ( isset ( $ statements [ $ key ] ) ) { list ( $ criteria , $ bindings ) = $ this -> buildCriteria ( $ statements [ $ key ] , $ bindValues ) ; if ( $ criteria ) { $ criteria = ...
Build criteria string and binding with various types added like WHERE and Having
47,403
protected function buildJoin ( $ statements ) { $ sql = '' ; if ( ! array_key_exists ( 'joins' , $ statements ) || ! is_array ( $ statements [ 'joins' ] ) ) { return $ sql ; } foreach ( $ statements [ 'joins' ] as $ joinArr ) { if ( is_array ( $ joinArr [ 'table' ] ) ) { $ mainTable = $ joinArr [ 'table' ] [ 0 ] ; $ al...
Build join string
47,404
public function apply ( float $ x , float $ y ) : array { return [ $ x * $ this -> values [ 0 ] + $ y * $ this -> values [ 2 ] + $ this -> values [ 4 ] , $ x * $ this -> values [ 2 ] + $ x * $ this -> values [ 3 ] + $ this -> values [ 5 ] , ] ; }
Applies this matrix onto a point and returns the resulting viewport point .
47,405
public static function applyMaskPenaltyRule1 ( ByteMatrix $ matrix ) : int { return ( self :: applyMaskPenaltyRule1Internal ( $ matrix , true ) + self :: applyMaskPenaltyRule1Internal ( $ matrix , false ) ) ; }
Applies mask penalty rule 1 and returns the penalty .
47,406
public static function applyMaskPenaltyRule2 ( ByteMatrix $ matrix ) : int { $ penalty = 0 ; $ array = $ matrix -> getArray ( ) ; $ width = $ matrix -> getWidth ( ) ; $ height = $ matrix -> getHeight ( ) ; for ( $ y = 0 ; $ y < $ height - 1 ; ++ $ y ) { for ( $ x = 0 ; $ x < $ width - 1 ; ++ $ x ) { $ value = $ array [...
Applies mask penalty rule 2 and returns the penalty .
47,407
public static function applyMaskPenaltyRule4 ( ByteMatrix $ matrix ) : int { $ numDarkCells = 0 ; $ array = $ matrix -> getArray ( ) ; $ width = $ matrix -> getWidth ( ) ; $ height = $ matrix -> getHeight ( ) ; for ( $ y = 0 ; $ y < $ height ; ++ $ y ) { $ arrayY = $ array [ $ y ] ; for ( $ x = 0 ; $ x < $ width ; ++ $...
Applies mask penalty rule 4 and returns the penalty .
47,408
public static function getDataMaskBit ( int $ maskPattern , int $ x , int $ y ) : bool { switch ( $ maskPattern ) { case 0 : $ intermediate = ( $ y + $ x ) & 0x1 ; break ; case 1 : $ intermediate = $ y & 0x1 ; break ; case 2 : $ intermediate = $ x % 3 ; break ; case 3 : $ intermediate = ( $ y + $ x ) % 3 ; break ; case...
Returns the mask bit for getMaskPattern at x and y .
47,409
private static function applyMaskPenaltyRule1Internal ( ByteMatrix $ matrix , bool $ isHorizontal ) : int { $ penalty = 0 ; $ iLimit = $ isHorizontal ? $ matrix -> getHeight ( ) : $ matrix -> getWidth ( ) ; $ jLimit = $ isHorizontal ? $ matrix -> getWidth ( ) : $ matrix -> getHeight ( ) ; $ array = $ matrix -> getArray...
Helper function for applyMaskPenaltyRule1 .
47,410
public function ensureCapacity ( int $ size ) : void { if ( $ size > count ( $ this -> bits ) << 5 ) { $ this -> bits -> setSize ( ( $ size + 31 ) >> 5 ) ; } }
Ensures that the array has a minimum capacity .
47,411
public function set ( int $ i ) : void { $ this -> bits [ $ i >> 5 ] = $ this -> bits [ $ i >> 5 ] | 1 << ( $ i & 0x1f ) ; }
Sets a specific bit .
47,412
public function getNextSet ( int $ from ) : int { if ( $ from >= $ this -> size ) { return $ this -> size ; } $ bitsOffset = $ from >> 5 ; $ currentBits = $ this -> bits [ $ bitsOffset ] ; $ bitsLength = count ( $ this -> bits ) ; $ currentBits &= ~ ( ( 1 << ( $ from & 0x1f ) ) - 1 ) ; while ( 0 === $ currentBits ) { i...
Gets the next set bit position from a given position .
47,413
public function setBulk ( int $ i , int $ newBits ) : void { $ this -> bits [ $ i >> 5 ] = $ newBits ; }
Sets a bulk of bits .
47,414
public function setRange ( int $ start , int $ end ) : void { if ( $ end < $ start ) { throw new InvalidArgumentException ( 'End must be greater or equal to start' ) ; } if ( $ end === $ start ) { return ; } -- $ end ; $ firstInt = $ start >> 5 ; $ lastInt = $ end >> 5 ; for ( $ i = $ firstInt ; $ i <= $ lastInt ; ++ $...
Sets a range of bits .
47,415
public function clear ( ) : void { $ bitsLength = count ( $ this -> bits ) ; for ( $ i = 0 ; $ i < $ bitsLength ; ++ $ i ) { $ this -> bits [ $ i ] = 0 ; } }
Clears the bit array unsetting every bit .
47,416
public function isRange ( int $ start , int $ end , bool $ value ) : bool { if ( $ end < $ start ) { throw new InvalidArgumentException ( 'End must be greater or equal to start' ) ; } if ( $ end === $ start ) { return true ; } -- $ end ; $ firstInt = $ start >> 5 ; $ lastInt = $ end >> 5 ; for ( $ i = $ firstInt ; $ i ...
Checks if a range of bits is set or not set .
47,417
public function appendBit ( bool $ bit ) : void { $ this -> ensureCapacity ( $ this -> size + 1 ) ; if ( $ bit ) { $ this -> bits [ $ this -> size >> 5 ] = $ this -> bits [ $ this -> size >> 5 ] | ( 1 << ( $ this -> size & 0x1f ) ) ; } ++ $ this -> size ; }
Appends a bit to the array .
47,418
public function appendBitArray ( self $ other ) : void { $ otherSize = $ other -> getSize ( ) ; $ this -> ensureCapacity ( $ this -> size + $ other -> getSize ( ) ) ; for ( $ i = 0 ; $ i < $ otherSize ; ++ $ i ) { $ this -> appendBit ( $ other -> get ( $ i ) ) ; } }
Appends another bit array to this array .
47,419
public function xorBits ( self $ other ) : void { $ bitsLength = count ( $ this -> bits ) ; $ otherBits = $ other -> getBitArray ( ) ; if ( $ bitsLength !== count ( $ otherBits ) ) { throw new InvalidArgumentException ( 'Sizes don\'t match' ) ; } for ( $ i = 0 ; $ i < $ bitsLength ; ++ $ i ) { $ this -> bits [ $ i ] = ...
Makes an exclusive - or comparision on the current bit array .
47,420
public function toBytes ( int $ bitOffset , int $ numBytes ) : SplFixedArray { $ bytes = new SplFixedArray ( $ numBytes ) ; for ( $ i = 0 ; $ i < $ numBytes ; ++ $ i ) { $ byte = 0 ; for ( $ j = 0 ; $ j < 8 ; ++ $ j ) { if ( $ this -> get ( $ bitOffset ) ) { $ byte |= 1 << ( 7 - $ j ) ; } ++ $ bitOffset ; } $ bytes [ $...
Converts the bit array to a byte array .
47,421
public function reverse ( ) : void { $ newBits = new SplFixedArray ( count ( $ this -> bits ) ) ; for ( $ i = 0 ; $ i < $ this -> size ; ++ $ i ) { if ( $ this -> get ( $ this -> size - $ i - 1 ) ) { $ newBits [ $ i >> 5 ] = $ newBits [ $ i >> 5 ] | ( 1 << ( $ i & 0x1f ) ) ; } } $ this -> bits = $ newBits ; }
Reverses the array .
47,422
public function getNumBlocks ( ) : int { $ total = 0 ; foreach ( $ this -> ecBlocks as $ ecBlock ) { $ total += $ ecBlock -> getCount ( ) ; } return $ total ; }
Returns the total number of EC block appearances .
47,423
public static function getCharacterSetEciByValue ( int $ value ) : ? self { if ( $ value < 0 || $ value >= 900 ) { throw new InvalidArgumentException ( 'Value must be between 0 and 900' ) ; } $ valueToEci = self :: valueToEci ( ) ; if ( ! array_key_exists ( $ value , $ valueToEci ) ) { return null ; } return $ valueToE...
Gets character set ECI by value .
47,424
public static function getCharacterSetEciByName ( string $ name ) : ? self { $ nameToEci = self :: nameToEci ( ) ; $ name = strtolower ( $ name ) ; if ( ! array_key_exists ( $ name , $ nameToEci ) ) { return null ; } return $ nameToEci [ $ name ] ; }
Returns character set ECI by name .
47,425
public static function getProvisionalVersionForDimension ( int $ dimension ) : self { if ( 1 !== $ dimension % 4 ) { throw new InvalidArgumentException ( 'Dimension is not 1 mod 4' ) ; } return self :: getVersionForNumber ( intdiv ( $ dimension - 17 , 4 ) ) ; }
Gets a provisional version number for a specific dimension .
47,426
public static function getVersionForNumber ( int $ versionNumber ) : self { if ( $ versionNumber < 1 || $ versionNumber > 40 ) { throw new InvalidArgumentException ( 'Version number must be between 1 and 40' ) ; } return self :: versions ( ) [ $ versionNumber - 1 ] ; }
Gets a version instance for a specific version number .
47,427
public static function decodeVersionInformation ( int $ versionBits ) : ? self { $ bestDifference = PHP_INT_MAX ; $ bestVersion = 0 ; foreach ( self :: VERSION_DECODE_INFO as $ i => $ targetVersion ) { if ( $ targetVersion === $ versionBits ) { return self :: getVersionForNumber ( $ i + 7 ) ; } $ bitsDifference = Forma...
Decodes version information from an integer and returns the version .
47,428
public function buildFunctionPattern ( ) : BitMatrix { $ dimension = $ this -> getDimensionForVersion ( ) ; $ bitMatrix = new BitMatrix ( $ dimension ) ; $ bitMatrix -> setRegion ( 0 , 0 , 9 , 9 ) ; $ bitMatrix -> setRegion ( $ dimension - 8 , 0 , 8 , 9 ) ; $ bitMatrix -> setRegion ( 0 , $ dimension - 8 , 9 , 8 ) ; $ m...
Builds the function pattern for the current version .
47,429
public static function unsignedRightShift ( int $ a , int $ b ) : int { return ( $ a >= 0 ? $ a >> $ b : ( ( $ a & 0x7fffffff ) >> $ b ) | ( 0x40000000 >> ( $ b - 1 ) ) ) ; }
Performs an unsigned right shift .
47,430
public static function numberOfTrailingZeros ( int $ i ) : int { $ lastPos = strrpos ( str_pad ( decbin ( $ i ) , 32 , '0' , STR_PAD_LEFT ) , '1' ) ; return $ lastPos === false ? 32 : 31 - $ lastPos ; }
Gets the number of trailing zeros .
47,431
public function writeString ( string $ content , string $ encoding = Encoder :: DEFAULT_BYTE_MODE_ECODING , ? ErrorCorrectionLevel $ ecLevel = null ) : string { if ( strlen ( $ content ) === 0 ) { throw new InvalidArgumentException ( 'Found empty contents' ) ; } if ( null === $ ecLevel ) { $ ecLevel = ErrorCorrectionLe...
Writes QR code and returns it as string .
47,432
public function writeFile ( string $ content , string $ filename , string $ encoding = Encoder :: DEFAULT_BYTE_MODE_ECODING , ? ErrorCorrectionLevel $ ecLevel = null ) : void { file_put_contents ( $ filename , $ this -> writeString ( $ content , $ encoding , $ ecLevel ) ) ; }
Writes QR code to a file .
47,433
public function get ( int $ x , int $ y ) : bool { $ offset = $ y * $ this -> rowSize + ( $ x >> 5 ) ; return 0 !== ( BitUtils :: unsignedRightShift ( $ this -> bits [ $ offset ] , ( $ x & 0x1f ) ) & 1 ) ; }
Gets the requested bit where true means black .
47,434
public function set ( int $ x , int $ y ) : void { $ offset = $ y * $ this -> rowSize + ( $ x >> 5 ) ; $ this -> bits [ $ offset ] = $ this -> bits [ $ offset ] | ( 1 << ( $ x & 0x1f ) ) ; }
Sets the given bit to true .
47,435
public function setRegion ( int $ left , int $ top , int $ width , int $ height ) : void { if ( $ top < 0 || $ left < 0 ) { throw new InvalidArgumentException ( 'Left and top must be non-negative' ) ; } if ( $ height < 1 || $ width < 1 ) { throw new InvalidArgumentException ( 'Width and height must be at least 1' ) ; }...
Sets a square region of the bit matrix to true .
47,436
public function getRow ( int $ y , BitArray $ row = null ) : BitArray { if ( null === $ row || $ row -> getSize ( ) < $ this -> width ) { $ row = new BitArray ( $ this -> width ) ; } $ offset = $ y * $ this -> rowSize ; for ( $ x = 0 ; $ x < $ this -> rowSize ; ++ $ x ) { $ row -> setBulk ( $ x << 5 , $ this -> bits [ ...
A fast method to retrieve one row of data from the matrix as a BitArray .
47,437
public function setRow ( int $ y , BitArray $ row ) : void { $ bits = $ row -> getBitArray ( ) ; for ( $ i = 0 ; $ i < $ this -> rowSize ; ++ $ i ) { $ this -> bits [ $ y * $ this -> rowSize + $ i ] = $ bits [ $ i ] ; } }
Sets a row of data from a BitArray .
47,438
public function getEnclosingRectangle ( ) : ? array { $ left = $ this -> width ; $ top = $ this -> height ; $ right = - 1 ; $ bottom = - 1 ; for ( $ y = 0 ; $ y < $ this -> height ; ++ $ y ) { for ( $ x32 = 0 ; $ x32 < $ this -> rowSize ; ++ $ x32 ) { $ bits = $ this -> bits [ $ y * $ this -> rowSize + $ x32 ] ; if ( 0...
This is useful in detecting the enclosing rectangle of a pure barcode .
47,439
public function getTopLeftOnBit ( ) : ? array { $ bitsOffset = 0 ; while ( $ bitsOffset < count ( $ this -> bits ) && 0 === $ this -> bits [ $ bitsOffset ] ) { ++ $ bitsOffset ; } if ( count ( $ this -> bits ) === $ bitsOffset ) { return null ; } $ x = intdiv ( $ bitsOffset , $ this -> rowSize ) ; $ y = ( $ bitsOffset ...
Gets the most top left set bit .
47,440
public function getBottomRightOnBit ( ) : ? array { $ bitsOffset = count ( $ this -> bits ) - 1 ; while ( $ bitsOffset >= 0 && 0 === $ this -> bits [ $ bitsOffset ] ) { -- $ bitsOffset ; } if ( $ bitsOffset < 0 ) { return null ; } $ x = intdiv ( $ bitsOffset , $ this -> rowSize ) ; $ y = ( $ bitsOffset % $ this -> rowS...
Gets the most bottom right set bit .
47,441
public function encode ( SplFixedArray $ data , SplFixedArray $ parity ) : void { for ( $ i = 0 ; $ i < $ this -> numRoots ; ++ $ i ) { $ parity [ $ i ] = 0 ; } $ iterations = $ this -> blockSize - $ this -> numRoots - $ this -> padding ; for ( $ i = 0 ; $ i < $ iterations ; ++ $ i ) { $ feedback = $ this -> indexOf [ ...
Encodes data and writes result back into parity array .
47,442
public function move ( float $ x , float $ y ) : self { $ path = clone $ this ; $ path -> operations [ ] = new Move ( $ x , $ y ) ; return $ path ; }
Moves the drawing operation to a certain position .
47,443
public function line ( float $ x , float $ y ) : self { $ path = clone $ this ; $ path -> operations [ ] = new Line ( $ x , $ y ) ; return $ path ; }
Draws a line from the current position to another position .
47,444
public function ellipticArc ( float $ xRadius , float $ yRadius , float $ xAxisRotation , bool $ largeArc , bool $ sweep , float $ x , float $ y ) : self { $ path = clone $ this ; $ path -> operations [ ] = new EllipticArc ( $ xRadius , $ yRadius , $ xAxisRotation , $ largeArc , $ sweep , $ x , $ y ) ; return $ path ; ...
Draws an elliptic arc from the current position to another position .
47,445
public function curve ( float $ x1 , float $ y1 , float $ x2 , float $ y2 , float $ x3 , float $ y3 ) : self { $ path = clone $ this ; $ path -> operations [ ] = new Curve ( $ x1 , $ y1 , $ x2 , $ y2 , $ x3 , $ y3 ) ; return $ path ; }
Draws a curve from the current position to another position .
47,446
public function append ( self $ other ) : self { $ path = clone $ this ; $ path -> operations = array_merge ( $ this -> operations , $ other -> operations ) ; return $ path ; }
Appends another path to this one .
47,447
public function get ( int $ x , int $ y ) : int { return $ this -> bytes [ $ y ] [ $ x ] ; }
Gets the byte for a specific position .
47,448
public function set ( int $ x , int $ y , int $ value ) : void { $ this -> bytes [ $ y ] [ $ x ] = $ value ; }
Sets the byte for a specific position .
47,449
public function clear ( int $ value ) : void { for ( $ y = 0 ; $ y < $ this -> height ; ++ $ y ) { for ( $ x = 0 ; $ x < $ this -> width ; ++ $ x ) { $ this -> bytes [ $ y ] [ $ x ] = $ value ; } } }
Clears the matrix with a specific value .
47,450
public function getCharacterCountBits ( Version $ version ) : int { $ number = $ version -> getVersionNumber ( ) ; if ( $ number <= 9 ) { $ offset = 0 ; } elseif ( $ number <= 26 ) { $ offset = 1 ; } else { $ offset = 2 ; } return $ this -> characterCountBitsForVersions [ $ offset ] ; }
Returns the number of bits used in a specific QR code version .
47,451
public function toCurves ( float $ fromX , float $ fromY ) : array { if ( sqrt ( ( $ fromX - $ this -> x ) ** 2 + ( $ fromY - $ this -> y ) ** 2 ) < self :: ZERO_TOLERANCE ) { return [ ] ; } if ( $ this -> xRadius < self :: ZERO_TOLERANCE || $ this -> yRadius < self :: ZERO_TOLERANCE ) { return [ new Line ( $ this -> x...
Converts the elliptic arc to multiple curves .
47,452
private function createUploadedFile ( UploadedFileInterface $ psrUploadedFile ) { $ temporaryPath = '' ; $ clientFileName = '' ; if ( UPLOAD_ERR_NO_FILE !== $ psrUploadedFile -> getError ( ) ) { $ temporaryPath = $ this -> getTemporaryPath ( ) ; $ psrUploadedFile -> moveTo ( $ temporaryPath ) ; $ clientFileName = $ psr...
Creates Symfony UploadedFile instance from PSR - 7 ones .
47,453
public function setTtl ( $ key , $ expire ) { if ( is_null ( $ expire ) ) { return ; } $ expire = ( int ) $ expire ; if ( $ expire > 0 ) { $ this -> getConnection ( ) -> expire ( $ key , $ expire ) ; } else { $ this -> getConnection ( ) -> persist ( $ key ) ; } }
Set a timeout on key .
47,454
public function remove ( array $ params ) { $ key = array_get ( $ params , 'key' ) ; $ member = array_get ( $ params , 'member' ) ; return $ this -> getConnection ( ) -> srem ( $ key , $ member ) ; }
Remove a member from a set .
47,455
public function index ( ) { return Admin :: content ( function ( Content $ content ) { $ content -> header ( 'Redis manager' ) ; $ content -> description ( 'Connections' ) ; $ content -> breadcrumb ( [ 'text' => 'Redis manager' ] ) ; $ connection = request ( 'conn' , 'default' ) ; $ manager = $ this -> manager ( ) ; $ ...
Index page .
47,456
public function edit ( Request $ request ) { return Admin :: content ( function ( Content $ content ) use ( $ request ) { $ connection = $ request -> get ( 'conn' , 'default' ) ; $ manager = $ this -> manager ( ) ; $ variables = [ 'conn' => $ connection , 'info' => $ manager -> getInformation ( ) , 'connections' => $ m...
Edit page .
47,457
public function console ( Request $ request ) { return Admin :: content ( function ( Content $ content ) use ( $ request ) { $ connection = $ request -> get ( 'conn' , 'default' ) ; $ manager = $ this -> manager ( ) ; $ vars = [ 'conn' => $ connection , 'info' => $ manager -> getInformation ( ) , 'connections' => $ man...
Redis console interface .
47,458
public function execute ( Request $ request ) { $ command = $ request -> get ( 'command' ) ; try { $ result = $ this -> manager ( ) -> execute ( $ command ) ; } catch ( \ Exception $ exception ) { return $ this -> renderException ( $ exception ) ; } if ( is_string ( $ result ) && Str :: startsWith ( $ result , [ 'ERR '...
Execute a redis command .
47,459
protected function getDumpedHtml ( $ var ) { ob_start ( ) ; dump ( $ var ) ; $ content = ob_get_contents ( ) ; ob_get_clean ( ) ; return substr ( $ content , strpos ( $ content , '<pre ' ) ) ; }
Get html of dumped variable .
47,460
public function getConnection ( $ connection = null ) { if ( $ connection ) { $ this -> connection = $ connection ; } return Redis :: connection ( $ this -> connection ) ; }
Get a registered connection instance .
47,461
public function scan ( $ pattern = '*' , $ count = 100 ) { $ client = $ this -> getConnection ( ) ; $ keys = [ ] ; foreach ( new Keyspace ( $ client -> client ( ) , $ pattern ) as $ item ) { $ keys [ ] = $ item ; if ( count ( $ keys ) == $ count ) { break ; } } $ script = <<<'LUA' local type = redis.call('type'...
Scan keys in redis by giving pattern .
47,462
public function fetch ( $ key ) { if ( ! $ this -> getConnection ( ) -> exists ( $ key ) ) { return [ ] ; } $ type = $ this -> getConnection ( ) -> type ( $ key ) -> __toString ( ) ; $ class = $ this -> { $ type } ( ) ; $ value = $ class -> fetch ( $ key ) ; $ ttl = $ class -> ttl ( $ key ) ; return compact ( 'key' , '...
Fetch value of a giving key .
47,463
public function update ( Request $ request ) { $ key = $ request -> get ( 'key' ) ; $ type = $ request -> get ( 'type' ) ; $ class = $ this -> { $ type } ( ) ; $ class -> update ( $ request -> all ( ) ) ; $ class -> setTtl ( $ key , $ request -> get ( 'ttl' ) ) ; }
Update a specified key .
47,464
public function del ( $ key ) { if ( is_string ( $ key ) ) { $ key = [ $ key ] ; } return $ this -> getConnection ( ) -> del ( $ key ) ; }
Remove the specified key .
47,465
public function remove ( array $ params ) { $ key = array_get ( $ params , 'key' ) ; $ member = array_get ( $ params , 'member' ) ; return $ this -> getConnection ( ) -> zrem ( $ key , $ member ) ; }
Remove a member from a sorted set .
47,466
public function remove ( array $ params ) { $ key = array_get ( $ params , 'key' ) ; $ index = array_get ( $ params , 'index' ) ; $ lua = <<<'LUA'redis.call('lset', KEYS[1], ARGV[1], '__DELETED__');redis.call('lrem', KEYS[1], 1, '__DELETED__');LUA ; return $ this -> getConnection ( ) -> eval ( $ lua , 1 , $ key , $ in...
Remove a member from list by index .
47,467
public function remove ( array $ params ) { $ key = array_get ( $ params , 'key' ) ; $ field = array_get ( $ params , 'field' ) ; return $ this -> getConnection ( ) -> hdel ( $ key , [ $ field ] ) ; }
Remove a field from a hash .
47,468
public function getScriptURL ( $ key ) { return isset ( $ this -> scripts [ $ key ] ) ? $ this -> scripts [ $ key ] : null ; }
Gets the Javascript source URLs .
47,469
private function extractWatermarkPath ( & $ manipulationGroup ) { if ( array_key_exists ( 'watermark' , $ manipulationGroup ) ) { $ watermarkPath = dirname ( $ manipulationGroup [ 'watermark' ] ) ; $ manipulationGroup [ 'watermark' ] = basename ( $ manipulationGroup [ 'watermark' ] ) ; return $ watermarkPath ; } }
Removes the watermark path from the manipulationGroup and returns it . This way it can be injected into the Glide server as the watermarks path .
47,470
public function watermarkOpacity ( int $ opacity ) { if ( $ opacity < 0 || $ opacity > 100 ) { throw InvalidManipulation :: valueNotInRange ( 'opacity' , $ opacity , 0 , 100 ) ; } return $ this -> addManipulation ( 'watermarkOpacity' , $ opacity ) ; }
Sets the opacity of the watermark . Only works with the imagick driver .
47,471
private function hasMultipleConversions ( array $ manipulations ) : bool { foreach ( $ manipulations as $ manipulation ) { if ( isset ( $ manipulation [ 0 ] ) && is_array ( $ manipulation [ 0 ] ) ) { return true ; } } return false ; }
Checks if the given manipulations has arrays inside or not .
47,472
public function getOption ( $ value ) { foreach ( $ this -> options as $ option ) { if ( $ option -> getValue ( ) === $ value ) { return $ option ; } } throw new DataGridColumnStatusException ( "Option [$value] does not exist" ) ; }
Get particular option
47,473
public function addOption ( $ value , $ text ) { if ( ! is_scalar ( $ value ) ) { throw new DataGridColumnStatusException ( 'Option value has to be scalar' ) ; } $ option = new Option ( $ this , $ value , $ text ) ; $ this -> options [ ] = $ option ; return $ option ; }
Add option to status select
47,474
public function setOptions ( array $ options ) { foreach ( $ options as $ value => $ text ) { $ this -> addOption ( $ value , $ text ) ; } return $ this ; }
Set all options at once
47,475
public function getTemplateVariables ( ) { return array_merge ( $ this -> template_variables , [ 'options' => $ this -> getOptions ( ) , 'column' => $ this -> getColumn ( ) , 'key' => $ this -> getKey ( ) , 'status' => $ this , ] ) ; }
Column can have variables that will be passed to custom template scope
47,476
public function submitted ( Form $ form ) { if ( ! isset ( $ form [ 'group_action' ] [ 'submit' ] ) || ! $ form [ 'group_action' ] [ 'submit' ] -> isSubmittedBy ( ) ) { return ; } $ values = $ form -> getValues ( ) ; $ values = $ values [ 'group_action' ] ; if ( $ values -> group_action === 0 || $ values -> group_actio...
Pass sub - form submission forward to custom submit function
47,477
protected function applyFilter ( $ row , Filter $ filter ) { if ( is_array ( $ row ) || $ row instanceof \ Traversable ) { if ( $ filter instanceof FilterDate ) { return $ this -> applyFilterDate ( $ row , $ filter ) ; } elseif ( $ filter instanceof FilterMultiSelect ) { return $ this -> applyFilterMultiSelect ( $ row ...
Apply fitler and tell whether row passes conditions or not
47,478
protected function applyFilterDate ( $ row , FilterDate $ filter ) { $ format = $ filter -> getPhpFormat ( ) ; $ condition = $ filter -> getCondition ( ) ; foreach ( $ condition as $ column => $ value ) { $ row_value = $ row [ $ column ] ; $ date = DateTimeHelper :: tryConvertToDateTime ( $ value , [ $ format ] ) ; if ...
Apply fitler date and tell whether row value matches or not
47,479
public function setPrimaryKey ( $ primary_key ) { if ( $ this -> dataModel instanceof DataModel ) { throw new DataGridException ( 'Please set datagrid primary key before setting datasource.' ) ; } $ this -> primary_key = $ primary_key ; return $ this ; }
By default ID you can change that
47,480
public function setDataSource ( $ source ) { $ this -> dataModel = new DataModel ( $ source , $ this -> primary_key ) ; $ this -> dataModel -> onBeforeFilter [ ] = [ $ this , 'beforeDataModelFilter' ] ; $ this -> dataModel -> onAfterFilter [ ] = [ $ this , 'afterDataModelFilter' ] ; $ this -> dataModel -> onAfterPagina...
Set Grid data source
47,481
public function setDefaultSort ( $ sort , $ use_on_reset = true ) { if ( is_string ( $ sort ) ) { $ sort = [ $ sort => 'ASC' ] ; } else { $ sort = ( array ) $ sort ; } $ this -> default_sort = $ sort ; $ this -> default_sort_use_on_reset = ( bool ) $ use_on_reset ; return $ this ; }
Set default sorting
47,482
public function getColumnDefaultSort ( $ columnKey ) { if ( isset ( $ this -> default_sort [ $ columnKey ] ) ) { return $ this -> default_sort [ $ columnKey ] ; } return NULL ; }
Return default sort for column if specified
47,483
public function findDefaultSort ( ) { if ( ! empty ( $ this -> sort ) ) { return ; } if ( $ this -> getSessionData ( '_grid_has_sorted' ) ) { return ; } if ( ! empty ( $ this -> default_sort ) ) { $ this -> sort = $ this -> default_sort ; } $ this -> saveSessionData ( '_grid_sort' , $ this -> sort ) ; }
User may set default sorting apply it
47,484
public function setSortable ( $ sortable = true ) { if ( $ this -> getItemsDetail ( ) ) { throw new DataGridException ( 'You can not use both sortable datagrid and items detail.' ) ; } $ this -> sortable = ( bool ) $ sortable ; return $ this ; }
Set grido to be sortable
47,485
public function setTreeView ( $ get_children_callback , $ tree_view_has_children_column = 'has_children' ) { if ( ! is_callable ( $ get_children_callback ) ) { throw new DataGridException ( 'Parameters to method DataGrid::setTreeView must be of type callable' ) ; } if ( is_callable ( $ tree_view_has_children_column ) )...
Setting tree view
47,486
public function addColumnText ( $ key , $ name , $ column = null ) { $ this -> addColumnCheck ( $ key ) ; $ column = $ column ? : $ key ; return $ this -> addColumn ( $ key , new Column \ ColumnText ( $ this , $ key , $ column , $ name ) ) ; }
Add text column with no other formating
47,487
public function addColumnLink ( $ key , $ name , $ href = null , $ column = null , array $ params = null ) { $ this -> addColumnCheck ( $ key ) ; $ column = $ column ? : $ key ; $ href = $ href ? : $ key ; if ( $ params === null ) { $ params = [ $ this -> primary_key ] ; } return $ this -> addColumn ( $ key , new Colum...
Add column with link
47,488
public function addColumnNumber ( $ key , $ name , $ column = null ) { $ this -> addColumnCheck ( $ key ) ; $ column = $ column ? : $ key ; return $ this -> addColumn ( $ key , new Column \ ColumnNumber ( $ this , $ key , $ column , $ name ) ) ; }
Add column with possible number formating
47,489
public function addColumnDateTime ( $ key , $ name , $ column = null ) { $ this -> addColumnCheck ( $ key ) ; $ column = $ column ? : $ key ; return $ this -> addColumn ( $ key , new Column \ ColumnDateTime ( $ this , $ key , $ column , $ name ) ) ; }
Add column with date formating
47,490
public function addColumnStatus ( $ key , $ name , $ column = null ) { $ this -> addColumnCheck ( $ key ) ; $ column = $ column ? : $ key ; return $ this -> addColumn ( $ key , new Column \ ColumnStatus ( $ this , $ key , $ column , $ name ) ) ; }
Add column status
47,491
public function getColumn ( $ key ) { if ( ! isset ( $ this -> columns [ $ key ] ) ) { throw new DataGridColumnNotFoundException ( "There is no column at key [$key] defined." ) ; } return $ this -> columns [ $ key ] ; }
Return existing column
47,492
public function addActionCallback ( $ key , $ name , $ callback = null ) { $ this -> addActionCheck ( $ key ) ; $ params = [ '__id' => $ this -> primary_key ] ; $ this -> actions [ $ key ] = $ action = new Column \ ActionCallback ( $ this , $ key , $ name , $ params ) ; if ( $ callback ) { if ( ! is_callable ( $ callba...
Create action callback
47,493
public function addFilterText ( $ key , $ name , $ columns = null ) { $ columns = $ columns === null ? [ $ key ] : ( is_string ( $ columns ) ? [ $ columns ] : $ columns ) ; if ( ! is_array ( $ columns ) ) { throw new DataGridException ( 'Filter Text can accept only array or string.' ) ; } $ this -> addFilterCheck ( $ k...
Add filter fot text search
47,494
public function addFilterSelect ( $ key , $ name , array $ options , $ column = null ) { $ column = $ column ? : $ key ; if ( ! is_string ( $ column ) ) { throw new DataGridException ( 'Filter Select can only filter in one column.' ) ; } $ this -> addFilterCheck ( $ key ) ; return $ this -> filters [ $ key ] = new Filt...
Add select box filter
47,495
public function addFilterMultiSelect ( $ key , $ name , array $ options , $ column = null ) { $ column = $ column ? : $ key ; if ( ! is_string ( $ column ) ) { throw new DataGridException ( 'Filter MultiSelect can only filter in one column.' ) ; } $ this -> addFilterCheck ( $ key ) ; return $ this -> filters [ $ key ] ...
Add multi select box filter
47,496
public function addFilterDate ( $ key , $ name , $ column = null ) { $ column = $ column ? : $ key ; if ( ! is_string ( $ column ) ) { throw new DataGridException ( 'FilterDate can only filter in one column.' ) ; } $ this -> addFilterCheck ( $ key ) ; return $ this -> filters [ $ key ] = new Filter \ FilterDate ( $ thi...
Add datepicker filter
47,497
public function getFilter ( $ key ) { if ( ! isset ( $ this -> filters [ $ key ] ) ) { throw new DataGridException ( "Filter [{$key}] is not defined" ) ; } return $ this -> filters [ $ key ] ; }
Get defined filter
47,498
public function setDefaultFilter ( array $ default_filter , $ use_on_reset = true ) { foreach ( $ default_filter as $ key => $ value ) { $ filter = $ this -> getFilter ( $ key ) ; if ( ! $ filter ) { throw new DataGridException ( "Can not set default value to nonexisting filter [$key]" ) ; } if ( $ filter instanceof Fi...
If we want to sent some initial filter
47,499
public function findDefaultFilter ( ) { if ( ! empty ( $ this -> filter ) ) { return ; } if ( $ this -> getSessionData ( '_grid_has_filtered' ) ) { return ; } if ( ! empty ( $ this -> default_filter ) ) { $ this -> filter = $ this -> default_filter ; } foreach ( $ this -> filter as $ key => $ value ) { $ this -> saveSe...
User may set default filter find it