idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
43,100 | public static function fromMethod ( string $ method , string $ class = null , bool $ withParents = false ) : array { if ( $ class ) { try { $ refMethod = new \ ReflectionMethod ( $ class , $ method ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Method '{$class}::{$method}' not found." , Exception :: METHOD_NOT_FOUND ) ; } } else { try { $ refMethod = new \ ReflectionMethod ( $ method ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Method '{$method}' not found." , Exception :: METHOD_NOT_FOUND ) ; } } $ docComment = $ refMethod -> getDocComment ( ) ; if ( $ withParents ) { $ refClass = $ refMethod -> getDeclaringClass ( ) ; while ( 1 ) { if ( $ refClass = $ refClass -> getParentClass ( ) ) { try { $ refMethod = $ refClass -> getMethod ( $ method ) ; } catch ( \ ReflectionException $ e ) { break ; } if ( ! $ refMethod ) { continue ; } if ( $ parentDoc = $ refMethod -> getDocComment ( ) ) { $ docComment = $ docComment === false ? $ parentDoc : "{$parentDoc}{$docComment}" ; } } else { break ; } } } unset ( $ refMethod , $ refClass ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; } | Extract the annotations from a method . |
43,101 | public static function fromProperty ( string $ class , string $ property ) : array { try { $ property = new \ ReflectionProperty ( $ class , $ property ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Property '{$class}::{$property}' not found." , Exception :: PROPERTY_NOT_FOUND ) ; } $ docComment = $ property -> getDocComment ( ) ; unset ( $ property ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; } | Extract the annotations from a property . |
43,102 | public static function fromClass ( string $ class , bool $ withParents = false ) : array { try { $ class = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Class '{$class}' not found." , Exception :: CLASS_NOT_FOUND ) ; } $ docComment = $ class -> getDocComment ( ) ; if ( $ withParents ) { while ( 1 ) { if ( $ class = $ class -> getParentClass ( ) ) { if ( $ parentDoc = $ class -> getDocComment ( ) ) { $ docComment = $ docComment === false ? $ parentDoc : "{$parentDoc}{$docComment}" ; } } else { break ; } } } unset ( $ class ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; } | Extract the annotations from a class . |
43,103 | public static function fromFunction ( string $ fn ) : array { try { $ fn = new \ ReflectionFunction ( $ fn ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Function {$fn} not found." , Exception :: FUNCTION_NOT_FOUND ) ; } $ docComment = $ fn -> getDocComment ( ) ; unset ( $ fn ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; } | Extract the annotations from a function . |
43,104 | public function getGroups ( $ byid = false , $ skip_guest = false ) { if ( $ byid ) { $ data = $ this -> byid ; if ( $ skip_guest ) { unset ( $ data [ - 1 ] ) ; } } else { $ data = $ this -> groups ; if ( $ skip_guest ) { unset ( $ data [ 'Core' ] [ - 1 ] ) ; } } return $ data ; } | Returns all groups |
43,105 | public function getGroupById ( $ id_group ) { if ( array_key_exists ( $ id_group , $ this -> byid ) ) { return $ this -> byid [ $ id_group ] ; } return false ; } | Returns a group by it s id |
43,106 | public function getGroupByAppAndName ( $ app , $ name ) { if ( array_key_exists ( $ app , $ this -> groups ) && array_key_exists ( $ name , $ this -> groups [ $ app ] ) ) { return $ this -> groups [ $ app ] [ $ name ] ; } return false ; } | Returns a group by app and name |
43,107 | public function execute ( Framework $ framework , RequestAbstract $ request , Response $ response , $ value = null ) { if ( ! ( $ request instanceof WebRequest ) ) { return $ value ; } $ fullUrl = $ request -> getRequestedUrl ( ) ; $ urlParts = parse_url ( $ fullUrl ) ; if ( $ urlParts == false ) { return $ value ; } $ urlParts = $ this -> verifyPath ( $ urlParts ) ; $ completeUrl = $ response -> buildUrl ( $ urlParts ) ; if ( $ completeUrl !== $ request -> getRequestedUrl ( ) ) { $ response -> redirectTo ( $ completeUrl ) ; return null ; } return $ value ; } | Replaces the event name with a redirect event if the url hasn t a slash at the end of the url . |
43,108 | protected function verifyPath ( $ urlParts ) { if ( isset ( $ urlParts [ 'path' ] ) ) { $ path = $ urlParts [ 'path' ] ; if ( substr ( $ path , - 1 ) !== '/' && ( strrpos ( $ path , '.' ) === false || strrpos ( $ path , '.' ) < strrpos ( $ path , '/' ) ) ) { $ path .= '/' ; } $ urlParts [ 'path' ] = $ path ; } return $ urlParts ; } | Verifies the path of the url and adds a slash at the end if there is no slash . |
43,109 | private function generateMovesForBots ( ) { foreach ( $ this -> getPlayers ( ) as & $ player ) { $ last_move = $ player -> getLastMoveIndex ( ) ; if ( $ player -> isBot ( ) && empty ( $ last_move ) ) { $ move = $ this -> generateMove ( ) ; $ player -> move ( $ move ) ; } } return $ this ; } | Generate Moves For Bots |
43,110 | public function getWinners ( ) { $ outcomes = $ this -> getOutcomes ( ) ; foreach ( $ outcomes as $ outcome ) { $ winners [ ] = $ outcome [ 'winners' ] ; } return $ winners ; } | Get Game Winners |
43,111 | public function findByKey ( $ key ) { $ document = $ this -> collection -> findOne ( [ '_id' => $ key ] ) ; return $ this -> hydrateEntity ( $ document ) ; } | Finds an item by key |
43,112 | public function findByKeys ( array $ keys ) { $ result = [ ] ; $ list = $ this -> collection -> find ( [ '_id' => [ '$in' => $ keys ] ] ) ; foreach ( $ list as $ document ) { $ result [ ] = $ this -> hydrateEntity ( $ document ) ; } return $ result ; } | Finds a list of items by keys |
43,113 | public function add ( $ key , $ data ) { $ toInsert = $ this -> getDocumentData ( $ data ) ; $ result = $ this -> collection -> insertOne ( $ toInsert ) ; $ data -> _id = $ result -> getInsertedId ( ) ; } | adds an item to the registry |
43,114 | protected function getDocumentData ( $ document ) { if ( is_array ( $ document ) ) { $ data = $ document ; } elseif ( $ document instanceof AbstractDocument ) { $ reflectionClass = new \ ReflectionClass ( $ document ) ; $ documentProperty = $ reflectionClass -> getParentClass ( ) -> getProperty ( 'document' ) ; $ documentProperty -> setAccessible ( true ) ; $ data = $ documentProperty -> getValue ( $ document ) ; foreach ( $ data as $ key => & $ value ) { if ( $ value instanceof DocumentSerializableInterface ) { $ value = $ value -> documentSerialize ( ) -> jsonSerialize ( ) ; } } } else { throw new \ Exception ( 'Invalid data type, array or AbstractDocument expected' ) ; } return $ data ; } | Gets document data |
43,115 | private function hydrateEntity ( $ document ) { $ class = $ this -> entityClass ; $ reflectionClass = new \ ReflectionClass ( AbstractDocument :: class ) ; $ entity = new $ class ( ) ; if ( ! ( $ entity instanceof AbstractDocument ) ) { throw new \ Exception ( sprintf ( '"%s" is not a subclass of "%s"' , $ this -> entityClass , AbstractDocument :: class ) ) ; } $ documentProperty = $ reflectionClass -> getProperty ( 'document' ) ; $ documentProperty -> setAccessible ( true ) ; $ documentProperty -> setValue ( $ entity , $ document ) ; return $ entity ; } | Hydrates a document entity with a mongo document |
43,116 | protected function buildItem ( $ position , array $ item ) { $ position += 1 ; list ( $ title , $ aAttr , $ liAttr ) = $ item ; $ base = $ this -> baseAttr ; $ esc = $ this -> escaper -> attr ; $ meta = $ base [ 'meta' ] ; $ meta [ 'content' ] = $ position ; $ liAttr = $ esc ( array_merge_recursive ( $ liAttr , $ base [ 'li' ] ) ) ; $ aAttr = $ esc ( array_merge_recursive ( $ aAttr , $ base [ 'a' ] ) ) ; $ spanAttr = $ esc ( $ base [ 'span' ] ) ; $ title = "<span $spanAttr>$title</span>" ; $ anchor = "<a $aAttr>$title</a>" ; $ meta = $ this -> void ( 'meta' , $ meta ) ; $ this -> html .= $ this -> indent ( 2 , "<li {$liAttr}>" ) ; $ this -> html .= $ this -> indent ( 3 , $ anchor ) ; $ this -> html .= $ this -> indent ( 3 , $ meta ) ; $ this -> html .= $ this -> indent ( 2 , '</li>' ) ; } | build an item |
43,117 | protected function buildActive ( array $ active ) { $ active [ 2 ] = array_merge_recursive ( $ active [ 2 ] , [ 'class' => 'active' ] ) ; $ this -> buildItem ( count ( $ this -> stack ) , $ active ) ; } | build the active item |
43,118 | public function item ( $ title , $ uri = '#' , $ liAttr = [ ] ) { $ this -> stack [ ] = [ $ this -> escaper -> html ( $ title ) , [ 'href' => $ uri ] , $ liAttr , ] ; return $ this ; } | add an item |
43,119 | public function rawItem ( $ title , $ uri = '#' , $ liAttr = [ ] ) { $ this -> stack [ ] = [ $ title , [ 'href' => $ uri ] , $ liAttr ] ; return $ this ; } | add a raw item |
43,120 | public function items ( array $ items ) { foreach ( $ items as $ uri => $ title ) { list ( $ title , $ uri , $ liAttr ) = $ this -> fixData ( $ uri , $ title ) ; $ this -> item ( $ title , $ uri , $ liAttr ) ; } return $ this ; } | add an array of items |
43,121 | public function rawItems ( array $ items ) { foreach ( $ items as $ uri => $ title ) { list ( $ title , $ uri , $ liAttr ) = $ this -> fixData ( $ uri , $ title ) ; $ this -> rawItem ( $ title , $ uri , $ liAttr ) ; } return $ this ; } | add an array of raw items |
43,122 | protected function fixData ( $ uri , $ title ) { $ liAttr = [ ] ; if ( is_int ( $ uri ) ) { $ uri = '#' ; } if ( is_array ( $ title ) ) { $ liAttr = $ title ; $ title = array_shift ( $ liAttr ) ; } return [ $ title , $ uri , $ liAttr ] ; } | fixes item data |
43,123 | public function raw ( $ key ) { if ( ! is_string ( $ key ) ) { throw new \ Calf \ Exception \ InvalidArgument ( 'Key must be string.' ) ; } if ( ! isset ( $ this -> _keys [ $ key ] ) ) { throw new \ Calf \ Exception \ Runtime ( 'Key doesn\'t exists: ' . $ key ) ; } return $ this -> _values [ $ key ] ; } | Get raw value |
43,124 | public function generateAutomaticResponseContent ( $ code , $ reasonPhrase , $ title = null , $ description = null ) { if ( $ title === null ) { $ title = $ code . ' ' . $ reasonPhrase ; } return sprintf ( $ this -> template , $ title , $ code , $ reasonPhrase , $ description ) ; } | Generates response with built - in template . |
43,125 | public function addMethod ( $ method ) { $ method = strtoupper ( $ method ) ; if ( ! in_array ( $ method , self :: $ availableMethods ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid method for route with path "%s". Method must be one of: ' . implode ( ', ' , self :: $ availableMethods ) . '. Got "%s" instead.' , $ this -> getPath ( ) , $ method ) ) ; } if ( ! in_array ( $ method , $ this -> methods ) ) { $ this -> methods [ ] = $ method ; } if ( $ method == 'GET' ) { $ this -> addMethod ( 'HEAD' ) ; } return $ this ; } | Adds method to array of methods accepted by Route |
43,126 | public function getAll ( ) { $ collection = new Collection ; $ keys = $ this -> database -> keys ( $ this -> namespace . ':*' ) ; foreach ( $ keys as $ key ) { list ( $ namespace , $ name ) = explode ( ':' , $ key ) ; if ( ! $ collection -> has ( $ name ) ) { $ collection -> put ( $ name , $ this -> get ( $ name ) ) ; } } return $ collection ; } | Fetch all the queues inside the queues namespace with the delayed and reserved . |
43,127 | public function get ( $ name ) { $ namespaced = $ this -> namespace . ':' . $ name ; $ queued = $ this -> length ( $ namespaced , 'list' ) ; $ delayed = $ this -> length ( $ namespaced . ':delayed' , 'zset' ) ; $ reserved = $ this -> length ( $ namespaced . ':reserved' , 'zset' ) ; return array ( 'queued' => $ queued , 'delayed' => $ delayed , 'reserved' => $ reserved ) ; } | Get the items that a concrete queue contain . |
43,128 | public function getItems ( $ name , $ type ) { $ namespaced = $ this -> namespace . ':' . $ name ; $ key = ( $ type === 'queued' ) ? $ namespaced : $ namespaced . ':' . $ type ; if ( ! $ this -> exists ( $ key ) ) throw new QueueNotFoundException ( $ key ) ; $ type = $ this -> type ( $ key ) ; $ length = $ this -> length ( $ key , $ type ) ; $ method = 'get' . ucwords ( $ type ) . 'Items' ; $ items = $ this -> { $ method } ( $ key , $ length ) ; return Collection :: make ( $ items ) ; } | Retruns a list of items for a given key . |
43,129 | protected function getListItems ( $ key , $ total , $ offset = 0 ) { $ items = array ( ) ; for ( $ i = $ offset ; $ i < $ total ; $ i ++ ) { $ items [ $ i ] = $ this -> database -> lindex ( $ key , $ i ) ; } return $ items ; } | Returns a list of items inside a list . |
43,130 | public function type ( $ key ) { if ( Str :: endsWith ( $ key , ':queued' ) ) { $ key = str_replace ( ':queued' , '' , $ key ) ; } return $ this -> database -> type ( $ key ) ; } | Returns the type of a Redis key . |
43,131 | public function length ( $ key , $ type = null ) { if ( is_null ( $ type ) ) $ type = $ this -> type ( $ key ) ; switch ( $ type ) { case 'list' : return $ this -> database -> llen ( $ key ) ; case 'zset' : return $ this -> database -> zcard ( $ key ) ; default : throw new UnexpectedValueException ( "List type '{$type}' not supported." ) ; } } | Return the length of a given list or set . |
43,132 | public function remove ( $ key , $ value , $ type = null ) { if ( is_null ( $ type ) ) $ type = $ this -> type ( $ key ) ; switch ( $ type ) { case 'list' : $ key = str_replace ( ':queued' , '' , $ key ) ; $ random = Str :: quickRandom ( 64 ) ; $ this -> database -> lset ( $ key , $ value , $ random ) ; return $ this -> database -> lrem ( $ key , 1 , $ random ) ; case 'zset' : return $ this -> database -> zrem ( $ key , $ value ) ; default : throw new UnexpectedValueException ( "Unable to delete {$value} from {$key}. List type {$type} not supported." ) ; } } | Remove an item with a given key index or value . |
43,133 | static public function read ( Smd $ smd , $ classname ) { $ reflectedclass = new \ ReflectionClass ( $ classname ) ; return self :: isValid ( $ smd , $ reflectedclass ) ? new Service ( $ smd , $ reflectedclass ) : false ; } | Read the content of one class and return the result of the analysis . Return FALSE if the cass found is not a valid service . |
43,134 | static protected function isValid ( Smd $ smd , \ ReflectionClass $ reflectedclass ) { $ validator = $ smd -> getServiceValidator ( ) ; if ( $ validator && is_callable ( $ validator ) ) { if ( call_user_func_array ( $ validator , [ $ reflectedclass ] ) === false ) { return false ; } } return true ; } | Validate a class using the custom validation closure . |
43,135 | protected function toArrayPlain ( ) { $ classname = $ this -> resolveClassname ( ) ; $ methods = array ( ) ; foreach ( $ this -> getMethods ( ) as $ method ) { $ method_fullname = $ classname . '.' . $ method -> getName ( ) ; $ methods [ $ method_fullname ] = $ method -> toArray ( ) ; } return $ methods ; } | Return a plain representation of the class methods . |
43,136 | protected function buildLevel ( $ classname ) { $ parts = explode ( '.' , $ classname ) ; $ lastLevel = & $ this -> methods ; foreach ( $ parts as $ part ) { $ lastLevel [ $ part ] = array ( ) ; $ lastLevel = & $ lastLevel [ $ part ] ; } return $ lastLevel ; } | This method is still in development . |
43,137 | protected function toArrayTree ( ) { $ classname = $ this -> getDottedClassname ( ) ; $ lastLevel = $ this -> buildLevel ( $ classname ) ; foreach ( $ this -> getMethods ( ) as $ method ) { $ lastLevel [ $ method -> getName ( ) ] = $ method -> toArray ( ) ; } return $ this -> methods ; } | Return a tree representation of the methods of the reflected class . |
43,138 | public function toArray ( ) { $ fn = 'toArray' . ucfirst ( $ this -> presentation ) ; if ( ! method_exists ( $ this , $ fn ) ) { throw new \ Exception ( 'There is no method ' . $ fn . '.' ) ; } return $ this -> $ fn ( ) ; } | Build and return the class representation as an array . |
43,139 | protected function openStream ( $ path ) { if ( is_string ( $ path ) ) { if ( false !== strpos ( $ path , '://' ) ) { $ path = 'file://' . $ path ; } return fopen ( $ path , 'a' ) ; } return $ path ; } | Open stream for writing |
43,140 | public static function prepare ( $ data , $ forceWindows = false ) { $ lineBreak = "\n" ; if ( DS === '\\' || $ forceWindows === true ) { $ lineBreak = "\r\n" ; } return strtr ( $ data , array ( "\r\n" => $ lineBreak , "\n" => $ lineBreak , "\r" => $ lineBreak ) ) ; } | Prepares a ASCII string for writing . Converts line endings to the correct terminator for the current platform . If Windows \ r \ n will be used all other platforms will use \ n |
43,141 | public function mime ( ) { if ( ! $ this -> exists ( ) ) { return false ; } if ( function_exists ( 'finfo_open' ) ) { $ finfo = finfo_open ( FILEINFO_MIME ) ; $ finfo = finfo_file ( $ finfo , $ this -> pwd ( ) ) ; if ( ! $ finfo ) { return false ; } list ( $ type ) = explode ( ';' , $ finfo ) ; return $ type ; } if ( function_exists ( 'mime_content_type' ) ) { return mime_content_type ( $ this -> pwd ( ) ) ; } return false ; } | Get the mime type of the file . Uses the finfo extension if its available otherwise falls back to mime_content_type |
43,142 | public function setupCommand ( ) { $ serverPublicKeyString = Files :: getFileContents ( 'resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub' , FILE_TEXT ) ; if ( $ serverPublicKeyString === FALSE ) { $ this -> outputLine ( 'Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoServer.pub, exiting.' ) ; $ this -> quit ( 1 ) ; } $ serverPublicKeyFingerprint = $ this -> rsaWalletService -> registerPublicKeyFromString ( $ serverPublicKeyString ) ; $ this -> outputLine ( 'Registered sso demo server public key' ) ; $ clientPrivateKeyString = Files :: getFileContents ( 'resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key' , FILE_TEXT ) ; if ( $ clientPrivateKeyString === FALSE ) { $ this -> outputLine ( 'Could not open resource://Flowpack.SingleSignOn.DemoInstance/Private/Fixtures/DemoClient.key, exiting.' ) ; $ this -> quit ( 2 ) ; } $ clientPublicKeyFingerprint = $ this -> rsaWalletService -> registerKeyPairFromPrivateKeyString ( $ clientPrivateKeyString ) ; $ this -> outputLine ( 'Registered demo client key pair' ) ; $ globalSettings = $ this -> yamlSource -> load ( FLOW_PATH_CONFIGURATION . '/Settings' ) ; $ globalSettings [ 'Flowpack' ] [ 'SingleSignOn' ] [ 'Client' ] [ 'client' ] [ 'publicKeyFingerprint' ] = $ clientPublicKeyFingerprint ; $ globalSettings [ 'Flowpack' ] [ 'SingleSignOn' ] [ 'Client' ] [ 'server' ] [ 'DemoServer' ] [ 'publicKeyFingerprint' ] = $ serverPublicKeyFingerprint ; $ this -> yamlSource -> save ( FLOW_PATH_CONFIGURATION . '/Settings' , $ globalSettings ) ; $ this -> outputLine ( 'Updated settings' ) ; } | Set up the SSO demo instance |
43,143 | public function recv ( ) { $ message = $ this -> ws -> receive ( ) ; if ( empty ( $ message ) ) { return ; } $ message = $ this -> decodeMessage ( $ message ) ; $ this -> injest ( $ message ) ; } | Receive a message from the socket |
43,144 | public function suscribe ( $ events , Closure $ handler ) { if ( is_string ( $ events ) ) $ events = [ $ events ] ; foreach ( $ events as $ event ) { if ( ! array_key_exists ( $ event , $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] ) ) { $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] [ $ event ] = [ ] ; } $ this -> handlers [ static :: MESSAGE_TYPE_STANDARD ] [ $ event ] [ ] = $ handler ; } $ m = $ this -> bareMessage ( static :: MESSAGE_TYPE_SUSCRIBE ) ; $ m -> Payload [ 'Events' ] = $ events ; $ this -> send ( $ m ) ; } | Suscribe to a given event |
43,145 | public function reply ( $ requestId , $ replyClientId , Array $ payload ) { $ m = $ this -> bareMessage ( static :: MESSAGE_TYPE_REPLY ) ; $ m -> ReplyClientId = $ replyClientId ; $ m -> RequestId = $ requestId ; $ m -> Payload = $ payload ; $ this -> send ( $ m ) ; } | Reply to a given request |
43,146 | public function request ( $ requestClientId , Array $ payload , Closure $ handler ) { $ requestId = $ this -> uuid ( ) ; $ this -> handlers [ static :: MESSAGE_TYPE_REPLY ] [ $ requestId ] = $ handler ; $ m = $ this -> bareMessage ( static :: MESSAGE_TYPE_REQUEST ) ; $ m -> RequestClientId = $ requestClientId ; $ m -> RequestId = $ requestId ; $ m -> Payload = $ payload ; $ this -> send ( $ m ) ; } | Make a request to a client |
43,147 | public function emit ( $ event , Array $ payload ) { $ m = $ this -> bareMessage ( static :: MESSAGE_TYPE_STANDARD ) ; $ m -> Event = $ event ; $ m -> Payload = $ payload ; $ this -> send ( $ m ) ; } | Emit a given event |
43,148 | protected function serverRequest ( $ path , $ context ) { if ( strpos ( $ path , '/' ) === 0 ) { $ path = substr ( $ path , 1 ) ; } $ url = sprintf ( 'http://%s/%s' , $ this -> serverUrl , $ path ) ; $ context = stream_context_create ( $ context ) ; $ result = @ file_get_contents ( $ url , false , $ context ) ; if ( $ result === false ) { throw new ClientException ( 'Failed connecting to ' . $ url ) ; } if ( ( $ result = json_decode ( $ result ) ) === false ) { throw new ClientException ( "Failed decoding json response from server" ) ; } if ( empty ( $ result ) ) { throw new ClientException ( "Did not receive a valid client instance" ) ; } return $ result ; } | Execute a request against the server |
43,149 | protected function connectWs ( ) { $ wsUrl = sprintf ( 'ws://%s/v1/clients/%s/ws' , $ this -> serverUrl , $ this -> getId ( ) ) ; $ this -> ws = new WebsocketClient ( $ wsUrl , [ 'timeout' => 30 ] ) ; $ this -> ws -> setTimeout ( 30 ) ; } | Open the websocket connection to the eventsocket server |
43,150 | protected function bareMessage ( $ type ) { $ m = [ 'MessageType' => $ type , 'Event' => null , 'RequestId' => null , 'ReplyClientId' => null , 'RequestClientId' => null , 'Payload' => [ ] , 'Error' => null , ] ; return ( object ) $ m ; } | Instantiate a new message |
43,151 | protected function send ( $ message ) { $ message = $ this -> encodeMessage ( $ message ) ; $ this -> ws -> send ( $ message ) ; } | Send a Message |
43,152 | protected function injest ( $ message ) { switch ( $ message -> MessageType ) { case static :: MESSAGE_TYPE_BROADCAST : $ this -> handleBroadcast ( $ message ) ; break ; case static :: MESSAGE_TYPE_STANDARD : $ this -> handleStandard ( $ message ) ; break ; case static :: MESSAGE_TYPE_REQUEST : $ this -> handleRequest ( $ message ) ; break ; case static :: MESSAGE_TYPE_REPLY : $ this -> handleReply ( $ message ) ; break ; default : throw new ClientException ( 'Unknown MessageType: ' . var_export ( $ message -> MessageType , true ) ) ; } } | Injest and route an incomming message |
43,153 | protected function handleReply ( $ message ) { if ( ! array_key_exists ( $ message -> RequestId , $ this -> handlers [ static :: MESSAGE_TYPE_REPLY ] ) ) { throw new ClientException ( "Request handler not found" ) ; } $ this -> handlers [ static :: MESSAGE_TYPE_REPLY ] [ $ message -> RequestId ] ( $ message ) ; unset ( $ this -> handlers [ static :: MESSAGE_TYPE_REPLY ] [ $ message -> RequestId ] ) ; } | Handle an incomming reply |
43,154 | public function getFirstWorkEmail ( $ id ) { $ people = $ this -> model -> findOrfail ( $ id ) ; foreach ( $ people -> email as $ email ) { if ( $ email -> email_type_id == 3 ) { return $ email -> title ; } } return "there is no email address" ; } | Get the first work email found for a specific People ID |
43,155 | public function getFirstWorkTelephone ( $ id ) { $ people = $ this -> model -> findOrfail ( $ id ) ; foreach ( $ people -> telephone as $ telephone ) { if ( $ telephone -> telephone_type_id == 1 ) { return $ telephone -> title ; } } return "there is no telephone number" ; } | Get the first work telephone number found for a specific People ID |
43,156 | protected function setupBuildProperties ( BuildInterface $ build ) { $ project = $ build -> getProject ( ) ; $ build -> setProperty ( 'project.name' , $ project -> getName ( ) ) ; $ build -> setProperty ( 'build.number' , $ build -> getNumber ( ) ) ; $ build -> setProperty ( 'build.label' , $ build -> getLabel ( ) ) ; } | copies some basic informations to the build object . |
43,157 | protected function validateTask ( $ taskObject ) { try { if ( ! $ taskObject -> validate ( $ msg ) ) { $ this -> log -> warn ( "Task {$taskObject->getName()} is invalid." . ( $ msg ? "\nError message: $msg" : '' ) ) ; return false ; } return true ; } catch ( MalformedConfigException $ e ) { $ this -> log -> error ( "Error in task {$taskObject->getName()} configuration: " . $ e -> getMessage ( ) ) ; return false ; } } | Calls the validate method of a task . |
43,158 | public function getNickName ( ) : ? string { if ( ! $ this -> hasNickName ( ) ) { $ this -> setNickName ( $ this -> getDefaultNickName ( ) ) ; } return $ this -> nickName ; } | Get nick name |
43,159 | function init ( $ idBuilder = "0" , $ tabOnglets = array ( ) ) { $ this -> ongletsArray = $ tabOnglets ; $ this -> typeOngletsArray = array ( ) ; $ this -> optionsOngletParType = array ( ) ; $ this -> idOngletBuilder = $ idBuilder ; $ this -> largeurTotale = 680 ; $ this -> largeurEtiquette = 150 ; $ this -> numOngletSelected = 0 ; $ this -> champHiddenCourant = "" ; $ this -> isContours = true ; $ this -> isAncreOnglet = true ; $ this -> isSpaceInLibelle = true ; $ this -> styleContenu = "" ; } | Pour PHP 4 |
43,160 | function addContent ( $ ongletName = "default" , $ content = "" , $ isSelected = false , $ type = "default" , $ optionsParType = "" ) { $ this -> ongletsArray [ $ ongletName ] = $ content ; $ this -> typeOngletsArray [ $ ongletName ] = $ type ; $ this -> optionsOngletParType [ $ ongletName ] = $ optionsParType ; $ this -> listeOngletJSNameArray [ ] = $ this -> convertIntituleOnglet ( $ ongletName ) . ( count ( $ this -> ongletsArray ) - 1 ) . $ this -> idOngletBuilder ; if ( $ isSelected && count ( $ this -> ongletsArray ) > 0 ) { $ this -> numOngletSelected = count ( $ this -> ongletsArray ) - 1 ; } } | Ajoute du contenu |
43,161 | function getHTMLNoDiv ( ) { $ html = "" ; if ( $ this -> getCountOnglets ( ) > 0 ) { if ( isset ( $ this -> stylesOnglets ) && $ this -> stylesOnglets != '' ) { $ html = $ this -> stylesOnglets ; } $ html .= "<table width='" . $ this -> largeurTotale . "' cellspacing=0 cellpadding=0 border=0><tr><td>" ; $ html .= "<a name='onglet'></a>" ; $ html .= "<table cellspacing=0 cellpadding=0 border=0><tr>" ; $ i = 0 ; foreach ( $ this -> ongletsArray as $ fieldName => $ fieldValue ) { $ className = 'OngletOff' ; if ( $ i == $ this -> numOngletSelected ) { $ className = 'OngletOn' ; } $ html .= "<td height='25' width='" . $ this -> largeurEtiquette . "' class='" . $ className . "' style='border-left:1px solid #000000;'> " ; $ html .= $ fieldName . " </td><td width='4' " . "style='border-bottom:1px solid #000000;'> </td>" ; $ i ++ ; } $ styleContenu = "" ; if ( isset ( $ this -> styleContenu ) ) { $ styleContenu = $ this -> styleContenu ; } $ html .= "<td width='" . ( $ this -> largeurTotale - ( $ i * ( $ this -> largeurEtiquette + 4 ) ) ) . "' style='border-bottom:1px solid #000000;'> </td>" ; $ html .= "</tr></table></td></tr><tr><td " . "style='border-left:1px solid #000000;border-right:1px solid #000000;" . "border-bottom:1px solid #000000;padding:5px;" . $ styleContenu . "'>" ; $ i = 0 ; foreach ( $ this -> ongletsArray as $ fieldName => $ fieldValue ) { if ( $ i == $ this -> numOngletSelected ) { $ html .= $ fieldValue ; } $ i ++ ; } $ html .= "</td></tr></table>" ; } return $ html ; } | Si on affiche les onglets avec cette fonction c est un fonctionnement different le contenu n est pas dans les divs et les liens sur les onglets sont des url |
43,162 | public function find ( $ keyword , $ comp = null , $ type = self :: FIND_TYPE_KEY_ONLY ) { $ this -> _targetLineNumber = null ; $ items = $ this -> getTargetLines ( ) ; foreach ( $ items as $ lineNumber => $ line ) { $ line = trim ( trim ( $ line ) , ',' ) ; $ arr = explode ( '=>' , $ line ) ; foreach ( $ arr as $ idx => $ item ) { $ arr [ $ idx ] = trim ( $ item ) ; } $ key = $ arr [ 0 ] ; if ( count ( $ arr ) > 1 ) { $ val = $ arr [ 1 ] ; } else { $ val = $ arr [ 0 ] ; } $ key = str_replace ( "'" , "" , $ key ) ; $ val = str_replace ( "'" , "" , $ val ) ; $ ret = null ; switch ( $ type ) { case self :: FIND_TYPE_ALL : if ( $ key == $ keyword || $ val == $ comp ) { $ this -> _targetLineNumber = $ lineNumber ; return $ val ; } break ; case self :: FIND_TYPE_KEY_ONLY : if ( $ key == $ keyword ) { $ this -> _targetLineNumber = $ lineNumber ; return $ val ; } break ; case self :: FIND_TYPE_VALUE_ONLY : if ( $ val == $ keyword ) { $ this -> _targetLineNumber = $ lineNumber ; return $ val ; } break ; } } return null ; } | if the target array contains a key or value |
43,163 | public function save ( ) { $ this -> _contentArray = array_merge ( $ this -> _codesBeforeEditArea , $ this -> _editArea , $ this -> _codesAfterEditArea ) ; return $ this ; } | reconstruct the complete file in the memory |
43,164 | protected static function getName ( ElementInterface $ element ) { $ name = $ element -> getName ( ) ; if ( $ name === null || $ name === '' ) { throw new Exception \ DomainException ( sprintf ( '%s requires that the element has an assigned name; none discovered' , __METHOD__ ) ) ; } return $ name . '[]' ; } | Get element name |
43,165 | protected function startCommandsPlugin ( $ app ) { $ this -> onRegister ( 'commands' , function ( $ app ) { if ( $ app -> runningInConsole ( ) ) { foreach ( $ this -> findCommands as $ path ) { $ dir = path_get_directory ( ( new ReflectionClass ( get_called_class ( ) ) ) -> getFileName ( ) ) ; $ classes = $ this -> findCommandsIn ( path_join ( $ dir , $ path ) , $ this -> findCommandsRecursive ) ; $ this -> commands = array_merge ( $ this -> commands , $ classes ) ; } if ( is_array ( $ this -> commands ) && count ( $ this -> commands ) > 0 ) { $ commands = [ ] ; foreach ( $ this -> commands as $ k => $ v ) { if ( is_string ( $ k ) ) { $ app [ $ this -> commandPrefix . $ k ] = $ app -> share ( function ( $ app ) use ( $ k , $ v ) { return $ app -> build ( $ v ) ; } ) ; $ commands [ ] = $ this -> commandPrefix . $ k ; } else { $ commands [ ] = $ v ; } } $ this -> commands ( $ commands ) ; } } } ) ; } | startCommandsPlugin method . |
43,166 | protected function findCommandsIn ( $ path , $ recursive = false ) { $ classes = [ ] ; foreach ( $ this -> findCommandsFiles ( $ path ) as $ filePath ) { $ class = Util :: getClassNameFromFile ( $ filePath ) ; if ( $ class !== null ) { $ namespace = Util :: getNamespaceFromFile ( $ filePath ) ; if ( $ namespace !== null ) { $ class = "$namespace\\$class" ; } $ class = Str :: removeLeft ( $ class , '\\' ) ; $ parents = class_parents ( $ class ) ; if ( $ this -> findCommandsExtending !== null && in_array ( $ this -> findCommandsExtending , $ parents , true ) === false ) { continue ; } $ ref = new \ ReflectionClass ( $ class ) ; if ( $ ref -> isAbstract ( ) ) { continue ; } $ classes [ ] = Str :: removeLeft ( $ class , '\\' ) ; } } return $ classes ; } | findCommandsIn method . |
43,167 | public function getEventTalks ( $ eventId , array $ options = array ( ) ) { $ talks = $ this -> runCommand ( 'event.talks.get' , array ( 'eventId' => $ eventId ) , $ options ) ; return $ this -> assignIdsFromUri ( $ talks ) ; } | Get an array of talks for a given event |
43,168 | public static function factory ( $ config = array ( ) ) { $ defaults = array ( 'base_url' => self :: API_URL , 'version' => 'v2.1' , 'command.params' => array ( 'command.on_complete' => function ( $ command ) { $ response = $ command -> getResult ( ) ; unset ( $ response [ 'meta' ] ) ; if ( count ( $ response ) == 1 ) { $ command -> setResult ( reset ( $ response ) ) ; } } ) ) ; $ required = array ( 'base_url' , 'version' , ) ; $ config = Collection :: fromConfig ( $ config , $ defaults , $ required ) ; $ client = new self ( $ config -> get ( 'base_url' ) , $ config ) ; $ description = ServiceDescription :: factory ( __DIR__ . '/client.json' ) ; $ client -> setDescription ( $ description ) ; return $ client ; } | Factory method to create a new client . |
43,169 | protected function runCommand ( $ command , array $ defaultOptions = array ( ) , array $ options = array ( ) ) { $ command = $ this -> getCommand ( $ command , array_merge ( $ defaultOptions , $ options ) ) ; $ command -> execute ( ) ; return $ command -> getResult ( ) ; } | Run a command by the given name merging default and passed options |
43,170 | protected function assignIdsFromUri ( $ entries ) { foreach ( $ entries as & $ entry ) { $ entry [ 'id' ] = ( int ) preg_replace ( '#.*?(\d+)$#' , '$1' , $ entry [ 'uri' ] ) ; } return $ entries ; } | Loops through a set of entries assigning them IDs based on the item URI |
43,171 | public static function camelCase ( $ str , $ firstChar = 'lcfirst' ) { $ str = str_replace ( [ '-' , '_' , '.' ] , ' ' , $ str ) ; $ str = mb_convert_case ( $ str , MB_CASE_TITLE ) ; $ str = str_replace ( ' ' , '' , $ str ) ; if ( ! function_exists ( $ firstChar ) ) { $ firstChar = 'lcfirst' ; } $ str = call_user_func ( $ firstChar , $ str ) ; return $ str ; } | Retourne une chaine en camelCase avec lcfirst|ucfirst |
43,172 | public static function base64Encode ( $ str , $ stripEgal = true ) { $ str64 = base64_encode ( $ str ) ; if ( $ stripEgal ) { return rtrim ( strtr ( $ str64 , '+/' , '-_' ) , '=' ) ; } return $ str64 ; } | base64_decode sans les == de fin |
43,173 | public function path ( $ route , $ parameters = array ( ) ) { return $ this -> urlGenerator -> generate ( $ route , $ parameters , UrlGeneratorInterface :: ABSOLUTE_PATH ) ; } | Generate a path from the given parameters |
43,174 | public function url ( $ route , $ parameters = array ( ) ) { return $ this -> urlGenerator -> generate ( $ route , $ parameters , UrlGeneratorInterface :: ABSOLUTE_URL ) ; } | Generate an absolute URL from the given parameters |
43,175 | public static function invalidArgument ( string $ class , string $ method , string $ arg , \ Exception $ previous = null ) : self { return new self ( "invalid value of argument \"{$arg}\" in {$class}::{$method}" , self :: INVALID_ARGUMENT , $ previous ) ; } | Creates an exception if an invalid argument was given in a method call . |
43,176 | public function setBaseUrl ( $ url , $ replace = true ) { if ( $ replace || ! $ this -> baseUrl ) { $ this -> baseUrl = $ url ; } return $ this ; } | Set the base URL |
43,177 | public function addModule ( $ name , $ location , $ replace = false ) { if ( $ name == '' ) { throw new exception \ InvalidArgumentException ( 'The require.js module name must not be empty' ) ; } if ( $ replace || ! isset ( $ this -> modules [ $ name ] ) ) { $ this -> modules [ $ name ] = ( string ) $ location ; } return $ this ; } | Define a require . js module location |
43,178 | public function addPackage ( $ name , $ location = null , $ main = null ) { $ name = ( string ) $ name ; if ( $ name == '' ) { throw new exception \ InvalidArgumentException ( 'The require.js package name must not be empty' ) ; } if ( ! $ location && ! $ main ) { $ this -> packages [ $ name ] = $ name ; return $ this ; } $ this -> packages [ $ name ] = [ 'name' => $ name , ] ; if ( $ location ) { $ this -> packages [ $ name ] [ 'location' ] = ( string ) $ location ; } if ( $ main ) { $ this -> packages [ $ name ] [ 'main' ] = ( string ) $ main ; } return $ this ; } | Add a package definition . |
43,179 | public function addBundle ( $ name , array $ deps ) { if ( $ name == '' ) { throw new exception \ InvalidArgumentException ( 'The require.js bundle name must not be empty' ) ; } $ this -> bundles [ $ name ] = [ ] ; $ this -> addToBundle ( $ name , $ deps ) ; return $ this ; } | Add a new bundle definition . |
43,180 | public function addToBundle ( $ name , $ deps ) { if ( $ name == '' ) { throw new exception \ InvalidArgumentException ( 'The require.js bundle name must not be empty' ) ; } if ( ! is_array ( $ deps ) && ! ( $ deps instanceof \ Traversable ) ) { $ deps = [ $ deps ] ; } if ( ! isset ( $ this -> bundles [ $ name ] ) ) { $ this -> bundles [ $ name ] = [ ] ; } foreach ( $ deps as $ item ) { $ item = ( string ) $ item ; if ( $ item != '' ) { $ this -> bundles [ $ name ] [ ] = $ item ; } } return $ this ; } | Adde dependencies to an existing bundle |
43,181 | public function connectionString ( ) { if ( empty ( $ this -> username ) || empty ( $ this -> password ) ) { return sprintf ( "mongodb://%s:%d/%s" , $ this -> host , $ this -> port , $ this -> db ) ; } return sprintf ( "mongodb://%s:%s@%s:%d/%s" , $ this -> username , $ this -> password , $ this -> host , $ this -> port , $ this -> db ) ; } | Forms the connection String |
43,182 | private function _key ( $ identifier ) { extract ( $ identifier ) ; $ arg_string = "" ; return md5 ( serialize ( $ class . $ method . implode ( '~' , $ args ) ) ) ; } | Creates a key for cached class methods |
43,183 | public function isNegative ( $ binaryString ) { $ firstBit = $ binaryString [ 0 ] ; $ negativeFlag = $ firstBit & "\x80" ; $ isNegative = ord ( $ negativeFlag ) == 128 ; return $ isNegative ; } | Public for testing purposes |
43,184 | public function addOneToBytePreserveCarry ( $ currentByte , & $ carry ) { for ( $ i = 0 ; $ i < 8 ; $ i ++ ) { $ bitMaskValue = pow ( 2 , $ i ) ; $ mask = chr ( $ bitMaskValue ) ; $ filteredBit = $ currentByte & $ mask ; if ( $ carry == 1 && ord ( $ filteredBit ) == 0 ) { $ currentByte |= $ mask ; $ carry = 0 ; } else if ( $ carry == 1 && ord ( $ filteredBit ) >= 1 ) { $ flipMask = ~ $ mask ; $ currentByte &= $ flipMask ; } } return $ currentByte ; } | We add one by inserting the 1 into the first carry bit . |
43,185 | public static function import ( ) { if ( count ( func_get_args ( ) ) >= 2 && func_get_arg ( 1 ) !== null ) { extract ( func_get_arg ( 1 ) ) ; } if ( count ( func_get_args ( ) ) < 3 || func_get_arg ( 2 ) === true ) { $ exports = require func_get_arg ( 0 ) ; } else { $ exports = include func_get_arg ( 0 ) ; } return $ exports ; } | Includes a file with an empty variable scope . |
43,186 | public function init ( $ namespace ) { $ namespace = trim ( $ namespace , '\\' ) ; $ namespace_array = explode ( '\\' , $ namespace ) ; $ this -> template_path = implode ( '/' , array_slice ( $ namespace_array , 1 , 2 ) ) ; $ this -> template_path .= '/templates/' ; $ this -> template = call_user_func ( Factory :: load ( 'Config' ) -> get ( 'router.template' ) , $ namespace ) ; $ this -> setContent ( 'page' , Factory :: load ( 'Page' ) -> get ( ) , true ) ; $ module_name = implode ( '/' , array_slice ( $ namespace_array , 2 , 1 ) ) ; $ this -> compile_path = STORAGE_PATH . 'serpent_templates_compiled/' . $ module_name . '/' ; } | The view handler could extend this method to set some parameters . |
43,187 | public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillVersionTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ gossi \ trixionary \ model \ SkillVersion ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( SkillVersionTableMap :: DATABASE_NAME ) ; if ( count ( $ values ) == count ( $ values , COUNT_RECURSIVE ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ value ) { $ criterion = $ criteria -> getNewCriterion ( SkillVersionTableMap :: COL_ID , $ value [ 0 ] ) ; $ criterion -> addAnd ( $ criteria -> getNewCriterion ( SkillVersionTableMap :: COL_VERSION , $ value [ 1 ] ) ) ; $ criteria -> addOr ( $ criterion ) ; } } $ query = SkillVersionQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { SkillVersionTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { SkillVersionTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; } | Performs a DELETE on the database given a SkillVersion or Criteria object OR a primary key value . |
43,188 | public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillVersionTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = SkillVersionQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; } | Performs an INSERT on the database given a SkillVersion or Criteria object . |
43,189 | public function addAction ( Action $ action ) : Editbox { switch ( $ action -> getType ( ) ) { case Action :: SAVE : $ this -> actions [ 0 ] = $ action ; break ; case Action :: CANCEL : $ this -> actions [ 1 ] = $ action ; break ; case Action :: CONTEXT : default : if ( empty ( $ this -> actions [ 2 ] ) ) { $ this -> actions [ 2 ] = [ ] ; } $ this -> actions [ 2 ] [ ] = $ action ; break ; } return $ this ; } | Adds an action link to actions list |
43,190 | public function & createAction ( string $ type , string $ text , string $ href = '' , bool $ ajax = false , string $ confirm = '' ) : Action { $ action = new Action ( ) ; $ action -> setType ( $ type ) ; $ action -> setText ( $ text ) ; if ( ! empty ( $ href ) ) { $ action -> setHref ( $ href ) ; } $ action -> setAjax ( $ ajax ) ; if ( ! empty ( $ confirm ) ) { $ action -> setConfirm ( 'confirm' ) ; } $ this -> addAction ( $ action ) ; return $ action ; } | Creates an action object adds it to the actionslist and returns a reference to it |
43,191 | public function generateActions ( array $ actions ) : Editbox { foreach ( $ actions as $ action ) { $ action_object = new Action ( ) ; if ( empty ( $ action [ 'type' ] ) ) { $ action [ 'type' ] = 'context' ; } $ action_object -> setType ( $ action [ 'type' ] ) ; if ( ! empty ( $ action [ 'text' ] ) ) { $ action_object -> setText ( $ action [ 'text' ] ) ; } if ( ! empty ( $ action [ 'href' ] ) ) { $ action_object -> setHref ( $ action [ 'href' ] ) ; } if ( isset ( $ action [ 'ajax' ] ) ) { $ action_object -> setAjax ( $ action [ 'ajax' ] ) ; } if ( ! empty ( $ action [ 'icon' ] ) ) { $ action_object -> setIcon ( $ action [ 'icon' ] ) ; } if ( ! empty ( $ action [ 'confirm' ] ) ) { $ action_object -> setConfirm ( $ action [ 'confirm' ] ) ; } $ this -> addAction ( $ action_object ) ; } return $ this ; } | Generate actions from an array of action definitions |
43,192 | public function getFilter ( string $ fieldName ) : ? Condition { [ $ name , $ filters ] = $ this -> getArrayAndKeyName ( $ fieldName , 'filters' ) ; return array_first ( $ filters , function ( $ filter ) use ( $ name ) { return $ filter -> getName ( ) === $ name ; } ) ; } | It returns single filter by field name |
43,193 | public function getSort ( $ sortName ) : ? OrderBy { [ $ name , $ sorts ] = $ this -> getArrayAndKeyName ( $ sortName , 'sorts' ) ; return array_first ( $ sorts , function ( $ sort ) use ( $ name ) { return $ sort -> getName ( ) === $ name ; } ) ; } | It returns single sort by field name |
43,194 | public function where ( string $ key , string $ operation , $ value ) { if ( str_contains ( $ key , '.' ) ) { $ fullPath = explode ( '.' , $ key ) ; $ relationPath = implode ( '.' , array_slice ( $ fullPath , 0 , - 1 ) ) ; $ relationKey = last ( $ fullPath ) ; $ result = array_get ( $ this -> relations , $ relationPath , [ 'filters' => [ ] , 'sorts' => [ ] ] ) ; $ result [ 'filters' ] [ ] = new Condition ( $ relationKey , $ operation , $ value ) ; array_set ( $ this -> relations , $ relationPath , $ result ) ; } else { $ this -> filters [ ] = new Condition ( $ key , $ operation , $ value ) ; } return $ this ; } | It adds where condition |
43,195 | public function orderBy ( string $ key , string $ direction ) { if ( str_contains ( $ key , '.' ) ) { $ fullPath = explode ( '.' , $ key ) ; $ relationPath = implode ( '.' , array_slice ( $ fullPath , 0 , - 1 ) ) ; $ relationKey = last ( $ fullPath ) ; $ result = array_get ( $ this -> relations , $ relationPath , [ 'filters' => [ ] , 'sorts' => [ ] ] ) ; $ result [ 'sorts' ] [ ] = new OrderBy ( $ relationKey , $ direction ) ; array_set ( $ this -> relations , $ relationPath , $ result ) ; } else { $ this -> sorts [ ] = new OrderBy ( $ key , $ direction ) ; } return $ this ; } | It adds order by |
43,196 | public function applyFilters ( Builder $ query , string $ alias = null ) { foreach ( $ this -> getFilters ( ) as $ filter ) { $ filter -> apply ( $ query , $ alias ) ; } } | Applies filter to Eloquent Query builder |
43,197 | public function applyRelationFilters ( string $ relationName , string $ alias , Builder $ query ) { foreach ( $ this -> getRelationFilters ( $ relationName ) as $ filter ) { $ filter -> apply ( $ query , $ alias ) ; } } | Applies filters Eloquent Query builder for relation |
43,198 | public function applySorts ( Builder $ query , string $ alias = null ) { foreach ( $ this -> getSorts ( ) as $ sort ) { $ sort -> apply ( $ query , $ alias ) ; } } | Applies sorts Eloquent Query builder |
43,199 | public function applyRelationSorts ( string $ relationName , string $ alias , Builder $ query ) { foreach ( $ this -> getRelationSorts ( $ relationName ) as $ sorts ) { $ sorts -> apply ( $ query , $ alias ) ; } } | Applies sorts Eloquent Query builder for relation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.