idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
8,600
public function setLevel ( \ n2n \ log4php \ LoggerLevel $ level = null ) { if ( isset ( $ level ) ) { parent :: setLevel ( $ level ) ; } else { throw new \ n2n \ log4php \ LoggerException ( "log4php: Cannot set LoggerRoot level to null." , E_USER_WARNING ) ; } }
Override level setter to prevent setting the root logger s level to null . Root logger must always have a level .
8,601
public function pass ( DataBagInterface $ dataBag ) : DataBagInterface { $ dataToInsert = $ this -> getDataToInsert ( $ dataBag ) ; if ( $ this -> recordExists ( $ dataBag ) ) { $ this -> updateRecord ( $ dataToInsert , $ dataBag ) ; } else { $ this -> insertRecord ( $ dataToInsert , $ dataBag ) ; } return $ dataBag ; ...
DBAL Insert statement . Inserts data into a table using DBAL .
8,602
public function getRecordId ( array $ identifier , string $ autoIncrementColumn ) : int { if ( isset ( $ identifier [ $ autoIncrementColumn ] ) ) { return ( int ) $ identifier [ $ autoIncrementColumn ] ; } $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; $ queryBuilder -> select ( $ autoIncrementColumn...
Get auto - increment field value of the record using given id .
8,603
private function recordExists ( DataBagInterface $ dataBag ) : bool { $ id = $ this -> updateStrategy -> getRecordIdentifier ( $ dataBag ) ; if ( ! empty ( $ id ) ) { $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'count(*)' ) -> from ( $ this -> table ) -> setParameters ( ...
Checks if record already exists in the DB .
8,604
public function transform ( EntityContract $ entity ) { return $ this -> manager -> getSerializer ( ) -> serialize ( $ entity , Collection :: make ( array_merge ( $ this -> getSelectedAttributes ( ) , $ this -> getAuthorizedAttributes ( ) ) ) ) -> toArray ( ) ; }
Turn this item object into a generic array .
8,605
public function getMyType ( ) { $ className = get_class ( $ this ) ; $ classParts = explode ( "\\" , $ className ) ; $ classSingle = $ classParts [ count ( $ classParts ) - 1 ] ; $ classLowSingle = strtolower ( $ classSingle ) ; $ type = str_replace ( "message" , "" , $ classLowSingle ) ; if ( ! $ type ) { return "unkn...
Return type data
8,606
public function insert ( string $ query , array $ values = [ ] ) : int { try { return $ this -> connection -> insert ( $ query , $ values ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Performs a insert query and returns the number of inserted rows .
8,607
public function insertGetId ( string $ query , array $ values = [ ] , string $ sequence = null ) { try { return $ this -> connection -> insertGetId ( $ query , $ values , $ sequence ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Performs a insert query and returns the identifier of the last inserted row .
8,608
protected function getForeignModelFromRequest ( $ name ) { $ this -> checkForeignModelFromRequest ( $ name ) ; $ requestKey = $ this -> getRequestKeyFromString ( $ name ) ; return $ this -> getRequest ( ) -> attributes -> get ( $ requestKey ) ; }
Gets Foreign model from Request
8,609
public function checkDirectory ( ) : bool { if ( $ this -> directory == null ) { throw new LoggerException ( 'Log directory is not defined yet' ) ; } self :: $ directoryChecked = self :: $ directoryChecked ? : is_dir ( $ this -> directory ) ; if ( ! self :: $ directoryChecked ) { self :: $ directoryChecked = ( bool ) @...
Check directory .
8,610
public function logAny ( $ message , bool $ separate = false ) : ? bool { return $ this -> log ( self :: ANY , $ message , $ separate ) ; }
Log any .
8,611
public function logFail ( $ message , bool $ separate = false ) : ? bool { return $ this -> log ( self :: FAIL , $ message , $ separate ) ; }
Log fail .
8,612
public function logWarn ( $ message , bool $ separate = false ) : ? bool { return $ this -> log ( self :: WARN , $ message , $ separate ) ; }
Log warn .
8,613
public function logInfo ( $ message , bool $ separate = false ) : ? bool { return $ this -> log ( self :: INFO , $ message , $ separate ) ; }
Log info .
8,614
public function logDebug ( $ message , bool $ separate = false ) : ? bool { return $ this -> log ( self :: DEBUG , $ message , $ separate ) ; }
Log debug .
8,615
public function get_routes ( $ include_admin = false ) { $ routes = array_merge ( $ this -> public_routes , $ this -> routes ) ; if ( $ include_admin === true ) { $ routes = array_merge ( $ this -> admin_routes , $ routes ) ; } uksort ( $ routes , function ( $ a , $ b ) { if ( strlen ( $ a ) == strlen ( $ b ) ) { if ( ...
gets the page routes
8,616
public function clean ( $ value ) { $ value = PruneWhitespaceCleaner :: get ( ) -> clean ( $ value ) ; if ( $ value === '' || $ value === null || $ value === false ) { return $ this -> openDate ; } $ match = preg_match ( '/^(\d{4})-(\d{1,2})-(\d{1,2})$/' , $ value , $ parts ) ; $ valid = ( $ match && checkdate ( ( int ...
Cleans a submitted date and returns the date in ISO 8601 machine format if the date is a valid date . Otherwise returns the original submitted value .
8,617
public function addAll ( $ elements ) { if ( $ elements instanceof CollectionInterface ) { $ elements = $ elements -> toArray ( ) ; } else { $ elements = array_values ( $ elements ) ; } $ this -> elements = array_merge ( $ this -> elements , $ elements ) ; return $ this ; }
Adds elements to the end of the list .
8,618
public function insert ( $ index , $ element ) { if ( 0 < $ index && $ this -> count ( ) < $ index ) { throw new \ OutOfBoundsException ( ) ; } array_splice ( $ this -> elements , $ index , 0 , $ element ) ; foreach ( $ this -> subLists as $ subList ) { $ subList -> insert ( $ index , $ element , true ) ; } return $ th...
Inserts the element at the specified position in this list .
8,619
public function insertAll ( $ index , $ elements ) { if ( 0 < $ index && $ this -> count ( ) < $ index ) { throw new \ OutOfBoundsException ( ) ; } if ( $ elements instanceof CollectionInterface ) { $ elements = $ elements -> toArray ( ) ; } else { $ elements = array_values ( $ elements ) ; } array_splice ( $ this -> e...
Inserts all of the elements into this list at the specified position .
8,620
public function set ( $ index , $ element ) { if ( false === array_key_exists ( $ index , $ this -> elements ) ) { throw new \ OutOfBoundsException ( ) ; } $ this -> elements [ $ index ] = $ element ; foreach ( $ this -> subLists as $ subList ) { $ subList -> set ( $ index , $ element , true ) ; } return $ this ; }
Replaces the element at the specified position in this list with the specified element .
8,621
public function remove ( $ element ) { $ key = array_search ( $ element , $ this -> elements , true ) ; if ( false !== $ key ) { unset ( $ this -> elements [ $ key ] ) ; $ this -> elements = array_values ( $ this -> elements ) ; } foreach ( $ this -> subLists as $ subList ) { $ subList -> drop ( $ key , true ) ; } retu...
Removes the first instance of the element from the list if it is present .
8,622
public function removeAll ( $ elements ) { if ( $ elements instanceof CollectionInterface ) { $ elements = $ elements -> toArray ( ) ; } $ this -> elements = array_values ( array_udiff ( $ this -> elements , $ elements , function ( $ a , $ b ) { if ( $ a === $ b ) { return 0 ; } elseif ( is_int ( $ a ) && is_object ( $...
Removes all instances of the elements from the list if they are present .
8,623
public function drop ( $ index ) { if ( false === array_key_exists ( $ index , $ this -> elements ) ) { throw new \ OutOfBoundsException ( ) ; } unset ( $ this -> elements [ $ index ] ) ; $ this -> elements = array_values ( $ this -> elements ) ; foreach ( $ this -> subLists as $ subList ) { $ subList -> drop ( $ index...
Removes the element at the specified position in this list .
8,624
public function clear ( ) { $ this -> elements = array ( ) ; foreach ( $ this -> subLists as $ subList ) { $ subList -> clear ( true ) ; } return $ this ; }
Removes all elements from the list .
8,625
public function retainAll ( $ elements ) { if ( $ elements instanceof CollectionInterface ) { $ elements = $ elements -> toArray ( ) ; } $ this -> elements = array_values ( array_uintersect ( $ this -> elements , $ elements , function ( $ a , $ b ) { if ( $ a === $ b ) { return 0 ; } elseif ( is_int ( $ a ) && is_objec...
Retains only the elements in the list that are contained in the specified collection .
8,626
public function parse ( ) { if ( empty ( $ this -> pattern ) ) { $ this -> addLiteral ( '' ) ; return $ this -> head ; } $ count = preg_match_all ( $ this -> regex , $ this -> pattern , $ matches , PREG_OFFSET_CAPTURE ) ; if ( $ count === false ) { $ error = error_get_last ( ) ; throw new \ n2n \ log4php \ LoggerExcept...
Parses the conversion pattern string converts it to a chain of pattern converters and returns the first converter in the chain .
8,627
private function addLiteral ( $ string ) { $ converter = new \ n2n \ log4php \ pattern \ converter \ ConverterLiteral ( $ string ) ; $ this -> addToChain ( $ converter ) ; }
Adds a literal converter to the converter chain .
8,628
private function addConverter ( $ word , $ modifiers , $ option ) { $ formattingInfo = $ this -> parseModifiers ( $ modifiers ) ; $ option = trim ( $ option , "{} " ) ; if ( isset ( $ this -> converterMap [ $ word ] ) ) { $ converter = $ this -> getConverter ( $ word , $ formattingInfo , $ option ) ; $ this -> addToCha...
Adds a non - literal converter to the converter chain .
8,629
private function getConverter ( $ word , $ info , $ option ) { if ( ! isset ( $ this -> converterMap [ $ word ] ) ) { throw new \ n2n \ log4php \ LoggerException ( "Invalid keyword '%$word' in converison pattern. Ignoring keyword." ) ; } $ converterClass = $ this -> converterMap [ $ word ] ; if ( ! class_exists ( $ con...
Determines which converter to use based on the conversion word . Creates an instance of the converter using the provided formatting info and option and returns it .
8,630
private function parseModifiers ( $ modifiers ) { $ info = new \ n2n \ log4php \ formatting \ FormattingInfo ( ) ; if ( empty ( $ modifiers ) ) { return $ info ; } $ pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/' ; if ( ! preg_match ( $ pattern , $ modifiers ) ) { throw new \ n2n \ log4php \ LoggerException ( "log4php: Invalid...
Parses the formatting modifiers and produces the corresponding \ n2n \ log4php \ formatting \ FormattingInfo object .
8,631
public function getMyChats ( Request $ request ) { $ loginHelper = $ this -> container -> get ( 'sopinet_login_helper' ) ; try { $ user = $ loginHelper -> getUser ( $ request ) ; } catch ( Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; } $ em = $ this -> container -> get ( 'doctrine.orm.default_entit...
Funcion para obtener mis chats
8,632
private function indentationModeBlock ( string $ line ) : int { $ mode = 0 ; if ( substr ( $ line , - 1 , 1 ) == '{' ) { $ mode |= self :: C_INDENT_INCREMENT_AFTER ; $ this -> defaultLevelIncrement ( ) ; } if ( substr ( $ line , 0 , 1 ) == '}' ) { $ this -> defaultLevelDecrement ( ) ; if ( $ this -> defaultLevelIsZero ...
Returns the indentation mode based blocks of code .
8,633
private function indentationModeSwitch ( string $ line ) : int { $ mode = 0 ; if ( substr ( $ line , 0 , 5 ) == 'case ' ) { $ mode |= self :: C_INDENT_INCREMENT_AFTER ; } if ( substr ( $ line , 0 , 8 ) == 'default:' ) { $ this -> defaultLevel [ ] = 0 ; $ mode |= self :: C_INDENT_INCREMENT_AFTER ; } if ( substr ( $ line...
Returns the indentation mode based on a line of code for switch statements .
8,634
public function setLabelAttribute ( string $ name , ? string $ value ) { if ( $ value === '' || $ value === null ) { unset ( $ this -> labelAttributes [ $ name ] ) ; } else { if ( $ name == 'class' && isset ( $ this -> labelAttributes [ $ name ] ) ) { $ this -> labelAttributes [ $ name ] .= ' ' ; $ this -> labelAttribu...
Sets the value of an attribute the label for this form control .
8,635
protected function getHtmlPrefixLabel ( ) : string { if ( isset ( $ this -> labelPosition ) ) { if ( ! isset ( $ this -> attributes [ 'id' ] ) ) { $ id = Html :: getAutoId ( ) ; $ this -> attributes [ 'id' ] = $ id ; $ this -> labelAttributes [ 'for' ] = $ id ; } else { $ this -> labelAttributes [ 'for' ] = $ this -> a...
Returns HTML code for a label for this form control te be inserted before the HTML code of this form control .
8,636
public function getByIsoCode ( $ sCode ) { if ( array_key_exists ( $ sCode , $ this -> aSupportedCurrencies ) ) { return $ this -> aSupportedCurrencies [ $ sCode ] ; } else { throw new CurrencyException ( '"' . $ sCode . '" is not a valid currency code.' ) ; } }
Returns a currency by it s ISO 4217 code
8,637
public function format ( $ sCode , $ nValue , $ bIncludeSymbol = true ) { try { $ oCurrency = $ this -> getByIsoCode ( $ sCode ) ; $ sOut = number_format ( $ nValue , $ oCurrency -> decimal_precision , $ oCurrency -> decimal_symbol , $ oCurrency -> thousands_separator ) ; if ( $ bIncludeSymbol ) { if ( $ oCurrency -> s...
Formats a currency
8,638
protected function initViewVars ( $ view ) { $ view -> set ( 'controller' , $ this -> getName ( ) ) ; $ view -> set ( 'action' , $ this -> getAction ( ) ) ; if ( method_exists ( $ view , 'setRequest' ) ) { $ view -> setRequest ( $ this -> getRequest ( ) ) ; } return $ view ; }
Init View variables
8,639
protected function initViewContentBlocks ( $ view ) { $ view -> setBlock ( 'content' , $ this -> getRequest ( ) -> getControllerName ( ) . '/' . $ this -> getRequest ( ) -> getActionName ( ) ) ; return $ view ; }
Init View Content block
8,640
public static function addRow ( DetailTable $ table , $ header , ? string $ value , string $ format ) : void { if ( $ value !== null && $ value !== '' ) { $ table -> addRow ( $ header , [ 'class' => 'number' ] , sprintf ( $ format , $ value ) ) ; } else { $ table -> addRow ( $ header ) ; } }
Adds a row with a numeric value to a detail table .
8,641
public function setMigrationName ( $ migrationName ) { $ this -> migrationName = $ migrationName ; $ migrationNameAsUnderscoreSrtring = S :: underscored ( $ migrationName ) ; $ items = explode ( '_' , $ migrationNameAsUnderscoreSrtring ) ; if ( count ( $ items ) >= 3 ) { $ this -> action = in_array ( $ items [ 0 ] , $ ...
Sets a migration name .
8,642
public function append ( \ n2n \ log4php \ logging \ LoggingEvent $ event ) { $ priority = $ this -> getSyslogPriority ( $ event -> getLevel ( ) ) ; $ message = $ this -> layout -> format ( $ event ) ; openlog ( $ this -> ident , $ this -> intOption , $ this -> intFacility ) ; syslog ( $ priority , $ message ) ; closel...
Appends the event to syslog .
8,643
private function getSyslogPriority ( \ n2n \ log4php \ LoggerLevel $ level ) { if ( $ this -> overridePriority ) { return $ this -> intPriority ; } return $ level -> getSyslogEquivalent ( ) ; }
Determines which syslog priority to use based on the given level .
8,644
private function parseOption ( ) { $ value = 0 ; $ options = explode ( '|' , $ this -> option ) ; foreach ( $ options as $ option ) { if ( ! empty ( $ option ) ) { $ constant = "LOG_" . trim ( $ option ) ; if ( defined ( $ constant ) ) { $ value |= constant ( $ constant ) ; } else { throw new \ n2n \ log4php \ LoggerEx...
Parses a syslog option string and returns the correspodning int value .
8,645
private function parseFacility ( ) { if ( ! empty ( $ this -> facility ) ) { $ constant = "LOG_" . trim ( $ this -> facility ) ; if ( defined ( $ constant ) ) { return constant ( $ constant ) ; } else { throw new \ n2n \ log4php \ LoggerException ( "log4php: Invalid syslog facility provided: {$this->facility}." , E_USE...
Parses the facility string and returns the corresponding int value .
8,646
private function parsePriority ( ) { if ( ! empty ( $ this -> priority ) ) { $ constant = "LOG_" . trim ( $ this -> priority ) ; if ( defined ( $ constant ) ) { return constant ( $ constant ) ; } else { throw new \ n2n \ log4php \ LoggerException ( "log4php: Invalid syslog priority provided: {$this->priority}." , E_USE...
Parses the priority string and returns the corresponding int value .
8,647
protected function findProperties ( \ ReflectionClass $ reflection ) : void { if ( false !== $ reflection -> getParentClass ( ) ) { $ this -> findProperties ( $ reflection -> getParentClass ( ) ) ; } $ this -> properties = array_unique ( array_merge ( $ this -> properties , array_keys ( $ reflection -> getDefaultProper...
Finds all properties in class .
8,648
protected function findReflectionProperty ( $ property , \ ReflectionClass $ reflection ) { if ( $ reflection -> hasProperty ( $ property ) ) { $ refProp = $ reflection -> getProperty ( $ property ) ; $ refProp -> setAccessible ( true ) ; return $ refProp ; } if ( false !== $ reflection -> getParentClass ( ) ) { return...
Finds the reflection property .
8,649
protected function fail ( $ message = null , $ validation = null ) { $ this -> trigger ( 'json-fail' , $ this , $ message , $ validation ) ; $ this -> trigger ( 'response-fail' , $ this , $ message , $ validation ) ; $ json = array ( 'error' => true ) ; if ( $ message ) { $ json [ 'message' ] = $ message ; } if ( $ val...
Sets a fail format
8,650
protected function success ( $ results = null ) { $ this -> trigger ( 'json-success' , $ this , $ results ) ; $ this -> trigger ( 'response-success' , $ this , $ results ) ; $ json = array ( 'error' => false ) ; if ( $ results ) { $ json [ 'results' ] = $ results ; } $ body = json_encode ( $ json , JSON_PRETTY_PRINT ) ...
Sets a success format
8,651
protected function initBundleDirectoryStructure ( InputInterface $ input , OutputInterface $ output ) { $ frameworkPath = $ this -> container -> getParameter ( 'behat.silverstripe_extension.framework_path' ) ; $ _GET [ 'flush' ] = 1 ; require_once $ frameworkPath . '/core/Core.php' ; unset ( $ _GET [ 'flush' ] ) ; $ fe...
Inits bundle directory structure
8,652
public function insert ( array $ rows ) : int { try { $ query = ( clone $ this ) -> addInsert ( $ rows ) -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ statements = $ this -> database -> getGrammar ( ) -> compileInsert ( $ query ) ; $ count = 0 ; foreach ( $ statements as $ statement ) { $ count += $ this ...
Inserts rows to a table . Doesn t modify itself .
8,653
public function insertGetId ( array $ row , string $ sequence = null ) { try { $ query = ( clone $ this ) -> addInsert ( [ $ row ] ) -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ statements = $ this -> database -> getGrammar ( ) -> compileInsert ( $ query ) ; $ id = null ; foreach ( $ statements as $ stat...
Inserts a row to a table and returns the inserted row identifier . Doesn t modify itself .
8,654
public function insertFromSelect ( $ columns , $ selectQuery = null ) : int { return ( clone $ this ) -> addInsertFromSelect ( $ columns , $ selectQuery ) -> insert ( [ ] ) ; }
Inserts rows to a table from a select query . Doesn t modify itself .
8,655
protected function getParentName ( $ name ) { return ( string ) substr ( $ name , 0 , ( int ) strrpos ( $ name , $ this -> separator ) ) ; }
Get name for parent loader
8,656
public function invoke ( $ object , $ value ) { if ( null !== $ value ) { $ this -> method -> invoke ( $ object , $ value ) ; } }
passes procured value to the instance
8,657
public function findAllToRefreshToken ( bool $ force = false ) { $ query = $ this -> newQuery ( ) ; return $ force ? $ query -> get ( ) : $ query -> whereNull ( 'token' ) -> get ( ) ; }
Find all user that have a null token .
8,658
public function render ( $ format = 'd.m.Y H:i:s' ) { $ output = $ this -> getContext ( ) . ': ' ; $ date = $ this -> extractDateFromRevisionFile ( ) ; if ( $ date === null ) { $ date = $ this -> extractDateFromSurfPath ( ) ; } if ( $ date === null ) { $ date = new \ DateTime ( 'now' ) ; } $ output .= $ date -> format ...
Show release string based on symlink
8,659
public function isPublished ( ) { $ user = Yii :: $ app -> core -> getUser ( ) ; if ( isset ( $ user ) ) { if ( $ this -> createdBy == $ user -> id ) { return true ; } if ( $ this -> isPublic ( ) && $ this -> isVisibilityProtected ( ) ) { return true ; } } return $ this -> isPublic ( ) && $ this -> isVisibilityPublic (...
Check whether content is published . To consider a model as published it must be publicly visible in either active or frozen status .
8,660
public function clean ( $ value ) { if ( $ value === '' || $ value === null || $ value === false ) { return null ; } $ tmp = $ value ; foreach ( $ this -> ambiguities as $ unambiguity => $ ambiguities ) { foreach ( $ ambiguities as $ ambiguity ) { $ tmp = str_replace ( $ ambiguity , $ unambiguity , $ tmp ) ; } } if ( P...
Replaces all ambiguous characters in a submitted values with the intended characters .
8,661
protected function doActionObject ( $ method , ObjectBuilderInterface $ builder , array $ options ) : void { if ( null !== $ this -> parent ) { $ this -> parent -> { $ method } ( $ builder , $ options ) ; } $ this -> innerType -> { $ method } ( $ builder , $ options ) ; foreach ( $ this -> typeExtensions as $ extension...
Build or finish the object .
8,662
public static function isTraditional ( $ str ) { if ( empty ( $ str ) ) { throw new Exception ( 'Argument str cannot be empty' ) ; } $ ords = self :: utf8ToUnicode ( $ str ) ; foreach ( $ ords as $ val ) { if ( ! empty ( $ val ) && array_key_exists ( $ val , self :: $ trad2simple ) ) { return true ; } } return false ; ...
Is string made up of traditional Chinese characters? At least one character .
8,663
public static function trad2simp ( $ str ) { if ( empty ( $ str ) ) { throw new Exception ( 'Argument str cannot be empty' ) ; } $ ords = self :: utf8ToUnicode ( $ str ) ; foreach ( $ ords as $ k => $ val ) { if ( $ val !== false && array_key_exists ( $ val , self :: $ trad2simple ) ) { $ ords [ $ k ] = self :: $ trad2...
Converts traditional to simplified .
8,664
public static function simp2trad ( $ str ) { if ( empty ( $ str ) ) { throw new Exception ( 'Argument str cannot be empty' ) ; } $ charArray = array_flip ( self :: $ trad2simple ) ; $ ords = self :: utf8ToUnicode ( $ str ) ; foreach ( $ ords as $ k => $ val ) { if ( array_key_exists ( $ val , $ charArray ) ) { $ ords [...
Converts simplified to traditional .
8,665
private static function unicodeToUtf8 ( $ arr ) { $ dest = '' ; foreach ( $ arr as $ src ) { $ dest .= self :: utf8 ( $ src ) ; } return $ dest ; }
Takes an array of integers representing the Unicode characters and returns a UTF - 8 string .
8,666
public function setDomQuery ( $ userid , $ userkey , $ action ) { $ request = $ this -> appendChild ( $ this -> createElement ( 'query' ) ) ; $ userid = $ this -> createElement ( 'userid' , $ userid ) ; $ userkey = $ this -> createElement ( 'userkey' , $ userkey ) ; $ action = $ this -> createElement ( 'action' , $ act...
Set Query & Auth Params
8,667
public function createFromCartItem ( $ order , $ cartItem , $ config = [ ] ) { $ model = $ this -> getModelObject ( ) ; $ model -> orderId = $ order -> id ; $ model -> createdBy = $ order -> creator -> id ; $ model -> copyForUpdateFrom ( $ cartItem , [ 'primaryUnitId' , 'purchasingUnitId' , 'quantityUnitId' , 'weightUn...
Create Order Item from cart item
8,668
protected function serveFromCache ( $ cacheFile , $ hit = true ) { $ _stats = stat ( $ this -> cacheDir . $ cacheFile ) ; $ this -> setCacheHeaders ( $ _stats [ 9 ] , $ cacheFile , $ hit ) ; header ( 'Content-Type: image/png' , true ) ; echo file_get_contents ( $ this -> cacheDir . $ cacheFile ) ; exit ( 0 ) ; }
Serve a file from the cache setting headers as we go then halt execution
8,669
protected function setCacheHeaders ( $ lastModified , $ file , $ hit ) { $ this -> cacheHeadersSet = true ; $ this -> cacheHeadersMaxAge = 31536000 ; $ this -> cacheHeadersLastModified = $ lastModified ; $ this -> cacheHeadersExpires = time ( ) + $ this -> cacheHeadersMaxAge ; $ this -> cacheHeadersFile = $ file ; $ th...
Set the correct cache headers
8,670
protected function serveNotModified ( $ file ) { if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } elseif ( $ this -> input -> server ( 'HTTP_IF_NONE_MATCH' ) ) { $ headers = array ( ) ; $ headers [ 'If-None-Match' ] = $ this -> input -> server ( 'HTTP_IF_NONE_MATCH' ) ; }...
Serve the not modified headers if appropriate
8,671
public function getRecentByAdmin ( $ limit = 5 , $ config = [ ] ) { $ modelClass = static :: $ modelClass ; $ modelTable = $ this -> getModelTable ( ) ; $ siteId = Yii :: $ app -> core -> siteId ; $ config [ 'conditions' ] [ ] = "$modelTable.access >=" . Announcement :: ACCESS_APP_ADMIN ; return $ modelClass :: find ( ...
It returns the most recent announcements that can be displayed on Admin .
8,672
public function calculate ( PriceRule $ priceRule , float $ price , array $ options = [ ] ) { $ payload = $ priceRule -> payload ; $ options = ( object ) $ options ; $ parser = new StdMathParser ( ) ; if ( ! isset ( $ payload -> expression ) ) { throw new Exceptions \ PriceRuleWrongPayloadException ( 'Missing expressio...
Given the base priceRule calculate the final price .
8,673
public function paymentButton ( Environment $ environment , $ text = null , $ amount = null , $ currency = null , $ style = 'btn btn-lg btn-primary' ) { return $ environment -> render ( '@c975LPayment/fragments/paymentButton.html.twig' , array ( 'text' => $ text , 'amount' => $ amount , 'currency' => strtolower ( $ cur...
Returns xhtml code for Payment button
8,674
public static function createClass ( $ class , $ data ) { if ( ! class_exists ( $ class ) ) { return null ; } $ ref = new \ ReflectionClass ( $ class ) ; if ( $ ref -> isAbstract ( ) ) { return null ; } $ store = new $ class ( $ data ) ; return $ store ; }
Create a class if exists and not abstract
8,675
public static function getStoreClass ( $ inValue , array $ defaultClassName ) { if ( $ inValue && isset ( $ inValue -> _className ) && class_exists ( $ inValue -> _className ) ) { return $ inValue -> _className ; } if ( count ( $ defaultClassName ) == 1 && class_exists ( $ defaultClassName [ 0 ] ) ) { return $ defaultC...
return a string that represent a store .
8,676
public static function matchType ( $ inValue , $ className ) { if ( $ inValue instanceof \ stdClass ) { $ inValueKeys = array_keys ( get_object_vars ( $ inValue ) ) ; if ( in_array ( '_type' , $ inValueKeys ) ) { $ tempStore = new $ className ( ) ; $ tempStoreType = $ tempStore -> get_type ( ) ; if ( $ tempStoreType ==...
Use the _type in value to detect if matches with an array of classes given
8,677
public static function checkStoreClass ( $ store , array $ storeClasses , array $ allowedId ) { if ( is_string ( $ store ) && strstr ( $ store , '_' ) ) { list ( $ prefix , $ id ) = explode ( '_' , $ store ) ; if ( in_array ( $ prefix , $ allowedId ) ) { return true ; } return false ; } if ( in_array ( get_class ( $ st...
Check if the store class type is part of declared classes in storeClasses .
8,678
public function copy ( $ source , $ destination ) { $ contents = $ this ( 'file' , $ source ) -> getContent ( ) ; $ template = $ this -> engine -> compile ( $ contents ) ; $ code = $ template ( $ this -> schema ) ; $ code = str_replace ( '\\\\' , '\\' , $ code ) ; $ code = str_replace ( '\}' , '}' , $ code ) ; $ code =...
Copy the contents from to
8,679
public function & add ( $ filter ) { $ filters = func_get_args ( ) ; foreach ( $ filters as $ filter ) { if ( ! ( $ filter instanceof \ Erebot \ Interfaces \ Event \ Match ) ) { throw new \ Erebot \ InvalidValueException ( 'Not a valid matcher' ) ; } if ( ! in_array ( $ filter , $ this -> submatchers , true ) ) { $ thi...
Adds one or more subfilters to this filter .
8,680
public function & remove ( $ filter ) { $ filters = func_get_args ( ) ; foreach ( $ filters as $ filter ) { if ( ! ( $ filter instanceof \ Erebot \ Interfaces \ Event \ Match ) ) { throw new \ Erebot \ InvalidValueException ( 'Not a valid matcher' ) ; } $ key = array_search ( $ filter , $ this -> submatchers , true ) ;...
Removes one or more subfilters from this filter .
8,681
public function createFormControl ( ComplexControl $ parentControl , string $ slatJointName , ? string $ controlName = null ) : Control { $ control = $ this -> slatJoints [ $ slatJointName ] -> createControl ( $ controlName ?? $ slatJointName ) ; $ parentControl -> addFormControl ( $ control ) ; return $ control ; }
Creates a form control using a slat joint and returns the created form control .
8,682
public function getHtmlColumnGroup ( ) : string { $ ret = '' ; foreach ( $ this -> slatJoints as $ factory ) { $ ret .= $ factory -> getHtmlCol ( ) ; } $ ret .= '<col/>' ; return $ ret ; }
Returns the inner HTML code of the colgroup element of the table form control .
8,683
public function getHtmlHeader ( ) : string { $ ret = Html :: generateTag ( 'tr' , [ 'class' => [ OverviewTable :: $ class , 'header' ] ] ) ; foreach ( $ this -> slatJoints as $ factory ) { $ ret .= $ factory -> getHtmlColumnHeader ( ) ; } $ ret .= '<th class="error"></th>' ; $ ret .= '</tr>' ; if ( $ this -> filter ) {...
Returns the inner HTML code of the thead element of the table form control .
8,684
public function getOrdinal ( string $ slatJointName ) : int { $ ordinal = 0 ; $ key = null ; foreach ( $ this -> slatJoints as $ key => $ slat_joint ) { if ( $ key == $ slatJointName ) break ; $ ordinal += $ slat_joint -> getColSpan ( ) ; } if ( $ key != $ slatJointName ) { throw new LogicException ( "SlatJoint '%s' no...
Returns the 0 - indexed ordinal of a slat joint in the underlying table of the louver form control .
8,685
public function set ( $ key , $ value ) { if ( ( is_array ( $ value ) && ( bool ) count ( array_filter ( array_keys ( $ value ) , 'is_string' ) ) ) || ( is_object ( $ value ) && get_class ( $ value ) == 'stdClass' ) ) { $ value = new self ( $ value ) ; } elseif ( is_array ( $ value ) && empty ( $ value ) ) { $ value = ...
Sets a value to the requested key
8,686
public function toArray ( $ convertRecursively = true ) { if ( $ convertRecursively ) { return json_decode ( json_encode ( $ this ) , true ) ; } else { return ( array ) $ this -> data ; } }
Recursively converts all the Object instances to array
8,687
public function process ( ContainerBuilder $ container ) { $ frameworkPath = $ container -> getParameter ( 'behat.silverstripe_extension.framework_path' ) ; $ _GET [ 'flush' ] = 1 ; require_once $ frameworkPath . '/core/Core.php' ; if ( class_exists ( 'TestRunner' ) ) { \ TestRunner :: use_test_manifest ( ) ; } else { ...
Loads kernel file .
8,688
public static function wrap ( Filter $ filter , Range $ range = null ) { if ( null === $ range ) { return $ filter ; } return new self ( $ filter , $ range ) ; }
utility method that wraps given filter with given range
8,689
public static function totalDays ( $ interval ) { if ( $ interval -> days !== false ) { return $ interval -> days ; } else { return $ interval -> d + self :: totalMonths ( $ interval ) * 30 ; } }
Total days in interval
8,690
public function getRegionObj ( $ region ) { try { $ regionObj = $ this -> getSession ( ) -> getPage ( ) -> find ( 'css' , ( false !== strpos ( $ region , "'" ) ) ? str_replace ( "'" , "\'" , $ region ) : $ region ) ; if ( $ regionObj ) { return $ regionObj ; } } catch ( \ Symfony \ Component \ CssSelector \ Exception \...
Returns MinkElement based off region defined in . yml file . Also supports direct CSS selectors and regions identified by a data - title attribute . When using the data - title attribute ensure not to include double quotes .
8,691
public function parseUrl ( $ url ) { $ url = parse_url ( $ url ) ; $ url [ 'vars' ] = array ( ) ; if ( ! isset ( $ url [ 'fragment' ] ) ) { $ url [ 'fragment' ] = null ; } if ( isset ( $ url [ 'query' ] ) ) { parse_str ( $ url [ 'query' ] , $ url [ 'vars' ] ) ; } return $ url ; }
Parses given URL and returns its components
8,692
public function joinUrlParts ( ) { if ( 0 === func_num_args ( ) ) { throw new \ InvalidArgumentException ( 'Need at least one argument' ) ; } $ parts = func_get_args ( ) ; $ trimSlashes = function ( & $ part ) { $ part = trim ( $ part , '/' ) ; } ; array_walk ( $ parts , $ trimSlashes ) ; return implode ( '/' , $ parts...
Joins URL parts into an URL using forward slash . Forward slash usages are normalised to one between parts . This method takes variable number of parameters .
8,693
public function selectOption ( $ select , $ option ) { $ field = $ this -> getSession ( ) -> getPage ( ) -> findField ( $ this -> fixStepArgument ( $ select ) ) ; if ( $ field && $ field -> isVisible ( ) ) { parent :: selectOption ( $ select , $ option ) ; } else { $ this -> selectOptionWithJavascript ( $ select , $ op...
Selects option in select field with specified id|name|label|value .
8,694
public function selectOptionWithJavascript ( $ select , $ option ) { $ select = $ this -> fixStepArgument ( $ select ) ; $ option = $ this -> fixStepArgument ( $ option ) ; $ page = $ this -> getSession ( ) -> getPage ( ) ; $ field = $ page -> findField ( $ select ) ; if ( null === $ field ) { throw new ElementNotFound...
Selects option in select field with specified id|name|label|value using javascript This method uses javascript to allow selection of options that may be overridden by javascript libraries and thus hide the element .
8,695
public static function corAuxiliar ( $ name ) { $ style = str_replace ( "#" , "" , $ name ) ; $ style = strlen ( $ style ) === 3 ? $ style [ 0 ] . $ style [ 0 ] . $ style [ 1 ] . $ style [ 1 ] . $ style [ 2 ] . $ style [ 2 ] : $ style ; $ todo = hexdec ( $ style [ 0 ] . $ style [ 1 ] ) + hexdec ( $ style [ 2 ] . $ styl...
retorna cor auxiliar inversa em hexadecimal
8,696
protected function updateStatus ( $ post , $ status ) { $ this -> modelService -> updateStatus ( $ post , $ status ) ; return $ this -> checkStatus ( $ post ) ; }
Update post status and redirect to the last step filled by user .
8,697
public function execute ( Work $ work , stdClass $ payload , array $ data = [ ] ) { $ generator = $ this -> manager -> getRepository ( ) -> findOneById ( $ payload -> data -> id ) ; $ result = $ this -> manager -> generate ( $ generator , $ data ) ; }
Dispatch a work .
8,698
public function renderMessages ( ) { $ return = '' ; $ messages = $ this -> getForm ( ) -> getMessages ( ) ; foreach ( $ messages as $ type => $ lines ) { if ( $ type == "error" ) { $ return .= ErrorsHelper :: render ( $ lines ) ; } else { $ return .= MessagesHelper :: render ( $ lines , $ type ) ; } } return $ return ...
The errors are rendered using the Errors View Helper
8,699
protected function getHtmlErrorCell ( ) : string { $ ret = '' ; if ( ! $ this -> isValid ( ) ) { $ error_messages = $ this -> getErrorMessages ( true ) ; $ ret .= '<td class="error">' ; if ( ! empty ( $ error_messages ) ) { foreach ( $ error_messages as $ message ) { $ ret .= Html :: txt2Html ( $ message ) ; $ ret .= '...
Returns a table cell with the errors messages of all form controls at this row .