idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
43,200
protected function getArrayAndKeyName ( string $ fieldName , string $ key ) : array { if ( ! in_array ( $ key , [ 'filters' , 'sorts' ] , true ) ) { throw new InvalidArgumentException ( 'Key must be one of [filters, sorts]' ) ; } if ( str_contains ( $ fieldName , '.' ) ) { $ path = explode ( '.' , $ fieldName ) ; $ name = array_pop ( $ path ) ; $ relationPath = implode ( '.' , $ path ) ; $ array = array_get ( $ this -> relations , "$relationPath.$key" , [ ] ) ; } else { $ name = $ fieldName ; $ array = ( $ key === 'filters' ) ? $ this -> filters : $ this -> sorts ; } return [ $ name , $ array ] ; }
Helper function to figure out which array to use
43,201
public function getResolvedArtisanCommand ( InputInterface $ input = null ) { $ name = $ this -> getCommandName ( $ input ) ; try { $ command = $ this -> find ( $ name ) ; } catch ( Exception $ e ) { EventLog :: logError ( 'command.notFound' , $ e , [ 'name' => $ name ] ) ; return null ; } return $ command ; }
resolve the artisan command
43,202
public function toArray ( $ recursive = true ) { $ array = [ ] ; $ data = $ this -> data ; foreach ( $ data as $ key => $ value ) { if ( $ recursive && $ value instanceof self ) { $ array [ $ key ] = $ value -> toArray ( ) ; } else { $ array [ $ key ] = $ value ; } } return $ array ; }
Converts the instance to an array
43,203
private function _convertedValue ( $ value , $ key , $ prefix ) { if ( $ this -> getTransformsToConfig ( ) ) { if ( is_iterable ( $ value ) ) $ value = new static ( $ value , $ prefix ? "$prefix.$key" : $ key , true ) ; } return $ value ; }
Internal method to convert any value to a new configuration object if required .
43,204
public static function createWriter ( $ type ) { switch ( $ type ) { case self :: JSON : return new Impl \ Json ( ) ; case self :: YAML : return new Impl \ Yaml ( ) ; case self :: INI : return new Impl \ Ini ( ) ; case self :: COLUMNS : return new Impl \ Columns ( ) ; case self :: TABLE : return new Impl \ ConsoleTable ( ) ; case self :: MARKDOWN : return new Impl \ MarkdownTable ( ) ; case self :: DUMP : return new Impl \ Dump ( ) ; } throw new UnknownWriterTypeException ( "Sorry, writer type {$type} is not something I do" ) ; }
Create a writer for the specified type .
43,205
public static function supportedTypes ( ) { return [ self :: YAML , self :: JSON , self :: INI , self :: COLUMNS , self :: TABLE , self :: MARKDOWN , self :: DUMP ] ; }
Returns an array of supported output formats
43,206
public function setHolder ( $ holder ) { if ( ! is_string ( $ holder ) || strlen ( trim ( $ holder ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid holder, must be a non empty string' ) ; $ this -> holder = $ holder ; }
Set the holder of this IncassoAccount
43,207
public function setNumber ( $ number ) { if ( ! is_string ( $ number ) || strlen ( trim ( $ number ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid number, must be a non empty string' ) ; $ this -> number = $ number ; }
Set the number of this IncassoAccount
43,208
public function setCity ( $ city ) { if ( ! is_string ( $ city ) || strlen ( trim ( $ city ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid city, must be a non empty string' ) ; $ this -> city = $ city ; }
Set the city of this IncassoAccount
43,209
public function getRouteCollectionForType ( $ type ) { if ( isset ( $ this -> collections [ $ type ] ) ) { return $ this -> collections [ $ type ] ; } if ( ! $ this -> metadataFactory -> hasMetadataFor ( $ type ) ) { throw new ResourceNotFoundException ( sprintf ( 'No metadata found for module type "%s".' , $ type ) ) ; } $ metadata = $ this -> metadataFactory -> getMetadataFor ( $ type ) ; $ routes = $ metadata -> getRoutes ( ) ; $ this -> provider -> addModularPrefix ( $ routes ) ; $ routes -> addPrefix ( $ this -> routePrefix [ 'path' ] , $ this -> routePrefix [ 'defaults' ] , $ this -> routePrefix [ 'requirements' ] ) ; return $ this -> collections [ $ type ] = $ routes ; }
Returns the route collection for a module type .
43,210
public function getGeneratorForModule ( ModuleInterface $ module ) { $ type = $ module -> getModularType ( ) ; $ collection = $ this -> getRouteCollectionForType ( $ type ) ; if ( array_key_exists ( $ type , $ this -> generators ) ) { return $ this -> generators [ $ type ] ; } if ( null === $ this -> options [ 'cache_dir' ] ) { return $ this -> generators [ $ type ] = new $ this -> options [ 'generator_class' ] ( $ collection , $ this -> context , $ this -> logger ) ; } $ cacheClass = sprintf ( '%s_UrlGenerator' , $ type ) ; $ cache = $ this -> getConfigCacheFactory ( ) -> cache ( $ this -> options [ 'cache_dir' ] . '/' . $ cacheClass . '.php' , function ( ConfigCacheInterface $ cache ) use ( $ cacheClass , $ collection ) { $ dumper = new $ this -> options [ 'generator_dumper_class' ] ( $ collection ) ; $ options = [ 'class' => $ cacheClass , 'base_class' => $ this -> options [ 'generator_base_class' ] , ] ; $ cache -> write ( $ dumper -> dump ( $ options ) , $ collection -> getResources ( ) ) ; } ) ; require_once $ cache -> getPath ( ) ; return $ this -> generators [ $ type ] = new $ cacheClass ( $ this -> context , $ this -> logger ) ; }
Returns a generator for a module .
43,211
public function getModuleByRequest ( Request $ request ) { $ parameters = $ this -> getInitialMatcher ( ) -> matchRequest ( $ request ) ; return $ this -> provider -> loadModuleByRequest ( $ request , $ parameters ) ; }
Returns a module by matching the request .
43,212
public function getInitialMatcher ( ) { if ( null !== $ this -> initialMatcher ) { return $ this -> initialMatcher ; } $ route = sprintf ( '%s/{_modular_path}' , $ this -> routePrefix [ 'path' ] ) ; $ collection = new RouteCollection ; $ collection -> add ( 'modular' , new Route ( $ route , $ this -> routePrefix [ 'defaults' ] , array_merge ( $ this -> routePrefix [ 'requirements' ] , [ '_modular_path' => '.+' ] ) ) ) ; return $ this -> initialMatcher = new UrlMatcher ( $ collection , $ this -> context ) ; }
Returns a matcher that matches a Request to the route prefix .
43,213
private function getLogFileName ( ) : string { $ file_name = $ this -> file_name ; if ( $ this -> filename_processor ) { $ file_name = $ this -> filename_processor -> process ( $ file_name ) ; } $ file_name = self :: escapeFileName ( $ file_name ) ; return $ file_name ; }
Get log file name
43,214
protected function _initialize ( ) { $ this -> uri -> _fetch_uri_string ( ) ; $ this -> uri -> _remove_url_suffix ( ) ; $ this -> uri -> _explode_segments ( ) ; $ this -> segments = $ this -> uri -> segments ; $ this -> _parseRoutes ( ) ; $ this -> uri -> _reindex_segments ( ) ; }
Set the route mapping
43,215
protected function _setRequest ( $ segments = array ( ) ) { $ segments = $ this -> _validateRequest ( $ segments ) ; if ( count ( $ segments ) == 0 ) { return $ this -> uri -> _reindex_segments ( ) ; } $ this -> setClass ( $ segments [ 0 ] ) ; if ( isset ( $ segments [ 1 ] ) ) { $ this -> method = $ segments [ 1 ] ; } else { $ segments [ 1 ] = 'index' ; } $ this -> uri -> rsegments = $ segments ; }
Set the Route
43,216
public function findByRoleId ( $ roleId ) { $ select = $ this -> getSelect ( $ this -> getUserTableName ( ) ) ; $ select -> where ( array ( $ this -> getTableName ( ) . '.role_id' => $ roleId ) ) ; $ select -> join ( $ this -> getTableName ( ) , $ this -> getTableName ( ) . '.user_id = ' . $ this -> getUserTableName ( ) . '.user_id' , array ( ) , Select :: JOIN_INNER ) ; $ select -> group ( $ this -> getUserTableName ( ) . '.user_id' ) ; $ entityPrototype = $ this -> getZfcUserOptions ( ) -> getUserEntityClass ( ) ; return $ this -> select ( $ select , new $ entityPrototype , $ this -> getZfcUserHydrator ( ) ) ; }
Finds users with a specific role
43,217
public function insert ( $ userRoleLinker , $ tableName = null , HydratorInterface $ hydrator = null ) { $ this -> checkEntity ( $ userRoleLinker ) ; return parent :: insert ( $ userRoleLinker ) ; }
Add a new role of a user
43,218
public function delete ( $ userRoleLinker , $ tableName = null ) { $ this -> checkEntity ( $ userRoleLinker ) ; return parent :: delete ( array ( 'user_id' => $ userRoleLinker -> getUserId ( ) , 'role_id' => $ userRoleLinker -> getRoleId ( ) ) ) ; }
Deletes a role of a user
43,219
public static function delimit ( string $ str , string $ delimiter , string $ encoding = null ) : string { $ encoding = $ encoding ? : utils \ Str :: encoding ( $ str ) ; $ internalEncoding = mb_regex_encoding ( ) ; mb_regex_encoding ( $ encoding ) ; $ str = mb_ereg_replace ( '\B([A-Z])' , '-\1' , mb_ereg_replace ( "^[[:space:]]+|[[:space:]]+\$" , '' , $ str ) ) ; $ str = mb_strtolower ( $ str , $ encoding ) ; $ str = mb_ereg_replace ( '[-_\s]+' , $ delimiter , $ str ) ; mb_regex_encoding ( $ internalEncoding ) ; return $ str ; }
Delimits the given string on spaces underscores and dashes and before uppercase characters using the given delimiter string . The resulting string will also be trimmed and lower - cased .
43,220
public static function lower ( string $ str , string $ encoding = null ) : string { return mb_strtolower ( $ str , $ encoding ? : utils \ Str :: encoding ( $ str ) ) ; }
Converts all characters in the given string to lowercase .
43,221
public static function lowerFirst ( string $ str , string $ encoding = null ) : string { $ encoding = $ encoding ? : utils \ Str :: encoding ( $ str ) ; return mb_strtolower ( mb_substr ( $ str , 0 , 1 , $ encoding ) , $ encoding ) . mb_substr ( $ str , 1 , null , $ encoding ) ; }
Converts the first character in the given string to lowercase .
43,222
public static function upper ( string $ str , string $ encoding = null ) : string { return mb_strtoupper ( $ str , $ encoding ? : utils \ Str :: encoding ( $ str ) ) ; }
Converts all characters in the given string to uppercase .
43,223
public static function upperFirst ( string $ str , string $ encoding = null ) : string { $ encoding = $ encoding ? : utils \ Str :: encoding ( $ str ) ; return mb_strtoupper ( mb_substr ( $ str , 0 , 1 , $ encoding ) , $ encoding ) . mb_substr ( $ str , 1 , null , $ encoding ) ; }
Converts the first character in the given string to uppercase .
43,224
public function validates ( $ data = null ) { $ this -> errors = array ( ) ; if ( $ data === null ) { $ data = $ this -> data ( ) ; } foreach ( static :: $ _validates as $ field => $ validations ) { Validations :: run ( $ this , $ field , $ validations ) ; } return count ( $ this -> errors ) == 0 ; }
Validates the model data .
43,225
public static function resolveConfigHandler ( $ fileName ) { $ configHandler = NULL ; preg_match ( "/(\.)([a-z]{3,})/" , $ fileName , $ matches ) ; $ fileExtension = $ matches [ 2 ] ; if ( ! in_array ( $ fileExtension , ConfigConsts :: getExtensions ( ) ) ) { throw new ConfigException ( "Not correct config file extension." ) ; } switch ( $ fileExtension ) { case ( ConfigConsts :: INI ) : $ configHandler = new ConfigIniHandler ( ) ; break ; default : throw new ConfigException ( "Config handler wasn't set." ) ; } return $ configHandler ; }
Resolve config handler by file extension .
43,226
public static function create ( $ config = null ) { if ( $ config === null ) { return self :: getStandard ( ) ; } if ( is_array ( $ config ) || ( $ config instanceof Config ) ) { return new Env ( $ config ) ; } if ( $ config instanceof Env ) { return $ config ; } $ message = 'Factory accepts Env, Config, array or NULL' ; throw new InvalidConfig ( 'Env' , $ message , 0 , null , __NAMESPACE__ ) ; }
Creates an environment wrapper
43,227
private function getPluginMiddleware ( $ class ) { if ( $ this -> pluginMiddleware === null ) { $ this -> pluginMiddleware = file_exists ( $ this -> pluginManifestOfMiddleware ) ? include $ this -> pluginManifestOfMiddleware : [ ] ; } return isset ( $ this -> pluginMiddleware [ $ class ] ) && count ( $ this -> pluginMiddleware [ $ class ] ) == 1 ? $ this -> pluginMiddleware [ $ class ] [ 0 ] : null ; }
Get the full qualified class name of the plugin s middleware .
43,228
public function get ( $ messageId ) { if ( ! isset ( $ this -> messages [ $ messageId ] ) ) { return null ; } return new OutboxMessage ( $ messageId , $ this -> messages [ $ messageId ] -> getTransportOperations ( ) ) ; }
Fetches the given message from the storage . It returns null if no message is found .
43,229
public function store ( OutboxMessage $ message ) { $ messageId = $ message -> getMessageId ( ) ; if ( isset ( $ this -> messages [ $ messageId ] ) ) { throw new InvalidArgumentException ( "Outbox message with ID '$messageId' already exists in storage." ) ; } $ this -> messages [ $ messageId ] = new InMemoryStoredMessage ( $ messageId , $ message -> getTransportOperations ( ) ) ; $ this -> lastMessageId = $ messageId ; }
Stores the message to enable deduplication and re - dispatching of transport operations . Throws an exception if a message with the same ID already exists .
43,230
public static function patch ( $ options = [ ] ) { if ( static :: $ _interceptor ) { throw new JitException ( "An interceptor is already attached." ) ; } $ defaults = [ 'loader' => null ] ; $ options += $ defaults ; $ loader = $ options [ 'originalLoader' ] = $ options [ 'loader' ] ? : static :: composer ( ) ; if ( ! $ loader ) { throw new JitException ( "The loader option need to be a valid autoloader." ) ; } unset ( $ options [ 'loader' ] ) ; class_exists ( 'Lead\Jit\JitException' ) ; class_exists ( 'Lead\Jit\Node\NodeDef' ) ; class_exists ( 'Lead\Jit\Node\FunctionDef' ) ; class_exists ( 'Lead\Jit\Node\BlockDef' ) ; class_exists ( 'Lead\Jit\TokenStream' ) ; class_exists ( 'Lead\Jit\Parser' ) ; $ interceptor = new static ( $ options ) ; spl_autoload_unregister ( $ loader ) ; return static :: load ( $ interceptor ) ? $ interceptor : false ; }
Patch the autoloader to be intercepted by the current autoloader .
43,231
public static function composer ( ) { $ loaders = spl_autoload_functions ( ) ; foreach ( $ loaders as $ key => $ loader ) { if ( is_array ( $ loader ) && ( $ loader [ 0 ] instanceof ClassLoader ) ) { return $ loader ; } } }
Look for the composer autoloader .
43,232
public static function load ( $ interceptor = null ) { if ( static :: $ _interceptor ) { static :: unpatch ( ) ; } $ original = $ interceptor -> originalLoader ( ) ; $ success = spl_autoload_register ( $ interceptor -> loader ( ) , true , true ) ; spl_autoload_unregister ( $ original ) ; static :: $ _interceptor = $ interceptor ; return $ success ; }
Loads an interceptor autoloader .
43,233
public function loadFiles ( $ files ) { $ files = ( array ) $ files ; $ success = true ; foreach ( $ files as $ file ) { $ this -> loadFile ( $ file ) ; } return true ; }
Manualy load files .
43,234
public function cache ( $ file , $ content , $ timestamp = null ) { if ( ! $ cachePath = $ this -> cachePath ( ) ) { throw new JitException ( 'Error, any cache path has been defined.' ) ; } $ path = $ cachePath . DS . ltrim ( preg_replace ( '~:~' , '' , $ file ) , DS ) ; if ( ! @ file_exists ( dirname ( $ path ) ) ) { mkdir ( dirname ( $ path ) , 0755 , true ) ; } if ( file_put_contents ( $ path , $ content ) === false ) { throw new JitException ( "Unable to create a cached file at `'{$file}'`." ) ; } if ( $ timestamp ) { touch ( $ path , $ timestamp ) ; } return $ path ; }
Cache helper .
43,235
protected function backup ( $ process ) { if ( $ process ) { $ this -> line ( '' ) ; $ ok = $ this -> confirm ( 'Wanna make backup for database ? [yes/no]' , false ) ; if ( $ ok ) { if ( Database :: export ( ) ) { $ this -> info ( 'The database saved' ) ; } else { $ this -> error ( "The database wasn't saved" ) ; } } } }
Make backup for database .
43,236
protected function checkClassForCompability ( $ className ) { $ result = $ className ; if ( isset ( DeferredExceptionsGlobal :: $ defExcClasses [ $ className ] ) ) { if ( ! DeferredExceptionsGlobal :: $ defExcClasses [ $ className ] ) { $ result = null ; } } else { if ( ! class_exists ( $ className ) || ! is_subclass_of ( $ className , 'Exception' ) ) { DeferredExceptionsGlobal :: $ defExcClasses [ $ className ] = false ; $ result = null ; } else { DeferredExceptionsGlobal :: $ defExcClasses [ $ className ] = true ; } } return $ result ; }
Check the class for existance and inheritance from the \ Exception class
43,237
protected function getCompatibleClass ( $ className ) { if ( ! $ className || ! is_string ( $ className ) ) { $ className = get_class ( $ this ) ; } $ class = $ className ; if ( ! $ this -> checkClassForCompability ( $ class ) ) { $ class = $ this -> checkClassForCompability ( $ class . 'Exception' ) ; } if ( ! $ class ) { if ( $ parent = get_parent_class ( $ className ) ) { $ class = $ this -> getCompatibleClass ( $ parent ) ; } else { $ class = __NAMESPACE__ . '\DeferredExceptionsException' ; } } return $ class ; }
Returns the class to throw exception
43,238
public function exception ( $ message , $ code = 0 , $ prevException = null , $ className = null ) { $ class = $ this -> getCompatibleClass ( $ className ) ; $ this -> defExcLastErrorMessage = $ message ; $ this -> defExcLastError = $ code ; $ exception = [ 'time' => microtime ( true ) , 'class' => $ class , 'code' => $ code , 'message' => $ message , ] ; $ this -> defExcErrors [ ] = $ exception ; DeferredExceptionsGlobal :: $ defExcErrorsGlobal [ ] = $ exception ; if ( $ this -> useExceptions ( ) ) { throw new $ class ( $ message , $ code , $ prevException ) ; } }
Throws the Exception or save last error
43,239
protected static function __formatMessage ( array $ error , $ template = null ) { static $ patterns = [ '~\:\:time~us' , '~\:\:microtime~us' , '~\:\:class~us' , '~\:\:code~us' , '~\:\:message~us' , ] ; if ( empty ( $ error [ 'time' ] ) ) $ error [ 'time' ] = microtime ( true ) ; if ( empty ( $ error [ 'class' ] ) ) $ error [ 'class' ] = __NAMESPACE__ . '\DeferredExceptionsException' ; if ( empty ( $ error [ 'code' ] ) ) $ error [ 'code' ] = 0 ; if ( empty ( $ error [ 'message' ] ) ) $ error [ 'message' ] = '' ; $ time = [ ] ; preg_match ( '~(\d*)(\.(\d{0,6}))?~' , $ error [ 'time' ] , $ time ) ; $ sec = ( int ) $ time [ 1 ] ; $ usec = sprintf ( '%0-6s' , isset ( $ time [ 3 ] ) ? ( int ) $ time [ 3 ] : 0 ) ; $ replaces = [ date ( 'Y-m-d H:i:s' , $ sec ) , date ( 'Y-m-d H:i:s' , $ sec ) . ':' . $ usec , $ error [ 'class' ] , $ error [ 'code' ] , $ error [ 'message' ] , ] ; return preg_replace ( $ patterns , $ replaces , ! empty ( $ template ) && is_string ( $ template ) ? $ template : DeferredExceptionsGlobal :: $ defExcDefaultErrorListTemplate ) ; }
Format message string for output .
43,240
public function throwAll ( $ releaseOnThrow = true , $ template = null ) { return $ this -> __throw ( false , $ releaseOnThrow , $ template ) ; }
Throws exception with a list of all deferred exceptions of a class instance .
43,241
public static function throwGlobal ( $ releaseOnThrow = false , $ template = null ) { if ( ! empty ( DeferredExceptionsGlobal :: $ defExcErrorsGlobal ) ) { $ message = "There are the following exceptions:\n" ; foreach ( DeferredExceptionsGlobal :: $ defExcErrorsGlobal as $ error ) { $ message .= self :: __formatMessage ( $ error , $ template ) . "\n" ; } if ( $ releaseOnThrow ) { DeferredExceptionsGlobal :: $ defExcErrorsGlobal = [ ] ; } $ result = count ( DeferredExceptionsGlobal :: $ defExcErrorsGlobal ) ; throw new DeferredExceptionsException ( $ message ) ; } return false ; }
Throws all deferred exceptions of all derived classes .
43,242
public function lang ( $ name , $ vars = [ ] , $ template = self :: USE_NOT_TPL ) { $ request = Request :: instance ( ) ; $ config = $ this -> resolve ( RESOLVE_LANG , $ name ) ; $ name = $ config [ 1 ] ; $ config = $ config [ 0 ] ; if ( isset ( $ config [ $ request -> lang ] [ $ name ] ) ) { if ( $ template == self :: USE_NOT_TPL ) { if ( count ( $ vars ) == 0 ) { return $ config [ $ request -> lang ] [ $ name ] ; } else { $ content = $ config [ $ request -> lang ] [ $ name ] ; foreach ( $ vars as $ key => $ value ) { $ content = preg_replace ( '#\{' . $ key . '\}#isU' , $ value , $ content ) ; } return $ content ; } } else { $ tpl = new Template ( $ config [ $ request -> lang ] [ $ name ] , $ name , 0 , Template :: TPL_STRING ) ; $ tpl -> assign ( $ vars ) ; return $ tpl -> show ( Template :: TPL_COMPILE_TO_STRING , Template :: TPL_COMPILE_LANG ) ; } } else { $ this -> addError ( 'sentence ' . $ name . '/' . $ request -> lang . ' not found' , __FILE__ , __LINE__ , ERROR_WARNING ) ; return 'sentence not found (' . $ name . ',' . $ request -> lang . ')' ; } }
load a sentence from config instance
43,243
public function send ( ) { if ( is_null ( $ this -> Transport ) ) { throw new TransportException ( ) ; } $ this -> Transport -> setRequest ( $ this ) ; return $ this -> Transport -> makeHttpRequest ( $ this ) ; }
Send request data method
43,244
public function setMethod ( $ method ) { $ method = ( int ) $ method ; switch ( $ this -> method ) { case self :: METHOD_AUTO : case self :: METHOD_GET : case self :: METHOD_POST : $ this -> method = $ method ; break ; default : throw new InvalidArgumentException ( ) ; } }
Setter for request method
43,245
public function addPostField ( $ field , $ value ) { if ( is_null ( $ this -> postData ) ) { $ this -> postData = array ( ) ; } if ( is_array ( $ this -> postData ) ) { $ this -> postData [ $ field ] = ( string ) $ value ; return $ this ; } else { throw new LogicException ( 'cannot set field for non array' ) ; } }
Add POST parameter
43,246
private function createPaymillMethod ( array $ data ) { $ paymentMethod = new PaymillMethod ( ) ; $ paymentMethod -> setApiToken ( $ data [ 'api_token' ] ) -> setCreditCardNumber ( $ data [ 'credit_card_1' ] . $ data [ 'credit_card_2' ] . $ data [ 'credit_card_3' ] . $ data [ 'credit_card_4' ] ) -> setCreditCardOwner ( $ data [ 'credit_card_owner' ] ) -> setCreditCardExpirationMonth ( $ data [ 'credit_card_expiration_month' ] ) -> setCreditCardExpirationYear ( $ data [ 'credit_card_expiration_year' ] ) -> setCreditCardSecurity ( $ data [ 'credit_card_security' ] ) ; return $ paymentMethod ; }
Given some data creates a PaymillMethod object
43,247
private static function driver ( ) { $ options = config ( 'cache.options' ) ; $ driver = config ( 'cache.default' ) ; switch ( $ driver ) { case 'file' : return instance ( FileDriver :: class ) ; break ; case 'apc' : return instance ( ApcDriver :: class ) ; break ; case 'database' : return instance ( PDODriver :: class ) ; break ; default : exception ( DriverNotFoundException :: class ) ; break ; } }
Set the cache surface driver .
43,248
public static function put ( $ name , $ value , $ lifetime ) { return self :: driver ( ) -> put ( $ name , $ value , $ lifetime ) ; }
Set an cache item to cache data .
43,249
protected function exportRecord ( AbstractRecord $ record , DataDimensions $ dataDimensions ) { $ precalculate = $ this -> precalculateExportRecord ( $ record , $ dataDimensions ) ; $ allowedProperties = array_intersect_key ( $ record -> getProperties ( ) , $ precalculate [ 'allowedProperties' ] ) ; $ record = clone $ record ; $ record -> setProperties ( $ allowedProperties ) ; return $ record ; }
Make sure the returned record is a new instance an does only contain properties of it s current view
43,250
public function use_view ( $ view ) { $ views = call_user_func ( array ( $ this -> model , 'views' ) ) ; if ( ! array_key_exists ( $ view , $ views ) ) { throw new \ OutOfBoundsException ( 'Cannot use undefined database view, must be defined with Model.' ) ; } $ this -> view = $ views [ $ view ] ; $ this -> view [ '_name' ] = $ view ; return $ this ; }
Set a view to use instead of the table
43,251
public function or_where ( ) { $ condition = func_get_args ( ) ; is_array ( reset ( $ condition ) ) and $ condition = reset ( $ condition ) ; return $ this -> _where ( $ condition , 'or_where' ) ; }
Set or_where condition
43,252
protected function _parse_where_array ( array $ val , $ base = '' , $ or = false ) { $ or and $ this -> or_where_open ( ) ; foreach ( $ val as $ k_w => $ v_w ) { if ( is_array ( $ v_w ) and ! empty ( $ v_w [ 0 ] ) and is_string ( $ v_w [ 0 ] ) ) { ! $ v_w [ 0 ] instanceof \ Database_Expression and strpos ( $ v_w [ 0 ] , '.' ) === false and $ v_w [ 0 ] = $ base . $ v_w [ 0 ] ; call_fuel_func_array ( array ( $ this , ( $ k_w === 'or' ? 'or_' : '' ) . 'where' ) , $ v_w ) ; } elseif ( is_int ( $ k_w ) or $ k_w == 'or' ) { $ k_w === 'or' ? $ this -> or_where_open ( ) : $ this -> where_open ( ) ; $ this -> _parse_where_array ( $ v_w , $ base , $ k_w === 'or' ) ; $ k_w === 'or' ? $ this -> or_where_close ( ) : $ this -> where_close ( ) ; } else { ! $ k_w instanceof \ Database_Expression and strpos ( $ k_w , '.' ) === false and $ k_w = $ base . $ k_w ; $ this -> where ( $ k_w , $ v_w ) ; } } $ or and $ this -> or_where_close ( ) ; }
Parses an array of where conditions into the query
43,253
public function order_by ( $ property , $ direction = 'ASC' ) { if ( is_array ( $ property ) ) { foreach ( $ property as $ p => $ d ) { if ( is_int ( $ p ) ) { is_array ( $ d ) ? $ this -> order_by ( $ d [ 0 ] , $ d [ 1 ] ) : $ this -> order_by ( $ d , $ direction ) ; } else { $ this -> order_by ( $ p , $ d ) ; } } return $ this ; } if ( ! $ property instanceof \ Fuel \ Core \ Database_Expression and strpos ( $ property , '.' ) === false ) { $ property = $ this -> alias . '.' . $ property ; } $ this -> order_by [ ] = array ( $ property , $ direction ) ; return $ this ; }
Set the order_by
43,254
public function related ( $ relation , $ conditions = array ( ) ) { if ( is_array ( $ relation ) ) { foreach ( $ relation as $ k_r => $ v_r ) { is_array ( $ v_r ) ? $ this -> related ( $ k_r , $ v_r ) : $ this -> related ( $ v_r ) ; } return $ this ; } if ( strpos ( $ relation , '.' ) ) { $ rels = explode ( '.' , $ relation ) ; $ model = $ this -> model ; foreach ( $ rels as $ r ) { $ rel = call_user_func ( array ( $ model , 'relations' ) , $ r ) ; if ( empty ( $ rel ) ) { throw new \ UnexpectedValueException ( 'Relation "' . $ r . '" was not found in the model "' . $ model . '".' ) ; } $ model = $ rel -> model_to ; } } else { $ rel = call_user_func ( array ( $ this -> model , 'relations' ) , $ relation ) ; if ( empty ( $ rel ) ) { throw new \ UnexpectedValueException ( 'Relation "' . $ relation . '" was not found in the model.' ) ; } } $ this -> relations [ $ relation ] = array ( $ rel , $ conditions ) ; if ( ! empty ( $ conditions [ 'related' ] ) ) { $ conditions [ 'related' ] = ( array ) $ conditions [ 'related' ] ; foreach ( $ conditions [ 'related' ] as $ k_r => $ v_r ) { is_array ( $ v_r ) ? $ this -> related ( $ relation . '.' . $ k_r , $ v_r ) : $ this -> related ( $ relation . '.' . $ v_r ) ; } unset ( $ conditions [ 'related' ] ) ; } return $ this ; }
Set a relation to include
43,255
public function set ( $ property , $ value = null ) { if ( is_array ( $ property ) ) { foreach ( $ property as $ p => $ v ) { $ this -> set ( $ p , $ v ) ; } return $ this ; } $ this -> values [ $ property ] = $ value ; return $ this ; }
Set any properties for insert or update
43,256
public function get ( ) { $ columns = $ this -> select ( ) ; $ select = $ columns ; if ( $ this -> use_subquery ( ) ) { $ select = array ( ) ; foreach ( $ columns as $ c ) { $ select [ ] = $ c [ 0 ] ; } } $ query = call_fuel_func_array ( 'DB::select' , $ select ) ; $ query -> from ( array ( $ this -> _table ( ) , $ this -> alias ) ) ; $ tmp = $ this -> build_query ( $ query , $ columns ) ; $ query = $ tmp [ 'query' ] ; $ models = $ tmp [ 'models' ] ; foreach ( $ models as $ name => $ values ) { if ( strpos ( $ name , '.' ) ) { unset ( $ models [ $ name ] ) ; $ rels = explode ( '.' , $ name ) ; $ ref = & $ models [ array_shift ( $ rels ) ] ; foreach ( $ rels as $ rel ) { empty ( $ ref [ 'models' ] ) and $ ref [ 'models' ] = array ( ) ; empty ( $ ref [ 'models' ] [ $ rel ] ) and $ ref [ 'models' ] [ $ rel ] = array ( ) ; $ ref = & $ ref [ 'models' ] [ $ rel ] ; } $ ref = $ values ; } } $ rows = $ query -> execute ( $ this -> connection ) -> as_array ( ) ; $ result = array ( ) ; $ model = $ this -> model ; $ select = $ this -> select ( ) ; $ primary_key = $ model :: primary_key ( ) ; foreach ( $ rows as $ id => $ row ) { $ this -> hydrate ( $ row , $ models , $ result , $ model , $ select , $ primary_key ) ; unset ( $ rows [ $ id ] ) ; } return $ result ; }
Build the query and return hydrated results
43,257
public function get_query ( ) { $ columns = $ this -> select ( false ) ; $ select = $ columns ; if ( $ this -> use_subquery ( ) ) { $ select = array ( ) ; foreach ( $ columns as $ c ) { $ select [ ] = $ c [ 0 ] ; } } $ query = call_fuel_func_array ( 'DB::select' , $ select ) ; $ query -> set_connection ( $ this -> connection ) ; $ query -> from ( array ( $ this -> _table ( ) , $ this -> alias ) ) ; $ tmp = $ this -> build_query ( $ query , $ columns ) ; return $ tmp [ 'query' ] ; }
Get the Query as it s been build up to this point and return it as an object
43,258
public function get_one ( ) { $ limit = $ this -> limit ; $ rows_limit = $ this -> rows_limit ; if ( $ this -> rows_limit !== null ) { $ this -> limit = null ; $ this -> rows_limit = 1 ; } else { $ this -> limit = 1 ; $ this -> rows_limit = null ; } $ result = $ this -> get ( ) ; $ this -> limit = $ limit ; $ this -> rows_limit = $ rows_limit ; return $ result ? reset ( $ result ) : null ; }
Build the query and return single object hydrated
43,259
public function count ( $ column = null , $ distinct = true ) { $ select = $ column ? : \ Arr :: get ( call_user_func ( $ this -> model . '::primary_key' ) , 0 ) ; $ select = ( strpos ( $ select , '.' ) === false ? $ this -> alias . '.' . $ select : $ select ) ; $ columns = \ DB :: expr ( 'COUNT(' . ( $ distinct ? 'DISTINCT ' : '' ) . \ Database_Connection :: instance ( $ this -> connection ) -> quote_identifier ( $ select ) . ') AS count_result' ) ; $ query = \ DB :: select ( $ columns ) ; $ query -> from ( array ( $ this -> _table ( ) , $ this -> alias ) ) ; $ tmp = $ this -> build_query ( $ query , $ columns , 'select' ) ; $ query = $ tmp [ 'query' ] ; $ count = $ query -> execute ( $ this -> connection ) -> get ( 'count_result' ) ; if ( $ count === null ) { return false ; } return ( int ) $ count ; }
Count the result of a query
43,260
public function max ( $ column ) { is_array ( $ column ) and $ column = array_shift ( $ column ) ; $ columns = \ DB :: expr ( 'MAX(' . \ Database_Connection :: instance ( $ this -> connection ) -> quote_identifier ( $ this -> alias . '.' . $ column ) . ') AS max_result' ) ; $ query = \ DB :: select ( $ columns ) ; $ query -> from ( array ( $ this -> _table ( ) , $ this -> alias ) ) ; $ tmp = $ this -> build_query ( $ query , $ columns , 'max' ) ; $ query = $ tmp [ 'query' ] ; $ max = $ query -> execute ( $ this -> connection ) -> get ( 'max_result' ) ; if ( $ max === null ) { return false ; } return $ max ; }
Get the maximum of a column for the current query
43,261
public function insert ( ) { $ res = \ DB :: insert ( call_user_func ( $ this -> model . '::table' ) , array_keys ( $ this -> values ) ) -> values ( array_values ( $ this -> values ) ) -> execute ( $ this -> write_connection ) ; if ( $ res [ 1 ] === 0 ) { return false ; } return $ res [ 0 ] ; }
Run INSERT with the current values
43,262
public function update ( ) { $ tmp_relations = $ this -> relations ; $ this -> relations = array ( ) ; $ query = \ DB :: update ( call_user_func ( $ this -> model . '::table' ) ) ; $ tmp = $ this -> build_query ( $ query , array ( ) , 'update' ) ; $ query = $ tmp [ 'query' ] ; $ res = $ query -> set ( $ this -> values ) -> execute ( $ this -> write_connection ) ; $ this -> relations = $ tmp_relations ; return $ res >= 0 ; }
Run UPDATE with the current values
43,263
public function delete ( ) { $ tmp_relations = $ this -> relations ; $ this -> relations = array ( ) ; $ query = \ DB :: delete ( call_user_func ( $ this -> model . '::table' ) ) ; $ tmp = $ this -> build_query ( $ query , array ( ) , 'delete' ) ; $ query = $ tmp [ 'query' ] ; $ res = $ query -> execute ( $ this -> write_connection ) ; $ this -> relations = $ tmp_relations ; return $ res > 0 ; }
Run DELETE with the current values
43,264
public static function createServiceManager ( array $ config = [ ] ) { $ serviceManager = new ServiceManager ( new Config ( $ config ) ) ; $ serviceManager -> addInitializer ( function ( $ instance , ServiceLocatorInterface $ serviceLocator ) { if ( $ instance instanceof ModelManagerAwareInterface ) { $ instance -> setModelManager ( $ serviceLocator -> get ( 'modelmanager' ) ) ; } } ) ; $ serviceManager -> addInitializer ( function ( $ instance , ServiceLocatorInterface $ serviceLocator ) { if ( $ instance instanceof ServiceLocatorAwareInterface ) { $ instance -> setServiceLocator ( $ serviceLocator ) ; } } ) ; return $ serviceManager ; }
Creates a service manager instnace
43,265
public function getListeners ( $ eventName = NULL ) { if ( $ eventName === NULL ) { $ listeners = [ ] ; foreach ( array_keys ( $ this -> listeners ) as $ k ) { $ listeners [ $ k ] = [ ] ; foreach ( clone $ this -> listeners [ $ k ] as $ listener ) { $ listeners [ $ k ] [ ] = $ listener ; } } ksort ( $ listeners ) ; return $ listeners ; } if ( $ eventName instanceof \ ReflectionClass ) { $ eventName = $ eventName -> name ; } if ( empty ( $ this -> listeners [ $ eventName ] ) ) { return [ ] ; } $ listeners = [ ] ; foreach ( clone $ this -> listeners [ $ eventName ] as $ listener ) { $ listeners [ ] = $ listener ; } return $ listeners ; }
Get all event listeners for the given event .
43,266
protected function getRequiredType ( callable $ callback ) { $ ref = new \ ReflectionFunction ( $ callback ) ; if ( $ ref -> getNumberOfParameters ( ) > 0 ) { $ params = $ ref -> getParameters ( ) ; if ( isset ( $ params [ 0 ] ) && NULL !== ( $ type = $ params [ 0 ] -> getClass ( ) ) ) { return $ type ; } } }
Determines the type of the first callback argument and returns it .
43,267
protected function collectListeners ( $ event ) { $ tmp = is_object ( $ event ) ? get_class ( $ event ) : ( string ) $ event ; if ( isset ( $ this -> listeners [ $ tmp ] ) ) { $ listeners = clone $ this -> listeners [ $ tmp ] ; } else { $ listeners = new \ SplPriorityQueue ( ) ; } while ( false !== ( $ tmp = get_parent_class ( $ tmp ) ) ) { if ( isset ( $ this -> listeners [ $ tmp ] ) && ! $ this -> listeners [ $ tmp ] -> isEmpty ( ) ) { foreach ( clone $ this -> listeners [ $ tmp ] as $ listener ) { $ listeners -> insert ( $ listener , $ listener -> getPriority ( ) ) ; } } } return $ listeners ; }
Collect all event listeners for the given event including inherited listeners .
43,268
public function addNestedWhereQuery ( $ query ) { if ( count ( $ query -> wheres ) ) { $ wheres = $ this -> wheres ? : [ ] ; $ this -> wheres = array_merge ( $ wheres , $ query -> wheres ) ; } return $ this ; }
Merge another query builder wheres with the query builder wheres .
43,269
public function postField ( $ column , $ value = null ) { if ( is_array ( $ column ) ) { return $ this -> postFieldNested ( function ( $ query ) use ( $ column ) { foreach ( $ column as $ key => $ value ) { $ query -> postField ( $ key , $ value ) ; } } ) ; } $ this -> body [ ] = compact ( 'column' , 'value' ) ; return $ this ; }
Add a post field to the query .
43,270
public function postFieldNested ( Closure $ callback ) { $ query = $ this -> newQuery ( ) ; call_user_func ( $ callback , $ query ) ; return $ this -> addNestedPostFieldQuery ( $ query ) ; }
Add a nested post field to the query .
43,271
public function addNestedPostFieldQuery ( $ query ) { if ( count ( $ query -> body ) ) { $ body = $ this -> body ? : [ ] ; $ this -> body = array_merge ( $ body , $ query -> body ) ; } return $ this ; }
Merge another query builder body with the query builder body .
43,272
public function setCurrent ( ) : void { $ this -> current = true ; $ parent = $ this -> parent ; if ( $ parent instanceof Item ) { $ parent -> setCurrent ( ) ; } }
Nastavi jako aktivni i s rodici
43,273
public static function setDecoration ( string $ sContent , string $ sStyleName ) : string { return self :: _applyCode ( $ sContent , self :: $ _aBackgroundCodes [ $ sStyleName ] ) ; }
set a decoration of the text
43,274
public static function setBackground ( string $ sContent , string $ sColorName ) : string { if ( ! isset ( self :: $ _aBackgroundCodes [ $ sColorName ] ) ) { $ sColorName = 'black' ; } return self :: _applyCode ( $ sContent , self :: $ _aBackgroundCodes [ $ sColorName ] ) ; }
set a color of the background
43,275
public static function setColor ( string $ sContent , string $ sColorName ) : string { if ( ! isset ( self :: $ _aBackgroundCodes [ $ sColorName ] ) ) { $ sColorName = 'white' ; } return self :: _applyCode ( $ sContent , self :: $ _aBackgroundCodes [ $ sColorName ] ) ; }
set a color of the text
43,276
public function DiscussionModel ( $ Value = FALSE ) { if ( $ Value !== FALSE ) { $ this -> _DiscussionModel = $ Value ; } if ( $ this -> _DiscussionModel === FALSE ) { require_once ( dirname ( __FILE__ ) . DS . 'class.discussionmodel.php' ) ; $ this -> _DiscussionModel = new DiscussionModel ( ) ; } return $ this -> _DiscussionModel ; }
Makes a discussion model available .
43,277
public function DiscussionSql ( $ SearchModel , $ AddMatch = TRUE ) { if ( $ AddMatch ) { $ Perms = CategoryModel :: CategoryWatch ( ) ; if ( $ Perms !== TRUE ) { $ this -> SQL -> WhereIn ( 'd.CategoryID' , $ Perms ) ; } $ SearchModel -> AddMatchSql ( $ this -> SQL , 'd.Name, d.Body' , 'd.DateInserted' ) ; } $ this -> SQL -> Select ( 'd.DiscussionID as PrimaryID, d.Name as Title, d.Body as Summary, d.Format, d.CategoryID, d.Score' ) -> Select ( 'd.DiscussionID' , "concat('/discussion/', %s)" , 'Url' ) -> Select ( 'd.DateInserted' ) -> Select ( 'd.InsertUserID as UserID' ) -> Select ( "'Discussion'" , '' , 'RecordType' ) -> From ( 'Discussion d' ) ; if ( $ AddMatch ) { $ Result = $ this -> SQL -> GetSelect ( ) ; $ this -> SQL -> Reset ( ) ; } else { $ Result = $ this -> SQL ; } return $ Result ; }
Execute discussion search query .
43,278
public function Search ( $ SearchModel ) { $ SearchModel -> AddSearch ( $ this -> DiscussionSql ( $ SearchModel ) ) ; $ SearchModel -> AddSearch ( $ this -> CommentSql ( $ SearchModel ) ) ; }
Add the searches for Vanilla to the search model .
43,279
public function move ( $ up ) { $ table = $ this -> getTableName ( ) ; if ( $ up && ( $ this -> position > 1 ) ) { $ this -> position -- ; $ this -> app [ 'redbean' ] -> exec ( 'UPDATE ' . $ table . ' SET position = position + 1 WHERE position = ?' , [ $ this -> position ] ) ; } else if ( ! $ up && ( $ this -> position < $ this -> app [ 'redbean' ] -> count ( $ table ) ) ) { $ this -> position ++ ; $ this -> app [ 'redbean' ] -> exec ( 'UPDATE ' . $ table . ' SET position = position - 1 WHERE position = ?' , [ $ this -> position ] ) ; } }
Moves this model up or down in position
43,280
protected function sortableUpdate ( ) { $ table = $ this -> getTableName ( ) ; if ( ! $ this -> position || ( $ this -> position && count ( $ this -> app [ 'redbean' ] -> find ( $ table , 'position = ? AND id != ?' , [ $ this -> position , $ this -> id ] ) ) ) ) { $ position = $ this -> app [ 'redbean' ] -> getCell ( 'SELECT position FROM ' . $ table . ' ORDER BY position DESC LIMIT 1' ) ; $ this -> position = $ position + 1 ; } }
RedBean update method Automates position assigning
43,281
public function add ( $ name , $ callback , $ error_message ) { $ this -> _callbacks [ $ name ] = $ callback ; $ this -> _messages [ $ name ] = $ error_message ; }
Adds a user defined validator .
43,282
public function setMessages ( $ messages ) { foreach ( $ messages as $ name => $ message ) { $ this -> _messages [ $ name ] = $ message ; } }
Adds user defined error messages .
43,283
public static function getSecondsBetweenDates ( \ DateTime $ dateA , \ DateTime $ dateB ) { $ diff = $ dateA -> diff ( $ dateB ) ; $ sec = $ diff -> s ; $ sec += $ diff -> i * 60 ; $ sec += $ diff -> h * 3600 ; $ sec += $ diff -> days * 86400 ; return $ sec ; }
Calculates the seconds between two dates .
43,284
public static function verifyCredentials ( ObjectRetriever $ retriever , $ username , $ password ) { $ namespaceCoid = new IRI ( 'coid://' . $ username ) ; if ( COIDParser :: getType ( $ namespaceCoid ) != COIDParser :: COID_ROOT ) return self :: RESULT_INVALID_USERNAME ; if ( strlen ( $ password ) != 40 ) return self :: RESULT_INVALID_PASSWORD ; $ namespace = $ retriever -> getObject ( $ namespaceCoid ) ; if ( ! isset ( $ namespace ) ) return self :: RESULT_NAMESPACE_NOT_FOUND ; $ reader = new NodeReader ( [ 'prefixes' => [ 'co' => 'coid://cloudobjects.io/' ] ] ) ; $ sharedSecret = $ reader -> getAllValuesNode ( $ namespace , 'co:hasSharedSecret' ) ; if ( count ( $ sharedSecret ) != 1 ) return self :: RESULT_SHARED_SECRET_NOT_RETRIEVABLE ; if ( $ reader -> getFirstValueString ( $ sharedSecret [ 0 ] , 'co:hasTokenValue' ) == $ password ) return self :: RESULT_OK ; else return self :: RESULT_SHARED_SECRET_INCORRECT ; }
Verifies credentials .
43,285
public function add ( MergeRuleInterface $ rule , $ name = null ) { if ( ! empty ( $ name ) ) { $ this -> _items [ $ name ] = $ rule ; } else { $ this -> _items [ ] = $ rule ; } return $ this ; }
add a rule
43,286
public function handleQuitCommand ( CommandEvent $ event , EventQueueInterface $ queue ) { $ message = sprintf ( $ this -> message , $ event -> getNick ( ) ) ; $ queue -> ircQuit ( $ message ) ; }
Terminates the connection to a server from which a quit command is received .
43,287
protected function blockQuote ( $ Line ) { if ( ! $ this -> config ( 'markup.quote.keepSigns' ) ) { return parent :: blockQuote ( $ Line ) ; } if ( mb_ereg ( '^>([ ]?.*)' , $ Line [ 'text' ] , $ matches ) ) { $ matches = str_replace ( ">" , "&gt;" , $ matches [ 1 ] ) ; $ Block = array ( 'element' => array ( 'name' => 'blockquote' , 'handler' => 'lines' , 'text' => [ "&gt;{$matches}" ] , ) , ) ; return $ Block ; } }
Injects a greater - than sign at the start of a quote block .
43,288
protected function blockQuoteContinue ( $ Line , array $ Block ) { if ( ! $ this -> config ( 'markup.quote.keepSigns' ) ) { return parent :: blockQuote ( $ Line ) ; } if ( mb_ereg ( '^>([ ]?.*)' , $ Line [ 'text' ] , $ matches ) ) { if ( isset ( $ Block [ 'interrupted' ] ) ) { $ Block [ 'element' ] [ 'text' ] [ ] = '' ; unset ( $ Block [ 'interrupted' ] ) ; } $ matches = str_replace ( ">" , "&gt;" , $ matches [ 1 ] ) ; $ Block [ 'element' ] [ 'text' ] [ ] = "&gt;{$matches}" ; return $ Block ; } }
Injects a greater - than sign at the beginning of each line in a quote block .
43,289
public function move ( $ new_path ) { $ info = pathinfo ( $ this -> path ) ; $ new_path = $ this -> area -> get_path ( $ new_path ) ; $ new_path = rtrim ( $ new_path , '\\/' ) . DS . $ info [ 'basename' ] ; $ return = $ this -> area -> rename ( $ this -> path , $ new_path ) ; $ return and $ this -> path = $ new_path ; return $ return ; }
Move file to new directory
43,290
private function queryFor ( MapInterface $ changesets , MapInterface $ entities ) : Query { $ this -> variables = new Map ( Str :: class , MapInterface :: class ) ; $ query = $ changesets -> reduce ( new Query \ Query , function ( Query $ carry , Identity $ identity , MapInterface $ changeset ) use ( $ entities ) : Query { $ entity = $ entities -> get ( $ identity ) ; $ meta = ( $ this -> metadata ) ( \ get_class ( $ entity ) ) ; if ( $ meta instanceof Aggregate ) { return $ this -> matchAggregate ( $ identity , $ entity , $ meta , $ changeset , $ carry ) ; } else if ( $ meta instanceof Relationship ) { return $ this -> matchRelationship ( $ identity , $ entity , $ meta , $ changeset , $ carry ) ; } } ) ; $ query = $ this -> variables -> reduce ( $ query , function ( Query $ carry , Str $ variable , MapInterface $ changeset ) : Query { return $ this -> update ( $ variable , $ changeset , $ carry ) ; } ) ; $ this -> variables = null ; return $ query ; }
Build the query to update all entities at once
43,291
private function matchAggregate ( Identity $ identity , object $ entity , Aggregate $ meta , MapInterface $ changeset , Query $ query ) : Query { $ name = $ this -> name -> sprintf ( \ md5 ( $ identity -> value ( ) ) ) ; $ query = $ query -> match ( ( string ) $ name , $ meta -> labels ( ) -> toPrimitive ( ) ) -> withProperty ( $ meta -> identity ( ) -> property ( ) , ( string ) $ name -> prepend ( '{' ) -> append ( '_identity}' ) ) -> withParameter ( ( string ) $ name -> append ( '_identity' ) , $ identity -> value ( ) ) ; $ this -> variables = $ this -> variables -> put ( $ name , $ this -> buildProperties ( $ changeset , $ meta -> properties ( ) ) ) ; return $ meta -> children ( ) -> filter ( static function ( string $ property ) use ( $ changeset ) : bool { return $ changeset -> contains ( $ property ) ; } ) -> reduce ( $ query , function ( Query $ carry , string $ property , Child $ child ) use ( $ changeset , $ name ) : Query { $ changeset = $ changeset -> get ( $ property ) ; $ childName = null ; $ relName = $ name -> append ( '_' ) -> append ( $ property ) ; $ this -> variables = $ this -> variables -> put ( $ relName , $ this -> buildProperties ( $ changeset , $ child -> relationship ( ) -> properties ( ) ) ) ; if ( $ changeset -> contains ( $ child -> relationship ( ) -> childProperty ( ) ) ) { $ childName = $ relName -> append ( '_' ) -> append ( $ child -> relationship ( ) -> childProperty ( ) ) ; $ this -> variables = $ this -> variables -> put ( $ childName , $ changeset -> get ( $ child -> relationship ( ) -> childProperty ( ) ) ) ; } return $ carry -> match ( ( string ) $ name ) -> linkedTo ( $ childName ? ( string ) $ childName : null , $ child -> labels ( ) -> toPrimitive ( ) ) -> through ( ( string ) $ child -> relationship ( ) -> type ( ) , ( string ) $ relName ) ; } ) ; }
Add match clause to match all parts of the aggregate that needs to be updated
43,292
private function matchRelationship ( Identity $ identity , object $ entity , Relationship $ meta , MapInterface $ changeset , Query $ query ) : Query { $ name = $ this -> name -> sprintf ( \ md5 ( $ identity -> value ( ) ) ) ; $ this -> variables = $ this -> variables -> put ( $ name , $ this -> buildProperties ( $ changeset , $ meta -> properties ( ) ) ) ; return $ query -> match ( ) -> linkedTo ( ) -> through ( ( string ) $ meta -> type ( ) , ( string ) $ name ) -> withProperty ( $ meta -> identity ( ) -> property ( ) , ( string ) $ name -> prepend ( '{' ) -> append ( '_identity}' ) ) -> withParameter ( ( string ) $ name -> append ( '_identity' ) , $ identity -> value ( ) ) ; }
Add the match clause for a relationship
43,293
private function buildProperties ( MapInterface $ changeset , MapInterface $ properties ) : MapInterface { return $ changeset -> filter ( static function ( string $ property ) use ( $ properties ) { return $ properties -> contains ( $ property ) ; } ) ; }
Build a collection with only the elements that are properties
43,294
private function update ( Str $ variable , MapInterface $ changeset , Query $ query ) : Query { return $ query -> set ( sprintf ( '%s += {%s_props}' , $ variable , $ variable ) ) -> withParameter ( ( string ) $ variable -> append ( '_props' ) , $ changeset -> reduce ( [ ] , static function ( array $ carry , string $ key , $ value ) : array { $ carry [ $ key ] = $ value ; return $ carry ; } ) ) ; }
Add a clause to set all properties to be updated on the wished variable
43,295
protected function createRoutesStub ( ) { if ( ! file_exists ( app_path ( 'Routes' ) ) ) { mkdir ( app_path ( 'Routes' ) , 0755 ) ; } if ( $ this -> create ( 'routes.stub' , 'Routes' , $ this -> getRoutesName ( ) ) ) { $ this -> info ( 'add ' . $ this -> getNamespace ( ) . '\\Routes\\' . $ this -> getRoutesName ( ) . '::routes( $router ); in your routes contract.' ) ; } }
Create Routes Stub
43,296
public function reset ( ) { unset ( $ this -> _registry ) ; unset ( $ this -> _mixin ) ; unset ( $ this -> _errorHandler ) ; unset ( $ this -> _errorContext ) ; unset ( $ this -> _middleware ) ; return $ this ; }
Resets all internal state
43,297
public function loggerFactory ( ) { if ( ! isset ( $ this -> _loggerFactory ) ) { $ this -> _loggerFactory = new Logging \ DefaultLoggerFactory ( ) ; } return $ this -> _loggerFactory ; }
Gets the logger factory used to create loggers
43,298
public function rand ( $ min = 0 , $ max = 0 ) { if ( ! $ max ) $ max = getrandmax ( ) ; return $ this -> registry ( ) -> isRegistered ( self :: REGISTRY_RAND ) ? $ this -> lookup ( self :: REGISTRY_RAND ) : rand ( $ min , $ max ) ; }
Returns the current random number in the registry or generates a new one
43,299
public function run ( $ server = null , $ stream = null ) { $ server = $ server ? : $ _SERVER ; $ stream = $ stream ? : fopen ( 'php://output' , 'w' ) ; $ controller = $ this -> controller ( ) ; foreach ( $ this -> _middleware as $ middleware ) $ controller = new $ middleware ( $ controller , $ this ) ; $ requestFactory = new Http \ RequestFactory ( $ server ) ; $ response = $ controller -> execute ( $ requestFactory -> create ( ) ) ; $ sender = new Http \ ResponseSender ( $ response , $ stream ) ; $ sender -> send ( ) ; }
Processes an HTTP request copies response to STDOUT