idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
20,300
public static function currentPage ( ) { $ uri = static :: to ( static :: detectPath ( ) ) ; foreach ( $ _GET as $ k => $ v ) { $ uri -> param ( $ k , $ v ) ; } return $ uri ; }
Create new URI instance to the current page
20,301
public function path ( $ path ) { $ path = explode ( '/' , $ path ) ; for ( $ i = 0 ; $ i < count ( $ path ) ; $ i ++ ) { $ path [ $ i ] = urlencode ( $ path [ $ i ] ) ; } $ this -> path = implode ( '/' , $ path ) ; return $ this ; }
Set the URI path
20,302
public function param ( $ param , $ value ) { if ( $ value !== null ) { $ param = rawurlencode ( $ param ) ; $ value = rawurlencode ( $ value ) ; $ this -> params [ $ param ] = $ value ; } else { if ( isset ( $ this -> params [ $ param ] ) ) { unset ( $ this -> params [ $ param ] ) ; } } return $ this ; }
Set a query param
20,303
public static function parse ( $ uri ) { $ uri = static :: to ( static :: detectPathFrom ( parse_url ( $ uri , PHP_URL_PATH ) ) ) ; $ query = array ( ) ; parse_str ( parse_url ( $ uri , PHP_URL_QUERY ) , $ query ) ; foreach ( $ query as $ k => $ v ) { $ uri -> param ( $ k , $ v ) ; } return $ uri ; }
Parse an URI string
20,304
protected function getWhere ( $ name ) { if ( isset ( $ this -> wheres [ $ name ] ) ) { return $ this -> wheres [ $ name ] ; } if ( isset ( self :: $ patterns [ $ name ] ) ) { return self :: $ patterns [ $ name ] ; } return false ; }
Get conditional pattern for route variables
20,305
public function matches ( $ requestUri ) { $ requestUri = $ this -> normalizeUri ( $ requestUri ) ; $ regex = $ this -> compile ( ) ; if ( preg_match ( '#^' . $ regex . '$#i' , $ requestUri , $ out ) ) { $ this -> data = $ this -> getOnlyStringKeys ( $ out ) ; return true ; } return false ; }
Check if a route matches a given url
20,306
protected function normalizeUri ( $ requestUri ) { $ len = strlen ( $ requestUri ) ; if ( $ len == 0 ) { return '/' ; } if ( $ len == 1 ) { return $ requestUri ; } return trim ( $ requestUri , '/' ) ; }
Prepare uri for regex match
20,307
protected function getOnlyStringKeys ( array $ array ) { $ allowed = array_filter ( array_keys ( $ array ) , function ( $ key ) { return ! is_int ( $ key ) ; } ) ; return array_intersect_key ( $ array , array_flip ( $ allowed ) ) ; }
Get arrays elements that contains only associative keys
20,308
public function saveContact ( Contact $ contactMessage ) { $ mapper = $ this -> getServiceLocator ( ) -> get ( 'contact_mapper' ) ; $ mapper -> insert ( $ contactMessage ) ; }
Saves the contact message to the database for later administration
20,309
public function sendMessage ( Contact $ contactMessage ) { $ serverName = ( $ _SERVER [ 'HTTP_HOST' ] ? $ _SERVER [ 'HTTP_HOST' ] : $ _SERVER [ 'SERVER_NAME' ] ) ; $ message = new Message ( ) ; $ message -> addFrom ( new Address ( $ contactMessage -> getEmail ( ) , $ contactMessage -> getFirstName ( ) . ' ' . $ contactMessage -> getLastName ( ) ) ) ; $ message -> setSubject ( $ contactMessage -> getSubject ( ) ) ; $ body = <<<MSGNew Message \nFrom: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \nSubject: [$serverName contact] {$contactMessage->getSubject()} \nMessage: {$contactMessage->getMessage()} \nMSG ; $ message -> setBody ( $ body ) ; return $ this -> getServiceLocator ( ) -> get ( 'transport' ) -> send ( $ message ) ; }
Composes & sends the email from a contact message
20,310
protected function processHtmlOptions ( ) { if ( isset ( $ this -> htmlOptions [ 'prepend' ] ) ) { $ this -> prependText = $ this -> htmlOptions [ 'prepend' ] ; unset ( $ this -> htmlOptions [ 'prepend' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'append' ] ) ) { $ this -> appendText = $ this -> htmlOptions [ 'append' ] ; unset ( $ this -> htmlOptions [ 'append' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'hint' ] ) ) { $ this -> hintText = $ this -> htmlOptions [ 'hint' ] ; unset ( $ this -> htmlOptions [ 'hint' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'labelOptions' ] ) ) { $ this -> labelOptions = $ this -> htmlOptions [ 'labelOptions' ] ; unset ( $ this -> htmlOptions [ 'labelOptions' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'prependOptions' ] ) ) { $ this -> prependOptions = $ this -> htmlOptions [ 'prependOptions' ] ; unset ( $ this -> htmlOptions [ 'prependOptions' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'appendOptions' ] ) ) { $ this -> appendOptions = $ this -> htmlOptions [ 'appendOptions' ] ; unset ( $ this -> htmlOptions [ 'appendOptions' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'hintOptions' ] ) ) { $ this -> hintOptions = $ this -> htmlOptions [ 'hintOptions' ] ; unset ( $ this -> htmlOptions [ 'hintOptions' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'errorOptions' ] ) ) { $ this -> errorOptions = $ this -> htmlOptions [ 'errorOptions' ] ; unset ( $ this -> htmlOptions [ 'errorOptions' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'captchaOptions' ] ) ) { $ this -> captchaOptions = $ this -> htmlOptions [ 'captchaOptions' ] ; unset ( $ this -> htmlOptions [ 'captchaOptions' ] ) ; } }
Processes the html options .
20,311
protected function getAppend ( ) { if ( $ this -> hasAddOn ( ) ) { $ htmlOptions = $ this -> appendOptions ; if ( isset ( $ htmlOptions [ 'class' ] ) ) $ htmlOptions [ 'class' ] .= ' add-on' ; else $ htmlOptions [ 'class' ] = 'add-on' ; ob_start ( ) ; if ( isset ( $ this -> appendText ) ) echo CHtml :: tag ( 'span' , $ htmlOptions , $ this -> appendText ) ; echo '</div>' ; return ob_get_clean ( ) ; } else return '' ; }
Returns the append element for the input .
20,312
protected function getError ( ) { return $ this -> form -> error ( $ this -> model , $ this -> attribute , $ this -> errorOptions ) ; }
Returns the error text for the input .
20,313
protected function getHint ( ) { if ( isset ( $ this -> hintText ) ) { $ htmlOptions = $ this -> hintOptions ; if ( isset ( $ htmlOptions [ 'class' ] ) ) $ htmlOptions [ 'class' ] .= ' help-block' ; else $ htmlOptions [ 'class' ] = 'help-block' ; return CHtml :: tag ( 'p' , $ htmlOptions , $ this -> hintText ) ; } else return '' ; }
Returns the hint text for the input .
20,314
protected function getContainerCssClass ( ) { $ attribute = $ this -> attribute ; return $ this -> model -> hasErrors ( CHtml :: resolveName ( $ this -> model , $ attribute ) ) ? CHtml :: $ errorCss : '' ; }
Returns the container CSS class for the input .
20,315
protected function getAddonCssClass ( ) { $ classes = array ( ) ; if ( isset ( $ this -> prependText ) ) $ classes [ ] = 'input-prepend' ; if ( isset ( $ this -> appendText ) ) $ classes [ ] = 'input-append' ; return implode ( ' ' , $ classes ) ; }
Returns the input container CSS classes .
20,316
public function pass ( $ key , $ value ) { if ( ! isset ( $ this -> _session ) ) throw new \ Exception ( 'm\Http\Response: No session object available to flash "' . $ key . '" to.' ) ; $ this -> _session -> flash ( $ key , $ value ) ; return $ this ; }
Pass flash data to the next page .
20,317
public function passMany ( array $ data ) { if ( ! isset ( $ this -> _session ) ) throw new \ Exception ( 'm\Http\Response: No session object available to flash "' . $ key . '" to.' ) ; $ this -> _session -> flashMany ( $ data ) ; return $ this ; }
Add an array of data to pass to the next page .
20,318
public function getHeader ( $ key ) { return isset ( $ this -> _headers [ $ key ] ) ? $ this -> _headers [ $ key ] : null ; }
Returns the value of the requested header or null if it does not exist .
20,319
public function redirect ( $ url , $ status = 302 ) { $ this -> _headers [ 'Location' ] = ( string ) $ url ; $ this -> _status = ( integer ) $ status ; return $ this ; }
Automatically sets the response headers and status for a redirect .
20,320
public function cache ( $ expires ) { if ( $ expires === false ) { $ this -> _headers [ 'Expires' ] = 'Mon, 26 Jul 1997 05:00:00 GMT' ; $ this -> _headers [ 'Cache-Control' ] = array ( 'no-store, no-cache, must-revalidate' , 'post-check=0, pre-check=0' , 'max-age=0' ) ; $ this -> _headers [ 'Pragma' ] = 'no-cache' ; } else { $ expires = is_string ( $ expires ) ? strtotime ( $ expires ) : $ expires ; $ this -> _headers [ 'Expires' ] = gmdate ( 'D, d M Y H:i:s' , $ expires ) . ' GMT' ; $ this -> _headers [ 'Cache-Control' ] = 'max-age=' . ( $ expires - time ( ) ) ; } return $ this ; }
Sets the caching headers for the response .
20,321
public function sendStatus ( $ protocol = null ) { if ( null === $ protocol ) { $ protocol = isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : 'HTTP/1.1' ; } header ( $ protocol . ' ' . $ this -> _status . ' ' . $ this -> getStatusMessage ( $ this -> _status ) ) ; return $ this ; }
Sends the HTTP status header .
20,322
public function sendHeaders ( ) { foreach ( $ this -> _headers as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ v ) { header ( $ key . ': ' . $ v , false ) ; } } else { header ( $ key . ': ' . $ value ) ; } } return $ this ; }
Sends all of the set HTTP headers .
20,323
public function send ( $ protocol = null ) { if ( ob_get_length ( ) > 0 ) { ob_end_clean ( ) ; } if ( ! headers_sent ( ) ) $ this -> sendStatus ( $ protocol ) -> sendHeaders ( ) ; echo $ this -> _body ; exit ; }
Sends the response and ends the application .
20,324
protected function validateConfiguration ( $ config ) { $ requiredFields = $ this -> getRequiredConfigurationFields ( ) ; $ missingFields = [ ] ; foreach ( $ requiredFields as $ requiredField ) { if ( array_key_exists ( $ requiredField , $ config ) === false ) { $ missingFields [ ] = $ requiredField ; } } if ( count ( $ missingFields ) > 0 ) { throw new \ RuntimeException ( 'Some fields are not configured: ' . implode ( ', ' , $ missingFields ) ) ; } }
Validates the configuration Checks if all the fields are present
20,325
protected function bootTwig ( ) { $ options = $ this -> getTwigOptions ( ) ; $ options [ 'twig.path' ] [ ] = __DIR__ . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'views' ; if ( $ this [ 'debug' ] === false ) { $ options [ 'twig.options' ] [ 'cache' ] = $ this [ 'app.cache' ] . DIRECTORY_SEPARATOR . 'twig' ; } $ this -> register ( new TwigServiceProvider ( ) , $ options ) ; $ this -> extend ( 'twig.runtimes' , function ( $ runtimes , $ app ) { return array_merge ( $ runtimes , [ FormRenderer :: class => 'twig.form.renderer' , ] ) ; } ) ; $ this -> extend ( 'twig' , function ( \ Twig_Environment $ twig , Application $ app ) { $ twig -> addExtension ( new ImagineExtension ( $ app ) ) ; $ twig -> addExtension ( new ConfigExtension ( $ app ) ) ; return $ twig ; } ) ; }
Boots the Twig Service Provider
20,326
protected function bootForm ( ) { $ this -> register ( new FormServiceProvider ( ) , array ( 'form.secret' => $ this [ 'form.secret' ] ) ) ; $ this -> register ( new ValidatorServiceProvider ( ) , array ( ) ) ; $ this -> register ( new CsrfServiceProvider ( ) ) ; }
Boots the Form Service Provider and Validator Service Provider
20,327
protected function bootSwiftmailer ( ) { $ this -> register ( new \ Silex \ Provider \ SwiftmailerServiceProvider ( ) , array ( 'swiftmailer.use_spool' => false , 'swiftmailer.options' => array ( 'host' => $ this [ 'smtp.host' ] , 'port' => $ this [ 'smtp.port' ] , 'username' => $ this [ 'smtp.username' ] , 'password' => $ this [ 'smtp.password' ] , 'encryption' => $ this [ 'smtp.encryption' ] , 'auth_mode' => $ this [ 'smtp.auth_mode' ] ) ) ) ; }
Boots the Swiftmailer Service Provider
20,328
protected function registerControllers ( ) { $ this [ 'controllers.page' ] = function ( $ app ) { return new PageController ( $ app ) ; } ; $ this [ 'controllers.imagine' ] = function ( $ app ) { return new ImagineController ( $ app ) ; } ; $ this [ 'controllers.error' ] = function ( $ app ) { return new ErrorController ( $ app ) ; } ; }
Register the controllers in the container
20,329
protected function registerRoutes ( ) { $ this -> get ( $ this [ 'imagine.thumbnail_url' ] . '{size}/{checksum}/{path}' , function ( Application $ app , Request $ request , $ path , $ size , $ checksum ) { return $ app [ 'controllers.imagine' ] -> resizeImageAction ( $ request , $ path , $ size , $ checksum ) ; } ) -> assert ( 'path' , '.+' ) ; $ this -> get ( '' , function ( Application $ app , Request $ request ) { return $ app [ 'controllers.page' ] -> showHomePageAction ( $ request ) ; } ) ; $ this -> error ( function ( NotFoundHttpException $ e , $ code ) { return $ this [ 'controllers.error' ] -> notFoundAction ( $ e ) ; } ) ; $ this -> error ( function ( \ Exception $ e , $ code ) { return $ this [ 'controllers.error' ] -> internalServerErrorAction ( $ e ) ; } ) ; }
Register the routes and link them to the controller actions
20,330
public function trigger ( $ args = array ( ) , $ precedence = null ) { if ( is_null ( $ precedence ) ) { $ functions = array ( ) ; ksort ( $ this -> hooks ) ; foreach ( $ this -> hooks as $ function_set ) { foreach ( $ function_set as $ function ) { $ functions [ ] = $ function ; } } $ return = array ( ) ; foreach ( $ functions as $ function ) { $ return [ ] = call_user_func_array ( $ function , $ args ) ; } return $ return ; } else { $ return = array ( ) ; if ( isset ( $ this -> hooks [ $ precedence ] ) && is_array ( $ this -> hooks [ $ precedence ] ) ) { foreach ( $ this -> hooks [ $ precedence ] as $ function ) { $ return [ ] = call_user_func_array ( $ function , $ args ) ; } } return $ return ; } }
Invokes all callback attached to the event
20,331
public function sendToEmail ( Request $ request , UserMailer $ userMailer ) { $ this -> validate ( $ request , [ 'email' => 'required|email' ] ) ; $ request = $ request -> only ( 'email' ) ; $ request [ 'token' ] = str_random ( 40 ) ; $ this -> resetPasswordRepo -> create ( $ request ) ; $ userMailer -> sendResetPasswordEmailTo ( $ request ) ; return redirect ( ) -> route ( 'core::home' ) ; }
send a message to the email of the user
20,332
public function resetPassword ( Request $ request ) { $ this -> validate ( $ request , [ 'password' => 'required|confirmed' , 'token' => 'required' ] ) ; $ record = $ this -> resetPasswordRepo -> where ( 'token' , $ request [ 'token' ] ) ; $ email = $ record -> first ( ) -> email ; $ record -> delete ( ) ; $ user = $ this -> userRepo -> where ( 'email' , $ email ) -> update ( [ 'password' => $ request [ 'password' ] ] ) ; return redirect ( ) -> route ( 'core::home' ) ; }
to save then new password
20,333
public function map ( $ sourcePath , $ targetPath ) { if ( file_exists ( $ sourcePath ) ) { $ items = array ( ) ; if ( is_file ( $ sourcePath ) ) { $ items [ $ targetPath ] = $ sourcePath ; } elseif ( is_dir ( $ sourcePath ) ) { $ finder = new Finder \ Finder ( ) ; foreach ( $ finder -> in ( $ sourcePath ) -> files ( ) as $ file ) { $ fileTargetPath = $ targetPath . "/" . $ file -> getRelativePathname ( ) ; $ items [ $ fileTargetPath ] = $ file -> getPathname ( ) ; } } foreach ( $ items as $ target => $ source ) { $ formulae = new AssetFormulae ( ) ; $ formulae -> setInputs ( array ( $ source ) ) ; $ formulae -> setOptions ( array ( "output" => $ target ) ) ; $ this -> append ( $ formulae ) ; } } }
Map files from source to target path
20,334
public function item ( $ offset ) { if ( isset ( $ this -> formulae [ $ offset ] ) ) { $ item = $ this -> formulae [ $ offset ] ; } else { $ item = null ; } return $ item ; }
Return paths relation
20,335
public function attach ( $ resource ) { if ( ! is_resource ( $ resource ) || "stream" !== get_resource_type ( $ resource ) ) { throw new \ InvalidArgumentException ( "Argument must be of the type stream resource, " . gettype ( $ resource ) . " given." ) ; } $ this -> resource = $ resource ; }
Attach resource .
20,336
public static function beginsWith ( $ subject , $ prefix , $ encoding = null ) { return Rope :: of ( $ subject , $ encoding ) -> beginsWith ( $ prefix ) ; }
Return whether or not the provided subject beings with the prefix .
20,337
public static function endsWith ( $ subject , $ suffix , $ encoding = null ) { return Rope :: of ( $ subject , $ encoding ) -> endsWith ( $ suffix ) ; }
Return whether or not the provided subject ends with suffix .
20,338
public static function contains ( $ subject , $ inner , $ encoding = null ) { return Rope :: of ( $ subject , $ encoding ) -> contains ( $ inner ) ; }
Return whether or not the subject contains the inner string .
20,339
public function listAction ( ) { $ subscriptionManager = $ this -> get ( 'phlexible_message.subscription_manager' ) ; $ subscriptions = [ ] ; foreach ( $ subscriptionManager -> findAll ( ) as $ subscription ) { $ subscriptions [ ] = [ 'id' => $ subscription -> getId ( ) , 'filterId' => $ subscription -> getFilter ( ) -> getId ( ) , 'filter' => $ subscription -> getFilter ( ) -> getTitle ( ) , 'handler' => $ subscription -> getHandler ( ) , ] ; } return new JsonResponse ( $ subscriptions ) ; }
List subscriptions .
20,340
public function createAction ( Request $ request ) { $ filterId = $ request -> get ( 'filter' ) ; $ handler = $ request -> get ( 'handler' ) ; $ subscriptionManager = $ this -> get ( 'phlexible_message.subscription_manager' ) ; $ filterManager = $ this -> get ( 'phlexible_message.filter_manager' ) ; $ filter = $ filterManager -> find ( $ filterId ) ; $ subscription = $ subscriptionManager -> create ( ) -> setUserId ( $ this -> getUser ( ) -> getId ( ) ) -> setFilter ( $ filter ) -> setHandler ( $ handler ) ; $ subscriptionManager -> updateSubscription ( $ subscription ) ; return new ResultResponse ( true , 'Subscription created.' ) ; }
Create subscription .
20,341
public function deleteAction ( $ id ) { $ subscriptionManager = $ this -> get ( 'phlexible_message.subscription_manager' ) ; $ subscription = $ subscriptionManager -> find ( $ id ) ; $ subscriptionManager -> deleteSubscription ( $ subscription ) ; return new ResultResponse ( true , 'Subscription deleted.' ) ; }
Delete subscription .
20,342
public function filterByStructureNodeId ( $ structureNodeId = null , $ comparison = null ) { if ( is_array ( $ structureNodeId ) ) { $ useMinMax = false ; if ( isset ( $ structureNodeId [ 'min' ] ) ) { $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_STRUCTURE_NODE_ID , $ structureNodeId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ structureNodeId [ 'max' ] ) ) { $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_STRUCTURE_NODE_ID , $ structureNodeId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_STRUCTURE_NODE_ID , $ structureNodeId , $ comparison ) ; }
Filter the query on the structure_node_id column
20,343
public function filterByParentId ( $ parentId = null , $ comparison = null ) { if ( is_array ( $ parentId ) ) { $ useMinMax = false ; if ( isset ( $ parentId [ 'min' ] ) ) { $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_PARENT_ID , $ parentId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ parentId [ 'max' ] ) ) { $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_PARENT_ID , $ parentId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( StructureNodeParentTableMap :: COL_PARENT_ID , $ parentId , $ comparison ) ; }
Filter the query on the parent_id column
20,344
public function useStructureNodeRelatedByStructureNodeIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinStructureNodeRelatedByStructureNodeId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'StructureNodeRelatedByStructureNodeId' , '\gossi\trixionary\model\StructureNodeQuery' ) ; }
Use the StructureNodeRelatedByStructureNodeId relation StructureNode object
20,345
public function useStructureNodeRelatedByParentIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinStructureNodeRelatedByParentId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'StructureNodeRelatedByParentId' , '\gossi\trixionary\model\StructureNodeQuery' ) ; }
Use the StructureNodeRelatedByParentId relation StructureNode object
20,346
public function setParams ( array $ params = [ ] ) { if ( empty ( $ params ) || count ( $ params ) < 4 ) { throw new \ InvalidArgumentException ( 'Missing required params for Octopush message' ) ; } foreach ( $ params as $ key => $ param ) { if ( ! in_array ( $ key , array_merge ( $ this -> requiredKeys , $ this -> optionalKeys ) ) ) { throw new \ InvalidArgumentException ( 'Missing required params for Octopush message' ) ; } } foreach ( $ params as $ key => $ value ) { $ method = 'set' . $ this -> setMethod ( $ key ) ; $ this -> $ method ( $ value ) ; } $ this -> params [ 'sending_time' ] = ( new \ DateTime ( ) ) -> getTimestamp ( ) ; if ( isset ( $ this -> params [ 'sending_date' ] ) ) { $ this -> params [ 'sms_mode' ] = static :: WITH_DELAY ; } if ( isset ( $ this -> params [ 'request_keys' ] ) ) { $ this -> params [ 'request_sha1' ] = $ this -> encrypt ( $ this -> params ) ; } if ( $ this -> params [ 'sms_type' ] === 'FR' ) { $ this -> params [ 'sms_text' ] .= PHP_EOL . 'STOP au XXXXX' ; } return $ this ; }
Set the parameters message
20,347
public function encrypt ( array $ params = [ ] ) { $ requestString = '' ; $ requestKey = $ this -> params [ 'request_keys' ] ; for ( $ i = 0 , $ n = strlen ( $ requestKey ) ; $ i < $ n ; ++ $ i ) { $ char = $ requestKey [ $ i ] ; if ( ! isset ( $ this -> encryptData [ $ char ] ) || ! isset ( $ params [ $ this -> encryptData [ $ char ] ] ) ) { continue ; } $ requestString .= $ params [ $ this -> encryptData [ $ char ] ] ; } return sha1 ( $ requestString ) ; }
Encoding request_sha1 Optionnel
20,348
public function setRequestMode ( $ mode ) { if ( ! in_array ( $ mode , [ 'real' , 'simu' ] ) ) { $ message = sprintf ( 'The request mode %s is not supported, real or simu expected!' , $ mode ) ; throw new \ InvalidArgumentException ( $ message , 500 ) ; } $ this -> params [ 'request_mode' ] = $ mode ; return $ this ; }
The request_mode param Optionnel
20,349
protected function parseDefinition ( $ definition = null ) { if ( is_null ( $ definition ) ) { if ( ! is_null ( $ this -> definition ) ) { throw new \ InvalidArgumentException ( 'Cannot parse rule definitions for rule "' . $ this -> name . '", attrib "' . $ this -> attrib -> getName ( ) . '" without definition!' ) ; } $ definition = $ this -> definition ; $ this -> definition = null ; } if ( is_string ( $ definition ) || is_callable ( $ definition ) ) { $ definition = array ( 'constraint' => $ definition ) ; } $ definition = array_merge ( self :: $ DEFAULT_ATTRIBS , $ definition ) ; $ this -> sufficient = $ definition [ 'sufficient' ] ; $ this -> skipEmpty = $ definition [ 'skipEmpty' ] ; $ this -> error = $ definition [ 'error' ] ; if ( is_callable ( $ definition [ 'constraint' ] ) && is_array ( $ definition [ 'constraint' ] ) ) { $ cb = $ definition [ 'constraint' ] ; $ definition [ 'constraint' ] = function ( ) use ( $ cb ) { $ args = func_get_args ( ) ; return call_user_func_array ( $ cb , $ args ) ; } ; } elseif ( is_string ( $ definition [ 'constraint' ] ) ) { $ args = preg_split ( '/:/' , $ definition [ 'constraint' ] ) ; $ method = 'rule' . array_shift ( $ args ) ; $ found = false ; foreach ( $ this -> dataFilter -> getPredefinedRuleClasses ( ) as $ className ) { if ( is_callable ( array ( $ className , $ method ) ) && method_exists ( $ className , $ method ) ) { $ definition [ 'constraint' ] = call_user_func_array ( array ( $ className , $ method ) , $ args ) ; $ found = true ; break ; } } if ( ! $ found ) { throw new \ InvalidArgumentException ( 'Could not use constraint "' . $ definition [ 'constraint' ] . '" for rule "' . $ this -> name . '", attrib "' . $ this -> attrib -> getName ( ) . '" because no ' . 'predefined rule class found implementing "' . $ method . '()"' ) ; } } $ constraintClass = is_object ( $ definition [ 'constraint' ] ) ? get_class ( $ definition [ 'constraint' ] ) : '(Scalar)' ; if ( $ constraintClass !== 'Closure' ) { throw new \ InvalidArgumentException ( 'Definition for rule "' . $ this -> name . '", attrib "' . $ this -> attrib -> getName ( ) . '"' . ' has an invalid constraint of class ' . $ constraintClass ) ; } $ this -> constraint = $ definition [ 'constraint' ] ; }
The long description
20,350
public function getError ( \ DataFilter \ Attribute $ attrib = null ) { if ( $ this -> error === false ) { return null ; } if ( ! $ attrib ) { $ attrib = $ this -> attrib ; } $ formatData = array ( 'rule' => $ this -> name ) ; if ( $ attrib ) { $ formatData [ 'attrib' ] = $ attrib -> getName ( ) ; } $ error = $ this -> error ; if ( ! $ error && $ attrib ) { $ error = $ attrib -> getDefaultErrorStr ( ) ; } if ( ! $ error ) { $ error = $ this -> dataFilter -> getErrorTemplate ( ) ; } return U :: formatString ( $ error , $ formatData ) ; }
Returns error string or null
20,351
public function isAssignableFrom ( Type $ type ) { if ( ! $ type instanceof ArrayType ) return false ; if ( ! $ type -> itemType -> equals ( $ this -> itemType ) ) return false ; if ( ! $ type -> keyType -> equals ( $ this -> keyType ) ) return false ; return true ; }
Checks whether the provided type represents an array whose key and value type are equal to the key and value type of this instance .
20,352
public function isAssignableFromValue ( $ value ) { if ( ! is_array ( $ value ) ) return false ; foreach ( $ value as $ key => $ item ) { if ( ! $ this -> itemType -> isAssignableFromValue ( $ item ) ) return false ; if ( ! $ this -> keyType -> isAssignableFromValue ( $ key ) ) return false ; } return true ; }
Checks whether the provided value is an array and all keys and values are assignable to the key and value type of this instance .
20,353
public function indexAction ( ) { $ output = '' ; $ output .= '<a href="' . $ this -> generateUrl ( 'gui_status_listeners' ) . '">listeners</a><br/>' ; $ output .= '<a href="' . $ this -> generateUrl ( 'gui_status_php' ) . '">php</a><br/>' ; $ output .= '<a href="' . $ this -> generateUrl ( 'gui_status_load' ) . '">load</a><br/>' ; return new Response ( $ output ) ; }
List status actions .
20,354
public function listenersAction ( ) { $ dispatcher = $ this -> get ( 'event_dispatcher' ) ; $ listenerNames = array_keys ( $ dispatcher -> getListeners ( ) ) ; sort ( $ listenerNames ) ; $ output = '<pre>' ; $ output .= str_repeat ( '=' , 3 ) . str_pad ( ' Events / Listeners ' , 80 , '=' ) . PHP_EOL . PHP_EOL ; foreach ( $ listenerNames as $ listenerName ) { $ listeners = $ dispatcher -> getListeners ( $ listenerName ) ; $ output .= $ listenerName . ' (<a href="#' . $ listenerName . '">' . count ( $ listeners ) . ' listeners</a>)' . PHP_EOL ; } foreach ( $ listenerNames as $ listenerName ) { $ listeners = $ dispatcher -> getListeners ( $ listenerName ) ; if ( ! $ listenerName ) { $ listenerName = '(global)' ; } $ output .= PHP_EOL . PHP_EOL . str_repeat ( '-' , 3 ) . '<a name="' . $ listenerName . '"></a>' . str_pad ( ' ' . $ listenerName . ' ' , 80 , '-' ) . PHP_EOL . PHP_EOL ; foreach ( $ listeners as $ listener ) { if ( is_array ( $ listener ) ) { if ( is_object ( $ listener [ 0 ] ) ) { $ listener = get_class ( $ listener [ 0 ] ) . '->' . $ listener [ 1 ] . '()' ; } else { $ listener = implode ( '::' , $ listener ) . '()' ; } } $ output .= '* ' . $ listener . PHP_EOL ; } } return new Response ( $ output ) ; }
Show events .
20,355
public function addBuyerHubRefAsBuyer ( BuyerHubRef $ buyerHubRef ) { if ( ! count ( $ this -> buyerHubRefsAsBuyer ) ) { $ buyerHubRef -> setIsDefault ( true ) ; } $ this -> buyerHubRefsAsBuyer [ ] = $ buyerHubRef ; $ buyerHubRef -> setBuyer ( $ this ) ; }
Add BuyerHubRef as Buyer
20,356
public function addSellerHubRefAsSeller ( SellerHubRef $ sellerHubRef ) { if ( ! count ( $ this -> sellerHubRefsAsSeller ) ) { $ sellerHubRef -> setIsDefault ( true ) ; } $ this -> sellerHubRefsAsSeller [ ] = $ sellerHubRef ; $ sellerHubRef -> setSeller ( $ this ) ; }
Add SellerHubRef as Seller
20,357
public function getAccountByCode ( $ type_code ) { switch ( $ type_code ) { case Account :: TYPE_ACCOUNTS_RECEIVABLE : case Account :: TYPE_ACCOUNTS_PAYABLE : case Account :: TYPE_SALES : case Account :: TYPE_BANK : foreach ( $ this -> getAccounts ( ) as $ account ) { if ( $ account -> getTypeCode ( ) == $ type_code ) { return $ account ; } } $ account = new Account ( ) ; $ account -> setBalance ( 0 ) ; $ account -> setProfile ( $ this ) ; $ account -> setTypeCode ( $ type_code ) ; $ account -> setName ( $ this -> getName ( ) . Account :: getAccountNameSuffix ( $ type_code ) ) ; return $ account ; default : throw new \ Exception ( 'Invalid account code: ' . $ account_code ) ; } }
Get Profile s account by code
20,358
public function can ( $ permission , $ requireAll = false ) { if ( $ this -> cachedRoles ( ) -> where ( 'name' , 'admin' ) -> count ( ) ) { return true ; } return $ this -> entrustCan ( $ permission , $ requireAll = false ) ; }
Check if user has a permission by its name . return rearly if the user is in the admin group .
20,359
final public static function fromString ( string $ token ) : self { if ( Binary :: safeStrlen ( $ token ) < self :: TOKEN_CHAR_LENGTH ) { throw new \ RuntimeException ( 'Invalid token provided.' ) ; } $ instance = new static ( ) ; $ instance -> token = new HiddenString ( $ token ) ; $ instance -> selector = Binary :: safeSubstr ( $ token , 0 , 32 ) ; $ instance -> verifier = Binary :: safeSubstr ( $ token , 32 ) ; $ instance -> verifierHash = null ; \ sodium_memzero ( $ token ) ; return $ instance ; }
Recreates a SplitToken object from a string .
20,360
public function toValueHolder ( array $ metadata = [ ] ) : SplitTokenValueHolder { if ( null === $ this -> verifierHash ) { throw new \ RuntimeException ( 'toValueHolder() does not work SplitToken object created with fromString().' ) ; } return new SplitTokenValueHolder ( $ this -> selector , $ this -> verifierHash , $ this -> expiresAt , $ metadata , $ this ) ; }
Produce a new SplitTokenValue instance .
20,361
private function findAvailableParameterValue ( ReflectionParameter $ p , array $ availableParameters ) { $ isClass = null !== $ p -> getClass ( ) ; if ( $ isClass ) { $ parameterName = $ p -> getClass ( ) -> getName ( ) ; } else { $ parameterName = $ p -> getName ( ) ; } if ( array_key_exists ( $ parameterName , $ availableParameters ) ) { return $ availableParameters [ $ parameterName ] ; } if ( $ p -> isDefaultValueAvailable ( ) ) { return $ p -> getDefaultValue ( ) ; } throw new BadFunctionCallException ( sprintf ( 'parameter "%s" expected by callback not available' , $ parameterName ) ) ; }
Find the parameter required by the callback .
20,362
public static function isValid ( $ port ) { $ port_valid = false ; if ( is_int ( $ port ) ) { $ port_valid = self :: portIsInValidRange ( $ port ) ; } elseif ( is_null ( $ port ) ) { $ port_valid = true ; } return $ port_valid ; }
Validates a given port . A port is valid if it is either null or an integer between 1 and 65535 inclusive .
20,363
public function toUriString ( Scheme $ scheme = null ) { $ normalized_port = $ this -> normalizePortAgainstScheme ( $ scheme ) ; $ uri_string = ( string ) $ normalized_port ; if ( ! is_null ( $ normalized_port ) ) { $ uri_string = ":" . $ uri_string ; } return $ uri_string ; }
Returns a string representation of the port formatted so that it can be compiled into a complete URI string per the Uri object s string specification .
20,364
public function normalizePortAgainstScheme ( Scheme $ scheme = null ) { $ scheme_port_array = new ArrayHelper ( $ this -> scheme_ports ) ; $ scheme_string = ( string ) $ scheme ; $ standard_port = $ scheme_port_array -> valueLookup ( $ scheme_string ) ; if ( $ this -> port == $ standard_port ) { $ normalized_port = null ; } else { $ normalized_port = $ this -> port ; } return $ normalized_port ; }
Normalizes the port against a given scheme so that the scheme is reported as null if the port is standard for the scheme .
20,365
public function menu ( $ name ) { if ( array_key_exists ( $ name , $ this -> menus ) ) { return $ this -> menus [ $ name ] ; } return $ this -> menus [ $ name ] = new MenuBuilder ( $ name , $ this -> config ) ; }
Create MenuItem for specified menu .
20,366
public function getItemUuiD ( $ menuItem ) { $ itemID = '' ; if ( is_a ( $ menuItem , MenuItem :: class ) ) { $ itemID = 'MenuItem' . $ menuItem -> getURL ( ) ; } if ( is_a ( $ menuItem , MenuBuilder :: class ) ) { $ itemID = 'MenuBuilder' . $ menuItem -> getName ( ) ; } return Str :: limit ( md5 ( Str :: slug ( $ itemID ) ) , 12 , null ) ; }
Generate Item uuid .
20,367
public function delete ( $ key ) { if ( $ this -> has ( $ key ) ) { unset ( $ this -> collection [ $ key ] ) ; return true ; } return false ; }
Entfernt ein Element aus der Collection .
20,368
protected function generate ( FileGenerator $ generator ) { $ fqcn = $ this -> convertToFullQualifyClassName ( $ this -> getNameInput ( ) ) ; $ path = $ this -> getRelativePath ( $ fqcn ) . '.php' ; if ( $ generator -> exists ( $ path ) ) { $ this -> error ( $ this -> type . ' already exists!' ) ; return false ; } return $ this -> generateFile ( $ generator , $ path , $ fqcn ) ; }
Generate files .
20,369
public function PHPErrorHandler ( $ error_level , $ error_message , $ error_file , $ error_line , $ error_context ) { $ message = $ error_message . ' | File: {file} | Ln: {line}' ; $ context = array ( 'file' => $ error_file , 'line' => $ error_line ) ; switch ( $ error_level ) { case E_USER_ERROR : case E_RECOVERABLE_ERROR : $ this -> logger -> error ( $ message , $ context ) ; break ; case E_WARNING : case E_USER_WARNING : $ this -> logger -> warning ( $ message , $ context ) ; break ; case E_NOTICE : case E_USER_NOTICE : $ this -> logger -> notice ( $ message , $ context ) ; break ; case E_STRICT : $ this -> logger -> debug ( $ message , $ context ) ; break ; default : $ this -> logger -> warning ( $ message , $ context ) ; } return ; }
Logger provided error handler
20,370
public function PHPShutdownHandler ( ) { session_write_close ( ) ; if ( $ lasterror = error_get_last ( ) ) { $ message = $ lasterror [ 'message' ] . ' | File: {file} | Ln: {line}' ; $ context = array ( 'file' => $ lasterror [ 'file' ] , 'line' => $ lasterror [ 'line' ] ) ; $ this -> logger -> log ( $ this -> shutdownLogLevel , $ message , $ context ) ; } }
Logger provided shutdown handler
20,371
public function PHPExceptionHandler ( $ exception ) { session_write_close ( ) ; $ message = $ exception -> getMessage ( ) . ' | File: {file} | Ln: {line} | ST: {stacktrace}' ; $ context = array ( 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'stacktrace' => $ exception -> getTraceAsString ( ) ) ; $ this -> logger -> log ( $ this -> exceptionLogLevel , $ message , $ context ) ; }
Logger provided uncaught Exception handler
20,372
private function installAssets ( \ TridentKernel $ kernel , $ name , $ from , OutputInterface $ output ) { $ output -> write ( sprintf ( 'Installing assets for "%s"' , $ name ) ) ; $ filesystem = new FileSystem ( ) ; if ( ! $ filesystem -> exists ( $ from ) ) { $ output -> writeln ( '... <comment>N/A</comment>' ) ; return ; } try { $ filesystem -> symlink ( $ from , $ kernel -> getAssetDir ( ) . '/' . strtolower ( $ name ) ) ; $ output -> writeln ( '... <info>Done</info>' ) ; } catch ( IOExceptionInterface $ e ) { $ output -> writeln ( '... <error>Error</error>' ) ; } }
Install assets from on directory to another .
20,373
private function flushAssets ( \ TridentKernel $ kernel , OutputInterface $ output ) { $ filesystem = new FileSystem ( ) ; $ output -> write ( 'Clearing existing assets' ) ; try { if ( $ filesystem -> exists ( $ kernel -> getAssetDir ( ) ) ) { $ filesystem -> remove ( $ kernel -> getAssetDir ( ) ) ; } $ output -> writeln ( '... <info>Done</info>' ) ; $ output -> writeln ( '' ) ; return true ; } catch ( \ Exception $ e ) { $ output -> writeln ( '... <error>Error</error>' ) ; $ output -> writeln ( '' ) ; return false ; } }
Flush all existing assets
20,374
public function login ( $ lgname , $ lgpassword , $ lgdomain = null ) { $ path = '?action=login&lgname=' . $ lgname . '&lgpassword=' . $ lgpassword ; if ( isset ( $ lgdomain ) ) { $ path .= '&lgdomain=' . $ lgdomain ; } $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , null ) ; $ path = '?action=login&lgname=' . $ lgname . '&lgpassword=' . $ lgpassword . '&lgtoken=' . $ this -> validateResponse ( $ response ) -> login [ 'token' ] ; if ( isset ( $ lgdomain ) ) { $ path .= '&lgdomain=' . $ lgdomain ; } $ headers = ( array ) $ this -> options -> get ( 'headers' ) ; $ headers [ 'Cookie' ] = ! empty ( $ headers [ 'Cookie' ] ) ? empty ( $ headers [ 'Cookie' ] ) : '' ; $ headers [ 'Cookie' ] = $ headers [ 'Cookie' ] . $ response -> headers [ 'Set-Cookie' ] ; $ this -> options -> set ( 'headers' , $ headers ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , null ) ; $ responseBody = $ this -> validateResponse ( $ response ) ; $ headers = ( array ) $ this -> options -> get ( 'headers' ) ; $ cookiePrefix = $ responseBody -> login [ 'cookieprefix' ] ; $ cookie = $ cookiePrefix . 'UserID=' . $ responseBody -> login [ 'lguserid' ] . '; ' . $ cookiePrefix . 'UserName=' . $ responseBody -> login [ 'lgusername' ] ; $ headers [ 'Cookie' ] = $ headers [ 'Cookie' ] . '; ' . $ response -> headers [ 'Set-Cookie' ] . '; ' . $ cookie ; $ this -> options -> set ( 'headers' , $ headers ) ; return $ this -> validateResponse ( $ response ) ; }
Method to login and get authentication tokens .
20,375
public function logout ( ) { $ path = '?action=login' ; $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to logout and clear session data .
20,376
public function getUserInfo ( array $ ususers , array $ usprop = null ) { $ path = '?action=query&list=users' ; $ path .= '&ususers=' . $ this -> buildParameter ( $ ususers ) ; if ( isset ( $ usprop ) ) { $ path .= '&usprop' . $ this -> buildParameter ( $ usprop ) ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get user information .
20,377
public function getCurrentUserInfo ( array $ uiprop = null ) { $ path = '?action=query&meta=userinfo' ; if ( isset ( $ uiprop ) ) { $ path .= '&uiprop' . $ this -> buildParameter ( $ uiprop ) ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get current user information .
20,378
public function getUserContribs ( $ ucuser = null , $ ucuserprefix = null , $ uclimit = null , $ ucstart = null , $ ucend = null , $ uccontinue = null , $ ucdir = null , array $ ucnamespace = null , array $ ucprop = null , array $ ucshow = null , $ uctag = null , $ uctoponly = null ) { $ path = '?action=query&list=usercontribs' ; if ( isset ( $ ucuser ) ) { $ path .= '&ucuser=' . $ ucuser ; } if ( isset ( $ ucuserprefix ) ) { $ path .= '&ucuserprefix=' . $ ucuserprefix ; } if ( isset ( $ uclimit ) ) { $ path .= '&uclimit=' . $ uclimit ; } if ( isset ( $ ucstart ) ) { $ path .= '&ucstart=' . $ ucstart ; } if ( isset ( $ ucend ) ) { $ path .= '&ucend=' . $ ucend ; } if ( $ uccontinue ) { $ path .= '&uccontinue=' ; } if ( isset ( $ ucdir ) ) { $ path .= '&ucdir=' . $ ucdir ; } if ( isset ( $ ucnamespace ) ) { $ path .= '&ucnamespace=' . $ this -> buildParameter ( $ ucnamespace ) ; } if ( isset ( $ ucprop ) ) { $ path .= '&ucprop=' . $ this -> buildParameter ( $ ucprop ) ; } if ( isset ( $ ucshow ) ) { $ path .= '&ucshow=' . $ this -> buildParameter ( $ ucshow ) ; } if ( isset ( $ uctag ) ) { $ path .= '&uctag=' . $ uctag ; } if ( isset ( $ uctoponly ) ) { $ path .= '&uctoponly=' . $ uctoponly ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get user contributions .
20,379
public function blockUser ( $ user , $ expiry = null , $ reason = null , $ anononly = null , $ nocreate = null , $ autoblock = null , $ noemail = null , $ hidename = null , $ allowusertalk = null , $ reblock = null , $ watchuser = null ) { $ token = $ this -> getToken ( $ user , 'block' ) ; $ path = '?action=unblock' ; $ data = array ( 'user' => $ user , 'token' => $ token , 'expiry' => $ expiry , 'reason' => $ reason , 'anononly' => $ anononly , 'nocreate' => $ nocreate , 'autoblock' => $ autoblock , 'noemail' => $ noemail , 'hidename' => $ hidename , 'allowusetalk' => $ allowusertalk , 'reblock' => $ reblock , 'watchuser' => $ watchuser , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to block a user .
20,380
public function assignGroup ( $ username , $ add = null , $ remove = null , $ reason = null ) { $ token = $ this -> getToken ( $ username , 'unblock' ) ; $ path = '?action=userrights' ; $ data = array ( 'username' => $ username , 'token' => $ token , 'add' => $ add , 'remove' => $ remove , 'reason' => $ reason , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to assign a user to a group .
20,381
public function emailUser ( $ target , $ subject = null , $ text = null , $ ccme = null ) { $ token = $ this -> getToken ( $ target , 'emailuser' ) ; $ path = '?action=emailuser' ; $ data = array ( 'target' => $ target , 'token' => $ token , 'subject' => $ subject , 'text' => $ text , 'ccme' => $ ccme , ) ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , $ data ) ; return $ this -> validateResponse ( $ response ) ; }
Method to email a user .
20,382
public function getCaptured ( $ i ) { if ( $ this -> success ) { if ( $ i >= 0 ) { $ i ++ ; if ( array_key_exists ( $ i , $ this -> matches ) ) { return new Group ( $ this -> matches [ $ i ] ) ; } else { throw new RuntimeException ( "The index " . $ i . " does not identify any captured subpattern" ) ; } } else { throw new RuntimeException ( "Negative indexes are not allowed" ) ; } } else { throw new RuntimeException ( "The matching was not succesfull" ) ; } }
Return a captured group .
20,383
public function BeginExport ( $ Path , $ Source = '' ) { $ this -> BeginTime = microtime ( TRUE ) ; $ TimeStart = list ( $ sm , $ ss ) = explode ( ' ' , microtime ( ) ) ; if ( $ this -> UseCompression && function_exists ( 'gzopen' ) ) $ fp = gzopen ( $ Path , 'wb' ) ; else $ fp = fopen ( $ Path , 'wb' ) ; $ this -> _File = $ fp ; fwrite ( $ fp , 'Vanilla Export: ' . $ this -> Version ( ) ) ; if ( $ Source ) fwrite ( $ fp , self :: DELIM . ' Source: ' . $ Source ) ; fwrite ( $ fp , self :: NEWLINE . self :: NEWLINE ) ; $ this -> Comment ( 'Exported Started: ' . date ( 'Y-m-d H:i:s' ) ) ; }
Create the export file and begin the export .
20,384
public function Comment ( $ Message , $ Echo = TRUE ) { fwrite ( $ this -> _File , self :: COMMENT . ' ' . str_replace ( self :: NEWLINE , self :: NEWLINE . self :: COMMENT . ' ' , $ Message ) . self :: NEWLINE ) ; if ( $ Echo ) echo $ Message , "\n" ; }
Write a comment to the export file .
20,385
public function PDO ( $ DsnOrPDO = NULL , $ Username = NULL , $ Password = NULL ) { if ( ! is_null ( $ DsnOrPDO ) ) { if ( $ DsnOrPDO instanceof PDO ) $ this -> _PDO = $ DsnOrPDO ; else { $ this -> _PDO = new PDO ( $ DsnOrPDO , $ Username , $ Password ) ; if ( strncasecmp ( $ DsnOrPDO , 'mysql' , 5 ) == 0 ) $ this -> _PDO -> exec ( 'set names utf8' ) ; } } return $ this -> _PDO ; }
Gets or sets the PDO connection to the database .
20,386
public function has ( MongoCollection $ dataGateway , $ id ) { $ id = ( string ) $ id ; if ( ! $ this -> splObjectStorage -> contains ( $ dataGateway ) ) { return false ; } if ( isset ( $ this -> splObjectStorage [ $ dataGateway ] [ $ id ] ) ) { return true ; } return false ; }
Check whether the given data gateway exists in the current store
20,387
public function get ( MongoCollection $ dataGateway , $ id ) { $ id = ( string ) $ id ; if ( $ this -> has ( $ dataGateway , $ id ) ) { return $ this -> splObjectStorage [ $ dataGateway ] [ $ id ] ; } }
Retrieve the given data gateway from the store
20,388
public function getRevisionNumber ( $ revisionNumber , $ columnList = array ( '*' ) ) { $ query = $ this -> deriveRevisions ( ) ; if ( $ revisionNumber > 1 ) { $ query -> skip ( $ revisionNumber - 1 ) -> take ( 1 ) ; } return $ query -> get ( $ columnList ) -> first ( ) ; }
Gets a single revision from the list .
20,389
public static function removeExpired ( array $ where = array ( ) ) { if ( static :: $ revisionCount <= 0 ) { return TRUE ; } if ( static :: hasAlternateRevisionTable ( ) ) { $ query = \ DB :: table ( static :: $ revisionTable ) ; } else { $ query = self :: onlyTrashed ( ) ; } if ( count ( $ where ) > 0 ) { foreach ( $ where as $ key => $ value ) { $ query -> where ( $ key , '=' , $ value ) ; } } if ( count ( static :: $ keyColumns ) > 0 ) { foreach ( static :: $ keyColumns as $ column ) { $ query -> groupBy ( $ column ) ; } $ query -> having ( \ DB :: raw ( 'count(1)' ) , '>' , static :: $ revisionCount ) -> addSelect ( static :: $ keyColumns ) ; } else { $ query -> where ( \ DB :: raw ( 'count(1)' ) , '>' , static :: $ revisionCount ) ; } $ ids = array ( ) ; foreach ( $ query -> get ( ) as $ row ) { if ( static :: hasAlternateRevisionTable ( ) ) { $ filter = \ DB :: table ( static :: $ revisionTable ) ; } else { $ filter = self :: onlyTrashed ( ) ; } foreach ( static :: $ keyColumns as $ column ) { $ filter -> where ( $ column , '=' , $ row -> $ column ) ; } $ filter -> skip ( static :: $ revisionCount ) -> take ( PHP_INT_MAX ) -> orderBy ( 'created_at' , 'desc' ) -> addSelect ( 'id' ) ; foreach ( $ filter -> get ( ) as $ id ) { $ ids [ ] = $ id -> id ; } } if ( count ( $ ids ) > 0 ) { if ( static :: hasAlternateRevisionTable ( ) ) { $ delete = \ DB :: table ( static :: $ revisionTable ) ; } else { $ delete = self :: onlyTrashed ( ) ; } $ delete -> whereIn ( 'id' , $ ids ) ; if ( static :: hasAlternateRevisionTable ( ) ) { $ delete -> delete ( ) ; } else { $ delete -> forceDelete ( ) ; } } return TRUE ; }
Used in order to get rid of any expired revisions .
20,390
private function deriveRevisions ( ) { $ query = NULL ; if ( $ this -> hasAlternateRevisionTable ( ) ) { $ query = \ DB :: table ( static :: $ revisionTable ) ; } else { $ query = self :: onlyTrashed ( ) ; } foreach ( static :: $ keyColumns as $ column ) { $ query -> where ( $ column , '=' , $ this -> $ column ) ; } if ( static :: $ revisionCount > 0 ) { $ query -> take ( $ this -> revisionCount ) ; } return $ query -> orderBy ( 'created_at' , 'desc' ) ; }
Used in order to derive the actual query that is used to grab the revisions .
20,391
public static function filterRecursive ( array $ array , $ callback = null , $ removeEmptyArrays = false ) { if ( null !== $ callback && ! is_callable ( $ callback ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Second parameter of %s must be callable' , __METHOD__ ) ) ; } foreach ( $ array as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ value = static :: filterRecursive ( $ value , $ callback , $ removeEmptyArrays ) ; if ( $ removeEmptyArrays && ! ( bool ) $ value ) { unset ( $ array [ $ key ] ) ; } } else { if ( null !== $ callback && ! $ callback ( $ value ) ) { unset ( $ array [ $ key ] ) ; } elseif ( ! ( bool ) $ value ) { unset ( $ array [ $ key ] ) ; } } } unset ( $ value ) ; return $ array ; }
Exactly the same as array_filter except this function filters within multi - dimensional arrays
20,392
public function report ( string ... $ messages ) : ResultInterface { if ( ! empty ( $ messages ) ) { return ResultFactory :: makeFailure ( $ this -> checker , array_merge ( [ $ this -> failureMessage ] , $ messages ) ) ; } return ResultFactory :: makeSuccess ( $ this -> checker ) ; }
Returns result instance .
20,393
public function save ( $ key , $ content , $ ttl ) { $ cacheFile = $ this -> getCachePath ( $ key ) ; $ cache = json_encode ( [ 'ttl' => ( time ( ) + $ ttl ) , 'content' => $ content ] ) ; file_put_contents ( $ cacheFile , $ cache ) ; return true ; }
Save the given content into cache .
20,394
private function getCachePath ( $ cacheKey ) { $ folder = $ this -> cacheDir . substr ( $ cacheKey , 0 , 2 ) . DIRECTORY_SEPARATOR . substr ( $ cacheKey , 2 , 2 ) . DIRECTORY_SEPARATOR . substr ( $ cacheKey , 4 , 2 ) . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ folder ) ) { mkdir ( $ folder , 0755 , true ) ; } return $ folder . $ cacheKey ; }
Creates the cache folder hierarchy and returns the full path to the given cache file .
20,395
public static function getRelationInfo ( $ name , $ info = array ( ) ) { $ class = new \ ReflectionClass ( get_called_class ( ) ) ; $ namespace = $ class -> getNamespaceName ( ) ; $ info [ 'name' ] = $ name ; if ( ! isset ( $ info [ 'model' ] ) ) { $ info [ 'model' ] = Inflector :: modelise ( $ name ) ; } if ( strpos ( $ info [ 'model' ] , '\\' ) === false ) { $ info [ 'model' ] = "\\{$namespace}\\{$info['model']}" ; } $ model = new \ ReflectionClass ( $ info [ 'model' ] ) ; $ info [ 'class' ] = $ model -> getShortName ( ) ; return $ info ; }
Returns an array containing information about the relation .
20,396
public function belongsTo ( $ model , $ options = array ( ) ) { if ( isset ( $ this -> _relationsCache [ $ model ] ) ) { return $ this -> _relationsCache [ $ model ] ; } $ options = static :: getRelationInfo ( $ model , $ options ) ; if ( ! isset ( $ options [ 'localKey' ] ) ) { $ options [ 'localKey' ] = Inflector :: foreignKey ( $ model ) ; } if ( ! isset ( $ options [ 'foreignKey' ] ) ) { $ options [ 'foreignKey' ] = $ options [ 'model' ] :: primaryKey ( ) ; } return $ this -> _relationsCache [ $ model ] = $ options [ 'model' ] :: select ( ) -> where ( "{$options['foreignKey']} = ?" , $ this -> { $ options [ 'localKey' ] } ) -> fetch ( ) ; }
Returns the owning object .
20,397
public function hasMany ( $ model , $ options = array ( ) ) { $ options = static :: getRelationInfo ( $ model , $ options ) ; if ( ! isset ( $ options [ 'localKey' ] ) ) { $ options [ 'localKey' ] = static :: primaryKey ( ) ; } if ( ! isset ( $ options [ 'foreignKey' ] ) ) { $ options [ 'foreignKey' ] = Inflector :: foreignKey ( static :: table ( ) ) ; } return $ options [ 'model' ] :: select ( ) -> where ( "{$options['foreignKey']} = ?" , $ this -> { $ options [ 'localKey' ] } ) -> mergeNextWhere ( ) ; }
Returns an array of owned objects .
20,398
public function validate ( $ subject ) : bool { $ subject = $ this -> removePropertiesFromSubject ( $ subject , $ this -> schema ) ; $ subject = $ this -> removePatternPropertiesFromSubject ( $ subject , $ this -> schema ) ; if ( \ is_bool ( $ this -> schema [ 'additionalProperties' ] ) && $ this -> schema [ 'additionalProperties' ] === false ) { if ( count ( $ subject ) > 0 ) { return false ; } } elseif ( \ is_array ( $ this -> schema [ 'additionalProperties' ] ) ) { foreach ( $ subject as $ propertyValue ) { $ nodeValidator = new NodeValidator ( $ this -> schema [ 'additionalProperties' ] , $ this -> rootSchema ) ; if ( ! $ nodeValidator -> validate ( $ propertyValue ) ) { return false ; } } } return true ; }
Validates subject against additionalProperties
20,399
private function removePropertiesFromSubject ( array $ subject , array $ schema ) : array { if ( isset ( $ schema [ 'properties' ] ) && \ is_array ( $ schema [ 'properties' ] ) ) { $ propertyNames = \ array_keys ( $ schema [ 'properties' ] ) ; foreach ( $ propertyNames as $ propertyName ) { if ( isset ( $ subject [ $ propertyName ] ) ) { unset ( $ subject [ $ propertyName ] ) ; } } } return $ subject ; }
Removes properties defined in properties from subject