idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
2,900
private function translate ( ) : self { if ( empty ( $ this -> translations ) ) { return $ this ; } $ lang = $ this -> get ( 'lang' ) ; foreach ( $ this -> attributes as $ key => $ attribute ) { if ( in_array ( $ key , $ this -> translations , true ) ) { $ this -> set ( $ key , __ ( $ attribute , [ ] , $ lang ) ) ; } }...
Localization of fields .
2,901
protected function registerOrchid ( ) : self { $ this -> publishes ( [ realpath ( PLATFORM_PATH . '/install-stubs/routes/' ) => base_path ( 'routes' ) , realpath ( PLATFORM_PATH . '/install-stubs/Orchid/' ) => app_path ( 'Orchid' ) , ] , 'orchid-stubs' ) ; return $ this ; }
Register orchid .
2,902
public function registerViews ( ) : self { $ this -> loadViewsFrom ( PLATFORM_PATH . '/resources/views' , 'platform' ) ; $ this -> publishes ( [ PLATFORM_PATH . '/resources/views' => resource_path ( 'views/vendor/platform' ) , ] , 'views' ) ; return $ this ; }
Register views & Publish views .
2,903
public function register ( ) : void { $ this -> commands ( $ this -> commands ) ; $ this -> app -> singleton ( Dashboard :: class , function ( ) { return new Dashboard ( ) ; } ) ; if ( ! Route :: hasMacro ( 'screen' ) ) { Route :: macro ( 'screen' , function ( $ url , $ screen , $ name = null ) { return $ this -> any (...
Register bindings the service provider .
2,904
public function getAllCategories ( ) { $ categories = $ this -> exists ? self :: whereNotIn ( 'id' , [ $ this -> id ] ) -> get ( ) : self :: get ( ) ; return $ categories -> mapWithKeys ( function ( $ item ) { return [ $ item -> id => $ item -> term -> GetContent ( 'name' ) ] ; } ) -> toArray ( ) ; }
Select all categories except current .
2,905
public function newWithCreateTerm ( $ term ) : self { $ newTerm = Term :: firstOrCreate ( $ term ) ; $ this -> term_id = $ newTerm -> id ; $ this -> term ( ) -> associate ( $ newTerm ) ; $ this -> setTaxonomy ( ) ; return $ this ; }
Create category term .
2,906
public function setParent ( $ parent_id = null ) : self { $ parent_id = ( ( int ) $ parent_id > 0 ) ? ( int ) $ parent_id : null ; $ this -> setAttribute ( 'parent_id' , $ parent_id ) ; return $ this ; }
Set parent category .
2,907
public function utf8ToUtf16BigEndian ( $ str , $ setbom = true ) { if ( $ this -> mpdf -> checkSIP && preg_match ( "/([\x{20000}-\x{2FFFF}])/u" , $ str ) ) { if ( ! in_array ( $ this -> mpdf -> currentfontfamily , [ 'gb' , 'big5' , 'sjis' , 'uhc' , 'gbB' , 'big5B' , 'sjisB' , 'uhcB' , 'gbI' , 'big5I' , 'sjisI' , 'uhcI'...
Converts UTF - 8 strings to UTF16 - BE .
2,908
private function _getXAdvancePos ( $ pos ) { if ( strpos ( $ this -> GlyphClassMarks , $ this -> OTLdata [ $ pos ] [ 'hex' ] ) !== false ) { return $ pos ; } while ( isset ( $ this -> OTLdata [ $ pos + 1 ] [ 'hex' ] ) && strpos ( $ this -> GlyphClassMarks , $ this -> OTLdata [ $ pos + 1 ] [ 'hex' ] ) !== false ) { $ po...
the last of any Marks which immediately follow the current glyph
2,909
public static function getSizeFromName ( $ name ) { $ format = strtoupper ( $ name ) ; $ formats = [ '4A0' => [ 4767.87 , 6740.79 ] , '2A0' => [ 3370.39 , 4767.87 ] , 'A0' => [ 2383.94 , 3370.39 ] , 'A1' => [ 1683.78 , 2383.94 ] , 'A2' => [ 1190.55 , 1683.78 ] , 'A3' => [ 841.89 , 1190.55 ] , 'A4' => [ 595.28 , 841.89 ...
This method returns an array of width and height of given named format .
2,910
function array_merge_recursive_unique ( $ array1 , $ array2 ) { $ arrays = func_get_args ( ) ; $ narrays = count ( $ arrays ) ; $ ret = $ arrays [ 0 ] ; for ( $ i = 1 ; $ i < $ narrays ; $ i ++ ) { foreach ( $ arrays [ $ i ] as $ key => $ value ) { if ( ( ( string ) $ key ) === ( ( string ) ( ( int ) $ key ) ) ) { $ re...
for CSS handling
2,911
function _nthchild ( $ f , $ c ) { $ c += 1 ; $ select = false ; $ f_count = count ( $ f ) ; if ( $ f [ 0 ] === 'ODD' ) { $ a = 2 ; $ b = 1 ; } elseif ( $ f [ 0 ] === 'EVEN' ) { $ a = 2 ; $ b = 0 ; } elseif ( $ f_count === 2 ) { $ a = 0 ; $ b = $ f [ 1 ] + 0 ; } elseif ( $ f_count === 3 ) { if ( $ f [ 2 ] == '' ) { $ a...
mPDF 5 . 7 . 4 nth - child
2,912
protected function binseqToArray ( $ seq , array $ barcodeData ) { $ len = strlen ( $ seq ) ; $ w = 0 ; $ k = 0 ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ w += 1 ; if ( ( $ i == ( $ len - 1 ) ) or ( ( $ i < ( $ len - 1 ) ) and ( $ seq [ $ i ] != $ seq [ ( $ i + 1 ) ] ) ) ) { if ( $ seq [ $ i ] == '1' ) { $ t = true ;...
Convert binary barcode sequence to barcode array
2,913
private function checksum ( $ code ) { $ len = strlen ( $ code ) ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i += 2 ) { $ sum += $ code [ $ i ] ; } $ sum *= 3 ; for ( $ i = 1 ; $ i < $ len ; $ i += 2 ) { $ sum += ( $ code [ $ i ] ) ; } $ r = $ sum % 10 ; if ( $ r > 0 ) { $ r = ( 10 - $ r ) ; } return $ r ; }
Checksum for standard 2 of 5 barcodes .
2,914
public function getImportedExternalPageLinks ( $ pageNumber ) { $ links = [ ] ; $ reader = $ this -> getPdfReader ( $ this -> currentReaderId ) ; $ parser = $ reader -> getParser ( ) ; $ page = $ reader -> getPage ( $ pageNumber ) ; $ page -> getPageDictionary ( ) ; $ annotations = $ page -> getAttribute ( 'Annots' ) ;...
Imports the external page links
2,915
function _checkGSUBignore ( $ flag , $ glyph , $ MarkFilteringSet ) { $ ignore = false ; if ( ( ( $ flag & 0x0008 ) == 0x0008 ) && strpos ( $ this -> GlyphClassMarks , $ glyph ) ) { $ ignore = true ; } if ( ( ( $ flag & 0x0004 ) == 0x0004 ) && strpos ( $ this -> GlyphClassLigatures , $ glyph ) ) { $ ignore = true ; } i...
mPDF 5 . 7 . 1
2,916
function getGlyphData ( $ originalGlyphIdx , & $ maxdepth , & $ depth , & $ points , & $ contours ) { $ depth ++ ; $ maxdepth = max ( $ maxdepth , $ depth ) ; if ( count ( $ this -> glyphdata [ $ originalGlyphIdx ] [ 'compGlyphs' ] ) ) { foreach ( $ this -> glyphdata [ $ originalGlyphIdx ] [ 'compGlyphs' ] as $ glyphId...
Recursively get composite glyph data
2,917
function getGlyphs ( $ originalGlyphIdx , & $ start , & $ glyphSet , & $ subsetglyphs ) { $ glyphPos = $ this -> glyphPos [ $ originalGlyphIdx ] ; $ glyphLen = $ this -> glyphPos [ $ originalGlyphIdx + 1 ] - $ glyphPos ; if ( ! $ glyphLen ) { return ; } $ this -> seek ( $ start + $ glyphPos ) ; $ numberOfContours = $ t...
Recursively get composite glyphs
2,918
function getCMAP4 ( $ unicode_cmap_offset , & $ glyphToChar , & $ charToGlyph ) { $ this -> maxUniChar = 0 ; $ this -> seek ( $ unicode_cmap_offset + 2 ) ; $ length = $ this -> read_ushort ( ) ; $ limit = $ unicode_cmap_offset + $ length ; $ this -> skip ( 2 ) ; $ segCount = $ this -> read_ushort ( ) / 2 ; $ this -> sk...
CMAP Format 4
2,919
public function objectKey ( $ n ) { if ( $ this -> useRC128Encryption ) { $ len = 16 ; } else { $ len = 10 ; } return substr ( $ this -> md5toBinary ( $ this -> encryptionKey . pack ( 'VXxx' , $ n ) ) , 0 , $ len ) ; }
Compute key depending on object number where the encrypted data is stored
2,920
public function rc4 ( $ key , $ text ) { if ( $ this -> lastRc4Key != $ key ) { $ k = str_repeat ( $ key , 256 / strlen ( $ key ) + 1 ) ; $ rc4 = range ( 0 , 255 ) ; $ j = 0 ; for ( $ i = 0 ; $ i < 256 ; $ i ++ ) { $ t = $ rc4 [ $ i ] ; $ j = ( $ j + $ t + ord ( $ k [ $ i ] ) ) % 256 ; $ rc4 [ $ i ] = $ rc4 [ $ j ] ; $...
RC4 is the standard encryption algorithm used in PDF format
2,921
function svg_overflow ( $ x , $ y ) { $ x2 = $ x ; $ y2 = $ y ; if ( isset ( $ this -> svg_attribs [ 'overflow' ] ) ) { if ( $ this -> svg_attribs [ 'overflow' ] == 'hidden' ) { $ svg_w = preg_replace ( "/([0-9\.]*)(.*)/i" , "$1" , $ this -> svg_attribs [ 'width' ] ) ; $ svg_h = preg_replace ( "/([0-9\.]*)(.*)/i" , "$1...
check if points are within svg if not set to max
2,922
private function fourBytesToInt ( $ s ) { return ( ord ( $ s [ 0 ] ) << 24 ) + ( ord ( $ s [ 1 ] ) << 16 ) + ( ord ( $ s [ 2 ] ) << 8 ) + ord ( $ s [ 3 ] ) ; }
Read a 4 - byte integer from string
2,923
private function imageError ( $ file , $ firsttime , $ msg ) { $ this -> failedImages [ $ file ] = true ; if ( $ firsttime && ( $ this -> mpdf -> showImageErrors || $ this -> mpdf -> debug ) ) { throw new \ Mpdf \ MpdfImageException ( sprintf ( '%s (%s)' , $ msg , $ file ) ) ; } $ this -> logger -> warning ( sprintf ( ...
Throw an exception and save re - trying image URL s which have already failed
2,924
public static function getTagClassName ( $ tag ) { static $ map = [ 'BARCODE' => 'BarCode' , 'BLOCKQUOTE' => 'BlockQuote' , 'COLUMN_BREAK' => 'ColumnBreak' , 'COLUMNBREAK' => 'ColumnBreak' , 'DOTTAB' => 'DotTab' , 'FIELDSET' => 'FieldSet' , 'FIGCAPTION' => 'FigCaption' , 'FORMFEED' => 'FormFeed' , 'HGROUP' => 'HGroup' ...
Returns the fully qualified name of the class handling the rendering of the given tag
2,925
function GetFirstBlockFill ( ) { $ startfill = 0 ; for ( $ i = 1 ; $ i <= $ this -> blklvl ; $ i ++ ) { if ( $ this -> blk [ $ i ] [ 'bgcolor' ] || $ this -> blk [ $ i ] [ 'border_left' ] [ 'w' ] || $ this -> blk [ $ i ] [ 'border_right' ] [ 'w' ] || $ this -> blk [ $ i ] [ 'border_top' ] [ 'w' ] || $ this -> blk [ $ i...
Used when ColActive for tables - updated to return first block with background fill OR borders
2,926
function _moveToPrevChar ( & $ contentctr , & $ charctr , $ content ) { $ lastchar = false ; $ charctr -- ; while ( $ charctr < 0 ) { $ contentctr -- ; if ( $ contentctr < 0 ) { return false ; } if ( $ this -> usingCoreFont ) { $ charctr = strlen ( $ content [ $ contentctr ] ) - 1 ; } else { $ charctr = mb_strlen ( $ c...
Get previous character and move pointers
2,927
function _advanceFloatMargins ( ) { if ( isset ( $ this -> floatmargins [ 'L' ] ) && $ this -> floatmargins [ 'L' ] [ 'skipline' ] && $ this -> floatmargins [ 'L' ] [ 'y0' ] != $ this -> y ) { $ yadj = $ this -> y - $ this -> floatmargins [ 'L' ] [ 'y0' ] ; $ this -> floatmargins [ 'L' ] [ 'y0' ] = $ this -> y ; $ this...
Update values if set to skipline
2,928
function writeHTMLHeaders ( ) { if ( $ this -> mirrorMargins && ( $ this -> page ) % 2 == 0 ) { $ OE = 'E' ; } else { $ OE = 'O' ; } if ( $ OE === 'E' ) { $ this -> saveHTMLHeader [ $ this -> page ] [ $ OE ] [ 'html' ] = $ this -> HTMLHeaderE [ 'html' ] ; } else { $ this -> saveHTMLHeader [ $ this -> page ] [ $ OE ] [ ...
Called internally from Header
2,929
function ClearFloats ( $ clear , $ blklvl = 0 ) { list ( $ l_exists , $ r_exists , $ l_max , $ r_max , $ l_width , $ r_width ) = $ this -> GetFloatDivInfo ( $ blklvl , true ) ; $ end = $ currpos = ( $ this -> page * 1000 + $ this -> y ) ; if ( $ clear == 'BOTH' && ( $ l_exists || $ r_exists ) ) { $ this -> pageoutput [...
Added mPDF 3 . 0 Float DIV - CLEAR
2,930
function GetFloatDivInfo ( $ blklvl = 0 , $ clear = false ) { $ l_exists = false ; $ r_exists = false ; $ l_max = 0 ; $ r_max = 0 ; $ l_width = 0 ; $ r_width = 0 ; if ( count ( $ this -> floatDivs ) ) { $ currpos = ( $ this -> page * 1000 + $ this -> y ) ; foreach ( $ this -> floatDivs as $ f ) { if ( ( $ clear && $ f ...
Added mPDF 3 . 0 Float DIV
2,931
function SetStylesArray ( $ arr ) { $ style = '' ; foreach ( [ 'B' , 'I' ] as $ s ) { if ( isset ( $ arr [ $ s ] ) ) { if ( $ arr [ $ s ] ) { $ this -> $ s = true ; $ style .= $ s ; } else { $ this -> $ s = false ; } } elseif ( $ this -> $ s ) { $ style .= $ s ; } } $ this -> currentfontstyle = $ style ; $ this -> SetF...
Set multiple styles at one time
2,932
function Bookmark ( $ txt , $ level = 0 , $ y = 0 ) { $ txt = $ this -> purify_utf8_text ( $ txt ) ; if ( $ this -> text_input_as_HTML ) { $ txt = $ this -> all_entities_to_utf8 ( $ txt ) ; } if ( $ y == - 1 ) { if ( ! $ this -> ColActive ) { $ y = $ this -> y ; } else { $ y = $ this -> y0 ; } } $ bmo = [ 't' => $ txt ...
FROM class PDF_Bookmark
2,933
function IndexEntry ( $ txt , $ xref = '' ) { if ( $ xref ) { $ this -> IndexEntrySee ( $ txt , $ xref ) ; return ; } $ Present = false ; if ( $ this -> keep_block_together ) { } elseif ( $ this -> kwt ) { $ size = count ( $ this -> kwt_Reference ) ; for ( $ i = 0 ; $ i < $ size ; $ i ++ ) { if ( isset ( $ this -> kwt_...
FROM class PDF_Ref == INDEX
2,934
function IndexEntrySee ( $ txta , $ txtb ) { if ( $ this -> directionality == 'rtl' ) { if ( $ txta == strip_tags ( $ txta ) ) { $ txta = str_replace ( ':' , ' - ' , $ txta ) ; } if ( $ txtb == strip_tags ( $ txtb ) ) { $ txtb = str_replace ( ':' , ' - ' , $ txtb ) ; } } else { if ( $ txta == strip_tags ( $ txta ) ) { ...
Added function to add a reference Elephants . See Chickens
2,935
function is_utf8 ( & $ string ) { if ( $ string === mb_convert_encoding ( mb_convert_encoding ( $ string , "UTF-32" , "UTF-8" ) , "UTF-8" , "UTF-32" ) ) { return true ; } if ( $ this -> ignore_invalid_utf8 ) { $ string = mb_convert_encoding ( mb_convert_encoding ( $ string , "UTF-32" , "UTF-8" ) , "UTF-8" , "UTF-32" ) ...
Edited v1 . 2 Pass by reference ; option to continue if invalid UTF - 8 chars
2,936
function columnAdjustAdd ( $ type , $ k , $ xadj , $ yadj , $ a , $ b , $ c = 0 , $ d = 0 , $ e = 0 , $ f = 0 ) { if ( $ type === 'Td' ) { $ a += ( $ xadj * $ k ) ; $ b -= ( $ yadj * $ k ) ; return 'BT ' . sprintf ( '%.3F %.3F' , $ a , $ b ) . ' Td' ; } elseif ( $ type === 're' ) { $ a += ( $ xadj * $ k ) ; $ b -= ( $ ...
Callback function from function printcolumnbuffer in mpdf
2,937
private function imbCrc11Fcs ( $ codeArray ) { $ genpoly = 0x0F35 ; $ fcs = 0x07FF ; $ data = hexdec ( $ codeArray [ 0 ] ) << 5 ; for ( $ bit = 2 ; $ bit < 8 ; ++ $ bit ) { if ( ( $ fcs ^ $ data ) & 0x400 ) { $ fcs = ( $ fcs << 1 ) ^ $ genpoly ; } else { $ fcs = ( $ fcs << 1 ) ; } $ fcs &= 0x7FF ; $ data <<= 1 ; } for ...
Intelligent Mail Barcode calculation of Frame Check Sequence
2,938
private function imbReverseUs ( $ num ) { $ rev = 0 ; for ( $ i = 0 ; $ i < 16 ; ++ $ i ) { $ rev <<= 1 ; $ rev |= ( $ num & 1 ) ; $ num >>= 1 ; } return $ rev ; }
Reverse unsigned short value
2,939
private function imbTables ( $ n , $ size ) { $ table = [ ] ; $ lli = 0 ; $ lui = $ size - 1 ; for ( $ count = 0 ; $ count < 8192 ; ++ $ count ) { $ bitCount = 0 ; for ( $ bit_index = 0 ; $ bit_index < 13 ; ++ $ bit_index ) { $ bitCount += ( int ) ( ( $ count & ( 1 << $ bit_index ) ) != 0 ) ; } if ( $ bitCount == $ n )...
Generate Nof13 tables used for Intelligent Mail Barcode
2,940
private function decToHex ( $ number ) { $ hex = [ ] ; if ( $ number == 0 ) { return '00' ; } while ( $ number > 0 ) { if ( $ number == 0 ) { array_push ( $ hex , '0' ) ; } else { array_push ( $ hex , strtoupper ( dechex ( bcmod ( $ number , '16' ) ) ) ) ; $ number = bcdiv ( $ number , '16' , 0 ) ; } } $ hex = array_re...
Convert large integer number to hexadecimal representation .
2,941
public function subscriberByRequest ( array $ input , array $ headers ) : ? Subscriber { $ channel = Arr :: get ( $ input , 'channel_name' ) ; return $ channel ? $ this -> subscriberByChannel ( $ channel ) : null ; }
Get subscriber by request .
2,942
public function subscriberByChannel ( string $ channel ) : ? Subscriber { $ key = self :: SUBSCRIBER_KEY . ".{$channel}" ; return $ this -> cache -> get ( $ key ) ; }
Find subscriber by channel .
2,943
public function subscribersByTopic ( string $ topic ) { $ key = self :: TOPIC_KEY . ".{$topic}" ; if ( ! $ this -> cache -> has ( $ key ) ) { return new Collection ; } $ channels = json_decode ( $ this -> cache -> get ( $ key ) , true ) ; return ( new Collection ( $ channels ) ) -> map ( function ( string $ channel ) :...
Get collection of subscribers by channel .
2,944
public function storeSubscriber ( Subscriber $ subscriber , string $ topic ) : void { $ topicKey = self :: TOPIC_KEY . ".{$topic}" ; $ subscriberKey = self :: SUBSCRIBER_KEY . ".{$subscriber->channel}" ; $ topic = $ this -> cache -> has ( $ topicKey ) ? json_decode ( $ this -> cache -> get ( $ topicKey ) , true ) : [ ]...
Store subscription .
2,945
public function deleteSubscriber ( string $ channel ) : ? Subscriber { $ key = self :: SUBSCRIBER_KEY . ".{$channel}" ; $ hasSubscriber = $ this -> cache -> has ( $ key ) ; $ subscriber = $ this -> cache -> get ( $ key ) ; if ( $ hasSubscriber ) { $ this -> cache -> forget ( $ key ) ; } return $ subscriber ; }
Delete subscriber .
2,946
protected static function gatherSchemaImportsRecursively ( string $ path ) : string { if ( ! file_exists ( $ path ) ) { self :: throwFileNotFoundException ( $ path ) ; } return ( new Collection ( file ( $ path ) ) ) -> map ( function ( string $ line ) use ( $ path ) { if ( ! Str :: startsWith ( trim ( $ line ) , '#impo...
Get the schema starting from a root schema following the imports recursively .
2,947
protected function store ( CacheManager $ cache , string $ key , $ value , ? Carbon $ expiration , array $ tags ) : void { $ supportsTags = $ this -> useTags ( $ cache ) ; if ( $ expiration ) { $ supportsTags ? $ cache -> tags ( $ tags ) -> put ( $ key , $ value , $ expiration ) : $ cache -> put ( $ key , $ value , $ e...
Store value in cache .
2,948
protected function setNodeKey ( NodeValue $ nodeValue ) : void { if ( $ nodeValue -> getCacheKey ( ) ) { return ; } $ fields = data_get ( $ nodeValue -> getTypeDefinition ( ) , 'fields' , [ ] ) ; $ nodeKey = ( new Collection ( $ fields ) ) -> reduce ( function ( ? string $ key , FieldDefinitionNode $ field ) : ? string...
Set node s cache key .
2,949
public function apply ( $ builder , array $ args ) { $ this -> queryFilter -> filter ( $ builder , $ args ) ; foreach ( $ args as $ key => $ value ) { if ( $ builderDirective = Arr :: get ( $ this -> builderDirectives , $ key ) ) { $ builder = $ builderDirective -> handleBuilder ( $ builder , $ value ) ; } } foreach ( ...
Apply the bound QueryBuilderDirectives to the given builder .
2,950
public function addScopes ( array $ scopes ) : self { $ this -> scopes = array_merge ( $ this -> scopes , $ scopes ) ; return $ this ; }
Add scopes that are then called upon the query with the field arguments .
2,951
public function addBuilderDirective ( string $ argumentName , ArgBuilderDirective $ argBuilderDirective ) : self { $ this -> builderDirectives [ $ argumentName ] = $ argBuilderDirective ; return $ this ; }
Add a query builder directive keyed by the argument name .
2,952
protected function fieldValue ( string $ key ) { return $ this -> isBatched ( ) ? Arr :: get ( $ this -> operations , $ this -> batchIndex . '.' . $ key ) : $ this -> operations [ $ key ] ?? null ; }
If we are dealing with a batched request this gets the contents of the currently resolving batch index .
2,953
public function queueBroadcast ( GraphQLSubscription $ subscription , string $ fieldName , $ root ) : void { $ this -> eventsDispatcher -> dispatch ( new BroadcastSubscriptionEvent ( $ subscription , $ fieldName , $ root ) ) ; }
Queue pushing subscription data to subscribers .
2,954
public function broadcast ( GraphQLSubscription $ subscription , string $ fieldName , $ root ) : void { $ topic = $ subscription -> decodeTopic ( $ fieldName , $ root ) ; $ subscribers = $ this -> storage -> subscribersByTopic ( $ topic ) -> filter ( function ( Subscriber $ subscriber ) use ( $ subscription , $ root ) ...
Push subscription data to subscribers .
2,955
public function authorize ( Request $ request ) : Response { return $ this -> auth -> authorize ( $ request ) ? $ this -> broadcastManager -> authorized ( $ request ) : $ this -> broadcastManager -> unauthorized ( $ request ) ; }
Authorize the subscription .
2,956
public function handleStartRequest ( StartRequest $ startRequest ) : void { $ this -> requestStart = Carbon :: now ( ) ; $ this -> requestStartPrecise = $ this -> getTime ( ) ; }
Handle request start .
2,957
public function handleBuildExtensionsResponse ( BuildExtensionsResponse $ buildExtensionsResponse ) : ExtensionsResponse { $ requestEnd = Carbon :: now ( ) ; $ requestEndPrecise = $ this -> getTime ( ) ; return new ExtensionsResponse ( 'tracing' , [ 'version' => 1 , 'startTime' => $ this -> requestStart -> format ( Car...
Return additional information for the result .
2,958
public function record ( ResolveInfo $ resolveInfo , $ start , $ end ) : void { $ this -> resolverTraces [ ] = [ 'path' => $ resolveInfo -> path , 'parentType' => $ resolveInfo -> parentType -> name , 'returnType' => $ resolveInfo -> returnType -> __toString ( ) , 'fieldName' => $ resolveInfo -> fieldName , 'startOffse...
Record resolver execution time .
2,959
protected function diffTimeInNanoseconds ( $ start , $ end ) : int { if ( $ this -> platformSupportsNanoseconds ( ) ) { return $ end - $ start ; } return ( int ) ( ( $ end - $ start ) * 1000 * 1000 * 1000 ) ; }
Diff the time results to each other and convert to nanoseconds if needed .
2,960
public function serialize ( $ value ) : string { if ( $ value instanceof Carbon ) { return $ value -> toDateString ( ) ; } return $ this -> tryParsingDate ( $ value , InvariantViolation :: class ) -> toDateString ( ) ; }
Serialize an internal value ensuring it is a valid date string .
2,961
public function getKey ( ) : string { $ argKeys = $ this -> argKeys ( ) ; return $ this -> implode ( [ $ this -> privateCache ? 'auth' : null , $ this -> privateCache ? app ( 'auth' ) -> user ( ) -> getKey ( ) : null , strtolower ( $ this -> resolveInfo -> parentType -> name ) , $ this -> fieldKey , strtolower ( $ this...
Resolve key from root value .
2,962
public function getTags ( ) : array { $ typeTag = $ this -> implode ( [ 'graphql' , strtolower ( $ this -> fieldValue -> getParentName ( ) ) , $ this -> fieldKey , ] ) ; $ fieldTag = $ this -> implode ( [ 'graphql' , strtolower ( $ this -> fieldValue -> getParentName ( ) ) , $ this -> fieldKey , $ this -> resolveInfo -...
Get cache tags .
2,963
protected function argKeys ( ) : Collection { $ args = $ this -> args ; ksort ( $ args ) ; return ( new Collection ( $ args ) ) -> map ( function ( $ value , $ key ) { $ keyValue = is_array ( $ value ) ? json_encode ( $ value , true ) : $ value ; return "{$key}:{$keyValue}" ; } ) ; }
Convert input arguments to keys .
2,964
protected function setFieldKey ( ) { if ( ! $ this -> fieldValue || ! $ this -> rootValue ) { return ; } $ cacheFieldKey = $ this -> fieldValue -> getParent ( ) -> getCacheKey ( ) ; if ( $ cacheFieldKey ) { $ this -> fieldKey = data_get ( $ this -> rootValue , $ cacheFieldKey ) ; } }
Set the field key .
2,965
public function setResolverArguments ( $ root , array $ args , GraphQLContext $ context , ResolveInfo $ resolveInfo ) : self { return $ this -> setRoot ( $ root ) -> setArgs ( $ args ) -> setContext ( $ context ) -> setResolveInfo ( $ resolveInfo ) ; }
Set all resolver arguments at once .
2,966
public static function namespaceClassname ( string $ classCandidate , array $ namespacesToTry , callable $ determineMatch ) : ? string { if ( $ determineMatch ( $ classCandidate ) ) { return $ classCandidate ; } while ( ! empty ( $ namespacesToTry ) ) { $ className = array_shift ( $ namespacesToTry ) . '\\' . $ classCa...
Attempt to find a given class in the given namespaces .
2,967
public static function constructResolver ( string $ className , string $ methodName ) : Closure { if ( ! method_exists ( $ className , $ methodName ) ) { throw new DefinitionException ( "Method '{$methodName}' does not exist on class '{$className}'" ) ; } return Closure :: fromCallable ( [ app ( $ className ) , $ metho...
Construct a closure that passes through the arguments .
2,968
public function defer ( Closure $ resolver , string $ path ) { if ( $ data = Arr :: get ( $ this -> result , "data.{$path}" ) ) { return $ data ; } if ( $ this -> isDeferred ( $ path ) || ! $ this -> acceptFurtherDeferring ) { return $ this -> resolve ( $ resolver , $ path ) ; } $ this -> deferred [ $ path ] = $ resolv...
Register deferred field .
2,969
public function resolve ( Closure $ originalResolver , string $ path ) { $ isDeferred = $ this -> isDeferred ( $ path ) ; $ resolver = $ isDeferred ? $ this -> deferred [ $ path ] : $ originalResolver ; if ( $ isDeferred ) { $ this -> resolved [ ] = $ path ; unset ( $ this -> deferred [ $ path ] ) ; } return $ resolver...
Resolve field with data or resolver .
2,970
public function createResponse ( array $ result ) : Response { if ( empty ( $ this -> deferred ) ) { return response ( $ result ) ; } return response ( ) -> stream ( function ( ) use ( $ result ) : void { $ nested = 1 ; $ this -> result = $ result ; $ this -> isStreaming = true ; $ this -> stream -> stream ( $ result ,...
Return either a final response or a stream of responses .
2,971
protected function maxNestedFieldsResolved ( int $ nested ) : bool { if ( $ this -> maxNestedFields === 0 ) { return false ; } return $ nested >= $ this -> maxNestedFields ; }
Check if the maximum number of nested field has been resolved .
2,972
protected function executeDeferred ( ) : void { $ this -> result = app ( ) -> call ( [ $ this -> graphQL , 'executeRequest' ] ) ; $ this -> stream -> stream ( $ this -> result , $ this -> resolved , empty ( $ this -> deferred ) ) ; $ this -> resolved = [ ] ; }
Execute deferred fields .
2,973
protected function getSingleArgumentDefinition ( ) : InputValueDefinitionNode { if ( count ( $ this -> definitionNode -> arguments ) !== 1 ) { throw new DirectiveException ( "The @delete directive requires the field {$this->definitionNode->name->value} to only contain a single argument." ) ; } return $ this -> definiti...
Ensure there is only a single argument defined on the field .
2,974
public function build ( string $ schema ) : DocumentAST { $ document = DocumentAST :: fromSource ( $ schema ) ; $ document = $ this -> applyNodeManipulators ( $ document ) ; $ document = $ this -> mergeTypeExtensions ( $ document ) ; $ document = $ this -> applyFieldManipulators ( $ document ) ; $ document = $ this -> ...
Convert the base schema string into an AST by applying different manipulations .
2,975
protected function mergeTypeExtensions ( DocumentAST $ document ) : DocumentAST { $ document -> objectTypeDefinitions ( ) -> each ( function ( ObjectTypeDefinitionNode $ objectType ) use ( $ document ) { $ name = $ objectType -> name -> value ; $ objectType = $ document -> extensionsForType ( $ name ) -> reduce ( funct...
The final schema must not contain type extensions so we merge them here .
2,976
protected function addNodeSupport ( DocumentAST $ document ) : DocumentAST { $ hasTypeImplementingNode = $ document -> objectTypeDefinitions ( ) -> contains ( function ( ObjectTypeDefinitionNode $ objectType ) : bool { return ( new Collection ( $ objectType -> interfaces ) ) -> contains ( function ( NamedTypeNode $ int...
Inject the node type and a node field into Query .
2,977
public function unserialize ( $ subscription ) : self { $ data = json_decode ( $ subscription , true ) ; $ this -> operationName = $ data [ 'operation_name' ] ; $ this -> channel = $ data [ 'channel' ] ; $ this -> args = $ data [ 'args' ] ; $ this -> context = $ this -> contextSerializer ( ) -> unserialize ( $ data [ '...
Unserialize subscription from a JSON string .
2,978
public function serialize ( ) { return json_encode ( [ 'operation_name' => $ this -> operationName , 'channel' => $ this -> channel , 'args' => $ this -> args , 'context' => $ this -> contextSerializer ( ) -> serialize ( $ this -> context ) , 'query' => serialize ( AST :: toArray ( $ this -> query ) ) , ] ) ; }
Convert this into a JSON string .
2,979
public function query ( GraphQLRequest $ request ) { $ this -> eventsDispatcher -> dispatch ( new StartRequest ( $ request ) ) ; $ result = $ request -> isBatched ( ) ? $ this -> executeBatched ( $ request ) : $ this -> graphQL -> executeRequest ( $ request ) ; $ response = $ this -> createsResponse -> createResponse (...
Execute GraphQL query .
2,980
protected function executeBatched ( GraphQLRequest $ request ) : array { $ results = [ ] ; do { $ results [ ] = $ this -> graphQL -> executeRequest ( $ request ) ; } while ( $ request -> advanceBatchIndex ( ) ) ; return $ results ; }
Loop through the individual batched queries and collect the results .
2,981
public function decodeID ( string $ globalID ) : string { [ $ type , $ id ] = self :: decode ( $ globalID ) ; return $ id ; }
Decode the Global ID and get just the ID .
2,982
public function decodeType ( string $ globalID ) : string { [ $ type , $ id ] = self :: decode ( $ globalID ) ; return $ type ; }
Decode the Global ID and get just the type .
2,983
public function setRelations ( array $ relations ) : self { $ this -> relations = $ this -> newModelQuery ( ) -> with ( $ relations ) -> getEagerLoads ( ) ; return $ this ; }
Set the relations to be loaded .
2,984
protected function setModels ( $ models ) : self { $ this -> models = $ models instanceof EloquentCollection ? $ models : new EloquentCollection ( $ models ) ; return $ this ; }
Set one or more Model instances as an EloquentCollection .
2,985
public function loadRelationsForPage ( int $ perPage , int $ page = 1 ) : self { foreach ( $ this -> relations as $ name => $ constraints ) { $ this -> loadRelationForPage ( $ perPage , $ page , $ name , $ constraints ) ; } return $ this ; }
Load all relations for the model but constrain the query to the current page .
2,986
public function loadRelationForPage ( int $ first , int $ page , string $ relationName , Closure $ relationConstraints ) : self { $ this -> reloadModelsWithRelationCount ( ) ; $ relations = $ this -> buildRelationsFromModels ( $ relationName , $ relationConstraints ) -> map ( function ( Relation $ relation ) use ( $ fi...
Load only one page of relations of all the models .
2,987
protected function buildRelationsFromModels ( string $ relationName , Closure $ relationConstraints ) : Collection { return $ this -> models -> toBase ( ) -> map ( function ( Model $ model ) use ( $ relationName , $ relationConstraints ) { $ relation = $ this -> getRelationInstance ( $ relationName ) ; $ relation -> ad...
Get queries to fetch relationships .
2,988
protected function loadDefaultWith ( EloquentCollection $ collection ) : self { if ( $ collection -> isEmpty ( ) ) { return $ this ; } $ model = $ collection -> first ( ) ; $ reflection = new ReflectionClass ( $ model ) ; $ withProperty = $ reflection -> getProperty ( 'with' ) ; $ withProperty -> setAccessible ( true )...
Load default eager loads .
2,989
public function getRelationDictionary ( string $ relationName ) : array { return $ this -> models -> mapWithKeys ( function ( Model $ model ) use ( $ relationName ) { return [ $ this -> buildKey ( $ model -> getKey ( ) ) => $ model -> getRelation ( $ relationName ) ] ; } ) -> all ( ) ; }
Get an associative array of relations keyed by the models primary key .
2,990
protected function unionAllRelationQueries ( Collection $ relations ) : EloquentBuilder { return $ relations -> reduce ( function ( EloquentBuilder $ builder , Relation $ relation ) { return $ builder -> unionAll ( $ relation -> getQuery ( ) ) ; } , $ relations -> shift ( ) -> getQuery ( ) ) ; }
Merge all the relation queries into a single query with UNION ALL .
2,991
protected function associateRelationModels ( string $ relationName , EloquentCollection $ relationModels ) : self { $ relation = $ this -> getRelationInstance ( $ relationName ) ; $ relation -> match ( $ this -> models -> all ( ) , $ relationModels , $ relationName ) ; return $ this ; }
Associate the collection of all fetched relationModels back with their parents .
2,992
protected function hydratePivotRelation ( string $ relationName , EloquentCollection $ relationModels ) : self { $ relation = $ this -> getRelationInstance ( $ relationName ) ; if ( $ relationModels -> isNotEmpty ( ) && method_exists ( $ relation , 'hydratePivotRelation' ) ) { $ hydrationMethod = new ReflectionMethod (...
Ensure the pivot relation is hydrated too if it exists .
2,993
protected function convertWrappedDefinitionNode ( $ node , array $ wrappers = [ ] ) : Type { if ( $ node -> kind === NodeKind :: NON_NULL_TYPE || $ node -> kind === NodeKind :: LIST_TYPE ) { $ wrappers [ ] = $ node -> kind ; return $ this -> convertWrappedDefinitionNode ( $ node -> type , $ wrappers ) ; } return ( new ...
Unwrap the node if needed and convert to type .
2,994
protected function convertNamedTypeNode ( NamedTypeNode $ node ) : Type { $ nodeName = $ node -> name -> value ; switch ( $ nodeName ) { case 'ID' : return Type :: id ( ) ; case 'Int' : return Type :: int ( ) ; case 'Boolean' : return Type :: boolean ( ) ; case 'Float' : return Type :: float ( ) ; case 'String' : retur...
Converted named node to type .
2,995
public function handle ( FieldValue $ fieldValue ) : array { $ fieldDefinitionNode = $ fieldValue -> getField ( ) ; if ( $ resolverDirective = $ this -> directiveFactory -> createFieldResolver ( $ fieldDefinitionNode ) ) { $ this -> fieldValue = $ resolverDirective -> resolveField ( $ fieldValue ) ; } else { $ this -> ...
Convert a FieldValue to an executable FieldDefinition .
2,996
protected function getArgumentValues ( ) : Collection { return ( new Collection ( $ this -> fieldValue -> getField ( ) -> arguments ) ) -> map ( function ( InputValueDefinitionNode $ inputValueDefinition ) : ArgumentValue { return new ArgumentValue ( $ inputValueDefinition , $ this -> fieldValue ) ; } ) ; }
Get a collection of the fields argument definitions .
2,997
protected function handleArgDirectivesRecursively ( InputType $ type , InputValueDefinitionNode $ astNode , array $ argumentPath ) : void { if ( $ type instanceof NonNull ) { $ this -> handleArgDirectivesRecursively ( $ type -> getWrappedType ( ) , $ astNode , $ argumentPath ) ; return ; } $ directives = $ this -> dire...
Handle the ArgMiddleware .
2,998
protected function validateArgs ( ) : void { if ( ! $ this -> rules ) { return ; } $ validator = validator ( $ this -> args , $ this -> rules , $ this -> messages , [ 'root' => $ this -> root , 'context' => $ this -> context , 'resolveInfo' => $ this -> resolveInfo , ] ) ; if ( $ validator -> fails ( ) ) { foreach ( $ ...
Run the gathered validation rules on the arguments .
2,999
protected function resumeHandlingArgDirectives ( ) : void { $ snapshots = $ this -> handleArgDirectivesSnapshots ; $ this -> handleArgDirectivesSnapshots = [ ] ; foreach ( $ snapshots as $ handlerArgs ) { $ this -> handleArgDirectives ( ... $ handlerArgs ) ; } if ( count ( $ this -> handleArgDirectivesSnapshots ) > 0 )...
Continue evaluating the arg directives after validation has run .