idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
10,000 | public function join ( $ table , $ alias = null , $ on = null , $ type = 'INNER JOIN' ) { $ table = $ this -> connection -> quoteIdentifier ( $ table ) ; $ this -> joins [ $ alias ] = "$type $table $alias ON $on" ; return $ this ; } | Join a table |
10,001 | public function leftJoin ( $ table , $ alias = null , $ on = null ) { return $ this -> join ( $ table , $ alias , $ on , 'LEFT JOIN' ) ; } | LEFT OUTER Join a table |
10,002 | public function rightJoin ( $ table , $ alias = null , $ on = null ) { return $ this -> join ( $ table , $ alias , $ on , 'RIGHT JOIN' ) ; } | RIGHT OUTER Join a table |
10,003 | public function innerJoin ( $ table , $ alias = null , $ on = null ) { return $ this -> join ( $ table , $ alias , $ on , 'INNER JOIN' ) ; } | INNER Join a table |
10,004 | public function getLimit ( ) { if ( $ this -> offset && $ this -> limit ) { return $ this -> offset . ',' . $ this -> limit ; } return ( string ) $ this -> limit ; } | Get limit query part |
10,005 | public function getSelectQuery ( ) { $ sql = 'SELECT ' . $ this -> getSelect ( ) ; $ sql .= "\nFROM " . $ this -> getFrom ( ) ; if ( $ this -> where ) { $ sql .= "\nWHERE " . $ this -> getWhere ( ) ; } if ( $ this -> groupBy ) { $ sql .= "\nGROUP BY " . $ this -> getGroupBy ( ) ; } if ( $ this -> having ) { $ sql .= "\... | Get SQL select query |
10,006 | public function getInsertQuery ( ) { $ sql = 'INSERT INTO ' . $ this -> getTable ( ) ; $ sql .= "\n" . $ this -> getColumns ( ) ; $ sql .= "\nVALUES " . $ this -> getValues ( ) ; return $ sql ; } | Get SQL insert query |
10,007 | public function getUpdateQuery ( ) { $ sql = 'UPDATE ' . $ this -> getTable ( ) ; $ sql .= "\nSET " . $ this -> getSet ( ) ; if ( $ this -> where ) { $ sql .= "\nWHERE " . $ this -> getWhere ( ) ; } if ( $ this -> orderBy ) { $ sql .= "\nORDER BY " . $ this -> getOrderBy ( ) ; } if ( $ this -> limit ) { $ sql .= "\nLIM... | Get SQL update query |
10,008 | public function getDeleteQuery ( ) { $ sql = 'DELETE FROM ' . $ this -> getTable ( ) ; if ( $ this -> where ) { $ sql .= "\nWHERE " . $ this -> getWhere ( ) ; } if ( $ this -> limit ) { $ sql .= "\nLIMIT " . $ this -> getLimit ( ) ; } return $ sql ; } | Get SQL delete query |
10,009 | public function mergeParams ( $ method , Array $ params = [ ] ) { $ newParams = [ ] ; $ preparedParams = $ this -> defaultParams ; $ preparedParams [ 'bean' ] = $ params ; $ newParams [ $ method ] = $ preparedParams ; return $ newParams ; } | Group params in a bean |
10,010 | public function getSearchFields ( ) { $ fields = parent :: getSearchFields ( ) ; $ class = $ this -> modelClass ; $ use_autocomplete = $ this -> getConvertToAutocomplete ( ) ; $ db = Config :: inst ( ) -> get ( $ class , "db" ) ; $ has_one = Config :: inst ( ) -> get ( $ class , "has_one" ) ; $ has_many = Config :: ins... | Extend default search fields and add extra functionality . |
10,011 | public function scan ( string $ dir , string $ type = null , & $ res = [ ] , int $ timeout = 0 ) : array { $ res = [ ] ; if ( $ dirs = $ this -> listFiles ( $ dir ) ) { foreach ( $ dirs as $ d ) { if ( $ type && ( strpos ( $ type , 'file' ) === 0 ) && ! isset ( $ d [ 'num' ] ) ) { $ res [ ] = $ d [ 'name' ] ; } else if... | Scans all the content from a directory including the subdirectories |
10,012 | public function delete ( $ item ) { self :: log ( 'delete:' . $ item ) ; if ( $ this -> checkFilePath ( $ item ) && ftp_delete ( $ this -> cn , $ item ) ) { return true ; } return false ; } | Deletes a file from the server |
10,013 | public function put ( $ src , $ dest ) { if ( file_exists ( $ src ) && ( $ dest = $ this -> checkFilePath ( $ dest ) ) && ftp_put ( $ this -> cn , $ dest , $ src , FTP_BINARY ) ) { return true ; } return false ; } | Puts a file on the server |
10,014 | public function get ( $ src , $ dest ) { if ( $ src = $ this -> checkFilePath ( $ src ) && ftp_get ( $ this -> cn , $ dest , $ src , FTP_BINARY ) ) { return true ; } return false ; } | Gets a file from the server |
10,015 | public function move ( string $ old , string $ new ) { if ( ! empty ( $ old ) && ! empty ( $ new ) && ( $ old = $ this -> checkFilePath ( $ old ) ) && ftp_rename ( $ this -> cn , $ old , $ new ) ) { return true ; } return false ; } | Moves or renames a file on the server |
10,016 | public function exists ( string $ path ) { if ( ! empty ( $ path ) ) { $ dir = dirname ( $ path ) ; $ ext = \ bbn \ str :: file_ext ( $ path ) ; $ file = basename ( $ path ) ; if ( \ is_array ( $ files = $ this -> listFiles ( $ dir ) ) ) { foreach ( $ files as $ f ) { if ( $ f [ 'basename' ] === $ file ) { return true ... | Checks if a file is present in a folder on the server |
10,017 | protected function findEndStandardBlock ( $ name , $ lineNumber , $ maxLine , $ targetStepsInto = 0 ) { $ stepsInto = 0 ; for ( $ i = $ lineNumber ; $ i <= $ maxLine ; $ i ++ ) { if ( $ this -> lineTypes [ 'end' . $ name ] [ $ i ] && $ i > $ lineNumber ) { $ stepsInto -- ; if ( $ stepsInto === $ targetStepsInto ) { ret... | Generic algorithm to find the end of a block |
10,018 | public function equals ( Rule $ rule ) { if ( $ this -> ruleHash !== $ rule -> ruleHash ) { return false ; } if ( count ( $ this -> literals ) != count ( $ rule -> literals ) ) { return false ; } for ( $ i = 0 , $ n = count ( $ this -> literals ) ; $ i < $ n ; $ i ++ ) { if ( $ this -> literals [ $ i ] !== $ rule -> li... | Checks if this rule is equal to another one |
10,019 | public static function convertBytes ( $ value ) { if ( is_numeric ( $ value ) ) { return $ value ; } $ value_length = \ strlen ( $ value ) ; $ qty = ( int ) substr ( $ value , 0 , $ value_length - 1 ) ; $ unit = Str :: strtolower ( substr ( $ value , $ value_length - 1 ) ) ; switch ( $ unit ) { case 'k' : $ qty *= 1024... | Convert a shorthand byte value from a PHP configuration directive to an integer value |
10,020 | public function addURL ( $ url , $ options = array ( ) ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; foreach ( $ options as $ option => $ value ) { curl_setopt ( $ ch , $ option , $ value ) ; } return $ this -> addCurl ( $ ch ) ; } | simplifies example and allows for additional curl options to be passed in via array |
10,021 | public function update ( UserPolicy $ user , Team $ team ) { if ( $ user -> canDo ( 'team.team.edit' ) && $ user -> isAdmin ( ) ) { return true ; } return $ team -> user_id == user_id ( ) && $ team -> user_type == user_type ( ) ; } | Determine if the given user can update the given team . |
10,022 | public function destroy ( UserPolicy $ user , Team $ team ) { return $ team -> user_id == user_id ( ) && $ team -> user_type == user_type ( ) ; } | Determine if the given user can delete the given team . |
10,023 | public function includeJavascript ( $ scripts ) { $ src = ( ! is_array ( $ scripts ) ) ? Array ( $ scripts ) : $ scripts ; $ html = '' ; foreach ( $ scripts as $ s ) { if ( ! strstr ( $ s , '/' ) ) { $ s = '/js/' . $ s ; } $ html .= "\n" . '<script type="text/javascript" src="' . $ s . '"></script>' ; } return $ html ;... | Creates a javascript include tag |
10,024 | public function htmlHead ( $ custom_head_markup = '' ) { if ( ! empty ( $ custom_head_markup ) ) { $ this -> custom_head_markup = $ custom_head_markup ; } $ html = $ this -> doc_type . "\n" ; $ html .= $ this -> opening_html_tag . "\n" ; $ html .= '<head>' . "\n" ; $ html .= '<meta http-equiv="Content-Type" content="te... | Renders the HTML head |
10,025 | public static function simplePayload ( array $ payload ) : array { $ payload = array_filter ( $ payload , function ( $ val ) { if ( $ val instanceof PayloadInterface ) { $ val = $ val -> getPayload ( ) ; } if ( is_array ( $ val ) && empty ( $ val ) ) { return false ; } if ( is_null ( $ val ) ) { return false ; } if ( $... | If the input array contains objects of PayloadInterface it will convert these to simple arrays Also it will remove values that are null empty string or empty arrays |
10,026 | public static function rollback ( ) { foreach ( array_reverse ( self :: $ migrationClasses ) as $ migrationClass ) { $ instance = new $ migrationClass ; $ instance -> rollback ( ) ; } } | Rollback application migrations . |
10,027 | public function streamsChannel ( $ channel ) { $ response = $ this -> client -> get ( config ( 'twitch-api.api_url' ) . '/kraken/streams/' . $ channel ) ; return $ response -> json ( ) ; } | Returns a stream object if live . |
10,028 | public function getInheritedElement ( ) { if ( $ this -> inheritedElement !== null ) { return $ this -> inheritedElement ; } $ associatedClass = $ this -> getParent ( ) ; if ( ! $ associatedClass instanceof ClassDescriptor && ! $ associatedClass instanceof InterfaceDescriptor ) { return null ; } $ parentClass = $ assoc... | Returns the Method from which this method should inherit its information if any . |
10,029 | public function transform ( $ translation ) { $ translation = $ this -> entityToArray ( ContentTranslation :: class , $ translation ) ; return [ 'id' => ( int ) $ translation [ 'id' ] , 'langCode' => $ translation [ 'lang_code' ] , 'title' => $ translation [ 'title' ] , 'teaser' => $ translation [ 'teaser' ] , 'body' =... | Transforms content translation entity |
10,030 | protected function processBlockViewData ( BlockView $ blockView , ContextInterface $ context , DataAccessor $ data , $ deferred , $ encoding ) { if ( $ deferred ) { $ this -> expressionProcessor -> processExpressions ( $ blockView -> vars , $ context , $ data , true , $ encoding ) ; } $ this -> buildValueBags ( $ block... | Processes expressions that work with data |
10,031 | public static function fromArrayAndSettings ( $ cfg , $ settings , $ artifact = null ) { $ fileSpecification = new static ( $ cfg , $ settings -> getDirectory ( ) , $ artifact ) ; $ fileSpecification -> set ( "relativeSource" , $ fileSpecification -> getSource ( ) ) ; $ fileSpecification -> set ( "source" , $ settings ... | Creates a file specification from a plain settings array . The settings context is taken into consideration to generate paths relative to the settings . |
10,032 | public function setInterval ( $ interval ) { $ this -> interval = $ interval instanceof DateInterval ? $ interval : new DateInterval ( $ interval ) ; return $ this ; } | Set the limit interval |
10,033 | public function redirect ( $ default = 'home' ) { $ redirect = $ this -> getController ( ) -> plugin ( 'redirect' ) ; $ route = $ this -> getSession ( ) -> route ; if ( null === $ route ) { return $ redirect -> toRoute ( $ default ) ; } return $ redirect -> toRoute ( $ route -> getMatchedRouteName ( ) , $ route -> getP... | Redirect to last route |
10,034 | public function url ( $ default = 'home' ) { $ url = $ this -> getController ( ) -> plugin ( 'url' ) ; $ route = $ this -> getSession ( ) -> route ; if ( null === $ route ) { return $ url -> fromRoute ( $ default ) ; } return $ url -> fromRoute ( $ route -> getMatchedRouteName ( ) , $ route -> getParams ( ) ) ; } | Get last route URL |
10,035 | public function storeRoute ( MvcEvent $ event ) { if ( $ this -> ignore ) { return ; } $ request = $ event -> getRequest ( ) ; if ( $ request -> isXmlHttpRequest ( ) ) { return ; } $ appConfig = $ event -> getApplication ( ) -> getServiceManager ( ) -> get ( 'config' ) ; $ config = array_key_exists ( self :: CONFIG_KEY... | Store route in session so it can be returned to later . |
10,036 | public function resourceSupports ( ) { $ this -> supportedTypes = array_merge ( func_get_args ( ) , $ this -> supportedTypes ) ; $ this -> canClientAcceptThisResponse ( ) ; return $ this ; } | Set a list of content types that this resource supports . |
10,037 | public function resourceRequires ( ) { $ this -> requiredTypes = array_merge ( func_get_args ( ) , $ this -> requiredTypes ) ; $ this -> canServerSupportThisRequest ( ) ; return $ this ; } | Set a list of content types this resource requires . |
10,038 | public function renderResource ( $ view , array $ parameters = [ ] , $ statusCode = 200 ) { $ this -> findContentType ( ) -> findViewType ( ) -> buildViewTemplate ( $ view ) -> checkViewTemplateExists ( ) ; $ response = $ this -> createResponse ( $ statusCode ) ; $ response -> headers -> set ( 'Content-Type' , $ this -... | Creates a Response object and returns it . |
10,039 | protected function convertToArrayDescriptor ( $ descriptor ) { $ arrayDescriptor = new CollectionDescriptor ( 'array' ) ; $ arrayDescriptor -> setTypes ( array ( $ descriptor ) ) ; $ arrayDescriptor -> setKeyTypes ( array ( 'mixed' ) ) ; return $ arrayDescriptor ; } | Wraps the given Descriptor inside a Collection Descriptor of type array and returns that . |
10,040 | protected function findClassNameForType ( $ type ) { $ className = ( isset ( $ this -> typeToValueObjectClassName [ $ type ] ) ) ? $ this -> typeToValueObjectClassName [ $ type ] : false ; return $ className ; } | Returns the class name of the Value Object class associated with a given type or false if the type is unknown . |
10,041 | static public function getImplementations ( ) { $ list = array ( ) ; foreach ( self :: $ implementations as $ name => $ className ) { $ list [ ] = $ name ; } return $ list ; } | Returns a list with supported database implementations . |
10,042 | static public function create ( $ dbParams ) { if ( is_string ( $ dbParams ) ) { $ dbParams = self :: parseDSN ( $ dbParams ) ; } else if ( ! is_array ( $ dbParams ) ) { throw new ezcBaseValueException ( 'dbParams' , $ dbParams , 'string or array' , 'parameter' ) ; } $ impName = null ; foreach ( $ dbParams as $ key => ... | Creates and returns an instance of the specified ezcDbHandler implementation . |
10,043 | public function execute ( $ command , & $ output = null ) { $ cmd = "smbclient '\\\\{$this->host}\\{$this->share}' $this->password -U $this->username -W $this->domain -c '$command' 2>&1" ; exec ( $ cmd , $ output , $ return ) ; if ( $ return === 1 ) { $ errmsg = sprintf ( "Host: %s / Share: %s / Username: %s / Domain: ... | Executes the command line function that completes the remote windows operations |
10,044 | private function parseListing ( $ listing , $ subdir = '' ) { $ ret = new \ sb \ Samba \ Listing ( ) ; $ exp = '/^\s{2}([\w \-]+\.?\w{3,4})\s+([A-Z]?)\s+(\d+)\s+(\w{3}.+)$/' ; preg_match_all ( $ exp , $ listing , $ matches ) ; if ( $ matches [ 0 ] ) { $ ret -> name = $ matches [ 1 ] [ 0 ] ; $ ret -> type = $ matches [ ... | Converts a line of returned output into a \ sb \ Samba_Listing object |
10,045 | public function get ( $ id ) { $ data = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_PEDIDOVENDA . '/empresas/' . $ this -> companyId . '/filiais/' . $ id ) ; return $ data ; } | Gets the branch data according to the id parameter |
10,046 | protected static function getReferrerLocalList ( ) { $ botreferrerlist = array ( ) ; if ( isset ( $ GLOBALS [ 'BOTDETECTION' ] [ 'BOT_REFERRER' ] ) && \ is_array ( $ GLOBALS [ 'BOTDETECTION' ] [ 'BOT_REFERRER' ] ) ) { foreach ( $ GLOBALS [ 'BOTDETECTION' ] [ 'BOT_REFERRER' ] as $ search ) { $ botreferrerlist [ ] = $ se... | Get Referrer List self defined over localconfig |
10,047 | public function channelFileList ( $ cid , $ cpw = "" , $ path = "/" , $ recursive = FALSE ) { $ files = $ this -> execute ( "ftgetfilelist" , array ( "cid" => $ cid , "cpw" => $ cpw , "path" => $ path ) ) -> toArray ( ) ; $ count = count ( $ files ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ files [ $ i ] [ "sid" ]... | Returns a list of files and directories stored in the specified channels file repository . |
10,048 | public function channelGetById ( $ cid ) { if ( ! array_key_exists ( ( string ) $ cid , $ this -> channelList ( ) ) ) { throw new Exception ( "invalid channelID" , 0x300 ) ; } return $ this -> channelList [ intval ( ( string ) $ cid ) ] ; } | Returns the Channel object matching the given ID . |
10,049 | public function channelGetByName ( $ name ) { foreach ( $ this -> channelList ( ) as $ channel ) { if ( $ channel [ "channel_name" ] == $ name ) return $ channel ; } throw new Exception ( "invalid channelID" , 0x300 ) ; } | Returns the Channel object matching the given name . |
10,050 | public function clientList ( array $ filter = array ( ) ) { if ( $ this -> clientList === null ) { $ clients = $ this -> request ( "clientlist -uid -away -badges -voice -info -times -groups -icon -country -ip" ) -> toAssocArray ( "clid" ) ; $ this -> clientList = array ( ) ; foreach ( $ clients as $ clid => $ client ) ... | Returns an array filled with Client objects . |
10,051 | public function clientGetByName ( $ name ) { foreach ( $ this -> clientList ( ) as $ client ) { if ( $ client [ "client_nickname" ] == $ name ) return $ client ; } throw new Exception ( "invalid clientID" , 0x200 ) ; } | Returns the Client object matching the given name . |
10,052 | public function clientGetByUid ( $ uid ) { foreach ( $ this -> clientList ( ) as $ client ) { if ( $ client [ "client_unique_identifier" ] == $ uid ) return $ client ; } throw new Exception ( "invalid clientID" , 0x200 ) ; } | Returns the Client object matching the given unique identifier . |
10,053 | public function clientGetByDbid ( $ dbid ) { foreach ( $ this -> clientList ( ) as $ client ) { if ( $ client [ "client_database_id" ] == $ dbid ) return $ client ; } throw new Exception ( "invalid clientID" , 0x200 ) ; } | Returns the Client object matching the given database ID . |
10,054 | public function clientMove ( $ clid , $ cid , $ cpw = null ) { $ this -> clientListReset ( ) ; $ this -> execute ( "clientmove" , array ( "clid" => $ clid , "cid" => $ cid , "cpw" => $ cpw ) ) ; if ( $ clid instanceof Node ) { $ clid = $ clid -> getId ( ) ; } if ( $ cid instanceof Node ) { $ cid = $ cid -> getId ( ) ; ... | Moves a client to another channel . |
10,055 | public function serverGroupGetById ( $ sgid ) { if ( ! array_key_exists ( ( string ) $ sgid , $ this -> serverGroupList ( ) ) ) { throw new Exception ( "invalid groupID" , 0xA00 ) ; } return $ this -> sgroupList [ intval ( ( string ) $ sgid ) ] ; } | Returns the Servergroup object matching the given ID . |
10,056 | public function selectList ( $ meta , ... $ args ) { if ( ! $ args ) { throw new \ InvalidArgumentException ( ) ; } $ fields = null ; $ query = null ; if ( ! isset ( $ args [ 1 ] ) && $ args [ 0 ] instanceof Query \ Select ) { $ query = $ args [ 0 ] ; } elseif ( ( is_array ( $ args [ 0 ] ) || is_string ( $ args [ 0 ] )... | Dunno about this . Consider it unstable don t count on it still being here in v6 |
10,057 | public function assignRelated ( $ source , $ relationNames = null , $ meta = null ) { if ( ! $ source ) { return ; } $ stack = [ ] ; $ sourceIsArray = is_array ( $ source ) || $ source instanceof \ Traversable ; if ( ! $ sourceIsArray ) { $ source = array ( $ source ) ; } if ( $ meta !== null ) { $ meta = ! $ meta inst... | Retrieve related objects from the database and assign them to the source if the source field is not yet populated . |
10,058 | public function getRelated ( $ source , $ relationName , $ query = null , $ meta = null ) { if ( ! $ source ) { return ; } $ sourceIsArray = false ; $ test = $ source ; if ( is_array ( $ test ) || $ test instanceof \ Traversable ) { $ sourceIsArray = true ; $ test = $ test [ 0 ] ; } if ( ! $ meta ) { if ( $ query insta... | Get related objects from the database |
10,059 | public function insertTable ( $ meta , $ query ) { $ meta = $ meta instanceof Meta ? $ meta : $ this -> mapper -> getMeta ( $ meta ) ; if ( ! $ meta -> canInsert ) { throw new Exception ( "Class {$meta->class} prohibits insert" ) ; } $ query = $ query instanceof Query \ Insert ? $ query : new Query \ Insert ( [ 'values... | Insert values into a table |
10,060 | public function insert ( $ object , $ meta = null ) { $ query = new Query \ Insert ; if ( is_array ( $ meta ) ) { throw new \ BadMethodCallException ( "Please use insertTable()" ) ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ this -> mapper... | Insert an object into the database or values into a table |
10,061 | public function updateTable ( $ meta , ... $ args ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; if ( ! $ meta -> canUpdate ) { throw new Exception ( "Meta {$meta->id} prohibits update" ) ; } $ query = Query \ Update :: fromParamArgs ( $ args ) ; if ( ! $ query -> set ) { thro... | Update a table by criteria . |
10,062 | public function update ( $ object , $ meta = null ) { $ query = new Query \ Update ( ) ; if ( ! is_object ( $ object ) ) { throw new \ BadMethodCallException ( "Please use updateTable()" ) ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ this ... | Update an object in the database or update a table by criteria . |
10,063 | public function deleteTable ( $ meta , ... $ args ) { if ( ! isset ( $ args [ 0 ] ) ) { throw new \ InvalidArgumentException ( "Cannot delete from table without a condition (pass the string '1=1' if you really meant to do this)" ) ; } $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ;... | Delete from a table by criteria |
10,064 | public function delete ( $ object , $ meta = null ) { $ query = new Query \ Criteria ( ) ; if ( ! is_object ( $ object ) ) { throw new \ BadMethodCallException ( "Please use deleteTable()" ) ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ thi... | Delete an object from the database |
10,065 | public function save ( $ object , $ meta = null ) { if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ this -> mapper -> getMeta ( get_class ( $ object ) ) ; } if ( ! $ meta -> primary ) { throw new Exception ( "No primary key for {$meta->id}" ) ; }... | If an object has an autoincrement primary key insert or update as necessary . |
10,066 | public function createKeyCriteria ( $ meta , $ id , $ indexId = null ) { if ( $ indexId == null ) { $ indexId = 'primary' ; } $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; if ( ! isset ( $ meta -> indexes [ $ indexId ] ) ) { throw new Exception ( "Index $indexId does not exist on... | Creates an array criteria for a key index |
10,067 | public function next ( $ is_string = false ) { $ package = '' ; while ( true ) { if ( $ this -> pointer >= $ this -> length ) { return false ; } $ string = $ this -> string [ $ this -> pointer ] ; $ this -> pointer ++ ; if ( $ is_string === true ) { return ord ( $ string ) ; } $ value = decbin ( ord ( $ string ) ) ; if... | get the next |
10,068 | public static function registerAutoload ( $ base_namespace , $ base_path , $ extension = '.php' ) { spl_autoload_register ( function ( $ class_name ) use ( $ base_namespace , $ base_path , $ extension ) { $ file_path = self :: getFilePathForClassName ( $ class_name , $ base_namespace , $ base_path , $ extension ) ; if ... | For Autoload File |
10,069 | public static function removeFromArray ( & $ array , $ keychain ) { if ( ! is_array ( $ array ) ) { $ array = [ ] ; } if ( ! is_array ( $ keychain ) ) { $ keychain = [ $ keychain ] ; } $ headKey = array_shift ( $ keychain ) ; if ( empty ( $ keychain ) ) { unset ( $ array [ $ headKey ] ) ; } else { if ( isset ( $ array ... | Unset item and nested item in array |
10,070 | public function wd ( $ dir = null , $ code = E_USER_WARNING ) { if ( null !== $ dir && is_dir ( $ dir ) ) { $ this -> wd = $ dir ; if ( chdir ( $ dir ) === false ) { throw new \ Exception ( 'Cannot change to directory ' . $ dir . ' in ' . __METHOD__ , $ code ) ; return $ this ; } } else { $ dir = $ this -> wd ; } retur... | set working directory |
10,071 | protected function formatJSON ( SS_List $ list ) { $ ret = array ( ) ; foreach ( $ list as $ item ) { $ ret [ ] = array ( 'id' => $ item -> { $ this -> idField } , 'label' => $ item -> { $ this -> labelField } ) ; } return Convert :: array2json ( $ ret ) ; } | Formats JSON so that it is usable by the JS component |
10,072 | public function query ( SS_HTTPRequest $ r ) { return $ this -> formatJSON ( $ this -> source -> filter ( array ( $ this -> labelField . ':PartialMatch' => $ r -> getVar ( 'q' ) ) ) -> limit ( 10 ) ) ; } | An AJAX endpoint for querying the typeahead |
10,073 | protected function getValuesJSON ( ) { $ value = $ this -> value ; if ( $ value instanceof SS_List ) { $ values = $ value -> column ( $ this -> idField ) ; } else if ( is_array ( $ value ) ) { $ values = array_keys ( $ value ) ; } else if ( is_string ( $ value ) ) { $ values = explode ( ',' , $ value ) ; $ values = str... | Gets the current values assigned to the field formatted as a JSON array |
10,074 | public function setPrefetch ( SS_List $ list ) { if ( ! $ list instanceof SS_List ) { throw new Exception ( 'Prefetch list must be an instance of SS_List' ) ; } $ this -> prefetch = $ list ; return $ this ; } | Sets the prefetch records list |
10,075 | public function Field ( $ properties = array ( ) ) { Requirements :: javascript ( BOOTSTRAP_TAGFIELD_DIR . '/javascript/typeahead.js' ) ; Requirements :: javascript ( BOOTSTRAP_TAGFIELD_DIR . '/javascript/bootstrap-tagfield.js' ) ; Requirements :: javascript ( BOOTSTRAP_TAGFIELD_DIR . '/javascript/bootstrap-tagfield-in... | Renders the field |
10,076 | public function parse ( $ input ) { if ( strlen ( $ input ) == 0 ) { return null ; } return $ this -> parser -> parse ( new TokenStream ( $ this -> tokenizer -> getTokens ( $ input ) ) ) ; } | Parses the raw string input and returns the resulting root node . |
10,077 | public function compile ( $ input ) { if ( strlen ( $ input ) == 0 ) { return null ; } try { $ buffer = new Buffer ( ) ; $ this -> parse ( $ input ) -> compile ( $ buffer ) ; $ code = $ buffer -> getResult ( ) ; return $ code ; } catch ( \ UnexpectedValueException $ e ) { throw new \ UnexpectedValueException ( 'Error w... | Compile an input string to PHP code |
10,078 | protected function unlock ( string $ key ) { if ( ! isset ( $ this -> locks [ $ key ] ) ) { throw new InvalidArgumentError ( 'No lock was set on the given key.' ) ; } $ awaitable = $ this -> locks [ $ key ] ; unset ( $ this -> locks [ $ key ] ) ; $ awaitable -> resolve ( ) ; } | Unlocks the given key . Throws if the key was not locked . |
10,079 | private function _warmup ( ) { $ warmup = new Test ( 'warmup' , function ( ) { } ) ; $ this -> _overhead = $ warmup -> runTest ( $ this -> _count ) ; foreach ( $ this -> _tests as $ test ) { $ test -> runTest ( 1 ) ; } $ this -> out ( 'PHP Overhead: ' . 'time=' . Timer :: formatMS ( $ this -> _overhead [ 'time' ] ) . '... | Runs an empty test to determine the benchmark overhead and run each test once |
10,080 | public function outputTable ( array $ lines , $ padding = 4 ) { $ pad = function ( $ string , $ width ) use ( $ padding ) { if ( $ width > 0 ) { return str_pad ( $ string , $ width , ' ' ) . str_repeat ( ' ' , $ padding ) ; } else { return str_pad ( $ string , - $ width , ' ' , STR_PAD_LEFT ) . str_repeat ( ' ' , $ pad... | Output results in columns padding right if values are string left if numeric |
10,081 | public function formatResults ( array $ results ) { uasort ( $ results [ 'list' ] , function ( $ testOne , $ testTwo ) { if ( $ testOne [ 'time' ] === $ testTwo [ 'time' ] ) { return 0 ; } else { return ( $ testOne [ 'time' ] < $ testTwo [ 'time' ] ) ? - 1 : 1 ; } } ) ; $ minTime = INF ; $ minMemory = INF ; foreach ( $... | Format the results rounding numbers showing difference percentages and removing a flat time based on the benchmark overhead |
10,082 | protected function shouldSelect ( array $ columns = [ '*' ] ) { if ( $ columns === [ '*' ] ) { $ columns = [ $ this -> related -> getTable ( ) . '.*' ] ; } return array_merge ( $ columns , $ this -> aliasedPivotColumns ( ) ) ; } | Get the select columns for the relation query . |
10,083 | public function getProxyServer ( ) { $ proxy_options = $ this -> getOption ( EnumRequestOption :: PROXY_OPTIONS , [ ] ) ; return isset ( $ proxy_options [ EnumProxyOption :: PROXY_SERVER ] ) ? $ proxy_options [ EnumProxyOption :: PROXY_SERVER ] : '' ; } | Returns proxy server |
10,084 | public function getProxyPort ( ) { $ proxy_options = $ this -> getOption ( EnumRequestOption :: PROXY_OPTIONS , [ ] ) ; return isset ( $ proxy_options [ EnumProxyOption :: PROXY_PORT ] ) ? $ proxy_options [ EnumProxyOption :: PROXY_PORT ] : '' ; } | Returns proxy port |
10,085 | public function getProxyType ( ) { $ proxy_options = $ this -> getOption ( EnumRequestOption :: PROXY_OPTIONS , [ ] ) ; return isset ( $ proxy_options [ EnumProxyOption :: PROXY_TYPE ] ) ? $ proxy_options [ EnumProxyOption :: PROXY_TYPE ] : 'http' ; } | Returns proxy type |
10,086 | public function getProxyAuth ( ) { $ proxy_options = $ this -> getOption ( EnumRequestOption :: PROXY_OPTIONS , [ ] ) ; return isset ( $ proxy_options [ EnumProxyOption :: PROXY_AUTH ] ) ? $ proxy_options [ EnumProxyOption :: PROXY_AUTH ] : null ; } | Returns proxy auth |
10,087 | protected function build_input ( $ data , array $ fields = [ ] ) { $ fields = implode ( ' ' , $ fields ) ; return sprintf ( '<textarea id="%1$s" name="%1$s" %2$s>%3$s</textarea>%4$s' , $ this -> name , $ fields , esc_textarea ( $ data ) , $ this -> length_helper ( $ data ) ) ; } | Make input field |
10,088 | public function resolve ( $ route , $ req , $ res , array $ args ) { $ result = false ; if ( is_array ( $ route ) || is_string ( $ route ) ) { if ( is_string ( $ route ) && $ req -> params ( 'controller' ) ) { $ route = [ $ req -> params ( 'controller' ) , $ route ] ; } elseif ( is_string ( $ route ) ) { $ route = [ $ ... | Executes a route handler . |
10,089 | public function convert ( \ DOMElement $ parent , InterfaceDescriptor $ interface ) { $ child = new \ DOMElement ( 'interface' ) ; $ parent -> appendChild ( $ child ) ; foreach ( $ interface -> getParent ( ) as $ parentInterface ) { $ parentFqcn = is_string ( $ parentInterface ) === false ? $ parentInterface -> getFull... | Export the given reflected interface definition to the provided parent element . |
10,090 | private function handle ( $ key , ChildProcessContainer $ child ) { $ tube = $ this -> tube ; $ child -> processOutput ( 'child_' . $ tube . $ key ) ; if ( ! $ child -> checkHealth ( ) ) { $ child -> getReadyForBed ( ) ; } $ readyStatusses = array ( ChildProcessContainer :: STATUS_READY , ChildProcessContainer :: STATU... | Handles all child communication things |
10,091 | private function familyPlanning ( ) { list ( $ total , $ available ) = $ this -> countWorkers ( ) ; if ( $ this -> shutdownGracefully ) { if ( $ total > 0 ) { $ this -> verboseOutput ( "<info>Shutting down</info> $total remaining children" ) ; foreach ( $ this -> family as $ cnr => $ child ) { $ this -> verboseOutput (... | Produce more hands for the work needed |
10,092 | public function countWorkers ( ) { $ total = count ( $ this -> family ) ; $ busy = 0 ; $ available = 0 ; foreach ( $ this -> family as & $ child ) { switch ( $ child -> status ) { case ChildProcessContainer :: STATUS_ALIVE : case ChildProcessContainer :: STATUS_READY : $ available ++ ; break ; case ChildProcessContaine... | Returns an array with the worker counts |
10,093 | public function moreOrLess ( $ total , $ available ) { $ shouldHaveMoreWorkers = false ; $ shouldHaveLessWorkers = false ; $ minWorkers = $ this -> input -> getOption ( 'min-workers' ) ; $ maxWorkers = $ this -> input -> getOption ( 'max-workers' ) ; $ spareWorkers = $ this -> input -> getOption ( 'spare-workers' ) ; i... | Returns two booleans if there should be more or less workers |
10,094 | private function findDisposableWorkers ( ) { $ disposableStatusses = array ( ChildProcessContainer :: STATUS_READY , ChildProcessContainer :: STATUS_ALIVE ) ; foreach ( $ this -> family as & $ child ) { if ( in_array ( $ child -> status , $ disposableStatusses ) ) { if ( $ child -> getAge ( ) < 10 ) { continue ; } $ ch... | Finds disposable workers if it finds them it returns true |
10,095 | private function spawnChild ( ) { $ child = new ChildProcessContainer ( $ this -> consolePath , $ this -> input -> getOption ( 'worker-command' ) , $ this -> tube , $ this ) ; $ child -> start ( ) ; return $ child ; } | Spawns a new child |
10,096 | protected function createEventObject ( $ eventName , array $ data ) { if ( ! array_key_exists ( $ eventName , $ this -> options [ 'events' ] ) ) { throw new \ InvalidArgumentException ( 'Event is not defined.' ) ; } $ namespace = $ this -> options [ 'events' ] [ $ eventName ] [ 'object' ] ; $ instance = new $ namespace... | return event object or create it if not exist |
10,097 | public function triggerEvent ( $ name , array $ data = [ ] ) { try { $ event = $ this -> createEventObject ( $ name , $ data ) ; } catch ( \ InvalidArgumentException $ exception ) { return $ this ; } foreach ( $ this -> options [ 'events' ] [ $ name ] [ 'listeners' ] as $ eventListener ) { if ( $ event -> isPropagation... | trigger new event with automatic call all subscribed listeners |
10,098 | public function addEventListener ( $ eventName , array $ listeners ) { if ( ! array_key_exists ( $ eventName , $ this -> options [ 'events' ] ) ) { $ this -> options [ 'events' ] [ $ eventName ] = [ 'object' => BaseEvent :: class , 'listeners' => $ listeners , ] ; } $ this -> options [ 'events' ] [ $ eventName ] [ 'lis... | dynamically add new listener or listeners for given event name listeners are added at end of the list |
10,099 | public function readEventConfiguration ( $ path , $ type ) { if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( 'File ' . $ path . 'don\'t exists.' ) ; } $ name = '\BlueEvent\Event\Config\\' . ucfirst ( $ type ) . 'Config' ; if ( ! class_exists ( $ name ) ) { throw new \ InvalidArgumentException (... | read configuration from file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.