idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
8,000
public function toWebId ( bool $ ignoreAliases = false ) { if ( ! $ ignoreAliases && null !== ( $ alias = self :: getWebAliasForN2nLocale ( $ this ) ) ) { return $ alias ; } return mb_strtolower ( str_replace ( '_' , '-' , $ this -> getId ( ) ) ) ; }
ISO 639 - 1 - ISO 3166 - 1 Alpha 2
8,001
public function update ( array $ values ) : int { try { $ query = ( clone $ this ) -> addUpdate ( $ values ) -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ compiled = $ this -> database -> getGrammar ( ) -> compileUpdate ( $ query ) ; return $ this -> database -> update ( $ compiled -> getSQL ( ) , $ compi...
Updates the query target rows . Doesn t modify itself .
8,002
public function delete ( ) : int { try { $ query = ( clone $ this ) -> setDelete ( ) -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ compiled = $ this -> database -> getGrammar ( ) -> compileDelete ( $ query ) ; return $ this -> database -> delete ( $ compiled -> getSQL ( ) , $ compiled -> getBindings ( ) )...
Deletes the query target rows . Doesn t modify itself .
8,003
public function getTotalPrice ( $ precision = 2 ) { $ price = ( $ this -> price - $ this -> discount ) * $ this -> purchase ; return round ( $ price , $ precision ) ; }
Returns the total price of the item .
8,004
public static function findByParentCartId ( $ parentId , $ parentType , $ cartId ) { return self :: find ( ) -> where ( 'parentId=:pid AND parentType=:ptype AND cartId=:cid' , [ ':pid' => $ parentId , ':ptype' => $ parentType , ':cid' => $ cartId ] ) -> one ( ) ; }
Return the cart item associated with given parent id parent type and cart id .
8,005
private function allowedValues ( Annotation $ annotation ) : array { if ( $ annotation -> hasValueByName ( 'allowed' ) ) { return array_map ( 'trim' , explode ( '|' , $ annotation -> getAllowed ( ) ) ) ; } elseif ( $ annotation -> hasValueByName ( 'allowedSource' ) ) { return call_user_func ( array_map ( 'trim' , explo...
reads default value
8,006
public function pop ( ) : ? Job { $ key = $ this -> generateListKey ( ) ; $ element = $ this -> getFirstElementFromQueue ( $ key ) ; if ( $ element === null ) { return null ; } $ this -> getClient ( ) -> getRedis ( ) -> watch ( $ key ) ; while ( ! $ this -> getClient ( ) -> getRedis ( ) -> multi ( ) -> zrem ( $ key , $...
Pops the highest priority item off of the priority queue
8,007
private function getFirstElementFromQueue ( $ key ) : ? string { $ result = $ this -> getClient ( ) -> getRedis ( ) -> zrevrange ( $ key , 0 , 0 ) ; if ( empty ( $ result ) ) { return null ; } return $ result [ 0 ] ; }
Gets the head element off of the list
8,008
public function generateListKey ( ) : string { $ filter = [ $ this -> getClient ( ) -> getNamespace ( ) , 'queue' , \ str_replace ( ':' , '.' , $ this -> getName ( ) ) ] ; $ parts = \ array_filter ( $ filter , 'strlen' ) ; return \ implode ( ':' , $ parts ) ; }
Generates a unique key for the job
8,009
public function getStatsByType ( string $ date , string $ type ) : ? array { if ( $ this -> isValidDate ( $ date ) ) { $ results = $ this -> getClient ( ) -> getRedis ( ) -> hgetall ( $ date . '_' . $ type ) ; \ ksort ( $ results ) ; return $ results ; } return null ; }
Returns stats by a given type
8,010
private function isValidDate ( string $ date , string $ format = 'Y-m-d' ) : bool { $ d = DateTime :: createFromFormat ( $ format , $ date ) ; return $ d && $ d -> format ( $ format ) === $ date ; }
Returns true if the date is valid
8,011
protected function initInputWidget ( ) { $ this -> initI18N ( __DIR__ , 'onix-core' ) ; if ( ! isset ( $ this -> language ) ) { $ this -> language = Yii :: $ app -> language ; } $ this -> _lang = Env :: getLang ( $ this -> language ) ; if ( $ this -> pluginLoading ) { $ this -> _loadIndicator = static :: getLoadProgres...
Initializes the input widget .
8,012
protected function initDisability ( & $ options ) { if ( $ this -> disabled && ! isset ( $ options [ 'disabled' ] ) ) { $ options [ 'disabled' ] = true ; } if ( $ this -> readonly && ! isset ( $ options [ 'readonly' ] ) ) { $ options [ 'readonly' ] = true ; } }
Validates and sets disabled or readonly inputs .
8,013
protected function initLanguage ( $ property = 'language' , $ full = false ) { if ( empty ( $ this -> pluginOptions [ $ property ] ) ) { $ this -> pluginOptions [ $ property ] = $ full ? $ this -> language : $ this -> _lang ; } }
Initialize the plugin language .
8,014
protected function setLanguage ( $ prefix , $ assetPath = null , $ filePath = null , $ suffix = '.js' ) { $ pwd = Env :: getCurrentDir ( $ this ) ; $ s = DIRECTORY_SEPARATOR ; if ( $ assetPath === null ) { $ assetPath = "{$pwd}{$s}assets{$s}" ; } elseif ( substr ( $ assetPath , - 1 ) != $ s ) { $ assetPath .= $ s ; } i...
Sets the language JS file if it exists .
8,015
protected function getInput ( $ type , $ list = false ) { if ( $ this -> hasModel ( ) ) { $ input = 'active' . ucfirst ( $ type ) ; return $ list ? Html :: $ input ( $ this -> model , $ this -> attribute , $ this -> data , $ this -> options ) : Html :: $ input ( $ this -> model , $ this -> attribute , $ this -> options...
Generates an input .
8,016
public function executeHandler ( CommandInterface $ command , AggregateInterface $ aggregate ) : AggregateInterface { return $ this -> execute ( $ command , $ aggregate ) ; }
A wrapper for the execute function .
8,017
public function getAggregate ( string $ uuid , string $ aggregateClass , int $ user ) : AggregateInterface { return $ this -> aggregateFactory -> build ( $ uuid , $ aggregateClass , null , $ user ) ; }
Returns an Aggregate based on the provided uuid .
8,018
protected function createDefaultFactory ( ) { $ loader = $ this -> loader ? : $ this -> createDefaultLoader ( ) ; if ( $ this -> hierarchy ) { $ loader = new HierarchicalNameLoader ( $ loader ) ; } $ rootAdapter = $ this -> fallbackAdapter ? : $ this -> createDefaultFallbackAdapter ( ) ; return new AdapterLoaderFactory...
Create default adapter loader with optional hierarchy wrapper
8,019
public function setProperty ( $ name , $ value ) { if ( $ value === null ) { return ; } $ method = "set" . ucfirst ( $ name ) ; if ( ! method_exists ( $ this -> obj , $ method ) ) { throw new \ Exception ( "Error setting log4php property $name to $value: no method $method in class " . get_class ( $ this -> obj ) . "!" ...
Set a property on this PropertySetter s Object . If successful this method will invoke a setter method on the underlying Object . The setter is the one for the specified property name and the value is determined partly from the setter argument type and partly from the value specified in the call to this method .
8,020
public function add ( Message $ message , $ groupName = null ) { if ( ! isset ( $ this -> messages [ $ groupName ] ) ) { $ this -> messages [ $ groupName ] = array ( ) ; } $ this -> messages [ $ groupName ] [ ] = $ message ; }
adds a Messsage object
8,021
public function addAll ( array $ messages , $ groupName = null ) { foreach ( $ messages as $ message ) { $ this -> add ( $ message , $ groupName ) ; } }
Adds a collection of message objects .
8,022
public function createTable ( $ name , array $ options = [ ] ) { $ schema = isset ( $ options [ 'schema' ] ) ? new Schema ( $ options [ 'schema' ] ) : null ; $ table = new TableApi ( $ name , $ schema , $ this -> manipulation , $ this -> actions ) ; $ primaryKey = isset ( $ options [ 'primary_key' ] ) ? new PrimaryKey ...
Create new table .
8,023
public function createSchema ( $ name ) { $ schema = new Schema ( $ name ) ; $ this -> actions [ ] = function ( ) use ( $ schema ) { return $ this -> manipulation -> create ( $ schema ) ; } ; }
Create new schema .
8,024
public function dropSchema ( $ name ) { $ schema = new Schema ( $ name ) ; $ this -> actions [ ] = function ( ) use ( $ schema ) { return $ this -> manipulation -> drop ( $ schema ) ; } ; }
Drop schema .
8,025
public function validate ( Control $ control ) : bool { $ value = $ control -> getSubmittedValue ( ) ; if ( $ value === null || $ value === false || $ value === '' ) return true ; if ( ! is_scalar ( $ value ) ) throw new LogicException ( '%s is not a valid date.' , gettype ( $ value ) ) ; $ match = preg_match ( '/^(\d{...
Returns true if the value of the form control is a valid date . Otherwise returns false .
8,026
public static function truncate ( int $ minLength = null , int $ maxLength = null ) { if ( 0 >= $ maxLength ) { throw new \ InvalidArgumentException ( 'Max length must be greater than 0, otherwise truncation doesn\'t make sense' ) ; } $ self = new self ( $ minLength , $ maxLength ) ; $ self -> allowsTruncate = true ; r...
create instance which treats above max border not as error but will lead to a truncated value only
8,027
public function truncateToMaxBorder ( $ value ) { if ( $ this -> allowsTruncate ( $ value ) ) { if ( $ value instanceof Secret ) { return $ value -> substring ( 0 , $ this -> maxLength ) ; } return substr ( $ value , 0 , $ this -> maxLength ) ; } throw new \ LogicException ( 'Truncate value to max length not allowed' )...
truncates given value to max length
8,028
public function clean ( $ value ) { if ( $ value === '' || $ value === null || $ value === false ) { return null ; } $ tmp = PruneWhitespaceCleaner :: get ( ) -> clean ( $ value ) ; if ( $ tmp === '' || $ tmp === null ) { return null ; } return mb_substr ( $ tmp , 0 , $ this -> maxLength ) ; }
Returns a submitted value with leading and training whitespace removed .
8,029
public function compile ( $ force = false ) { $ this -> commandCaller -> compile ( $ this -> configFile , $ force , $ this -> target ) ; }
Compile the project
8,030
public function close ( ) : void { if ( $ this -> stream !== null ) { if ( $ this -> isPipe === true ) { pclose ( $ this -> stream ) ; } else { fclose ( $ this -> stream ) ; } } $ this -> detach ( ) ; }
Encerra o Stream .
8,031
private function loadDirectory ( ) { if ( $ this -> generator === null ) { return ; } foreach ( $ this -> generator as $ file ) { $ this -> files = $ this -> files -> put ( ( string ) $ file -> name ( ) , $ file ) ; } $ this -> generator = null ; }
Load all files of the directory
8,032
public function guess ( ) { if ( class_exists ( $ class = $ this -> namespaceBase . '\\' . $ this -> namespaceSuffix . '\\' . $ this -> contextClass ) ) { return $ class ; } if ( class_exists ( $ class = 'SilverStripe\\' . $ this -> namespaceBase . '\\' . $ this -> namespaceSuffix . '\\' . $ this -> contextClass ) ) { ...
Tries to guess context classname .
8,033
public function validate ( Control $ control ) : bool { $ value = $ control -> getSubmittedValue ( ) ; if ( $ value === '' || $ value === null || $ value === false ) { return false ; } if ( is_array ( $ value ) ) { return $ this -> validateArray ( $ value ) ; } return true ; }
Returns true if the form control has a value .
8,034
private function validateArray ( array $ array ) : bool { foreach ( $ array as $ element ) { if ( is_array ( $ element ) ) { $ tmp = $ this -> validateArray ( $ element ) ; if ( $ tmp === true ) { return true ; } } else { if ( $ element !== null && $ element !== false && $ element !== '' ) { return true ; } } } return ...
Validates recursively if one of the leaves has a value .
8,035
public function append ( string $ paramName , $ error , array $ details = [ ] ) : ParamError { $ error = ParamError :: fromData ( $ error , $ details ) ; if ( ! isset ( $ this -> errors [ $ paramName ] ) ) { $ this -> errors [ $ paramName ] = [ $ error -> id ( ) => $ error ] ; } else { $ this -> errors [ $ paramName ] ...
appends an error to the list of errors for given param name
8,036
public function existForWithId ( string $ paramName , string $ errorId ) : bool { return ( isset ( $ this -> errors [ $ paramName ] ) && isset ( $ this -> errors [ $ paramName ] [ $ errorId ] ) ) ; }
checks whether a param has a specific error
8,037
public function getFor ( string $ paramName ) : array { if ( isset ( $ this -> errors [ $ paramName ] ) ) { return $ this -> errors [ $ paramName ] ; } return [ ] ; }
returns a list of errors for given param
8,038
public function getForWithId ( string $ paramName , string $ errorId ) { if ( isset ( $ this -> errors [ $ paramName ] ) && isset ( $ this -> errors [ $ paramName ] [ $ errorId ] ) ) { return $ this -> errors [ $ paramName ] [ $ errorId ] ; } return null ; }
returns the error for given param and error id
8,039
private static function normalizeInterface ( $ iface ) { if ( ! is_string ( $ iface ) ) { throw new \ Erebot \ InvalidValueException ( 'Not an interface name' ) ; } $ ifaceName = str_replace ( '!' , '\\Erebot\\Interfaces\\' , $ iface ) ; if ( interface_exists ( $ ifaceName , true ) ) { return strtolower ( $ ifaceName )...
Normalize the name of a tentative interface .
8,040
public function setFactory ( $ iface , $ cls ) { $ ifaceName = self :: normalizeInterface ( $ iface ) ; if ( ! class_exists ( $ cls , true ) ) { throw new \ Erebot \ InvalidValueException ( 'No such class (' . $ cls . ')' ) ; } $ reflector = new \ ReflectionClass ( $ cls ) ; if ( ! $ reflector -> isSubclassOf ( $ iface...
Set the factory for the given interface .
8,041
public function getFactory ( $ iface ) { $ ifaceName = self :: normalizeInterface ( $ iface ) ; if ( ! isset ( $ this -> factories [ $ ifaceName ] ) ) { throw new \ Erebot \ InvalidValueException ( 'No such interface (' . $ iface . ')' ) ; } return $ this -> factories [ $ ifaceName ] ; }
Return the name of the class to use to create instances with the given interface .
8,042
protected static function ctcpQuote ( $ message ) { $ quoting = array ( "\000" => "\0200" , "\n" => "\020n" , "\r" => "\020r" , "\020" => "\020\020" , ) ; $ message = strtr ( $ message , $ quoting ) ; $ quoting = array ( "\001" => "\\a" , "\\" => "\\\\" , ) ; $ message = strtr ( $ message , $ quoting ) ; return $ messa...
Quotes a CTCP message .
8,043
protected function sendCommand ( $ command ) { if ( ! \ Erebot \ Utils :: stringifiable ( $ command ) ) { throw new \ Exception ( 'Invalid command (not a string)' ) ; } $ this -> connection -> getIO ( ) -> push ( ( string ) $ command ) ; }
Send a raw command to the IRC server .
8,044
protected function addTimer ( \ Erebot \ TimerInterface $ timer ) { $ bot = $ this -> connection -> getBot ( ) ; return $ bot -> addTimer ( $ timer ) ; }
Register a timer .
8,045
protected function removeTimer ( \ Erebot \ TimerInterface $ timer ) { $ bot = $ this -> connection -> getBot ( ) ; return $ bot -> removeTimer ( $ timer ) ; }
Unregister a timer .
8,046
private function parseSomething ( $ something , $ param , $ default ) { $ function = 'parse' . $ something ; $ bot = $ this -> connection -> getBot ( ) ; if ( $ this -> channel !== null ) { try { $ config = $ this -> connection -> getConfig ( $ this -> channel ) ; return $ config -> $ function ( '\\' . get_called_class...
\ internal Retrieves a parameter from the module s configuration by recursively traversing the configuration hierarchy and parses it using the appropriate function .
8,047
protected function getFormatter ( $ chan ) { $ cls = $ this -> getFactory ( '!Styling' ) ; if ( $ chan === false ) { return new $ cls ( $ this -> translator ) ; } elseif ( $ chan !== null ) { $ config = $ this -> connection -> getConfig ( $ chan ) ; try { return new $ cls ( $ config -> getTranslator ( get_called_class ...
Returns the appropriate formatter for the given channel .
8,048
public function setOpenDate ( string $ openDate ) : void { $ this -> cleaner -> setOpenDate ( $ openDate ) ; $ this -> formatter -> setOpenDate ( $ openDate ) ; }
Sets the open date . An empty submitted value will be replaced with the open date and an open date will be shown as an empty field .
8,049
public function reset ( ) { $ this -> cache -> setLocales ( null ) ; foreach ( $ this -> getLocales ( ) as $ locale ) { $ this -> cache -> saveLocale ( $ locale , null ) ; } $ this -> locales = [ ] ; $ this -> catalogues = [ ] ; }
Reset all cached data and loaded locates .
8,050
public function publish ( array $ events , CommandBus $ commandBus , bool $ qeueEvents = false ) : void { $ eventStreamObjects = [ ] ; foreach ( $ events as $ event ) { $ eventStreamObject = new EventStreamObject ( ) ; $ eventStreamObject -> setUuid ( $ event -> getCommand ( ) -> getAggregateUuid ( ) ) ; $ eventStreamO...
Dispatch all events to observing event handlers and save them to the Event Store .
8,051
public function publishQeued ( array $ eventQeueObjects ) : bool { $ eventStreamObjects = array_map ( function ( $ eventQeueObject ) { return $ eventQeueObject -> getEventStreamObject ( ) ; } , $ eventQeueObjects ) ; foreach ( $ eventStreamObjects as $ eventStreamObject ) { $ this -> eventStore -> add ( $ eventStreamOb...
Save qeued Events to the Event Stream .
8,052
public static function clearOutput ( ) : void { if ( self :: $ skipClearOutput ) return ; $ level = ob_get_level ( ) ; for ( $ i = $ level ; $ i > 0 ; -- $ i ) { if ( ! @ ob_end_clean ( ) ) { ob_clean ( ) ; } } if ( $ level > 0 ) { ob_start ( ) ; } }
Removes all output echoed before calling this method .
8,053
private static function error ( int $ statusCode ) : void { self :: clearOutput ( ) ; self :: $ status = $ statusCode ; header ( 'HTTP/1.1 ' . $ statusCode . ' ' . self :: $ httpStatuses [ $ statusCode ] ) ; }
Sets the status code for the HTTP request to a client or server error .
8,054
private static function redirect ( string $ url , bool $ forceRelative , int $ statusCode ) : void { if ( $ forceRelative && ! Url :: isRelative ( $ url ) ) { $ url = '/' ; } self :: clearOutput ( ) ; self :: $ status = $ statusCode ; header ( 'HTTP/1.1 ' . $ statusCode . ' ' . self :: $ httpStatuses [ $ statusCode ] )...
Redirects the user agent to a specified URL .
8,055
public function upload ( $ uploadedFile ) { if ( $ uploadedFile -> isValid ( ) ) { $ this -> getFilesystem ( ) -> putFileAs ( dirname ( $ this -> getPath ( ) ) , $ uploadedFile , $ this -> getName ( ) ) ; return true ; } else { $ this -> errors [ 'upload' ] = $ uploadedFile -> getErrorMessage ( ) ; } return false ; }
Upload file from http
8,056
private function loadXML ( $ url ) { if ( ! file_exists ( $ url ) ) { throw new \ n2n \ log4php \ LoggerException ( "File [$url] does not exist." ) ; } libxml_clear_errors ( ) ; $ oldValue = libxml_use_internal_errors ( true ) ; $ xml = @ simplexml_load_file ( $ url ) ; if ( $ xml === false ) { $ errorStr = "" ; foreac...
Loads and validates the XML .
8,057
public function removeReadStream ( $ stream ) { $ key = ( int ) $ stream ; if ( isset ( $ this -> streamsRead [ $ key ] ) ) { unset ( $ this -> streamsRead [ $ key ] ) ; } if ( isset ( $ this -> streamsDuplex [ $ key ] ) && ! isset ( $ this -> streamsWrite [ $ key ] ) ) { unset ( $ this -> streamsDuplex [ $ key ] ) ; }...
Remove the read event listener for the given stream .
8,058
public static function findByParentCartId ( $ parentId , $ parentType , $ orderId ) { return self :: find ( ) -> where ( 'parentId=:pid AND parentType=:ptype AND orderId=:oid' , [ ':pid' => $ parentId , ':ptype' => $ parentType , ':oid' => $ orderId ] ) -> one ( ) ; }
Return the order item associated with given parent id parent type and order id .
8,059
protected function get ( $ object_or_array , $ key , $ default = null ) { if ( is_array ( $ object_or_array ) ) { if ( is_null ( $ key ) ) { return $ object_or_array ; } if ( isset ( $ object_or_array [ $ key ] ) ) { return $ object_or_array [ $ key ] ; } foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! is_arr...
Get an item from an object or array using dot notation .
8,060
public static function addRow ( DetailTable $ table , $ header , ? string $ ip4Address ) : void { if ( $ ip4Address !== null && $ ip4Address !== '' ) { $ table -> addRow ( $ header , [ 'class' => 'ipv4' ] , $ ip4Address ) ; } else { $ table -> addRow ( $ header ) ; } }
Adds a row with a IPv4 value to a detail table .
8,061
public function paymentLink ( Environment $ environment , $ text = null , $ amount = null , $ currency = null ) { return $ environment -> render ( '@c975LPayment/fragments/paymentLink.html.twig' , array ( 'text' => $ text , 'amount' => $ amount , 'currency' => strtolower ( $ currency ) , ) ) ; }
Returns xhtml code for Payment link
8,062
public function pass ( DataBagInterface $ dataBag ) : DataBagInterface { $ from = $ dataBag [ $ this -> from ] ?? null ; $ dataBag [ $ this -> to ] = $ from ; return $ dataBag ; }
Copy data from one key to another . Create if doesn t exist .
8,063
public function setPattern ( $ pattern ) { if ( ! \ Erebot \ Utils :: stringifiable ( $ pattern ) ) { throw new \ Erebot \ InvalidValueException ( 'Pattern must be a string' ) ; } $ this -> pattern = $ pattern ; }
Sets the pattern associated with this filter .
8,064
public function setPrefixRequirement ( $ requirePrefix = false ) { if ( $ requirePrefix !== null && ! is_bool ( $ requirePrefix ) ) { throw new \ Erebot \ InvalidValueException ( '$requirePrefix must be a boolean or null' ) ; } $ this -> requirePrefix = $ requirePrefix ; }
Sets the constraint on prefix requirement .
8,065
public function iSaveWorkflow ( ) { $ locator = '#workflowSettings-buttons-submit' ; $ element = $ this -> minkContext -> getSession ( ) -> getPage ( ) -> find ( 'css' , $ locator ) ; $ element -> click ( ) ; }
Saving organization workflow
8,066
public function flatten ( $ data , $ originalNames = array ( ) ) { $ ret = array ( ) ; $ it = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ data ) ) ; foreach ( $ it as $ name => $ value ) { if ( ! is_array ( $ value ) ) { if ( isset ( $ originalNames [ $ name ] ) ) { $ name = $ originalNames [ $ n...
Flattent the given data
8,067
private function extractField ( $ blocks ) { $ fieldData = array ( ) ; $ pattern = "/([a-zA-Z]+) *(.+)/" ; foreach ( $ blocks as $ block ) { $ match = preg_match ( $ pattern , $ block , $ matches ) ; if ( count ( $ matches ) == 3 ) { $ docLabel = trim ( strtolower ( $ matches [ 1 ] ) ) ; $ docValue = trim ( $ matches [...
This is the main function supposed to parse and return fields properly
8,068
public function validate ( Control $ control ) : bool { $ value = $ control -> getSubmittedValue ( ) ; if ( $ value === '' || $ value === null || $ value === false ) { return true ; } if ( ! is_scalar ( $ value ) ) { return false ; } $ length = mb_strlen ( $ value , Html :: $ encoding ) ; return ( ( $ this -> minLength...
Returns true if the length of the value of a form control is within the specified range . Otherwise returns false .
8,069
protected function openFile ( ) { $ file = $ this -> getTargetFile ( ) ; if ( ! is_file ( $ file ) ) { $ dir = dirname ( $ file ) ; if ( ! is_dir ( $ dir ) ) { $ success = \ n2n \ io \ IoUtils :: mkdirs ( $ dir , 0777 , true ) ; if ( $ success === false ) { $ this -> warn ( "Failed creating target directory [$dir]. Clo...
Acquires the target file resource creates the destination folder if necessary . Writes layout header to file .
8,070
public function append ( \ n2n \ log4php \ logging \ LoggingEvent $ event ) { $ eventDate = $ this -> getDate ( $ event -> getTimestamp ( ) ) ; if ( ! isset ( $ this -> currentDate ) ) { $ this -> currentDate = $ eventDate ; } else if ( $ this -> currentDate !== $ eventDate ) { $ this -> currentDate = $ eventDate ; if ...
Appends a logging event .
8,071
public function migrate ( $ version = null , $ message = null , $ up = true ) { return $ this -> execute ( $ version , $ message , $ up ) ; }
Migrate the schema to the given version .
8,072
private function execute ( $ version = null , $ message = null , $ up = true ) { $ files = $ this -> migrationFiles -> get ( $ version , $ up ) ; if ( null === $ files ) { return 0 ; } $ this -> schemaManipulation -> execute ( 'BEGIN' ) ; try { foreach ( $ files as $ file ) { require_once $ file -> getPath ( ) ; $ defi...
Execute migrate .
8,073
public function extract ( Collection $ resources , Closure $ callback ) { foreach ( $ resources as $ resource ) { $ callback ( $ resource , [ $ this -> inflector -> singularize ( $ this -> getVariableName ( ) ) => $ resource ] ) ; } }
Extract a single resource .
8,074
public function parse ( Collection $ resources ) : Collection { return new Collection ( [ $ this -> inflector -> pluralize ( $ this -> getVariableName ( ) ) => $ resources ] ) ; }
Parse collection of resources .
8,075
public function csrfCheck ( ) { if ( ! $ this -> csrfCheck ) return ; $ control = $ this -> hiddenFieldSet -> getFormControlByName ( 'ses_csrf_token' ) ; $ ses_csrf_token1 = Abc :: $ session -> getCsrfToken ( ) ; $ ses_csrf_token2 = $ control -> getSubmittedValue ( ) ; if ( $ ses_csrf_token1 !== $ ses_csrf_token2 ) { t...
Defends against CSRF attacks using State Full Double Submit Cookie .
8,076
public function getMainForeignKeyColumnName ( ) { if ( empty ( $ this -> _detectedMainForeignKeyColumnName ) ) { foreach ( $ this -> getTableStructure ( ) -> getRelations ( ) as $ relationConfig ) { if ( $ relationConfig -> getType ( ) === Relation :: BELONGS_TO ) { $ this -> _detectedMainForeignKeyColumnName = $ relat...
Override if you wish to provide key manually
8,077
static public function makeDataForRecord ( $ key , $ value , $ foreignKeyValue = null ) { $ record = [ static :: getKeysColumnName ( ) => $ key , static :: getValuesColumnName ( ) => static :: encodeValue ( $ value ) , ] ; if ( $ foreignKeyValue !== null && ( $ foreignKeyColumn = static :: getInstance ( ) -> getMainFor...
Make array that represents DB record and can be saved to DB
8,078
static public function convertToDataForRecords ( array $ settingsAssoc , $ foreignKeyValue = null , $ additionalConstantValues = [ ] ) { $ records = [ ] ; foreach ( $ settingsAssoc as $ key => $ value ) { $ records [ ] = array_merge ( $ additionalConstantValues , static :: makeDataForRecord ( $ key , $ value , $ foreig...
Convert associative array to arrays that represent DB record and are ready for saving to DB
8,079
static public function decodeValues ( array $ settingsAssoc ) { foreach ( $ settingsAssoc as $ key => & $ value ) { $ value = static :: decodeValue ( $ value ) ; } return $ settingsAssoc ; }
Decode values for passed settings associative array
8,080
static public function updateOrCreateRecord ( array $ data ) { if ( empty ( $ data [ static :: getKeysColumnName ( ) ] ) ) { throw new \ InvalidArgumentException ( '$record argument does not contain value for key \'' . static :: getKeysColumnName ( ) . '\' or its value is empty' ) ; } else if ( ! array_key_exists ( sta...
Update existing value or create new one
8,081
static public function updateOrCreateRecords ( array $ records ) { $ table = static :: getInstance ( ) ; $ alreadyInTransaction = $ table :: inTransaction ( ) ; if ( ! $ alreadyInTransaction ) { $ table :: beginTransaction ( ) ; } try { foreach ( $ records as $ record ) { $ success = $ table :: updateOrCreateRecord ( $...
Update existing values and create new
8,082
public function getErrorMessage ( ) { $ errorValue = null ; if ( $ this -> hasError ( ) ) { $ errorValue = ( string ) $ this -> xmlElement -> errors -> error ; } return $ errorValue ; }
Returns the error message
8,083
public function offsetGet ( $ element ) { try { return ( bool ) $ this -> map -> find ( $ element ) ; } catch ( \ OutOfBoundsException $ e ) { return false ; } }
Get the value for an element
8,084
public function pass ( DataBagInterface $ dataBag ) : DataBagInterface { $ dataBag [ $ this -> field ] = ( $ this -> callback ) ( $ dataBag [ $ this -> field ] ?? null , $ dataBag ) ; return $ dataBag ; }
Mapping handler . Proceeds to transform an entry to a new value using callback function .
8,085
protected function warn ( $ message ) { $ id = get_class ( $ this ) . ( empty ( $ this -> name ) ? '' : ":{$this->name}" ) ; throw new \ n2n \ log4php \ LoggerException ( "log4php: [$id]: $message" , E_USER_WARNING ) ; }
Triggers a warning for this logger with the given message .
8,086
public static function factory ( $ config = array ( ) ) { $ config = self :: getConfigCollection ( $ config ) ; $ client = new EncodingClient ( $ config -> get ( 'base_url' ) , $ config -> get ( 'userid' ) , $ config -> get ( 'userkey' ) ) ; $ client -> setConfig ( $ config ) ; $ description = ServiceDescription :: fac...
Create new EncodingClient Instance
8,087
public static function buildInTypes ( ) : array { if ( null === self :: $ buildInParamBroker ) { self :: $ buildInParamBroker = [ 'array' => new param \ ArrayParamBroker ( ) , 'bool' => new param \ BoolParamBroker ( ) , 'customdatespan' => new param \ CustomDatespanParamBroker ( ) , 'date' => new param \ DateParamBroke...
returns list of build in param brokers
8,088
public function procure ( Request $ request , $ object , string $ group = null ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( 'Parameter $object must be an object instance' ) ; } foreach ( self :: targetMethodsOf ( $ object , $ group ) as $ targetMethod ) { $ targetMethod -> invoke ( $ obj...
fills given object with values from request
8,089
public function paramBroker ( $ type ) : ParamBroker { if ( isset ( $ this -> paramBrokers [ $ type ] ) ) { return $ this -> paramBrokers [ $ type ] ; } throw new \ RuntimeException ( 'No param broker found for ' . $ type ) ; }
returns param broker for requested type
8,090
public static function targetMethodsOf ( $ object , string $ group = null ) : Sequence { return methodsOf ( $ object , \ ReflectionMethod :: IS_PUBLIC ) -> filter ( function ( \ ReflectionMethod $ method ) use ( $ group ) { if ( $ method -> isStatic ( ) || $ method -> isConstructor ( ) || $ method -> isDestructor ( ) )...
returns all methods of given instance which are applicable for brokerage
8,091
public function clean ( $ value ) { if ( $ value === '' || $ value === null || $ value === false ) { return null ; } $ tmp = AmbiguityCleaner :: get ( ) -> clean ( $ value ) ; $ tmp = str_replace ( [ ' ' , "\t" , "\n" ] , '' , $ tmp ) ; if ( $ tmp === '' ) $ tmp = null ; return $ tmp ; }
Returns a submitted value with all whitespace removed .
8,092
public function getMappedMethod ( $ method ) { if ( ! array_key_exists ( $ method , self :: $ validatorMapping ) ) { throw new Exception ( sprintf ( 'Mapping for method "%s" not found, make sure it exists in the mapping file.' , $ method ) ) ; } return self :: $ validatorMapping [ $ method ] ; }
Get mapped method .
8,093
public function add ( ReferenceGeneratorInterface $ generator ) { $ this -> generators [ ] = $ generator ; usort ( $ this -> generators , array ( $ this , 'compareGenerators' ) ) ; }
Adds a generator .
8,094
public function get ( $ index ) { if ( $ index >= count ( $ this -> generators ) || $ index < 0 ) return null ; return $ this -> generators [ $ index ] ; }
Gets a generator by name .
8,095
public function remove ( $ index ) { if ( $ index >= count ( $ this -> generators ) || $ index < 0 ) return ; unset ( $ this -> generators [ $ index ] ) ; $ this -> generators = array_values ( $ this -> generators ) ; }
Removes a generator or an array of generators by name from the collection
8,096
public function addCollection ( ReferenceGeneratorCollection $ collection ) { foreach ( $ collection -> all ( ) as $ generator ) { $ this -> generators [ ] = $ generator ; } usort ( $ this -> generators , array ( $ this , 'compareGenerators' ) ) ; }
Adds a generator collection at the end of the current set by appending all generators of the added collection .
8,097
public function beforeScenario ( BeforeScenarioScope $ scope ) { $ core = $ scope -> getEnvironment ( ) -> getContext ( CoreContext :: class ) ; $ transport = $ core -> getServiceManager ( ) -> get ( 'Core/MailService' ) -> getTransport ( ) ; $ path = $ transport -> getOptions ( ) -> getPath ( ) . '/*.eml' ; foreach ( ...
Cleans all files before start test
8,098
protected function prepareExport ( $ data ) { return [ 'name' => $ this -> getName ( ) , 'info' => $ this -> info , 'hash' => $ this -> getHash ( ) , 'data_wrapper' => get_class ( $ this -> getDatawrapper ( ) ) , 'data' => $ data ] ; }
Prepare the info to be exported
8,099
public function table ( $ table , string $ alias = null ) : Query { return $ this -> builder ( ) -> table ( $ table , $ alias ) ; }
Makes a query builder instance with a selected table .