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 ( ) ) { $ posts = apply_filters ( 'staticwp_preload_' . $ post_type . '_posts' , $ query -> posts ) ; foreach ( $ posts as $ post_id ) { $ this -> updateHtml ( $ post_id ) ; } } }
|
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 -> getClientOriginalName ( ) , ] ) ; $ systemFileName = $ this -> createSystemFileName ( $ log , $ file ) ; $ filePath = $ this -> createFilePath ( $ folderName , $ systemFileName ) ; $ folderPath = $ this -> createFilePath ( $ folderName ) ; Storage :: put ( $ filePath , file_get_contents ( $ file -> path ( ) ) ) ; $ log -> fill ( [ 'file_path' => $ filePath , 'file_system_name' => $ systemFileName ] ) -> save ( ) ; if ( $ width ) $ this -> imageResize ( $ width , $ file , $ filePath ) ; $ updatedFiles [ ] = [ 'file_log_id' => $ log -> id , 'path' => asset ( $ log -> file_path ) , 'file_original_name' => $ log -> file_original_name ] ; } $ model -> $ fileAttrName = $ updatedFiles ; return $ model ; }
|
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 [ ] = $ file ; } if ( $ log ) Storage :: delete ( $ log -> file_path ) ; else Storage :: delete ( $ fileToDelete [ 'path' ] ) ; if ( $ log ) $ log -> delete ( ) ; $ model -> $ fileAttrName = $ updatedFiles ; return $ model ; }
|
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</info>' , get_class ( $ fixture ) ) ) ; } }
|
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 , JSON_ERROR_NONE | JSON_UNESCAPED_SLASHES ) ; } return ( string ) $ 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 ( ) ) ; if ( ( $ p - intval ( $ p ) ) === 0 ) { return new IntType ( $ p ) ; } return RationalTypeFactory :: fromFloat ( $ p ) ; }
|
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 ( $ a ( ) , $ exp ( ) ) ; return new FloatType ( $ p ) ; }
|
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 ( ) ) ) ; $ nn = $ this -> rationalDiv ( $ this -> rationalMul ( $ a -> numerator ( ) , $ d ) , $ a -> denominator ( ) ) -> get ( ) ; $ nd = $ this -> rationalDiv ( $ this -> rationalMul ( $ b -> numerator ( ) , $ d ) , $ b -> denominator ( ) ) -> get ( ) ; $ n = $ this -> intAdd ( new IntType ( $ nn ) , new IntType ( $ nd ) ) ; return RationalTypeFactory :: create ( $ n , $ d -> numerator ( ) ) ; }
|
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 ( ) , $ d ) , $ a -> denominator ( ) ) -> get ( ) ; $ nd = $ this -> rationalDiv ( $ this -> rationalMul ( $ b -> numerator ( ) , $ d ) , $ b -> denominator ( ) ) -> get ( ) ; $ n = $ this -> intSub ( new IntType ( $ nn ) , new IntType ( $ nd ) ) ; return RationalTypeFactory :: create ( $ n , $ d -> 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 ( ) -> get ( ) , $ exp2 ) ; $ denF = pow ( $ a -> denominator ( ) -> get ( ) , $ exp2 ) ; $ numR = RationalTypeFactory :: fromFloat ( $ numF ) ; $ denR = RationalTypeFactory :: fromFloat ( $ denF ) ; return $ this -> rationalDiv ( $ numR , $ denR ) ; }
|
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 ( $ a -> r ( ) , $ b -> i ( ) ) ) ; return ComplexTypeFactory :: create ( $ r , $ i ) ; }
|
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 ( ) , $ b -> i ( ) ) ) ; $ r = $ this -> rationalDiv ( $ this -> rationalAdd ( $ this -> rationalMul ( $ a -> r ( ) , $ b -> r ( ) ) , $ this -> rationalMul ( $ a -> i ( ) , $ b -> i ( ) ) ) , $ div ) ; $ i = $ this -> rationalDiv ( $ this -> rationalSub ( $ this -> rationalMul ( $ a -> i ( ) , $ b -> r ( ) ) , $ this -> rationalMul ( $ a -> r ( ) , $ b -> i ( ) ) ) , $ div ) ; return ComplexTypeFactory :: create ( $ r , $ 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 ) = $ this -> getPowExponentPartsFromPolar ( $ a , $ exp ) ; } return new ComplexType ( RationalTypeFactory :: fromFloat ( $ real ) , RationalTypeFactory :: fromFloat ( $ imaginary ) ) ; } $ n = $ exp ( ) ; $ nTheta = $ n * $ a -> theta ( ) -> get ( ) ; $ pow = pow ( $ a -> modulus ( ) -> get ( ) , $ n ) ; $ real = cos ( $ nTheta ) * $ pow ; $ imaginary = sin ( $ nTheta ) * $ pow ; return new ComplexType ( RationalTypeFactory :: fromFloat ( $ real ) , RationalTypeFactory :: fromFloat ( $ imaginary ) ) ; }
|
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 ( ) -> get ( ) == 0 ) { return new ComplexType ( RationalTypeFactory :: fromFloat ( $ r ) , RationalTypeFactory :: fromFloat ( $ i ) ) ; } $ na = pow ( $ base , $ exp -> r ( ) -> get ( ) ) ; $ rr = $ na * $ r ; $ ii = $ na * $ i ; return new ComplexType ( RationalTypeFactory :: fromFloat ( $ rr ) , RationalTypeFactory :: fromFloat ( $ ii ) ) ; }
|
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 has neither 'controller', 'fn' or 'file' defined" , E_USER_NOTICE ) ; return null ; } return new $ class ( ) ; }
|
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 ; } $ groupPrices [ $ itemPriceGroup ] += $ price ; if ( ! isset ( $ groupedItems [ $ itemPriceGroup ] ) ) { $ groupedItems [ $ itemPriceGroup ] = array ( 'items' => array ( ) ) ; if ( method_exists ( $ item , 'getCalcPriceGroupContent' ) && $ content = $ item -> getCalcPriceGroupContent ( ) ) { $ groupedItems [ $ itemPriceGroup ] = array_merge ( $ content , $ groupedItems [ $ itemPriceGroup ] ) ; } } $ groupedItems [ $ itemPriceGroup ] [ 'items' ] [ ] = $ item ; $ groupedItems [ $ itemPriceGroup ] [ 'price' ] = $ groupPrices [ $ itemPriceGroup ] ; $ groupedItems [ $ itemPriceGroup ] [ 'priceFormatted' ] = $ this -> itemPriceCalculator -> formatPrice ( $ groupPrices [ $ itemPriceGroup ] , null ) ; }
|
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 ( ) -> userId ) -> addSelect ( DB :: raw ( 'max(`bids`.`amount`) as `max_bid`' ) ) -> addSelect ( DB :: raw ( 'count(`bids`.`bid_id`) as `bid_count`' ) ) -> groupBy ( 'items.item_id' ) ; $ table = new InventoryBidding ( $ items ) ; return view ( 'mustard::inventory.bidding' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
|
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 ( ) ) ) ; } elseif ( $ action === "edit" && isset ( $ translations [ "edit" ] ) ) { $ route -> setPatternWithoutReset ( str_replace ( "edit" , $ translations [ "edit" ] , $ route -> getPattern ( ) ) ) ; } } return $ this ; }
|
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 ( $ newResource ) ; }
|
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 ; } return $ pattern ; }
|
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 ( isset ( $ _data [ $ i ] [ $ field ] ) and ! $ this -> IsFieldLocked ( $ field ) ) { $ this -> data [ $ i ] [ $ field ] = $ this -> Escape ( $ _data [ $ i ] [ $ field ] ) ; } } } } else { foreach ( $ this -> fields as $ field ) { if ( isset ( $ _data [ $ field ] ) and ! $ this -> IsFieldLocked ( $ field ) ) { $ this -> data [ 0 ] [ $ field ] = $ this -> Escape ( $ _data [ $ field ] ) ; } } } }
|
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_array ( $ locked_field ) ) { foreach ( $ locked_field as $ _locked_field ) { $ _locked_fields [ ] = $ _locked_field ; } } else { $ _locked_fields [ ] = $ locked_field ; } } if ( in_array ( $ this -> table , $ locked_tables ) and in_array ( $ field , $ _locked_fields ) ) { return true ; } return false ; }
|
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 -> col_info [ $ i ] -> type = @ pg_field_type ( $ res , $ i ) ; $ i ++ ; } }
|
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 -> result = array ( ) ; while ( $ rs = @ pg_fetch_array ( $ res , $ row_no , $ c_output ) and $ limit > $ i ) { $ this -> result [ $ i ] = ( $ offset ? $ rs [ $ offset ] : $ rs ) ; $ i ++ ; } @ pg_free_result ( $ this -> conn ) ; return $ this -> result ; }
|
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 ) { $ _errors [ ] = ( $ connection_status ? $ connection_status : '' ) ; } if ( $ last_error ) { $ _errors [ ] = ( $ last_error ? $ last_error : '' ) ; } if ( $ result_error ) { $ _errors [ ] = ( $ result_error ? $ result_error : '' ) ; } if ( $ last_notice ) { $ _errors [ ] = ( $ last_notice ? $ last_notice : '' ) ; } if ( count ( $ _errors ) > 0 ) { if ( $ _REQUEST [ act ] == 'api' ) { foreach ( $ _errors as $ _error ) { $ lines = explode ( "\n" , $ _error ) ; $ api_errors [ ] = $ lines ; } $ err_string = json_encode ( [ 'error' => 'DB_error' , 'errors' => $ api_errors ] ) ; } else { $ err_string = '<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> ' . $ this -> last_query . '<br /><pre class="red">' . implode ( '<br />' , $ _errors ) . "</pre></div>" ; } $ this -> errStr .= $ err_string ; $ GLOBALS [ no_refresh ] = 1 ; } }
|
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 color="555599" size="2"><b>(row)</b></font></td>' ; if ( is_numeric ( $ offset ) ) { $ z = 2 ; $ report .= '<td nowrap align="left" valign="top"><font size="1" color="555599">' . $ this -> col_info [ $ offset ] -> type . ' ' . $ this -> col_info [ $ offset ] -> size . '</font><br><font size=2><b>' . $ this -> col_info [ $ offset ] -> name . '</b></font></td>' ; } else { $ z = count ( $ this -> col_info ) ; for ( $ i = 0 ; $ i < $ z ; $ i ++ ) { $ report .= '<td nowrap align="left" valign="top"><font size="1" color="555599">' . $ this -> col_info [ $ i ] -> type . ' ' . $ this -> col_info [ $ i ] -> size . '</font><br><font size=2><b>' . $ this -> col_info [ $ i ] -> name . '</b></font></td>' ; } } $ report .= "</tr>" ; if ( is_array ( $ this -> result ) and count ( $ this -> result ) > 0 ) { $ i = 0 ; foreach ( $ this -> result as $ one_row ) { $ i ++ ; $ report .= '<tr bgcolor="ffffff"><td style="background-color:#eeeeee" nowrap align="middle"><font size="2" color="555599">' . $ i . '</font></td>' ; if ( is_array ( $ one_row ) ) { foreach ( $ one_row as $ item ) { $ report .= '<td nowrap style="background-color:#ffffff"><font size="2">' . htmlspecialchars ( $ item ) . '</font></td>' ; } } else { $ report .= '<td nowrap style="background-color:#ffffff"><font size="2">' . htmlspecialchars ( $ one_row ) . '</font></td>' ; } $ report .= "</tr>" ; } } else { $ report .= '<tr bgcolor="ffffff"><td colspan="' . ( $ z + 1 ) . '"><font size=2>No Results</font></td></tr>' ; } $ report .= "</table>" ; $ this -> printOutStr .= $ report ; }
|
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> " . $ this -> GetNumRows ( ) . "<br />" . ( $ this -> GetLastID ( ) ? "<b>Last INSERT ID:</b> " . $ this -> GetLastID ( ) . "<br />" : "" ) . "</div>" ; }
|
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 ; } $ this -> SetErrCode ( ) ; if ( ! $ this -> show_errors ) { $ this -> WriteError ( $ this -> GetErr ( ) ) ; } return false ; }
|
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" ) ; $ query_for_id = "SELECT CURRVAL('{$table_name}_" . @ pg_field_name ( $ res , $ offset ) . "_{$seq_suffix}'::regclass)" ; $ result_for_id = @ pg_query ( $ this -> conn , $ query_for_id ) ; $ last_id = @ pg_fetch_array ( $ result_for_id , 0 , PGSQL_NUM ) ; return $ last_id [ 0 ] ; } return null ; }
|
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 ] ; } return array ( ) ; }
|
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 " IN ('$comma_separated_items') " ; } elseif ( $ count_items == 1 ) { return " = '$comma_separated_items' " ; } else { return ' IS NULL ' ; } }
|
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 ) ; $ gateway -> setAuthorizeUri ( $ authorizeUri ) -> setAccessTokenUri ( $ accessTokenUri ) -> setRedirectUri ( $ redirectUri ) -> setClientCredentials ( $ this -> clientId , $ this -> clientSecret ) ; return $ gateway ; }
|
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 === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( UserRoleTableMap :: COL_USER_ID , $ user -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByUser() only accepts arguments of type \Alchemy\Component\Cerberus\Model\User or Collection' ) ; } }
|
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 = new $ message ( $ msgConf ) ; return $ 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 ] ; $ query = new MediaQuery ( $ type ) ; if ( ! empty ( $ matches [ 1 ] ) ) { $ query -> setIsOnly ( true ) ; } if ( ! empty ( $ matches [ 2 ] ) ) { $ query -> setIsNot ( true ) ; } return $ query ; } return null ; }
|
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]/' , $ normalizedConditionList ) ) { $ isAscii = false ; $ strLen = mb_strlen ( $ normalizedConditionList , $ charset ) ; $ getAnd = function ( $ i ) use ( $ normalizedConditionList ) { return strtolower ( substr ( $ normalizedConditionList , $ i , 5 ) ) ; } ; } else { $ isAscii = true ; $ strLen = strlen ( $ normalizedConditionList ) ; $ getAnd = function ( $ i ) use ( $ charset , $ normalizedConditionList ) { return mb_strtolower ( mb_substr ( $ normalizedConditionList , $ i , 5 , $ charset ) , $ charset ) ; } ; } for ( $ i = 0 , $ j = $ strLen ; $ i < $ j ; $ i ++ ) { if ( $ isAscii === true ) { $ char = $ normalizedConditionList [ $ i ] ; } else { $ char = mb_substr ( $ normalizedConditionList , $ i , 1 , $ charset ) ; } if ( $ char === " " && $ getAnd ( $ i ) === " and " ) { $ normalizedConditions [ ] = new MediaCondition ( trim ( $ currentCondition , " \r\n\t\f" ) ) ; $ currentCondition = "" ; $ i += ( 5 - 1 ) ; } else { $ currentCondition .= $ char ; } } $ currentCondition = trim ( $ currentCondition , " \r\n\t\f" ) ; if ( $ currentCondition !== "" ) { $ normalizedConditions [ ] = new MediaCondition ( trim ( $ currentCondition , " \r\n\t\f" ) ) ; } foreach ( $ normalizedConditions as $ normalizedCondition ) { $ conditions [ ] = $ normalizedCondition ; } } return $ conditions ; }
|
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 ( ) ; $ template -> messages = $ this -> mailer -> getMessages ( $ this -> messagesLimit ) ; return ( string ) $ template ; }
|
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 ) ; return $ this ; }
|
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 { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ charset ) . "' for argument 'charset' given." ) ; } return $ this ; }
|
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 ) ) ; } elseif ( $ item instanceof SQL \ SetMultiple and is_string ( $ content ) ) { return self :: renderMultiple ( $ value , $ content , $ item -> getKey ( ) ) ; } else { return '?' ; } }
|
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 $ ex ) { trigger_error ( $ ex -> getMessage ( ) , E_USER_NOTICE ) ; return $ this -> notFound ( $ request , $ response ) ; } if ( ! method_exists ( $ controller , '__invoke' ) ) { $ class = get_class ( $ controller ) ; trigger_error ( "Can't route to controller '$class': class does not have '__invoke' method" , E_USER_NOTICE ) ; return $ this -> notFound ( $ request , $ response ) ; } return $ controller ( $ request , $ response ) ; }
|
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 ] ] = [ 'name' => $ column [ 0 ] , 'visible' => isset ( $ column [ 1 ] ) ? $ column [ 1 ] : false , 'description' => isset ( $ column [ 2 ] ) ? $ column [ 2 ] : '' ] ; } return $ this ; }
|
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" ] ; $ datas = array_merge ( ( array ) $ datas , ( array ) $ metadata ) ; unset ( $ datas [ "metadata" ] ) ; } parent :: hydrate ( $ object , $ datas , $ soft , $ maxReferenceDepth ) ; if ( isset ( $ stream ) ) { $ object -> setStream ( $ stream ) ; } }
|
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" ] [ $ infos -> getField ( ) ] = $ datas [ $ infos -> getField ( ) ] ; unset ( $ datas [ $ infos -> getField ( ) ] ) ; } } } return $ datas ; }
|
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 ( ) -> getResult ( ) ; }
|
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 ( ) -> getResult ( ) ; }
|
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.scheduleTime' , 'ASC' ) ; return $ dqb -> getQuery ( ) -> getResult ( ) ; }
|
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 $ result ; } } if ( function_exists ( 'mime_content_type' ) && ( $ result = mime_content_type ( $ file ) ) !== false ) { return $ result ; } }
|
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.