idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
3,000 | protected function preload ( $ post_type = 'post' ) { $ args = array ( 'fields' => 'ids' , 'orderby' => 'post_date' , 'order' => 'DESC' , 'post_status' => 'publish' , 'post_type' => $ post_type , 'showposts' => - 1 , 'suppress_filters' => true , ) ; $ query = new WP_Query ( $ args ) ; if ( $ query -> have_posts ( ) ) {... | Loops through posts to compile static HTML for each . |
3,001 | public function upload ( $ model , $ folderName , $ files , $ fileAttrName = 'files' , $ width = null ) { $ updatedFiles = $ model -> $ fileAttrName ; foreach ( $ files as $ file ) { $ log = ( new FileLog ) -> create ( [ 'model_id' => $ model -> id , 'model_name' => $ folderName , 'file_original_name' => $ file -> getC... | Upload files for model without save model |
3,002 | public function delete ( $ model , $ log , $ fileAttrName = 'files' , $ fileLogId = 0 ) { $ updatedFiles = [ ] ; if ( $ log ) $ fileLogId = $ log -> id ; $ fileToDelete = [ ] ; foreach ( $ model -> files as $ file ) { if ( $ file [ 'file_log_id' ] == $ fileLogId ) $ fileToDelete = $ file ; else $ updatedFiles [ ] = $ f... | Delete file for model without save model |
3,003 | protected function getSupportedSizes ( ) { return [ FieldInterface :: SIZE_TINY , FieldInterface :: SIZE_SMALL , FieldInterface :: SIZE_MEDIUM , FieldInterface :: SIZE_NORMAL , FieldInterface :: SIZE_BIG ] ; } | Return an array of supported sizes . |
3,004 | protected function outputFixtures ( InputInterface $ input , OutputInterface $ output , $ fixtures ) { $ output -> writeln ( sprintf ( 'List of "%s" data fixtures ...' , $ this -> getTypeOfFixtures ( $ input ) ) ) ; foreach ( $ fixtures as $ fixture ) { $ output -> writeln ( sprintf ( ' <comment>></comment> <info>%s</... | Output list of fixtures |
3,005 | public function on ( string $ tag ) : Event { $ event = $ this -> events [ $ tag ] ?? null ; if ( $ event ) { return $ event ; } return $ this -> events [ $ tag ] = new Event ( $ this , $ tag ) ; } | Returns a registered Event if exists otherwise creates a new Event |
3,006 | public static function stringify ( $ value ) { if ( is_string ( $ value ) ) { return $ value ; } if ( $ value === null || is_bool ( $ value ) ) { return var_export ( $ value , true ) ; } if ( is_array ( $ value ) || ( is_object ( $ value ) && ! method_exists ( $ value , '__toString' ) ) ) { return json_encode ( $ value... | Converts a value into a string . |
3,007 | public function intAdd ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new IntType ( $ a ( ) + $ b ( ) ) ; } | Integer type addition |
3,008 | public function intSub ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new IntType ( $ a ( ) - $ b ( ) ) ; } | Integer type subtraction |
3,009 | public function intMul ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new IntType ( $ a ( ) * $ b ( ) ) ; } | Integer type multiplication |
3,010 | public function intPow ( IntType $ a , NI $ exp ) { if ( $ exp instanceof RationalType ) { $ b = new RationalType ( clone $ a , new IntType ( 1 ) ) ; return $ this -> rationalPow ( $ b , $ exp ) ; } if ( $ exp instanceof ComplexType ) { return $ this -> intComplexPow ( $ a ( ) , $ exp ) ; } $ p = pow ( $ a ( ) , $ exp ... | Integer Pow - raise number to the exponent Will return an IntType RationalType or ComplexType |
3,011 | public function intSqrt ( IntType $ a ) { $ res = $ this -> rationalSqrt ( new RationalType ( $ a , new IntType ( 1 ) ) ) ; if ( $ res -> isInteger ( ) ) { return $ res -> numerator ( ) ; } return $ res ; } | Integer sqrt Return IntType for perfect squares else RationalType |
3,012 | public function floatPow ( FloatType $ a , NI $ exp ) { if ( $ exp instanceof RationalType ) { $ b = RationalTypeFactory :: fromFloat ( $ a ( ) ) ; return $ this -> rationalPow ( $ b , $ exp ) -> asFloatType ( ) ; } if ( $ exp instanceof ComplexType ) { return $ this -> floatComplexPow ( $ a ( ) , $ exp ) ; } $ p = pow... | Float Pow - raise number to the exponent Will return a float type |
3,013 | public function wholeAdd ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new WholeIntType ( $ a ( ) + $ b ( ) ) ; } | Whole number addition |
3,014 | public function wholeSub ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new WholeIntType ( $ a ( ) - $ b ( ) ) ; } | Whole number subtraction |
3,015 | public function wholeMul ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new WholeIntType ( $ a ( ) * $ b ( ) ) ; } | Whole number multiplication |
3,016 | public function naturalAdd ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new NaturalIntType ( $ a ( ) + $ b ( ) ) ; } | Natural number addition |
3,017 | public function naturalSub ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new NaturalIntType ( $ a ( ) - $ b ( ) ) ; } | Natural number subtraction |
3,018 | public function naturalMul ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkIntTypes ( $ a , $ b ) ; return new NaturalIntType ( $ a ( ) * $ b ( ) ) ; } | Natural number multiplication |
3,019 | public function rationalAdd ( NI $ a , NI $ b ) { if ( ! $ a instanceof RationalType ) { $ a = $ a -> asRational ( ) ; } if ( ! $ b instanceof RationalType ) { $ b = $ b -> asRational ( ) ; } $ d = RationalTypeFactory :: create ( $ this -> lcm ( $ a -> denominator ( ) -> get ( ) , $ b -> denominator ( ) -> get ( ) ) ) ... | Rational number addition |
3,020 | public function rationalSub ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkRationalTypes ( $ a , $ b ) ; $ d = RationalTypeFactory :: create ( $ this -> lcm ( $ a -> denominator ( ) -> get ( ) , $ b -> denominator ( ) -> get ( ) ) ) ; $ nn = $ this -> rationalDiv ( $ this -> rationalMul ( $ a -> numerator ( ... | Rational number subtraction |
3,021 | public function rationalDiv ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkRationalTypes ( $ a , $ b ) ; $ n = $ this -> intMul ( $ a -> numerator ( ) , $ b -> denominator ( ) ) ; $ d = $ this -> intMul ( $ a -> denominator ( ) , $ b -> numerator ( ) ) ; return RationalTypeFactory :: create ( $ n , $ d ) ; } | Rational number division |
3,022 | public function rationalPow ( RationalType $ a , NI $ exp ) { if ( $ exp instanceof ComplexType ) { $ r = $ this -> floatComplexPow ( $ a ( ) , $ exp ) ; if ( $ r instanceof FloatType ) { return RationalTypeFactory :: fromFloat ( $ r ( ) ) ; } return $ r ; } $ exp2 = $ exp -> get ( ) ; $ numF = pow ( $ a -> numerator (... | Rational Pow - raise number to the exponent Will return a RationalType |
3,023 | public function complexAdd ( ComplexType $ a , ComplexType $ b ) { $ r = $ this -> rationalAdd ( $ a -> r ( ) , $ b -> r ( ) ) ; $ i = $ this -> rationalAdd ( $ a -> i ( ) , $ b -> i ( ) ) ; return ComplexTypeFactory :: create ( $ r , $ i ) ; } | Complex number addition |
3,024 | public function complexSub ( ComplexType $ a , ComplexType $ b ) { $ r = $ this -> rationalSub ( $ a -> r ( ) , $ b -> r ( ) ) ; $ i = $ this -> rationalSub ( $ a -> i ( ) , $ b -> i ( ) ) ; return ComplexTypeFactory :: create ( $ r , $ i ) ; } | Complex number subtraction |
3,025 | public function complexMul ( ComplexType $ a , ComplexType $ b ) { $ r = $ this -> rationalSub ( $ this -> rationalMul ( $ a -> r ( ) , $ b -> r ( ) ) , $ this -> rationalMul ( $ a -> i ( ) , $ b -> i ( ) ) ) ; $ i = $ this -> rationalAdd ( $ this -> rationalMul ( $ a -> i ( ) , $ b -> r ( ) ) , $ this -> rationalMul (... | Complex number multiplication |
3,026 | public function complexDiv ( ComplexType $ a , ComplexType $ b ) { if ( $ b -> isZero ( ) ) { throw new \ BadMethodCallException ( 'Cannot divide complex number by zero complex number' ) ; } $ div = $ this -> rationalAdd ( $ this -> rationalMul ( $ b -> r ( ) , $ b -> r ( ) ) , $ this -> rationalMul ( $ b -> i ( ) , $ ... | Complex number division |
3,027 | public function complexPow ( ComplexType $ a , NI $ exp ) { if ( $ exp instanceof ComplexType ) { $ comp = new Comparator ( ) ; $ zero = new IntType ( 0 ) ; $ real = 0 ; $ imaginary = 0 ; if ( ! ( $ comp -> eq ( $ a -> r ( ) , $ zero ) && $ comp -> eq ( $ a -> i ( ) , $ zero ) ) ) { list ( $ real , $ imaginary ) = $ th... | Complex Pow - raise number to the exponent Will return a ComplexType Exponent must be non complex |
3,028 | private function intComplexPow ( $ a , ComplexType $ exp ) { if ( $ exp -> isZero ( ) ) { return new IntType ( 1 ) ; } return $ this -> complexExponent ( $ a , $ exp ) ; } | Create Complex power from an integer |
3,029 | private function floatComplexPow ( $ a , ComplexType $ exp ) { if ( $ exp -> isZero ( ) ) { return new FloatType ( 1 ) ; } return $ this -> complexExponent ( $ a , $ exp ) ; } | Create complex power from a float |
3,030 | private function complexExponent ( $ base , ComplexType $ exp ) { if ( $ exp -> isReal ( ) ) { return $ this -> rationalPow ( RationalTypeFactory :: fromFloat ( $ base ) , $ exp -> r ( ) ) ; } $ b = $ exp -> i ( ) -> get ( ) ; $ n = log ( $ base ) ; $ r = cos ( $ b * $ n ) ; $ i = sin ( $ b * $ n ) ; if ( $ exp -> r ( ... | Create complex power from natural base and complex exponent |
3,031 | public function getRunner ( Route $ route ) { if ( isset ( $ route -> controller ) ) { $ class = Runner \ Controller :: class ; } elseif ( isset ( $ route -> fn ) ) { $ class = Runner \ Callback :: class ; } elseif ( isset ( $ route -> file ) ) { $ class = Runner \ PhpScript :: class ; } else { trigger_error ( "Route h... | Create Runner instance |
3,032 | protected function addPriceToPriceGroup ( $ price , $ item , & $ groupPrices , & $ groupedItems ) { $ itemPriceGroup = $ item -> getCalcPriceGroup ( ) ; if ( $ itemPriceGroup === null ) { $ itemPriceGroup = 'undefined' ; } if ( ! isset ( $ groupPrices [ $ itemPriceGroup ] ) ) { $ groupPrices [ $ itemPriceGroup ] = 0 ; ... | adds price to a price - group |
3,033 | public function UTCTimeZoneOffset ( ) : int { $ originDateTime = new \ DateTime ( 'now' , $ this ) ; $ utcTimeZone = new \ DateTimeZone ( 'UTC' ) ; $ utcDateTime = new \ DateTime ( 'now' , $ utcTimeZone ) ; return $ utcTimeZone -> getOffset ( $ utcDateTime ) - $ this -> getOffset ( $ originDateTime ) ; } | Get offset between a time zone and UTC time zone in seconds . |
3,034 | public function setFieldOption ( $ field , $ option , $ value ) { if ( ! isset ( $ this -> fields [ $ field ] ) ) { throw new \ Exception ( "Cannot set field option: Field {$field} not found" ) ; } $ this -> fields [ $ field ] [ 'options' ] [ $ option ] = $ value ; } | Override a field option |
3,035 | public function getBidding ( ) { $ items = Item :: typeAuction ( ) -> active ( ) -> whereHas ( 'bids' , function ( $ query ) { return $ query -> where ( 'user_id' , Auth :: user ( ) -> userId ) ; } ) ; $ items = Item :: typeAuction ( ) -> active ( ) -> leftJoin ( 'bids' ) -> where ( 'bids.user_id' , Auth :: user ( ) ->... | Return the inventory bidding items view . |
3,036 | private function filterByMethod ( array $ methods , $ alt ) { $ methods = array_flip ( array_map ( 'strtolower' , $ methods ) ) ; foreach ( $ this -> routes as $ route ) { if ( isset ( $ methods [ $ route -> getAction ( ) [ 1 ] ] ) === $ alt ) { $ route -> forget ( ) ; } } } | Forget the grouped routes filtering by http methods . |
3,037 | public function translate ( array $ translations ) { foreach ( $ this -> routes as $ route ) { $ action = $ route -> getAction ( ) [ 1 ] ; if ( $ action === "make" && isset ( $ translations [ "make" ] ) ) { $ route -> setPatternWithoutReset ( str_replace ( "make" , $ translations [ "make" ] , $ route -> getPattern ( ) ... | Translate the make or edit from resources path . |
3,038 | public function member ( $ route ) { $ resource = new self ; $ resource -> set ( $ route ) ; $ this -> nest ( $ resource ) ; } | Add a route or a group of routes to the resource it means that every added route will now receive the parameters of the resource like id . |
3,039 | public function nest ( self $ resource ) { foreach ( $ this -> routes as $ route ) { if ( $ route -> getAction ( ) [ 1 ] === "show" ) { $ this -> set ( $ resource -> forget ( ) -> setPrefix ( $ this -> getNestedPrefix ( $ route -> getPattern ( ) ) ) ) ; break ; } } return $ this ; } | Nested routes capture the relation between a resource and another resource . |
3,040 | public function shallow ( self $ resource ) { $ newResource = new self ; $ resource -> forget ( ) ; $ routes = $ resource -> all ( ) ; foreach ( $ routes as $ route ) { if ( strpos ( "index make create" , $ route -> getAction ( ) [ 1 ] ) !== false ) { $ newResource -> set ( $ route ) ; } } return $ this -> nest ( $ new... | Nest resources but with only build routes with the minimal amount of information to uniquely identify the resource . |
3,041 | protected function getNestedPrefix ( $ pattern ) { $ segments = explode ( "/" , $ pattern ) ; $ pattern = "" ; foreach ( $ segments as $ index => $ segment ) { if ( strpos ( $ segment , "{" ) === 0 ) { $ pattern .= "/{" . $ segments [ $ index - 1 ] . "_" . ltrim ( $ segment , "{" ) ; } else $ pattern .= $ segment ; } r... | Resolve the nesting pattern setting the prefixes based on parent resources patterns . |
3,042 | public function isBot ( ) : bool { if ( null === $ this -> isBot ) { $ this -> isBot = false ; foreach ( $ this -> botSignatures as $ botSignature ) { if ( preg_match ( $ botSignature , $ this -> name ) === 1 ) { $ this -> isBot = true ; break ; } } } return $ this -> isBot ; } | returns whether user agent is a bot or not |
3,043 | public function insert ( $ query , $ params = array ( ) ) { $ this -> _testQueryStarts ( $ query , 'insert' ) ; return $ this -> _executeQuery ( $ query , $ params , true ) ; } | executes INSERT query with placeholders in 2nd param |
3,044 | private function registerCommands ( ) { $ this -> commands ( [ Console \ Commands \ SeedCountries :: class , Console \ Commands \ SeedCurrencies :: class , Console \ Commands \ SeedTimezones :: class , Console \ Commands \ SeedTaxRates :: class , ] ) ; } | Register the console commands . |
3,045 | private function SetObjData ( $ _table , $ _fields , $ _data ) { $ this -> table = $ _table ; $ this -> fields = $ _fields ; $ this -> data [ ] = array ( ) ; if ( isset ( $ _data [ 0 ] ) and is_array ( $ _data [ 0 ] ) ) { for ( $ i = 0 ; $ i < count ( $ _data ) ; $ i ++ ) { foreach ( $ this -> fields as $ field ) { if ... | sets data to be inserted or updated - cleans unwanted chars |
3,046 | private function IsFieldLocked ( $ field ) { if ( ! is_array ( $ this -> locked_fields ) ) { return false ; } $ locked_tables = array_keys ( $ this -> locked_fields ) ; $ locked_fields = array_values ( $ this -> locked_fields ) ; $ _locked_fields = array ( ) ; foreach ( $ locked_fields as $ locked_field ) { if ( is_arr... | finds locked fields |
3,047 | private function FetchFields ( $ res ) { if ( ! $ this -> debug_on ) { return ; } $ i = 0 ; $ this -> col_info = array ( ) ; while ( $ i < @ pg_num_fields ( $ res ) ) { $ this -> col_info [ $ i ] -> name = @ pg_field_name ( $ res , $ i ) ; $ this -> col_info [ $ i ] -> size = @ pg_field_size ( $ res , $ i ) ; $ this ->... | fetches table fields |
3,048 | private function Fetch ( $ res , $ row_no = null , $ offset = null ) { if ( is_numeric ( $ row_no ) ) { $ limit = 1 ; } else { $ limit = $ this -> GetNumRows ( ) ; } if ( is_numeric ( $ offset ) ) { $ c_output = PGSQL_NUM ; } else { $ c_output = PGSQL_ASSOC ; } $ this -> FetchFields ( $ res ) ; $ i = 0 ; $ this -> resu... | fetches result into array . also gets info about fields |
3,049 | private function SetErrCode ( ) { $ connection_status = @ pg_connection_status ( $ this -> conn ) ; $ last_error = @ pg_last_error ( $ this -> conn ) ; $ result_error = @ pg_result_error ( $ this -> conn ) ; $ last_notice = @ pg_last_notice ( $ this -> conn ) ; $ _errors = array ( ) ; if ( $ connection_status ) { $ _er... | sets error code returned by pgsql |
3,050 | private function SetDebugDump ( $ offset = null ) { if ( ! $ this -> query_result or ! $ this -> debug_on ) { return ; } $ report = '<b>DATA:</b><br /> <table border="0" cellpadding="5" cellspacing="1" style="background-color:#555555"> <tr style="background-color:#eeeeee"><td nowrap valign="bottom"><font ... | Data dump from select query |
3,051 | private function SetQuerySummary ( ) { if ( ! $ this -> query_result or ! $ this -> debug_on ) { return ; } $ this -> printOutStr .= "<div class=\"alert alert-info\"><b>Query:</b> " . nl2br ( $ this -> last_query ) . "<br /> <b>Rows affected:</b> " . $ this -> GetAffRows ( ) . "<br /> <b>Num rows:</b> " .... | gathers some info about executed query |
3,052 | final function Query ( $ qry ) { $ GLOBALS [ 'qry_count' ] ++ ; $ GLOBALS [ 'qry' ] .= $ GLOBALS [ 'qry_count' ] . ':' . $ qry . "\n" ; $ this -> last_query = $ qry ; $ this -> query_result = $ this -> ExecQuery ( $ qry ) ; if ( $ this -> query_result ) { $ this -> SetQuerySummary ( ) ; return $ this -> query_result ; ... | runs query - wrapper for ExecQuery |
3,053 | final function GetLastID ( $ offset = 0 , $ seq_suffix = 'seq' ) { $ regs = array ( ) ; preg_match ( "/insert\\s*into\\s*\"?(\\w*)\"?/i" , $ this -> last_query , $ regs ) ; if ( count ( $ regs ) > 1 ) { $ table_name = $ regs [ 1 ] ; $ res = @ pg_query ( $ this -> conn , "SELECT * FROM $table_name WHERE 1 != 1" ) ; $ qu... | gets last inserted id |
3,054 | final function GetResults ( $ qry ) { if ( $ this -> lock_sel_data ) { return array ( ) ; } if ( $ this -> Query ( $ qry ) ) { $ this -> result = $ this -> Fetch ( $ this -> query_result ) ; $ this -> SetDebugDump ( ) ; return $ this -> result ; } return array ( ) ; } | gets results from select query |
3,055 | final function GetCol ( $ qry , $ offset = 0 ) { if ( $ this -> lock_sel_data ) { return array ( ) ; } if ( $ this -> Query ( $ qry ) ) { $ this -> result = $ this -> Fetch ( $ this -> query_result , null , $ offset ) ; $ this -> SetDebugDump ( $ offset ) ; return $ this -> result [ 0 ] ; } return array ( ) ; } | gets one col from a table |
3,056 | final function GetVar ( $ qry , $ row_no = 0 , $ offset = 0 ) { if ( $ this -> lock_sel_data ) { return array ( ) ; } if ( $ this -> Query ( $ qry ) ) { $ this -> result = $ this -> Fetch ( $ this -> query_result , $ row_no , $ offset ) ; $ this -> SetDebugDump ( $ offset ) ; return $ this -> result [ 0 ] [ 0 ] ; } ret... | gets one var from a table |
3,057 | function JoinNotEmpty ( $ separator , $ array ) { if ( ! is_array ( $ array ) ) { return '' ; } $ rv = trim ( array_shift ( $ array ) ) ; foreach ( $ array as $ item ) { $ item = $ this -> Escape ( trim ( $ item ) ) ; if ( $ rv != '' and $ item != '' ) { $ rv .= $ separator ; } $ rv .= $ item ; } return $ rv ; } | same as join but wont allow empty vals and escapes values for safe use in query |
3,058 | function IN ( $ items ) { $ comma_separated_items = $ this -> JoinNotEmpty ( "','" , is_array ( $ items ) ? $ items : explode ( ',' , $ items ) ) ; $ count_items = substr_count ( $ comma_separated_items , ',' ) + 1 ; if ( trim ( $ comma_separated_items ) == '' ) { $ count_items = 0 ; } if ( $ count_items > 1 ) { return... | sets SQL statement for IN items |
3,059 | public function setClientCredentials ( $ id , $ secret ) { $ this -> clientId = $ id ; $ this -> clientSecret = $ secret ; return $ this ; } | set the client credentials |
3,060 | public function getAuthenticationGateway ( $ authorizeUri , $ accessTokenUri , $ redirectUri ) { if ( ! $ this -> redirector instanceof Redirector ) { throw new \ RuntimeException ( "A Redirector is required for authentication" ) ; } $ gateway = new AuthenticationGateway ( $ this -> httpClient , $ this -> redirector ) ... | factory method for authentication gateway |
3,061 | public function getCheckinsGateway ( $ userId = null ) { $ gateway = new CheckinsGateway ( $ this -> httpClient ) ; $ this -> injectGatewayDependencies ( $ gateway , $ userId ) ; return $ gateway ; } | factory method for checkins gateway |
3,062 | public function getPhotosGateway ( $ userId = null ) { $ gateway = new PhotosGateway ( $ this -> httpClient ) ; $ this -> injectGatewayDependencies ( $ gateway , $ userId ) ; return $ gateway ; } | factory method for photos gateway |
3,063 | protected function getRequestUri ( ) { if ( ! $ this -> requestUri ) { $ this -> requestUri = rtrim ( $ this -> endpointUri , '/' ) . '/' . $ this -> version ; } return $ this -> requestUri ; } | get the uri to make requests to |
3,064 | public function filterByUser ( $ user , $ comparison = null ) { if ( $ user instanceof \ Alchemy \ Component \ Cerberus \ Model \ User ) { return $ this -> addUsingAlias ( UserRoleTableMap :: COL_USER_ID , $ user -> getId ( ) , $ comparison ) ; } elseif ( $ user instanceof ObjectCollection ) { if ( null === $ compariso... | Filter the query by a related \ Alchemy \ Component \ Cerberus \ Model \ User object |
3,065 | public function useUserQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinUser ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'User' , '\Alchemy\Component\Cerberus\Model\UserQuery' ) ; } | Use the User relation User object |
3,066 | public function to ( $ connector ) { if ( ! array_key_exists ( $ connector , $ this -> connectors ) ) { throw new ConnectorException ( "Connector [$connector] not found. Available connectors: " . implode ( ', ' , array_keys ( $ this -> connectors ) ) . '.' ) ; } return $ this -> connectors [ $ connector ] ; } | Get connector instance |
3,067 | public static function getMessage ( array $ config = [ ] ) : Message { $ message = Message :: class ; $ msgConf = $ config [ 'message' ] ?? [ ] ; if ( ! empty ( $ config [ 'message' ] [ 'instance' ] ) ) { $ message = $ config [ 'message' ] [ 'instance' ] ; unset ( $ config [ 'message' ] [ 'instance' ] ) ; } $ message =... | Initializes a Message instance from the logger configuration . Message configuration must be set in an array with the key message . |
3,068 | public static function getChannel ( array $ config = [ ] ) : Channel { $ channel = new Channel ( ) ; $ channel -> setHandler ( static :: getHandler ( $ config [ 'handler' ] ?? [ ] ) ) ; $ channel -> setFormatter ( static :: getFormatter ( $ config [ 'formatter' ] ?? [ ] ) ) ; return $ channel ; } | Initializes a Channel instance . |
3,069 | public static function getHandler ( array $ config = [ ] ) : AbstractHandler { if ( ! empty ( $ config [ 'instance' ] ) ) { $ handler = $ config [ 'instance' ] ; unset ( $ config [ 'instance' ] ) ; } else { $ handler = StreamHandler :: class ; } return new $ handler ( $ config ) ; } | Initializes a handler instance . If the configuration is empty a default handler is returned . All settings except instance are passed to the handler constructor . If declared an instance value must be a fully qualified class name . |
3,070 | public static function getFormatter ( array $ config = [ ] ) : AbstractFormatter { if ( ! empty ( $ config [ 'instance' ] ) ) { $ formatter = $ config [ 'instance' ] ; unset ( $ config [ 'instance' ] ) ; } else { $ formatter = JsonFormatter :: class ; } return new $ formatter ( $ config ) ; } | Initializes a formatter instance . If the configuration is empty a default formatter is returned . All settings except instance are passed to the formatter constructor . If declared an instance value must be a fully qualified class name . |
3,071 | public function setQueries ( $ queries ) { $ this -> queries = [ ] ; if ( ! is_array ( $ queries ) ) { $ queries = [ $ queries ] ; } foreach ( $ queries as $ query ) { $ this -> addQuery ( $ query ) ; } return $ this ; } | Sets the media queries for the rule . |
3,072 | protected function getQueryInstanceFromQueryString ( $ queryString ) { if ( preg_match ( '/^[ \r\n\t\f]*(?:(only[ \r\n\t\f]+)|(not[ \r\n\t\f]+))?([^ \r\n\t\f]*)[ \r\n\t\f]*(?:(?:and)?[ \r\n\t\f]*)*$/iD' , $ queryString , $ matches ) ) { $ type = $ matches [ 3 ] === "" ? MediaQuery :: TYPE_ALL : $ matches [ 3 ] ; $ quer... | Extracts the type from the query part of the media rule and returns a MediaQuery instance for it . |
3,073 | protected function parseConditionList ( $ conditionList ) { $ charset = $ this -> getCharset ( ) ; $ conditions = [ ] ; foreach ( Condition :: splitNestedConditions ( $ conditionList ) as $ normalizedConditionList ) { $ normalizedConditions = [ ] ; $ currentCondition = "" ; if ( preg_match ( '/[^\x00-\x7f]/' , $ normal... | Parses the condition part of the media rule . |
3,074 | public function getPanel ( ) { $ template = new FileTemplate ( ) ; $ template -> registerFilter ( new Engine ) ; $ template -> registerHelperLoader ( 'Nette\\Templating\\Helpers::loader' ) ; $ template -> setFile ( __DIR__ . '/MailPanel.latte' ) ; $ template -> baseUrl = $ this -> request -> getUrl ( ) -> getBaseUrl ( ... | Show content of panel |
3,075 | public function setCode ( int $ code , string $ reasonPhrase = null ) : self { $ this -> code = $ code ; $ this -> reasonPhrase = null === $ reasonPhrase ? Http :: reasonPhraseFor ( $ code ) : $ reasonPhrase ; return $ this ; } | sets the status code |
3,076 | private function fixateCode ( int $ code ) : self { $ this -> setCode ( $ code ) ; $ this -> fixed = true ; return $ this ; } | sets status code and sets status to fixed |
3,077 | public function created ( $ uri , string $ etag = null ) : self { $ this -> headers -> location ( $ uri ) ; if ( null !== $ etag ) { $ this -> headers -> add ( 'ETag' , $ etag ) ; } return $ this -> fixateCode ( 201 ) ; } | sets status to 201 Created |
3,078 | public function noContent ( ) : self { $ this -> allowsPayload = false ; $ this -> headers -> add ( 'Content-Length' , 0 ) ; return $ this -> fixateCode ( 204 ) ; } | sets status code to 204 No Content |
3,079 | public function resetContent ( ) : self { $ this -> allowsPayload = false ; $ this -> headers -> add ( 'Content-Length' , 0 ) ; return $ this -> fixateCode ( 205 ) ; } | sets status code to 205 Reset Content |
3,080 | public function partialContent ( $ lower , $ upper , $ total = '*' , string $ rangeUnit = 'bytes' ) : self { $ this -> headers -> add ( 'Content-Range' , $ rangeUnit . ' ' . $ lower . '-' . $ upper . '/' . $ total ) ; return $ this -> fixateCode ( 206 ) ; } | sets status code to 206 Partial Content |
3,081 | public function redirect ( $ uri , int $ statusCode = 302 ) : self { $ this -> headers -> location ( $ uri ) ; return $ this -> fixateCode ( $ statusCode ) ; } | sets status to 30x |
3,082 | public function unauthorized ( array $ challenges ) : self { if ( count ( $ challenges ) === 0 ) { throw new \ InvalidArgumentException ( 'Challenges must contain at least one entry' ) ; } $ this -> headers -> add ( 'WWW-Authenticate' , join ( ', ' , $ challenges ) ) ; return $ this -> fixateCode ( 401 ) ; } | sets status to 401 Unauthorized |
3,083 | public function rangeNotSatisfiable ( $ total , string $ rangeUnit = 'bytes' ) : self { $ this -> headers -> add ( 'Content-Range' , $ rangeUnit . ' */' . $ total ) ; return $ this -> fixateCode ( 416 ) ; } | sets status to 416 Range Not Satisfiable |
3,084 | public function line ( $ httpVersion , string $ sapi = PHP_SAPI ) : string { if ( 'cgi' === $ sapi ) { return 'Status: ' . $ this -> code . ' ' . $ this -> reasonPhrase ; } return $ httpVersion . ' ' . $ this -> code . ' ' . $ this -> reasonPhrase ; } | returns status line |
3,085 | public function department ( $ name , Closure $ callback ) { $ department = $ this -> createDepartment ( $ name ) ; call_user_func ( $ callback , $ department ) ; if ( is_null ( static :: $ departments ) ) { static :: $ departments = Collection :: make ( [ ] ) ; } static :: $ departments -> push ( $ department ) ; retu... | Register new department |
3,086 | public function setCharset ( $ charset ) { if ( is_string ( $ charset ) ) { if ( in_array ( $ charset , mb_list_encodings ( ) ) ) { $ this -> charset = $ charset ; } else { throw new \ InvalidArgumentException ( "Invalid value '" . $ charset . "' for argument 'charset' given. Charset not supported." ) ; } } else { thro... | Sets the charset for the style sheet . |
3,087 | public static function renderValue ( SQL \ Set $ item ) { $ value = $ item -> getValue ( ) ; $ content = $ item -> getContent ( ) ; if ( $ value instanceof SQL \ SQL ) { return $ value -> getContent ( ) ; } elseif ( $ value instanceof Query \ Select ) { return Compiler :: braced ( Select :: render ( $ value ) ) ; } els... | Render the value of Set object |
3,088 | public static function render ( SQL \ Set $ item ) { return Compiler :: expression ( array ( Compiler :: name ( $ item -> getContent ( ) ) , '=' , self :: renderValue ( $ item ) ) ) ; } | Render a Set object |
3,089 | public function withFactory ( $ factory ) { if ( ! is_callable ( $ factory ) ) { throw new \ InvalidArgumentException ( "Factory isn't callable" ) ; } $ runner = clone $ this ; $ runner -> factory = $ factory ; return $ runner ; } | Create a clone that uses the provided factory |
3,090 | public function run ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ route = $ request -> getAttribute ( 'route' ) ; $ name = ! empty ( $ route -> controller ) ? $ route -> controller : 'default' ; try { $ controller = call_user_func ( $ this -> getFactory ( ) , $ name ) ; } catch ( \ Exception $... | Route to a controller |
3,091 | public function setExtraColumn ( $ name , $ visible = false , $ description = '' ) { $ extraColumns = is_array ( $ name ) ? $ name : [ [ $ name , $ visible , $ description ] ] ; foreach ( $ extraColumns as $ column ) { if ( ! is_array ( $ column ) ) $ column = [ $ column ] ; $ this -> extraColumn [ $ column [ 0 ] ] = [... | Sets the Extra column . |
3,092 | public function hydrate ( & $ object , $ datas , $ soft = false , $ maxReferenceDepth = 10 ) { $ stream = $ object -> getStream ( ) ; if ( isset ( $ datas [ 'stream' ] ) ) { $ stream = $ datas [ 'stream' ] ; unset ( $ datas [ 'stream' ] ) ; } if ( isset ( $ datas [ "metadata" ] ) ) { $ metadata = $ datas [ "metadata" ]... | Hydrate an object from data |
3,093 | public function unhydrate ( $ object ) { $ datas = parent :: unhydrate ( $ object ) ; $ properties = $ this -> classMetadata -> getPropertiesInfos ( ) ; foreach ( $ properties as $ name => $ infos ) { if ( $ infos -> getMetadata ( ) ) { if ( isset ( $ datas [ $ infos -> getField ( ) ] ) ) { $ datas [ "metadata" ] [ $ i... | Unhydrate object to array |
3,094 | public function getPending ( ) { $ dqb = $ this -> _em -> createQueryBuilder ( ) ; $ dqb -> select ( array ( 'j' ) ) -> from ( 'PlaygroundCore\Entity\Cronjob' , 'j' ) -> where ( $ dqb -> expr ( ) -> in ( 'j.status' , array ( self :: STATUS_PENDING ) ) ) -> orderBy ( 'j.scheduleTime' , 'ASC' ) ; return $ dqb -> getQuery... | get pending cron jobs |
3,095 | public function getRunning ( ) { $ dqb = $ this -> _em -> createQueryBuilder ( ) ; $ dqb -> select ( array ( 'j' ) ) -> from ( 'PlaygroundCore\Entity\Cronjob' , 'j' ) -> where ( $ dqb -> expr ( ) -> in ( 'j.status' , array ( self :: STATUS_RUNNING ) ) ) -> orderBy ( 'j.scheduleTime' , 'ASC' ) ; return $ dqb -> getQuery... | get running cron jobs |
3,096 | public function getHistory ( ) { $ dqb = $ this -> _em -> createQueryBuilder ( ) ; $ dqb -> select ( array ( 'j' ) ) -> from ( 'PlaygroundCore\Entity\Cronjob' , 'j' ) -> where ( $ dqb -> expr ( ) -> in ( 'j.status' , array ( self :: STATUS_SUCCESS , self :: STATUS_MISSED , self :: STATUS_ERROR , ) ) ) -> orderBy ( 'j.s... | get completed cron jobs |
3,097 | public function process ( RequestInterface $ request , ResponseInterface $ response , DelegateInterface $ next = null ) { try { if ( $ next ) { return $ next -> next ( $ request , $ response ) ; } return $ response ; } catch ( \ Exception $ e ) { return WhoopsRunner :: handle ( $ e , $ request ) ; } } | Should be the very first middleware in the queue |
3,098 | public function iniHumanFriendlySize ( $ size ) { switch ( substr ( $ size , - 1 ) ) { case 'G' : $ size = $ size * 1024 ; case 'M' : $ size = $ size * 1024 ; case 'K' : $ size = $ size * 1024 ; } return $ this -> humanFileSize ( $ size ) ; } | Human friendly file size of a value using a convention supported in php ini values . |
3,099 | public function getMimeType ( $ file ) { if ( function_exists ( 'finfo_open' ) ) { $ const = defined ( 'FILEINFO_MIME_TYPE' ) ? FILEINFO_MIME_TYPE : FILEINFO_MIME ; $ info = finfo_open ( $ const ) ; if ( $ info && ( $ result = finfo_file ( $ info , $ file , $ const ) ) !== false ) { finfo_close ( $ info ) ; return $ re... | Get a file type based on the file MIME info . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.