idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
25,600
function oAuthParseResponse ( $ responseString ) { $ r = array ( ) ; foreach ( explode ( '&' , $ responseString ) as $ param ) { $ pair = explode ( '=' , $ param , 2 ) ; if ( count ( $ pair ) != 2 ) continue ; $ r [ urldecode ( $ pair [ 0 ] ) ] = urldecode ( $ pair [ 1 ] ) ; } return $ r ; }
Parse a URL - encoded OAuth response
25,601
function getAccessToken ( $ args = array ( ) ) { $ r = $ this -> oAuthRequest ( $ this -> accessTokenURL ( ) , $ args ) ; $ token = $ this -> oAuthParseResponse ( $ r ) ; $ this -> token = new OAuthConsumer ( $ token [ 'oauth_token' ] , $ token [ 'oauth_token_secret' ] ) ; return $ token ; }
Exchange the request token and secret for an access token and secret to sign API calls .
25,602
public function getDsn ( ) : string { $ _dsn = $ this -> getDriver ( ) . ':' . $ this -> getFilename ( ) ; $ this -> setDsn ( $ _dsn ) ; return $ _dsn ; }
Get DSN - SqLite formatting
25,603
public function execute ( $ login , InputInterface $ input ) { $ scriptToExecute = 'run.sh' ; if ( $ this -> gameData -> getServerOs ( ) == GameDataStorage :: OS_WINDOWS ) { $ scriptToExecute = 'run.bat' ; } $ player = $ this -> playerStorage -> getPlayerInfo ( $ login ) ; $ this -> chatNotification -> sendMessage ( 'expansion_core.chat_commands.restart.message' , null , [ '%nickname%' => $ player -> getNickName ( ) ] ) ; $ this -> application -> stopApplication ( ) ; $ process = new Process ( "bin/" . $ scriptToExecute . " &" ) ; $ process -> start ( ) ; }
Method called to execute the chat command .
25,604
public function getHeader ( ) { if ( null == $ this -> header ) { $ header = $ this -> getNextDataSet ( ) ; if ( null === $ header ) { throw new Exception ( "Cannot retrieve header" ) ; } $ this -> setHeader ( $ header ) ; } return $ this -> header ; }
Return CSV header as array .
25,605
public function reset ( ) { $ this -> header = null ; $ this -> line = 0 ; $ this -> file -> rewind ( ) ; return $ this ; }
Reset file .
25,606
public function listVerifiedEmailAddresses ( ) { $ rest = new SimpleEmailServiceRequest ( $ this , 'GET' ) ; $ rest -> setParameter ( 'Action' , 'ListVerifiedEmailAddresses' ) ; $ rest = $ rest -> getResponse ( ) ; if ( $ rest -> error === false && $ rest -> code !== 200 ) { $ rest -> error = array ( 'code' => $ rest -> code , 'message' => 'Unexpected HTTP status' ) ; } if ( $ rest -> error !== false ) { $ this -> __triggerError ( 'listVerifiedEmailAddresses' , $ rest -> error ) ; return false ; } $ response = array ( ) ; if ( ! isset ( $ rest -> body ) ) { return $ response ; } $ addresses = array ( ) ; foreach ( $ rest -> body -> ListVerifiedEmailAddressesResult -> VerifiedEmailAddresses -> member as $ address ) { $ addresses [ ] = ( string ) $ address ; } $ response [ 'Addresses' ] = $ addresses ; $ response [ 'RequestId' ] = ( string ) $ rest -> body -> ResponseMetadata -> RequestId ; return $ response ; }
Lists the email addresses that have been verified and can be used as the From address
25,607
public function deleteVerifiedEmailAddress ( $ email ) { $ rest = new SimpleEmailServiceRequest ( $ this , 'DELETE' ) ; $ rest -> setParameter ( 'Action' , 'DeleteVerifiedEmailAddress' ) ; $ rest -> setParameter ( 'EmailAddress' , $ email ) ; $ rest = $ rest -> getResponse ( ) ; if ( $ rest -> error === false && $ rest -> code !== 200 ) { $ rest -> error = array ( 'code' => $ rest -> code , 'message' => 'Unexpected HTTP status' ) ; } if ( $ rest -> error !== false ) { $ this -> __triggerError ( 'deleteVerifiedEmailAddress' , $ rest -> error ) ; return false ; } $ response [ 'RequestId' ] = ( string ) $ rest -> body -> ResponseMetadata -> RequestId ; return $ response ; }
Removes the specified email address from the list of verified addresses .
25,608
public function __triggerError ( $ functionname , $ error ) { if ( $ error == false ) { trigger_error ( sprintf ( "SimpleEmailService::%s(): Encountered an error, but no description given" , $ functionname ) , E_USER_WARNING ) ; } else if ( isset ( $ error [ 'curl' ] ) && $ error [ 'curl' ] ) { trigger_error ( sprintf ( "SimpleEmailService::%s(): %s %s" , $ functionname , $ error [ 'code' ] , $ error [ 'message' ] ) , E_USER_WARNING ) ; } else if ( isset ( $ error [ 'Error' ] ) ) { $ e = $ error [ 'Error' ] ; $ message = sprintf ( "SimpleEmailService::%s(): %s - %s: %s\nRequest Id: %s\n" , $ functionname , $ e [ 'Type' ] , $ e [ 'Code' ] , $ e [ 'Message' ] , $ error [ 'RequestId' ] ) ; trigger_error ( $ message , E_USER_WARNING ) ; } else { trigger_error ( sprintf ( "SimpleEmailService::%s(): Encountered an error: %s" , $ functionname , $ error ) , E_USER_WARNING ) ; } }
Trigger an error message
25,609
public function setParameter ( $ key , $ value , $ replace = true ) { if ( ! $ replace && isset ( $ this -> parameters [ $ key ] ) ) { $ temp = ( array ) ( $ this -> parameters [ $ key ] ) ; $ temp [ ] = $ value ; $ this -> parameters [ $ key ] = $ temp ; } else { $ this -> parameters [ $ key ] = $ value ; } }
Set request parameter
25,610
public function validate ( ) { if ( count ( $ this -> to ) == 0 ) return false ; if ( $ this -> from == null || strlen ( $ this -> from ) == 0 ) return false ; if ( ( $ this -> subject == null || strlen ( $ this -> subject ) == 0 ) && ( $ this -> messagetext == null || strlen ( $ this -> messagetext ) == 0 ) && ( $ this -> messagehtml == null || strlen ( $ this -> messagehtml ) == 0 ) ) { return false ; } return true ; }
Validates whether the message object has sufficient information to submit a request to SES . This does not guarantee the message will arrive nor that the request will succeed ; instead it makes sure that no required fields are missing .
25,611
public function filterBySenderlogin ( $ senderlogin = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ senderlogin ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_SENDERLOGIN , $ senderlogin , $ comparison ) ; }
Filter the query on the senderLogin column
25,612
public function filterByReceiverlogin ( $ receiverlogin = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ receiverlogin ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_RECEIVERLOGIN , $ receiverlogin , $ comparison ) ; }
Filter the query on the receiverLogin column
25,613
public function filterByTransactionid ( $ transactionid = null , $ comparison = null ) { if ( is_array ( $ transactionid ) ) { $ useMinMax = false ; if ( isset ( $ transactionid [ 'min' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_TRANSACTIONID , $ transactionid [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ transactionid [ 'max' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_TRANSACTIONID , $ transactionid [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_TRANSACTIONID , $ transactionid , $ comparison ) ; }
Filter the query on the transactionId column
25,614
public function filterByBillid ( $ billid = null , $ comparison = null ) { if ( is_array ( $ billid ) ) { $ useMinMax = false ; if ( isset ( $ billid [ 'min' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_BILLID , $ billid [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ billid [ 'max' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_BILLID , $ billid [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_BILLID , $ billid , $ comparison ) ; }
Filter the query on the billId column
25,615
public function filterByAmount ( $ amount = null , $ comparison = null ) { if ( is_array ( $ amount ) ) { $ useMinMax = false ; if ( isset ( $ amount [ 'min' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_AMOUNT , $ amount [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ amount [ 'max' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_AMOUNT , $ amount [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_AMOUNT , $ amount , $ comparison ) ; }
Filter the query on the amount column
25,616
public function filterByMessage ( $ message = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ message ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_MESSAGE , $ message , $ comparison ) ; }
Filter the query on the message column
25,617
public function filterByDatetime ( $ datetime = null , $ comparison = null ) { if ( is_array ( $ datetime ) ) { $ useMinMax = false ; if ( isset ( $ datetime [ 'min' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_DATETIME , $ datetime [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ datetime [ 'max' ] ) ) { $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_DATETIME , $ datetime [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( GamecurrencyTableMap :: COL_DATETIME , $ datetime , $ comparison ) ; }
Filter the query on the datetime column
25,618
public function setPriceModification ( $ value ) { if ( $ this -> exists ( ) ) { $ join = $ this -> manyMany ( 'Reservations' ) ; $ table = end ( $ join ) ; $ where = $ this -> getSourceQueryParam ( 'Foreign.Filter' ) ; $ where [ "`{$this->baseTable()}ID`" ] = $ this -> ID ; SQLUpdate :: create ( "`{$table}`" , array ( '`PriceModification`' => $ value ) , $ where ) -> execute ( ) ; } }
Set the price modification on the join
25,619
public function setOptions ( array $ options ) { foreach ( $ options as $ opt => $ val ) { $ this -> setOption ( $ opt , $ val ) ; } return $ this ; }
Sets the reader options .
25,620
public function setOption ( $ name , $ value ) { if ( ! in_array ( $ name , $ this -> validOptions ) ) { throw new Error ( 'Invalid option ' . $ name . '. Valid options are : ' . join ( ', ' , $ this -> validOptions ) ) ; } if ( 'header' == $ name ) { $ cnt = array_count_values ( $ value ) ; $ duplicates = array ( ) ; foreach ( $ cnt as $ f => $ c ) { if ( $ c > 1 ) { $ duplicates [ $ f ] = $ c ; } } if ( sizeof ( $ duplicates ) > 0 ) { $ msg = 'Duplicate fields found in header : ' . join ( ', ' , array_keys ( $ duplicates ) ) ; throw new Error ( $ msg ) ; } } $ this -> $ name = $ value ; return $ this ; }
Sets an option
25,621
protected function openFile ( ) { if ( is_null ( $ this -> fp ) ) { $ this -> fp = @ fopen ( $ this -> file , $ this -> mode ) ; if ( ! $ this -> fp ) { throw new Error ( 'Unable to open ' . $ this -> file ) ; } } return $ this ; }
Opens the CSV file for read
25,622
protected function readLine ( ) { if ( ! $ this -> valid ( ) ) { throw new Error ( 'End of stream reached, no data to read' ) ; } $ this -> currentData = fgetcsv ( $ this -> fp , null , $ this -> delimiter , $ this -> enclosure ) ; if ( false === $ this -> currentData ) { return false ; } elseif ( array ( null ) == $ this -> currentData ) { if ( ! $ this -> ignoreEmptyLines ) { throw new Error ( 'Empty line found in file' ) ; } return $ this -> readLine ( ) ; } $ this -> curLine ++ ; if ( $ this -> inputEncoding != $ this -> outputEncoding ) { $ inEnc = $ this -> inputEncoding ; $ outEnc = $ this -> outputEncoding ; array_walk ( $ this -> currentData , function ( & $ str ) use ( $ inEnc , $ outEnc ) { $ str = mb_convert_encoding ( $ str , $ outEnc , $ inEnc ) ; } ) ; } return $ this -> currentData ; }
Read the next line and applies encoding conversion if required
25,623
public function fetch ( ) { if ( ! $ this -> valid ( ) ) { return false ; } $ line = $ this -> current ( ) ; $ this -> readLine ( ) ; return $ line ; }
Fetches and returns the next line .
25,624
public function getHtmlPreview ( $ numLines = 5 ) { $ html = '<table>' ; if ( $ this -> header ) { $ html .= '<thead><tr>' ; foreach ( $ this -> header as $ h ) { $ html .= '<th>' . htmlentities ( $ h , ENT_QUOTES , 'UTF-8' ) . '</th>' ; } $ html .= '</tr></thead>' ; } $ html .= '<tbody>' ; $ i = 0 ; foreach ( $ this as $ line ) { if ( $ i >= $ numLines ) { break ; } $ html .= '<tr>' ; foreach ( $ line as $ v ) { $ html .= '<td>' . htmlentities ( $ v , ENT_QUOTES , 'UTF-8' ) . '</td>' ; } $ html .= '</tr>' ; $ i ++ ; } $ html .= '</tbody></table>' ; return $ html ; }
Returns an HTML table preview of the csv data
25,625
public function getNextFiscalYear ( ) { $ fiscalYearId = $ this -> FiscalYear -> lastFiscalYearByOrganization ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) ) ; $ FiscalYear = $ this -> FiscalYear -> byId ( $ fiscalYearId ) ; return json_encode ( array ( 'fiscalYear' => $ FiscalYear -> year + 1 ) ) ; }
Echo grid data in a jqGrid compatible format
25,626
protected function addDictionaryInformation ( ) { $ translations = [ ] ; $ this -> dictionary -> removeAllEntries ( ) ; $ this -> getDictionaryInformation ( $ this -> manialink , $ translations ) ; foreach ( $ translations as $ msgId => $ messages ) { foreach ( $ messages as $ message ) { $ this -> dictionary -> setEntry ( $ message [ 'Lang' ] , $ msgId , htmlspecialchars ( $ message [ 'Text' ] ) ) ; } } }
Add translations to dictionary .
25,627
protected function getDictionaryInformation ( $ control , & $ translations ) { foreach ( $ control -> getChildren ( ) as $ child ) { if ( ( $ child instanceof Label || $ child instanceof FmlLabel ) && $ child -> getTranslate ( ) ) { $ id = $ child -> getTextId ( ) ; if ( ! isset ( $ this -> cachedMessages [ $ id ] ) ) { $ textId = 'exp_' . md5 ( $ id ) ; $ messages = $ this -> translationHelper -> getTranslations ( $ child -> getTextId ( ) , [ ] ) ; $ translations [ $ textId ] = $ messages ; $ this -> cachedMessages [ $ textId ] = $ messages ; $ child -> setTextId ( $ textId ) ; } else { $ translations [ $ id ] = $ this -> cachedMessages [ $ id ] ; } } else { if ( $ child instanceof Container ) { $ this -> getDictionaryInformation ( $ child , $ translations ) ; } } } }
Recursive search all dome tree in order to find all translatable labels .
25,628
protected function configure ( \ Altamira \ JsWriter \ JsWriterAbstract $ jsWriter ) { $ confInstance = \ Altamira \ Config :: getInstance ( ) ; $ file = $ confInstance [ 'altamira.root' ] . $ confInstance [ 'altamira.typeconfigpath' ] ; $ config = \ parse_ini_file ( $ file , true ) ; $ libConfig = $ config [ strtolower ( $ jsWriter -> getLibrary ( ) ) ] ; $ type = static :: TYPE ; $ typeAttributes = preg_grep ( "/$type\./i" , array_keys ( $ libConfig ) ) ; foreach ( $ typeAttributes as $ key ) { $ attribute = preg_replace ( "/{$type}\./i" , '' , $ key ) ; $ this -> { $ attribute } = $ libConfig [ $ key ] ; } }
configures instance upon construct
25,629
public function getRendererOptions ( ) { $ opts = array ( ) ; foreach ( $ this -> allowedRendererOptions as $ opt ) { if ( isset ( $ this -> options [ $ opt ] ) ) $ opts [ $ opt ] = $ this -> options [ $ opt ] ; } return $ opts ; }
Return options specific to the renderer
25,630
public function isUserAdmin ( ) { $ user = $ this -> getUsersDatabase ( ) ; $ sr = $ user -> getById ( $ this -> _context -> authenticatedUserId ( ) ) ; return ( $ sr -> getField ( $ user -> getUserTable ( ) -> admin ) == "yes" ) ; }
Return true if the current user is an administrator .
25,631
public function getVoucherTypes ( ) { $ voucherTypes = array ( ) ; $ this -> VoucherType -> byOrganization ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) ) -> each ( function ( $ VoucherType ) use ( & $ voucherTypes ) { array_push ( $ voucherTypes , array ( 'label' => $ this -> Lang -> has ( $ VoucherType -> lang_key ) ? $ this -> Lang -> get ( $ VoucherType -> lang_key ) : $ VoucherType -> name , 'value' => $ VoucherType -> id ) ) ; } ) ; return $ voucherTypes ; }
Get voucher types
25,632
public function getFiscalYears ( ) { $ fiscalYears = array ( ) ; $ this -> FiscalYear -> byOrganization ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) ) -> each ( function ( $ FiscalYear ) use ( & $ fiscalYears ) { array_push ( $ fiscalYears , $ FiscalYear -> year ) ; } ) ; return $ fiscalYears ; }
Get organization fiscal years
25,633
public function getFirstAndLastDayOfCurrentMonth ( ) { $ Date = new Carbon ( 'first day of this month' ) ; $ Date2 = new Carbon ( 'last day of this month' ) ; return array ( 'userFormattedFrom' => $ Date -> format ( $ this -> Lang -> get ( 'form.phpShortDateFormat' ) ) , 'userFormattedTo' => $ Date2 -> format ( $ this -> Lang -> get ( 'form.phpShortDateFormat' ) ) , 'databaseFormattedFrom' => $ Date -> format ( 'Y-m-d' ) , 'databaseFormattedTo' => $ Date2 -> format ( 'Y-m-d' ) ) ; }
Get first day of current month
25,634
public function updateJournalVoucherStatus ( $ id , $ Journal = null , $ JournalVoucher = null , $ newStatus = null , $ databaseConnectionName = null ) { if ( empty ( $ newStatus ) ) { $ debitSum = $ this -> JournalEntry -> getJournalVoucherDebitSum ( $ id , $ databaseConnectionName ) ; $ creditSum = $ this -> JournalEntry -> getJournalVoucherCreditSum ( $ id , $ databaseConnectionName ) ; if ( round ( $ debitSum , 2 ) == round ( $ creditSum , 2 ) ) { $ status = 'B' ; } else { $ status = 'A' ; } } else { $ status = $ newStatus ; } if ( empty ( $ JournalVoucher ) ) { $ JournalVoucher = $ this -> JournalVoucher -> byId ( $ id , $ databaseConnectionName ) ; } $ currentStatus = $ JournalVoucher -> status ; if ( $ currentStatus != $ status ) { $ this -> JournalVoucher -> update ( array ( 'status' => $ status ) , $ JournalVoucher , $ databaseConnectionName ) ; if ( ! empty ( $ Journal ) ) { $ this -> Journal -> attachDetail ( $ Journal -> id , array ( 'field' => $ this -> Lang -> get ( 'decima-accounting::journal-management.status' ) , 'field_lang_key' => 'decima-accounting::journal-management.status' , 'old_value' => $ this -> Lang -> get ( 'decima-accounting::journal-management.' . $ currentStatus ) , 'new_value' => $ this -> Lang -> get ( 'decima-accounting::journal-management.' . $ status ) ) , $ Journal ) ; } } return $ status ; }
Update the status of an existing journal voucher
25,635
protected function clearTransients ( ) { Option :: where ( 'option_name' , 'like' , '_transient_%' ) -> delete ( ) ; Option :: where ( 'option_name' , 'like' , '_site_transient_%' ) -> delete ( ) ; return Option :: where ( 'option_name' , 'like' , '%_transient_%' ) -> count ( ) ; }
Clear the transients and check that they are all gone
25,636
public function createConnection ( $ maxAttempts = 3 ) { if ( is_null ( $ this -> connection ) ) { $ lastExcelption = $ this -> attemptConnection ( $ maxAttempts ) ; if ( ! is_null ( $ lastExcelption ) ) { $ this -> console -> getSfStyleOutput ( ) -> error ( [ "Looks like your Dedicated server is either offline or has wrong config settings" , "Error message: " . $ lastExcelption -> getMessage ( ) ] ) ; $ this -> logger -> error ( "Unable to open connection for Dedicated server" , [ "exception" => $ lastExcelption ] ) ; throw $ lastExcelption ; } $ event = new GenericEvent ( $ this -> connection ) ; $ this -> eventDispatcher -> dispatch ( self :: EVENT_CONNECTED , $ event ) ; } return $ this -> connection ; }
Attempt to connect to the dedicated server .
25,637
public function isLinked ( string $ host = null ) : bool { if ( $ host && isset ( $ this -> links [ $ host ] ) ) { return ( $ this -> links [ $ host ] -> status ( ) === Link :: STATUS_CONNECTED ) ; } if ( true !== $ this -> config -> get ( 'sharding' ) ) { foreach ( $ this -> links as $ link ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } switch ( trim ( ( string ) $ host ) ) { case '' : case Link :: TYPE_MASTER : foreach ( $ this -> links as $ link ) { if ( $ link -> getType ( ) == Link :: TYPE_MASTER ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } break ; case Link :: TYPE_SLAVE : foreach ( $ this -> links as $ link ) { if ( $ link -> getType ( ) == Link :: TYPE_SLAVE ) { return ( $ link -> status ( ) === Link :: STATUS_CONNECTED ) ; } } break ; } return false ; }
Is linked .
25,638
public function getLink ( string $ host = null ) : ? Link { if ( $ host && isset ( $ this -> links [ $ host ] ) ) { return $ this -> links [ $ host ] ; } $ host = trim ( ( string ) $ host ) ; if ( true === $ this -> config -> get ( 'sharding' ) ) { if ( $ host == '' || $ host == Link :: TYPE_MASTER ) { return Util :: arrayRand ( array_filter ( $ this -> links , function ( $ link ) { return $ link -> getType ( ) == Link :: TYPE_MASTER ; } ) ) ; } elseif ( $ host == Link :: TYPE_SLAVE ) { return Util :: arrayRand ( array_filter ( $ this -> links , function ( $ link ) { return $ link -> getType ( ) == Link :: TYPE_SLAVE ; } ) ) ; } } else { if ( $ host == '' ) { return Util :: arrayRand ( array_filter ( $ this -> links , function ( $ link ) { return $ link -> getType ( ) == Link :: TYPE_SINGLE ; } ) ) ; } } }
Get link .
25,639
protected function getStub ( $ name ) { if ( is_file ( $ path = base_path ( "resources/stubs/vendor/crud-generator/{$this->stubsGroup}/$name.stub" ) ) ) { return file_get_contents ( $ path ) ; } if ( is_file ( $ path = __DIR__ . "/../resources/stubs/{$this->stubsGroup}/$name.stub" ) ) { return file_get_contents ( $ path ) ; } return '' ; }
Retourne le contenu d un template .
25,640
protected function getLangPath ( ) { $ sectionSegments = $ this -> sectionSegments ; if ( $ this -> langDir ) { array_unshift ( $ sectionSegments , $ this -> langDir ) ; } return base_path ( 'resources/lang/fr/' . implode ( '/' , $ sectionSegments ) . '.php' ) ; }
Retourne le chemin vers le fichier des traductions .
25,641
public static function loadData ( ) : void { if ( Search :: $ loaded === false ) { $ filePath = Search :: $ DATA_DIR . "merged-ultraslim.json" ; $ contents = @ file_get_contents ( $ filePath ) ; if ( $ contents === false ) { throw new KBException ( "$filePath does not exist !" ) ; } Search :: $ data = json_decode ( $ contents ) ; Search :: $ loaded = true ; } }
Load data from disk
25,642
public static function getByName ( string $ name , int $ type = Search :: ANY ) : string { self :: loadData ( ) ; $ kbEntrys = self :: getVariable ( $ name ) ; if ( isset ( $ kbEntrys -> a ) ) { foreach ( $ kbEntrys -> a as $ kbEntry ) { if ( $ type === Search :: ANY ) { return Search :: $ data -> urls [ $ kbEntry -> u ] . "#" . $ kbEntry -> a ; } elseif ( $ type === Search :: MYSQL ) { if ( $ kbEntry -> t === Search :: MYSQL ) { return Search :: $ data -> urls [ $ kbEntry -> u ] . "#" . $ kbEntry -> a ; } } elseif ( $ type === Search :: MARIADB ) { if ( $ kbEntry -> t === Search :: MARIADB ) { return Search :: $ data -> urls [ $ kbEntry -> u ] . "#" . $ kbEntry -> a ; } } } } throw new KBException ( "$name does not exist for this type of documentation !" ) ; }
get the first link to doc available
25,643
public static function getVariable ( string $ name ) : stdClass { self :: loadData ( ) ; if ( isset ( Search :: $ data -> vars -> { $ name } ) ) { return Search :: $ data -> vars -> { $ name } ; } else { throw new KBException ( "$name does not exist !" ) ; } }
Get a variable
25,644
public static function getVariableType ( string $ name ) : string { self :: loadData ( ) ; $ kbEntry = self :: getVariable ( $ name ) ; if ( isset ( $ kbEntry -> t ) ) { return Search :: $ data -> varTypes -> { $ kbEntry -> t } ; } else { throw new KBException ( "$name does have a known type !" ) ; } }
get the type of the variable
25,645
public function notFound ( Request $ request , Response $ response ) { $ handler = $ this -> container -> get ( 'notFoundHandler' ) ; return $ handler ( $ request , $ response ) ; }
Not found .
25,646
public function setLocalRecord ( $ nick , $ checkpoints ) { if ( count ( $ checkpoints ) > 0 ) { $ this -> updateValue ( $ this -> playerGroup , 'LocalRecordCheckpoints' , Builder :: getArray ( $ checkpoints , true ) ) ; $ this -> updateValue ( $ this -> playerGroup , 'LocalRecordHolder' , Builder :: escapeText ( $ nick ) ) ; } else { $ this -> updateValue ( $ this -> playerGroup , 'LocalRecordCheckpoints' , "Integer[Integer]" ) ; $ this -> updateValue ( $ this -> playerGroup , 'LocalRecordHolder' , Builder :: escapeText ( "-" ) ) ; } }
Update with new local record .
25,647
public static function cutstr ( $ string , $ length , $ suffix = true , $ charset = "utf-8" , $ start = 0 , $ dot = ' ...' ) { $ str = str_replace ( [ '&amp;' , '&quot;' , '&lt;' , '&gt;' ] , [ '&' , '"' , '<' , '>' ] , $ string ) ; if ( function_exists ( "mb_substr" ) ) { $ strcut = mb_substr ( $ str , $ start , $ length , $ charset ) ; if ( mb_strlen ( $ str , $ charset ) > $ length ) { return $ suffix ? $ strcut . $ dot : $ strcut ; } return $ strcut ; } $ re = [ ] ; $ match = [ '' ] ; $ re [ 'utf-8' ] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/" ; $ re [ 'gb2312' ] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/" ; $ re [ 'gbk' ] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/" ; $ re [ 'big5' ] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/" ; preg_match_all ( $ re [ $ charset ] , $ str , $ match ) ; $ slice = join ( "" , array_slice ( $ match [ 0 ] , $ start , $ length ) ) ; $ strcut = str_replace ( [ '&' , '"' , '<' , '>' ] , [ '&amp;' , '&quot;' , '&lt;' , '&gt;' ] , $ slice ) ; return $ suffix ? $ strcut . $ dot : $ strcut ; }
cut string to set length return string
25,648
protected function updateRoles ( ) { foreach ( $ this -> roles ( ) as $ Role ) { $ this -> authManager -> add ( $ Role ) ; echo sprintf ( ' > role `%s` added.' , $ Role -> name ) . PHP_EOL ; } }
Update roles method
25,649
protected function updateRules ( ) { foreach ( $ this -> rules ( ) as $ Rule ) { $ this -> authManager -> add ( $ Rule ) ; echo sprintf ( ' > rule `%s` added.' , $ Rule -> name ) . PHP_EOL ; } }
Update rules method
25,650
protected function updatePermission ( ) { foreach ( $ this -> permissions ( ) as $ Permission ) { $ this -> authManager -> add ( $ Permission ) ; echo sprintf ( ' > permission `%s` added.' , $ Permission -> name ) . PHP_EOL ; } }
Update permissions method
25,651
protected function updateInheritanceRoles ( ) { foreach ( $ this -> inheritanceRoles ( ) as $ role => $ items ) { foreach ( $ items as $ item ) { $ this -> authManager -> addChild ( RbacFactory :: Role ( $ role ) , RbacFactory :: Role ( $ item ) ) ; echo sprintf ( ' > role `%s` inherited role `%s`.' , $ role , $ item ) . PHP_EOL ; } } }
Update inheritance roles method
25,652
protected function updateInheritancePermissions ( ) { foreach ( $ this -> inheritancePermissions ( ) as $ role => $ items ) { foreach ( $ items as $ item ) { $ this -> authManager -> addChild ( RbacFactory :: Role ( $ role ) , RbacFactory :: Permission ( $ item ) ) ; echo sprintf ( ' > role `%s` inherited permission `%s`.' , $ role , $ item ) . PHP_EOL ; } } }
Update inheritance permissions method
25,653
public function getModulePlugins ( $ excludeModulesOnReturn = array ( ) ) { $ modules = array ( ) ; $ excludeModules = array_values ( $ this -> getCoreModules ( ) ) ; foreach ( $ this -> getAllModules ( ) as $ module ) { if ( ! in_array ( $ module , array_merge ( $ excludeModules , $ excludeModulesOnReturn ) ) ) { $ modules [ ] = $ module ; } } return $ modules ; }
Returns all modules plugins that does not belong or treated as core modules
25,654
public function getMelisModules ( ) { $ modules = array ( ) ; foreach ( $ this -> getAllModules ( ) as $ module ) { if ( strpos ( $ module , 'Melis' ) !== false || strpos ( $ module , 'melis' ) !== false ) { $ modules [ ] = $ module ; } } return $ modules ; }
Returns all the modules that has been created by Melis
25,655
public function tree ( $ id = null ) { Configure :: write ( 'debug' , 0 ) ; if ( ! method_exists ( $ this -> _model , 'getTreeData' ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Method "%s" is not exists in model "%s"' , 'getTreeData()' , $ this -> _model -> name ) ) ; } if ( ! $ this -> _controller -> request -> is ( 'ajax' ) || ! $ this -> _controller -> request -> is ( 'post' ) || ! $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ [ 'text' => __d ( 'view_extension' , '&lt;None&gt;' ) , ] ] ; $ treeData = $ this -> _model -> getTreeData ( $ id ) ; if ( ! empty ( $ treeData ) ) { $ data = $ treeData ; } $ this -> _controller -> set ( compact ( 'data' ) ) ; $ this -> _controller -> set ( '_serialize' , 'data' ) ; }
Return data for tree view
25,656
public function build ( Injector $ injector = null ) : Injector { if ( $ injector === null ) { $ injector = new Injector ( ) ; } foreach ( $ this -> configs as $ config ) { $ config -> apply ( $ injector ) ; } return $ injector ; }
Build the injector using the provided configuration .
25,657
public function where ( ... $ arguments ) : self { switch ( count ( $ arguments ) ) { case 1 : if ( ! is_array ( $ arguments [ 0 ] ) ) { throw new InvalidArgumentException ; } foreach ( $ arguments [ 0 ] as $ column => $ data ) { if ( is_array ( $ data ) ) { $ this -> where ( $ column , ... $ data ) ; } else { $ this -> where ( $ column , $ data ) ; } } return $ this ; break ; case 2 : $ arguments = [ $ arguments [ 0 ] , '=' , $ arguments [ 1 ] , 'AND' ] ; break ; case 3 : array_push ( $ arguments , 'AND' ) ; break ; } return $ this -> setWhere ( [ 'column' => $ arguments [ 0 ] , 'value' => $ arguments [ 2 ] , 'operator' => $ arguments [ 3 ] , 'comparison' => $ arguments [ 1 ] ] ) ; }
Prepares a WHERE clause to be appended to the query string .
25,658
private function getNextOperator ( string $ column ) : ? string { reset ( $ this -> fragments [ 'where' ] ) ; while ( key ( $ this -> fragments [ 'where' ] ) !== $ column ) { next ( $ this -> fragments [ 'where' ] ) ; } next ( $ this -> fragments [ 'where' ] ) ; $ key = key ( $ this -> fragments [ 'where' ] ) ; return $ this -> fragments [ 'where' ] [ $ key ] [ 'operator' ] ; }
To accurately concatenate conditions in a WHERE clause the operators between conditions should be found by looking ahead from the current position in an iteration .
25,659
public function redirectToRoute ( Response $ response , $ route , array $ data = [ ] , array $ queryParams = [ ] , $ suffix = '' ) { $ url = $ this -> router -> pathFor ( $ route , $ data , $ queryParams ) . $ suffix ; return $ response -> withRedirect ( $ url , 301 ) ; }
Redirect to specific route .
25,660
public function getFactory ( $ name ) { if ( ! isset ( $ this -> factories [ $ name ] ) ) { throw new \ RuntimeException ( sprintf ( 'No factory registered with name "%s"' , $ name ) ) ; } return $ this -> factories [ $ name ] ; }
Get a factory by name
25,661
public static function writeFile ( $ _filepath , $ _contents , Smarty $ smarty ) { $ _error_reporting = error_reporting ( ) ; error_reporting ( $ _error_reporting & ~ E_NOTICE & ~ E_WARNING ) ; if ( $ smarty -> _file_perms !== null ) { $ old_umask = umask ( 0 ) ; } $ _dirpath = dirname ( $ _filepath ) ; if ( $ _dirpath !== '.' && ! file_exists ( $ _dirpath ) ) { mkdir ( $ _dirpath , $ smarty -> _dir_perms === null ? 0777 : $ smarty -> _dir_perms , true ) ; } $ _tmp_file = $ _dirpath . DS . str_replace ( array ( '.' , ',' ) , '_' , uniqid ( 'wrt' , true ) ) ; if ( ! file_put_contents ( $ _tmp_file , $ _contents ) ) { error_reporting ( $ _error_reporting ) ; throw new SmartyException ( "unable to write file {$_tmp_file}" ) ; } if ( Smarty :: $ _IS_WINDOWS ) { @ unlink ( $ _filepath ) ; $ success = @ rename ( $ _tmp_file , $ _filepath ) ; } else { $ success = @ rename ( $ _tmp_file , $ _filepath ) ; if ( ! $ success ) { @ unlink ( $ _filepath ) ; $ success = @ rename ( $ _tmp_file , $ _filepath ) ; } } if ( ! $ success ) { error_reporting ( $ _error_reporting ) ; throw new SmartyException ( "unable to write file {$_filepath}" ) ; } if ( $ smarty -> _file_perms !== null ) { chmod ( $ _filepath , $ smarty -> _file_perms ) ; umask ( $ old_umask ) ; } error_reporting ( $ _error_reporting ) ; return true ; }
Writes file in a safe way to disk
25,662
public function fake ( EntityInterface $ entity , array $ options = array ( ) ) { if ( ! empty ( $ options [ self :: OPTION_LOCALE ] ) ) { $ loc = $ options [ self :: OPTION_LOCALE ] ; if ( ! is_string ( $ loc ) || ! preg_match ( '#[a-z]{2,6}_[A-Z]{2,6}#' , $ loc ) ) { throw new BadValueException ( 'Given option "' . self :: OPTION_LOCALE . '" is not a valid string. Use "languageCode_countryCode", e.g. "de_DE" or "en_UK".' ) ; } $ this -> locale = $ loc ; $ this -> faker = Factory :: create ( $ this -> locale ) ; } $ attributes_to_exclude = array ( ) ; if ( ! empty ( $ options [ self :: OPTION_EXCLUDED_FIELDS ] ) ) { $ excluded = $ options [ self :: OPTION_EXCLUDED_FIELDS ] ; if ( ! is_array ( $ excluded ) ) { throw new BadValueException ( 'Given option "' . self :: OPTION_EXCLUDED_FIELDS . '" is not an array. It should be an array of attribute_names.' ) ; } $ attributes_to_exclude = $ excluded ; } $ type = $ entity -> getType ( ) ; foreach ( $ type -> getAttributes ( ) as $ attribute_name => $ attribute ) { if ( in_array ( $ attribute_name , $ attributes_to_exclude , true ) ) { continue ; } $ name = $ this -> getMethodNameFor ( $ attribute ) ; if ( null !== $ name ) { $ this -> $ name ( $ entity , $ attribute , $ options ) ; } else { $ this -> setValue ( $ entity , $ attribute , $ attribute -> getDefaultValue ( ) , $ options ) ; } } if ( array_key_exists ( self :: OPTION_MARK_CLEAN , $ options ) && true === $ options [ self :: OPTION_MARK_CLEAN ] ) { $ entity -> markClean ( ) ; } }
This method fills the given entity with fake data . You may customize the fake data generation used for each attribute by using the options array .
25,663
public function fakeData ( EntityTypeInterface $ type , array $ options = array ( ) ) { $ entity = $ type -> createEntity ( ) ; $ this -> fake ( $ entity , $ options ) ; return $ entity -> toArray ( ) ; }
Creates an array with fake data for the given type .
25,664
public function createFakeEntity ( EntityTypeInterface $ type , array $ options = array ( ) , EntityInterface $ parent = null ) { $ options [ self :: OPTION_MARK_CLEAN ] = true ; $ entity = $ type -> createEntity ( [ ] , $ parent ) ; $ this -> fake ( $ entity , $ options ) ; return $ entity ; }
Creates a entity with fake data for the given type .
25,665
protected function addText ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ min_length = $ attribute -> getOption ( 'min_length' ) ; $ max_length = $ attribute -> getOption ( 'max_length' ) ; if ( $ this -> shouldGuessByName ( $ options ) ) { $ value = TextGuesser :: guess ( $ attribute -> getName ( ) , $ this -> faker ) ; } if ( ! isset ( $ value ) ) { $ value = $ this -> faker -> words ( $ this -> faker -> numberBetween ( 2 , 10 ) , true ) ; } if ( $ min_length && ( $ len = mb_strlen ( $ value ) ) < $ min_length ) { $ repeat = ceil ( ( $ min_length - $ len ) / $ len ) ; $ value .= str_repeat ( $ value , $ repeat ) ; } if ( $ max_length && mb_strlen ( $ value ) > $ max_length ) { $ value = substr ( $ value , 0 , $ max_length ) ; $ value = preg_replace ( '#\s$#' , 'o' , $ value ) ; } $ this -> setValue ( $ entity , $ attribute , $ value , $ options ) ; }
Generates and adds fake data for a Text on a entity .
25,666
protected function addTextList ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ values = array ( ) ; $ number_of_values = $ this -> faker -> numberBetween ( 1 , 5 ) ; for ( $ i = 0 ; $ i < $ number_of_values ; $ i ++ ) { $ text = $ this -> faker -> words ( $ this -> faker -> numberBetween ( 1 , 3 ) , true ) ; if ( $ this -> shouldGuessByName ( $ options ) ) { $ closure = TextGuesser :: guess ( $ attribute -> getName ( ) , $ this -> faker ) ; if ( ! empty ( $ closure ) && is_callable ( $ closure ) ) { $ text = call_user_func ( $ closure ) ; } } $ values [ ] = $ text ; } $ this -> setValue ( $ entity , $ attribute , $ values , $ options ) ; }
Generates and adds fake data for a TextCollection on a entity .
25,667
protected function addTextarea ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ text = $ this -> faker -> paragraphs ( $ this -> faker -> numberBetween ( 1 , 5 ) ) ; $ this -> setValue ( $ entity , $ attribute , implode ( PHP_EOL . PHP_EOL , $ text ) , $ options ) ; }
Generates and adds fake data for a Textarea on a entity .
25,668
protected function addInteger ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ this -> setValue ( $ entity , $ attribute , $ this -> faker -> randomNumber ( 5 ) , $ options ) ; }
Generates and adds fake data for an Integer on a entity .
25,669
protected function addIntegerList ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ values = array ( ) ; $ number_of_values = $ this -> faker -> numberBetween ( 1 , 5 ) ; for ( $ i = 0 ; $ i < $ number_of_values ; $ i ++ ) { $ values [ ] = $ this -> faker -> randomNumber ( 5 ) ; } $ this -> setValue ( $ entity , $ attribute , $ values , $ options ) ; }
Generates and adds fake data for an IntegerList on a entity .
25,670
protected function addFloat ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ this -> setValue ( $ entity , $ attribute , $ this -> faker -> randomFloat ( 5 ) , $ options ) ; }
Generates and adds fake data for a Float on a entity .
25,671
protected function addUrl ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ this -> setValue ( $ entity , $ attribute , $ this -> faker -> url ( ) , $ options ) ; }
Generates and adds fake data for a Url on a entity .
25,672
protected function addUuid ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ this -> setValue ( $ entity , $ attribute , $ this -> faker -> uuid ( ) , $ options ) ; }
Generates and adds fake data for a Uuid on a entity .
25,673
protected function addChoice ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ allowed_values = $ attribute -> getOption ( 'allowed_values' ) ; $ choice = $ allowed_values [ array_rand ( $ allowed_values ) ] ; $ this -> setValue ( $ entity , $ attribute , $ choice , $ options ) ; }
Generates and adds fake data for a choice attribute on a entity .
25,674
protected function addKeyValue ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ values = array ( ) ; $ number_of_values = $ this -> faker -> numberBetween ( 1 , 5 ) ; for ( $ i = 0 ; $ i < $ number_of_values ; $ i ++ ) { $ values [ $ this -> faker -> word ] = $ this -> faker -> sentence ; } $ this -> setValue ( $ entity , $ attribute , $ values , $ options ) ; }
Generates and adds fake data for a KeyValue on a entity .
25,675
protected function addKeyValueList ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ collection = array ( ) ; $ numberOfEntries = $ this -> faker -> numberBetween ( 1 , 5 ) ; for ( $ i = 0 ; $ i < $ numberOfEntries ; $ i ++ ) { $ number_of_values = $ this -> faker -> numberBetween ( 1 , 5 ) ; for ( $ i = 0 ; $ i < $ number_of_values ; $ i ++ ) { $ collection [ $ this -> faker -> word ] = $ this -> faker -> words ( $ this -> faker -> numberBetween ( 1 , 3 ) , true ) ; } } $ this -> setValue ( $ entity , $ attribute , $ collection , $ options ) ; }
Generates and adds fake data for a KeyValueList on a entity .
25,676
protected function createComplexValue ( AttributeInterface $ attribute , array $ options = array ( ) ) { $ values = array ( ) ; $ value_holder = $ attribute -> createValueHolder ( ) ; $ value_type = $ value_holder -> getValueType ( ) ; if ( class_exists ( $ value_type ) && preg_grep ( '#ComplexValueInterface$#' , class_implements ( $ value_type ) ) ) { foreach ( $ value_type :: getPropertyMap ( ) as $ property_name => $ property_type ) { switch ( $ property_type ) { case ComplexValue :: VALUE_TYPE_TEXT : if ( $ this -> shouldGuessByName ( $ options ) ) { $ values [ $ property_name ] = TextGuesser :: guess ( $ property_name , $ this -> faker ) ; } if ( empty ( $ values [ $ property_name ] ) ) { $ values [ $ property_name ] = $ this -> faker -> words ( 3 , true ) ; } break ; case ComplexValue :: VALUE_TYPE_URL : $ values [ $ property_name ] = $ this -> faker -> url ; break ; case ComplexValue :: VALUE_TYPE_BOOLEAN : $ values [ $ property_name ] = $ this -> faker -> boolean ( ) ; break ; case ComplexValue :: VALUE_TYPE_INTEGER : $ values [ $ property_name ] = $ this -> faker -> numberBetween ( 0 , 10 ) ; break ; case ComplexValue :: VALUE_TYPE_FLOAT : $ values [ $ property_name ] = $ this -> faker -> randomFloat ( 5 ) ; break ; case ComplexValue :: VALUE_TYPE_ARRAY : $ numberOfEntries = $ this -> faker -> numberBetween ( 0 , 3 ) ; for ( $ i = 0 ; $ i < $ numberOfEntries ; $ i ++ ) { $ values [ $ property_name ] [ $ this -> faker -> word ] = $ this -> faker -> word ; } break ; default : throw new BadValueException ( sprintf ( 'Unexpected ComplexValue property type "%s" on %s' , $ property_type , $ value_type ) ) ; } } } return new $ value_type ( $ values ) ; }
Generates and adds fake data for a ComplexValue on a entity .
25,677
protected function addImage ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ image = $ this -> createComplexValue ( $ attribute , $ options ) ; $ this -> setValue ( $ entity , $ attribute , $ image , $ options ) ; }
Generates and adds fake data for an Image on a entity .
25,678
protected function addImageList ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ collection = array ( ) ; $ min_count = $ attribute -> getOption ( 'min_count' , 0 ) ; $ max_count = $ attribute -> getOption ( 'max_count' , 3 ) ; $ numberOfEntries = $ this -> faker -> numberBetween ( $ min_count , $ max_count ) ; $ image_attribute = new ImageAttribute ( 'someimage' , $ entity -> getType ( ) ) ; for ( $ i = 0 ; $ i < $ numberOfEntries ; $ i ++ ) { $ collection [ ] = $ this -> createComplexValue ( $ image_attribute , $ options ) ; } $ this -> setValue ( $ entity , $ attribute , $ collection , $ options ) ; }
Generates and adds fake data for a ImageList on a entity .
25,679
protected function addBoolean ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ this -> setValue ( $ entity , $ attribute , $ this -> faker -> boolean , $ options ) ; }
Generates and adds fake data for a Boolean on a entity .
25,680
protected function addEmbeddedEntityList ( EntityInterface $ entity , EmbeddedEntityListAttribute $ attribute , array $ options = array ( ) ) { $ options_clone = $ options ; $ entity_collection = new EntityList ( ) ; $ embedded_type_map = $ attribute -> getEmbeddedEntityTypeMap ( ) ; $ min_count = $ attribute -> getOption ( 'min_count' , 0 ) ; $ max_count = $ attribute -> getOption ( 'max_count' , 3 ) ; $ inline_mode = $ attribute -> getOption ( 'inline_mode' , false ) ; if ( true === $ inline_mode ) { $ number_of_new_embed_entries = 1 ; } else { $ number_of_new_embed_entries = $ this -> faker -> numberBetween ( $ min_count , $ max_count ) ; } for ( $ i = 0 ; $ i < $ number_of_new_embed_entries ; $ i ++ ) { $ embed_type = $ this -> faker -> randomElement ( $ embedded_type_map -> getValues ( ) ) ; $ new_entity = $ this -> createFakeEntity ( $ embed_type , $ options_clone , $ entity ) ; $ entity_collection -> addItem ( $ new_entity ) ; } $ this -> setValue ( $ entity , $ attribute , $ entity_collection , $ options ) ; }
Generates and adds fake data for a embed entities .
25,681
protected function addTimestamp ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ default_value = $ attribute -> getDefaultValue ( ) ; $ this -> setValue ( $ entity , $ attribute , $ default_value ? : $ this -> faker -> iso8601 , $ options ) ; }
Generates and adds fake data for a Timestamp on a entity .
25,682
protected function addGeoPoint ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ geopoint = [ 'lon' => $ this -> faker -> longitude , 'lat' => $ this -> faker -> latitude ] ; $ this -> setValue ( $ entity , $ attribute , $ geopoint , $ options ) ; }
Generates and adds fake data for a GeoPoint on a entity .
25,683
protected function addToken ( EntityInterface $ entity , AttributeInterface $ attribute , array $ options = array ( ) ) { $ min_length = $ attribute -> getOption ( 'min_length' , 1 ) ; $ max_length = $ attribute -> getOption ( 'max_length' , 40 ) ; $ size = $ this -> faker -> numberBetween ( $ min_length , $ max_length ) ; $ token = bin2hex ( mcrypt_create_iv ( ceil ( $ size / 2 ) , MCRYPT_DEV_URANDOM ) ) ; $ truncated_token = substr ( $ token , 0 , $ size ) ; $ this -> setValue ( $ entity , $ attribute , $ truncated_token , $ options ) ; }
Generates and adds fake data for a Token on a entity .
25,684
protected function setValue ( EntityInterface $ entity , AttributeInterface $ attribute , $ default_value , array $ options = array ( ) ) { $ attribute_name = $ attribute -> getName ( ) ; $ attribute_options = array ( ) ; if ( ! empty ( $ options [ self :: OPTION_FIELD_VALUES ] ) && is_array ( $ options [ self :: OPTION_FIELD_VALUES ] ) ) { $ attribute_options = $ options [ self :: OPTION_FIELD_VALUES ] ; } if ( empty ( $ attribute_options [ $ attribute_name ] ) ) { $ entity -> setValue ( $ attribute_name , $ default_value ) ; } else { $ option = $ attribute_options [ $ attribute_name ] ; if ( is_callable ( $ option ) ) { $ entity -> setValue ( $ attribute_name , call_user_func ( $ option ) ) ; } else { $ entity -> setValue ( $ attribute_name , $ option ) ; } } }
Sets either given default value or value from option to the given attribute .
25,685
protected function shouldGuessByName ( array $ options = array ( ) ) { if ( array_key_exists ( self :: OPTION_GUESS_PROVIDER_BY_NAME , $ options ) && false === $ options [ self :: OPTION_GUESS_PROVIDER_BY_NAME ] ) { return false ; } return true ; }
Returns whether or not the fake data generation should be dependant on the attribute_names the used types have .
25,686
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( GamecurrencyTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ eXpansion \ Framework \ GameCurrencyBundle \ Model \ Gamecurrency ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( GamecurrencyTableMap :: DATABASE_NAME ) ; $ criteria -> add ( GamecurrencyTableMap :: COL_ID , ( array ) $ values , Criteria :: IN ) ; } $ query = GamecurrencyQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { GamecurrencyTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { GamecurrencyTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; }
Performs a DELETE on the database given a Gamecurrency or Criteria object OR a primary key value .
25,687
protected function setErrorCallback ( ConnectionInterface $ connection , callable $ callback ) { $ connection -> setErrorCallback ( function ( $ connection , $ exception ) use ( $ callback ) { \ call_user_func ( $ callback , $ this , $ exception , $ connection ) ; } ) ; }
Sets the callback used to notify the client about connection errors .
25,688
protected function wrapCallback ( callable $ callback ) { return function ( $ response , $ connection , $ command ) use ( $ callback ) { if ( $ command && ! $ response instanceof ResponseInterface ) { $ response = $ command -> parseResponse ( $ response ) ; } \ call_user_func ( $ callback , $ response , $ this , $ command ) ; } ; }
Wraps a command callback used to parse the raw response by adding more arguments that will be passed back to user code .
25,689
protected function _setStorageTimeUpload ( $ time = null ) { $ time = ( int ) $ time ; if ( $ time > 0 ) { $ this -> _storageTimeUpload = $ time ; } }
Set time for storage old uploaded files
25,690
protected function _setUploadDir ( $ path = null ) { $ path = ( string ) $ path ; if ( file_exists ( $ path ) ) { $ this -> _pathUploadDir = $ path ; } }
Set path to upload directory
25,691
protected function _clearDir ( $ timeNow = null ) { $ clearPath = $ this -> getUploadDir ( ) ; $ storageTime = $ this -> _getStorageTimeUpload ( ) ; $ result = true ; $ oFolder = new Folder ( $ clearPath , true ) ; $ uploadedFiles = $ oFolder -> find ( '.*' , false ) ; if ( empty ( $ uploadedFiles ) ) { return $ result ; } if ( ! empty ( $ timeNow ) ) { $ timeNow = ( int ) $ timeNow ; } else { $ timeNow = time ( ) ; } $ uploadedFilesPath = $ oFolder -> pwd ( ) ; foreach ( $ uploadedFiles as $ uploadedFile ) { $ oFile = new File ( $ uploadedFilesPath . DS . $ uploadedFile ) ; $ lastChangeTime = $ oFile -> lastChange ( ) ; if ( $ lastChangeTime === false ) { continue ; } if ( ( $ timeNow - $ lastChangeTime ) > $ storageTime ) { if ( ! $ oFile -> delete ( ) ) { $ result = false ; } } } return true ; }
Cleanup the upload directory from old files
25,692
public function upload ( $ maxFileSize = null , $ acceptFileTypes = null ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> _controller -> request -> is ( 'ajax' ) || ! $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( __d ( 'view_extension' , 'Invalid request' ) ) ; } $ uploadDir = $ this -> getUploadDir ( ) ; if ( empty ( $ acceptFileTypes ) ) { $ acceptFileTypes = '/.+$/i' ; } $ opt = [ 'script_url' => '' , 'upload_url' => '' , 'param_name' => 'files' , 'upload_dir' => $ uploadDir , 'max_file_size' => $ maxFileSize , 'image_versions' => [ '' => [ 'auto_orient' => false ] ] , 'correct_image_extensions' => false , 'accept_file_types' => $ acceptFileTypes ] ; $ uploadHandler = new UploadHandler ( $ opt , false ) ; switch ( $ this -> _controller -> request -> method ( ) ) { case 'OPTIONS' : case 'HEAD' : $ data = $ uploadHandler -> head ( false ) ; break ; case 'GET' : $ data = $ uploadHandler -> get ( false ) ; break ; case 'PATCH' : case 'PUT' : case 'POST' : $ data = $ uploadHandler -> post ( false ) ; break ; default : throw new MethodNotAllowedException ( ) ; } return $ data ; }
AJAX upload file to server
25,693
private function saveImageContents ( Image $ client , SourceImage $ image , $ saveTo , OutputInterface $ output , $ stackName = null , $ format = 'jpg' ) { if ( ! $ stackName ) { $ output -> writeln ( 'Getting source image contents for <info>' . $ image -> hash . '</info> from <comment>' . $ image -> organization . '</comment>' ) ; } else { $ output -> writeln ( 'Rendering image <info>' . $ image -> hash . '</info> from <comment>' . $ image -> organization . '</comment> on stack <info>' . $ stackName . '</info>' ) ; } $ contents = $ this -> rokkaHelper -> getSourceImageContents ( $ client , $ image -> hash , $ image -> organization , $ stackName , $ format ) ; if ( ! $ contents ) { $ output -> writeln ( $ this -> formatterHelper -> formatBlock ( [ 'Error!' , 'Error getting image contents from Rokka.io!' , ] , 'error' , true ) ) ; return false ; } $ ret = file_put_contents ( $ saveTo , $ contents , FILE_BINARY ) ; if ( false == $ ret ) { $ output -> writeln ( $ this -> formatterHelper -> formatBlock ( [ 'Error!' , 'Error writing image contents to <info>' . $ saveTo . '</info>!' , ] , 'error' , true ) ) ; return false ; } $ output -> writeln ( 'Image saved to <info>' . $ saveTo . '</info>' ) ; return true ; }
Downloads and saves an image from Rokka .
25,694
public function filterByNbfinish ( $ nbfinish = null , $ comparison = null ) { if ( is_array ( $ nbfinish ) ) { $ useMinMax = false ; if ( isset ( $ nbfinish [ 'min' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_NBFINISH , $ nbfinish [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ nbfinish [ 'max' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_NBFINISH , $ nbfinish [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( RecordTableMap :: COL_NBFINISH , $ nbfinish , $ comparison ) ; }
Filter the query on the nbFinish column
25,695
public function filterByAvgscore ( $ avgscore = null , $ comparison = null ) { if ( is_array ( $ avgscore ) ) { $ useMinMax = false ; if ( isset ( $ avgscore [ 'min' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_AVGSCORE , $ avgscore [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ avgscore [ 'max' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_AVGSCORE , $ avgscore [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( RecordTableMap :: COL_AVGSCORE , $ avgscore , $ comparison ) ; }
Filter the query on the avgScore column
25,696
public function filterByCheckpoints ( $ checkpoints = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ checkpoints ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( RecordTableMap :: COL_CHECKPOINTS , $ checkpoints , $ comparison ) ; }
Filter the query on the checkpoints column
25,697
public function filterByPlayerId ( $ playerId = null , $ comparison = null ) { if ( is_array ( $ playerId ) ) { $ useMinMax = false ; if ( isset ( $ playerId [ 'min' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_PLAYER_ID , $ playerId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ playerId [ 'max' ] ) ) { $ this -> addUsingAlias ( RecordTableMap :: COL_PLAYER_ID , $ playerId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( RecordTableMap :: COL_PLAYER_ID , $ playerId , $ comparison ) ; }
Filter the query on the player_id column
25,698
public function filterByPlayer ( $ player , $ comparison = null ) { if ( $ player instanceof \ eXpansion \ Framework \ PlayersBundle \ Model \ Player ) { return $ this -> addUsingAlias ( RecordTableMap :: COL_PLAYER_ID , $ player -> getId ( ) , $ comparison ) ; } elseif ( $ player instanceof ObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( RecordTableMap :: COL_PLAYER_ID , $ player -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByPlayer() only accepts arguments of type \eXpansion\Framework\PlayersBundle\Model\Player or Collection' ) ; } }
Filter the query by a related \ eXpansion \ Framework \ PlayersBundle \ Model \ Player object
25,699
public function usePlayerQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinPlayer ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Player' , '\eXpansion\Framework\PlayersBundle\Model\PlayerQuery' ) ; }
Use the Player relation Player object