idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
2,800
public function sortByDimensionName ( $ direction ) { if ( $ this -> id != '$name' && $ this -> id != '$value' ) { throw new AnalyticsDbException ( 'In order to sort by dimension name, you need to first group by dimension name or dimension value.' ) ; } $ direction = ( int ) $ direction ; if ( $ this -> id == '$name' )...
Sort records by dimension name .
2,801
public function sortByDimensionValue ( $ direction ) { if ( $ this -> id != '$value' ) { throw new AnalyticsDbException ( 'In order to sort by dimension value, you need to first group by dimension value.' ) ; } $ direction = ( int ) $ direction ; $ this -> pipeline [ '$sort' ] = [ '_id.value' => $ direction ] ; return ...
Sort records by dimension value .
2,802
public function loadLanguage ( $ code ) { static $ languages_seen = array ( ) ; if ( isset ( $ this -> cache [ $ code ] ) ) return ; $ filename = $ this -> dir . '/Language/messages/' . $ code . '.php' ; $ fallback = ( $ code != 'en' ) ? 'en' : false ; if ( ! file_exists ( $ filename ) ) { $ filename = $ this -> dir . ...
Loads language into the cache handles message file and fallbacks
2,803
public function setCasServer ( $ server ) { $ this -> casServer = $ server ; $ this -> guzzleClient = new Client ( [ 'base_uri' => $ server , 'cookies' => true ] ) ; }
Set the CAS server URL
2,804
public function setTGT ( $ tgt ) { $ this -> tgt = $ tgt ; $ this -> tgtLocation = $ this -> casServer . $ this -> casRESTcontext . '/' . $ tgt ; }
Accepts the Ticket - Granting Ticket from the app running the client .
2,805
public function logout ( ) { $ this -> checkTgtExists ( ) ; $ this -> guzzleClient -> delete ( $ this -> tgtLocation ) ; $ this -> tgtLocation = null ; $ this -> tgt = null ; if ( $ this -> tgtStorageLocation ) { unlink ( $ this -> tgtStorageLocation ) ; } return true ; }
Logout of the CAS session and destroy the TGT .
2,806
public function post ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'POST' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP POST operation .
2,807
public function patch ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'PATCH' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP PATCH operation .
2,808
public function head ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'HEAD' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP HEAD operation .
2,809
public function put ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'PUT' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP PUT operation .
2,810
public function options ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'OPTIONS' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP OPTIONS operation .
2,811
public function delete ( $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { return $ this -> callRestService ( 'DELETE' , $ service , $ headers , $ body , $ form_params ) ; }
Request a Service Ticket for the CAS server and perform a HTTP DELETE operation .
2,812
private function callRestService ( $ method , $ service , $ headers = [ ] , $ body = '' , $ form_params = [ ] ) { $ this -> checkTgtExists ( ) ; $ serviceTicket = $ this -> getServiceTicket ( $ service ) ; if ( strpos ( $ service , '?' ) === false ) { $ finalService = $ service . '?ticket=' . $ serviceTicket ; } else {...
Set up and execute a REST request .
2,813
private function getServiceTicket ( $ service ) { try { $ response = $ this -> guzzleClient -> request ( 'POST' , $ this -> tgtLocation , [ 'verify' => $ this -> verifySSL , 'form_params' => [ 'service' => $ service ] ] ) ; return ( string ) $ response -> getBody ( ) ; } catch ( ClientException $ e ) { if ( $ e -> getC...
Request Service ticket from CAS server
2,814
public function login ( $ tgtStorageLocation = '' , $ forceAuth = false ) { if ( ( ! $ this -> casServer ) || ( ! $ this -> casPassword ) || ( ! $ this -> casUsername ) ) { throw new \ Exception ( 'CAS server and credentials must be set before calling login()' , 1 ) ; } $ this -> tgtStorageLocation = $ tgtStorageLocati...
Validate credentials against the CAS server and retrieve a Ticket - Granting Ticket . If a tgtStorageLocation is specified the fle is read and the saved TGT is used instead of validating credentials . If force_auth is TRUE always validate credentials .
2,815
private function loadTGTfromFile ( $ tgtStorageLocation ) { $ tgtStorageData = json_decode ( file_get_contents ( $ tgtStorageLocation ) , true ) ; if ( $ tgtStorageData [ 'username' ] ) { $ this -> casUsername = $ tgtStorageData [ 'username' ] ; } else { throw new \ Exception ( 'TGT storage missing "username" value!' ,...
Read the TGT data from a file
2,816
private function writeTGTtoFile ( $ tgtStorageLocation , $ tgt ) { $ tgtStorageData = [ 'TGT' => $ tgt , 'username' => $ this -> casUsername , 'server' => $ this -> casServer , 'context' => $ this -> casRESTcontext , 'saved' => time ( ) ] ; file_put_contents ( $ tgtStorageLocation , json_encode ( $ tgtStorageData ) ) ;...
Save the TGT data to a local file
2,817
public function create ( $ level , $ message ) { $ this -> next [ ] = [ 'level' => $ level , 'message' => $ message ] ; $ this -> session -> flash ( $ this -> key , $ this -> next ) ; return $ this ; }
Create a new flash message .
2,818
public function again ( ) { $ this -> next = $ this -> current -> map ( function ( $ item ) { return $ item -> toArray ( ) ; } ) -> merge ( $ this -> next ) -> toArray ( ) ; $ this -> session -> keep ( [ $ this -> key ] ) ; }
Reflash message to next session .
2,819
public function get ( $ level = null ) { if ( isset ( $ level ) ) { return $ this -> getMessage ( ) ; } return $ this -> current -> where ( 'level' , $ level ) ; }
Get the current flash message .
2,820
private function getFromSession ( ) { if ( $ this -> exists ( ) ) { $ flashes = $ this -> session -> get ( $ this -> key ) ; foreach ( $ flashes as $ flash ) { $ this -> current -> push ( new Flash ( $ flash [ 'level' ] , $ flash [ 'message' ] ) ) ; } } }
Get current flash message from session .
2,821
protected function gatherRoutes ( ) { $ basePath = $ this -> container -> get ( 'app.base_path' ) ; $ routesPath = $ this -> container -> get ( 'app.routes_path' ) ; include $ basePath . DIRECTORY_SEPARATOR . $ routesPath ; }
Get all the routes that match to the given request .
2,822
private static function template ( $ t , $ vars = array ( ) ) { $ t = preg_replace_callback ( '/\s+|<[^>]++>/' , array ( 'self' , 'templateCb' ) , $ t ) ; array_unshift ( $ vars , $ t ) ; $ code = call_user_func_array ( 'sprintf' , $ vars ) ; return $ code ; }
strips out unnecessary whitespace from a template
2,823
protected function linkifyCb ( $ matches ) { $ uri = ( isset ( $ matches [ 1 ] ) && strlen ( trim ( $ matches [ 1 ] ) ) ) ? $ matches [ 0 ] : "http://" . $ matches [ 0 ] ; $ openTags = array ( ) ; $ closeTags = array ( ) ; preg_match_all ( "/<(?!\/)([^\s>]*).*?>/" , $ matches [ 0 ] , $ openTags , PREG_SET_ORDER ) ; pre...
Detects and links URLs - callback
2,824
protected function linkify ( $ src ) { if ( stripos ( $ src , "http" ) === false && stripos ( $ src , "www" ) === false ) { return $ src ; } $ chars = "0-9a-zA-Z\$\-_\.+!\*,%" ; $ src_ = $ src ; $ src = preg_replace_callback ( "@(?<![\w]) (?:(https?://(?:www[0-9]*\.)?) | (?:www\d*\.) ) # domain ...
Detects and links URLs
2,825
public static function get ( string $ section , $ row = null ) { if ( $ row === null ) { return isset ( self :: $ config [ $ section ] ) ? self :: $ config [ $ section ] : null ; } else { return isset ( self :: $ config [ $ section ] [ $ row ] ) ? self :: $ config [ $ section ] [ $ row ] : null ; } }
Return current config
2,826
private function add ( $ s1 , $ s2 , $ scale ) { if ( $ this -> bcmath ) return bcadd ( $ s1 , $ s2 , $ scale ) ; else return $ this -> scale ( $ s1 + $ s2 , $ scale ) ; }
Adds two numbers using arbitrary precision when available .
2,827
private function mul ( $ s1 , $ s2 , $ scale ) { if ( $ this -> bcmath ) return bcmul ( $ s1 , $ s2 , $ scale ) ; else return $ this -> scale ( $ s1 * $ s2 , $ scale ) ; }
Multiples two numbers using arbitrary precision when available .
2,828
public function autocomplete ( $ postalcode , $ number = '' , $ extension = '' ) { $ postalcode = $ this -> determinePostalType ( $ postalcode ) ; $ this -> data = array_merge ( $ postalcode , [ 'streetnumber' => $ number , 'extension' => $ extension ] ) ; return $ this -> call ( 'autocomplete' , $ this -> prepareData ...
Get a full address after providing a postalcode and number the results also include the coordinates from the address .
2,829
public function reverse ( $ lat , $ lng ) { $ this -> data = [ 'lat' => $ lat , 'lng' => $ lng ] ; return $ this -> call ( 'reverse' , $ this -> prepareData ( $ this -> data ) ) ; }
Find an address by their coordinates returns a full address if found .
2,830
public function range ( $ nl_fourpp , $ range = 5000 , $ per_page = 10 , $ page = 1 ) { $ this -> data = [ 'nl_fourpp' => $ nl_fourpp , 'range' => $ range , 'per_page' => $ per_page , 'page' => $ page ] ; return $ this -> call ( 'range' , $ this -> prepareData ( $ this -> data ) ) ; }
Returns a list of postalcodes within a given range .
2,831
public function suggest ( $ nl_city , $ per_page = 10 ) { $ this -> data = [ 'nl_city' => $ nl_city , 'per_page' => $ per_page ] ; return $ this -> call ( 'suggest' , $ this -> prepareData ( $ this -> data ) ) ; }
Autocompletes a city name .
2,832
public function distance ( $ from_nl_fourpp , $ to_nl_fourpp , $ algorithm = 'road' ) { $ this -> data = [ 'from_nl_fourpp' => $ from_nl_fourpp , 'to_nl_fourpp' => $ to_nl_fourpp , 'algorithm' => $ algorithm ] ; return $ this -> call ( 'distance' , $ this -> prepareData ( $ this -> data ) ) ; }
Calculates the distance between two nl_fourpp postalcodes . Optional you can choose between road or straight distance .
2,833
public function coordinatesDistance ( $ lat1 , $ lng1 , $ lat2 , $ lng2 , $ miles = false ) { $ pi80 = M_PI / 180 ; $ lat1 *= $ pi80 ; $ lng1 *= $ pi80 ; $ lat2 *= $ pi80 ; $ lng2 *= $ pi80 ; $ r = 6372.797 ; $ dlat = $ lat2 - $ lat1 ; $ dlng = $ lng2 - $ lng1 ; $ a = sin ( $ dlat / 2 ) * sin ( $ dlat / 2 ) + cos ( $ l...
Helper method to calculate the distance between two coordinates .
2,834
public function determinePostalType ( $ postalcode ) { $ postalcode = str_replace ( ' ' , '' , $ postalcode ) ; if ( strlen ( $ postalcode ) == 6 ) { return [ 'nl_sixpp' => $ postalcode ] ; } if ( strlen ( $ postalcode ) == 4 ) { return [ 'nl_fourpp' => $ postalcode ] ; } throw new \ Exception ( 'No valid postalcode wa...
Checks if one of two valid postal types was sent along .
2,835
protected function prepareData ( $ data ) { $ data [ 'auth_key' ] = $ this -> api_key ; $ data [ 'format' ] = $ this -> api_format ; $ data [ 'pretty' ] = $ this -> api_pretty ; return $ data ; }
Make sure the data contains the api_key and desired format .
2,836
protected function call ( $ path , $ data ) { $ url = $ this -> api_host . $ path . '?' . http_build_query ( $ data ) ; $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , 5 ) ; $ return = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ return ;...
Method to do the actual call to Pro6PP s API and return the data in the given format .
2,837
public function getFormValue ( $ currentPage = false , $ encode = false ) { if ( $ currentPage ) $ url = $ encode ? $ this -> urlEncode ( Yii :: app ( ) -> getRequest ( ) -> getUrl ( ) ) : Yii :: app ( ) -> getRequest ( ) -> getUrl ( ) ; else $ url = $ this -> getUrlFromSubmitFields ( ) ; return $ url ; }
Get url from submitted data or the current page url for usage in a hidden form element
2,838
public function getLinkValue ( $ currentPage = false ) { return $ this -> encodeLinkValue ( $ currentPage ? Yii :: app ( ) -> request -> getUrl ( ) : $ this -> getUrlFromSubmitFields ( ) ) ; }
Get url from submitted data or the current page url for usage in a link
2,839
public function getUrl ( $ altUrl = false ) { $ url = $ this -> getUrlFromSubmitFields ( ) ; if ( ! $ url && $ altUrl ) $ url = $ altUrl ; return $ url ? $ url : Yii :: app ( ) -> homeUrl ; }
Get url from submitted data or session
2,840
private function getUrlFromSubmitFields ( ) { $ requestKey = $ this -> requestKey ; $ url = isset ( $ _GET [ $ requestKey ] ) && is_scalar ( $ _GET [ $ requestKey ] ) ? $ _GET [ $ requestKey ] : ( isset ( $ _POST [ $ requestKey ] ) && is_scalar ( $ _POST [ $ requestKey ] ) ? $ _POST [ $ requestKey ] : false ) ; $ url =...
Get the url from the request decodes if needed
2,841
public function addUserAgentHandler ( WURFL_Handlers_Handler $ handler ) { $ size = count ( $ this -> _userAgentHandlers ) ; if ( $ size > 0 ) { $ this -> _userAgentHandlers [ $ size - 1 ] -> setNextHandler ( $ handler ) ; } $ this -> _userAgentHandlers [ ] = $ handler ; return $ this ; }
Adds a WURFL_Handlers_Handler to the chain
2,842
public function set ( $ key , $ value = null ) { DotArr :: set ( $ this -> data , $ key , $ value ) ; }
Sets a value to the dot - notated internal array .
2,843
public function modal ( Modal \ Modal $ modal ) { $ html = '' ; if ( $ modal -> hasCloseButton ( ) ) { $ html .= html ( 'button' , [ 'type' => 'button' , 'class' => 'close' , 'data-dismiss' => 'modal' , 'aria-label' => $ modal -> getCloseButtonLabel ( ) ] , '<span aria-hidden="true">&times;</span>' ) ; } if ( $ modal -...
Render a modal
2,844
protected function normalizeRelationsData ( ) { if ( is_null ( $ this -> data [ 'relationships' ] ) ) { $ this -> data [ 'relationships' ] = [ ] ; } foreach ( [ 'normal' , 'reverse' , 'image' , 'file' , 'checkbox' , 'category' ] as $ key ) { if ( ! array_key_exists ( $ key , $ this -> data [ 'relationships' ] ) || ! is...
Makes sure that expected relations data is traversable
2,845
protected function getRelationsConfigReplace ( ) { $ relationships = $ this -> collectRelationshipDataForConfig ( ) ; if ( ! count ( $ relationships ) ) return '' ; $ replace = $ this -> tab ( ) . "protected \$relationsConfig = [\n" ; foreach ( $ relationships as $ name => $ relationship ) { $ replace .= $ this -> tab ...
Returns the replacement for the relations config placeholder
2,846
protected function getRelationshipsReplace ( ) { $ totalCount = $ this -> getTotalRelevantRelationshipCount ( ) ; if ( ! $ totalCount ) return '' ; $ replace = "\n" . $ this -> getRelationshipsIntro ( ) ; $ replace .= $ this -> getReplaceForNormalRelationships ( ) . $ this -> getReplaceForSpecialRelationships ( ) ; ret...
Returns the replacement for the relationships placeholder
2,847
protected function getTotalRelevantRelationshipCount ( ) { return count ( $ this -> getCombinedRelationships ( ) ) + count ( $ this -> data [ 'relationships' ] [ 'image' ] ) + count ( $ this -> data [ 'relationships' ] [ 'file' ] ) + count ( $ this -> data [ 'relationships' ] [ 'checkbox' ] ) + count ( $ this -> data [...
Returns the number of relationships to be considered for building up the stub replacement .
2,848
protected function determineCategoryRelationName ( ) { $ tryNames = config ( 'pxlcms.generator.standard_models.category_relation_names' , [ ] ) ; $ this -> categoryRelationName = null ; foreach ( $ tryNames as $ tryName ) { $ tryName = trim ( $ tryName ) ; if ( ! $ this -> doesRelationNameConflict ( $ tryName ) ) { $ t...
Attempts to determine a non - conflicting name for the relationship to the Category model
2,849
protected function doesRelationNameConflict ( $ name ) { $ relationships = array_merge ( $ this -> data [ 'relationships' ] [ 'normal' ] , $ this -> data [ 'relationships' ] [ 'reverse' ] , $ this -> data [ 'relationships' ] [ 'image' ] , $ this -> data [ 'relationships' ] [ 'file' ] , $ this -> data [ 'relationships' ...
Returns whether a given name is already in use by anything that it would conflict with for this model
2,850
protected function getRelationMethodSection ( array $ relationships , $ type = CmsModel :: RELATION_TYPE_MODEL ) { $ replace = '' ; $ relatedClassName = $ this -> context -> getModelNamespaceForSpecialModel ( $ type ) ; foreach ( $ relationships as $ name => $ relationship ) { $ relationParameters = '' ; $ relationMeth...
Returns stub section for relation method
2,851
public function setDefaultValue ( $ value ) { $ value = $ this -> mmAttribute -> valueToWidget ( $ value ) ; $ this -> set ( 'value' , $ value ) ; }
Set the default value of the Attribute
2,852
public function addProperties ( $ properties ) { if ( empty ( $ properties ) || ! count ( ( array ) $ properties ) ) { throw new \ Exception ( 'Empty properties given' ) ; } if ( ! is_array ( $ properties ) && ! is_object ( $ properties ) ) { throw new \ Exception ( 'Expected array or object' ) ; } foreach ( $ properti...
Add properties to this object validator
2,853
public function addProperty ( $ key , BaseValidator $ property ) { if ( property_exists ( $ this -> properties , $ key ) ) { throw new \ Exception ( 'Property key exists' ) ; } $ this -> properties -> { $ key } = $ property ; return $ this ; }
Add a property to this object validator
2,854
public static function castFrom ( $ requestUri , string $ requestMethod = null ) { if ( $ requestUri instanceof self ) { return $ requestUri ; } return new self ( $ requestUri , ( string ) $ requestMethod ) ; }
casts given values to an instance of UriRequest
2,855
public function methodEquals ( string $ method = null ) : bool { if ( empty ( $ method ) ) { return true ; } return $ this -> method === $ method ; }
checks if request method equals given method
2,856
public function satisfiesPath ( string $ expectedPath = null ) : bool { if ( empty ( $ expectedPath ) ) { return true ; } if ( preg_match ( '/^' . UriPath :: pattern ( $ expectedPath ) . '/' , $ this -> uri -> path ( ) ) >= 1 ) { return true ; } return false ; }
checks if given path is satisfied by request path
2,857
public function satisfies ( string $ method = null , string $ expectedPath = null ) : bool { return $ this -> methodEquals ( $ method ) && $ this -> satisfiesPath ( $ expectedPath ) ; }
checks if given method and path is satisfied by request
2,858
public function eachChild ( $ callback ) { foreach ( $ this -> children as $ child ) { call_user_func ( $ callback , $ child ) ; } return $ this ; }
Run a callback for each child .
2,859
protected function generateChildren ( ) { $ buffer = '' ; foreach ( $ this -> children as $ child ) { $ buffer .= $ child -> generate ( ) ; } return $ buffer ; }
Generate children .
2,860
protected function bind ( $ vars , ServerRequestInterface $ request , array $ parts ) { $ type = is_array ( $ vars ) && array_keys ( $ vars ) === array_keys ( array_keys ( $ vars ) ) ? 'numeric' : 'assoc' ; $ values = $ this -> bindParts ( $ vars , $ type , $ request , $ parts ) ; if ( $ vars instanceof Route ) { $ cla...
Fill out the routes variables based on the url parts .
2,861
protected function bindParts ( $ vars , $ type , ServerRequestInterface $ request , array $ parts ) { $ values = [ ] ; foreach ( $ vars as $ key => $ var ) { $ part = null ; $ bound = $ this -> bindPartObject ( $ var , $ part ) || $ this -> bindPartArray ( $ var , $ request , $ parts , $ part ) || $ this -> bindPartVar...
Fill out the values based on the url parts .
2,862
protected function bindPartArray ( $ var , ServerRequestInterface $ request , array $ parts , & $ part ) { if ( ! is_array ( $ var ) && ! $ var instanceof \ stdClass ) { return false ; } $ part = [ $ this -> bind ( $ var , $ request , $ parts ) ] ; return true ; }
Bind part if it s an array
2,863
protected function bindPartVar ( $ var , $ type , ServerRequestInterface $ request , array $ parts , & $ part ) { if ( ! is_string ( $ var ) || $ var [ 0 ] !== '$' ) { return false ; } $ options = array_map ( 'trim' , explode ( '|' , $ var ) ) ; $ part = $ this -> bindVar ( $ type , $ request , $ parts , $ options ) ; ...
Bind part if it s an variable
2,864
protected function bindPartConcat ( $ var , ServerRequestInterface $ request , array $ parts , & $ part ) { if ( ! is_string ( $ var ) || $ var [ 0 ] !== '~' || substr ( $ var , - 1 ) !== '~' ) { return false ; } $ pieces = array_map ( 'trim' , explode ( '~' , substr ( $ var , 1 , - 1 ) ) ) ; $ bound = array_filter ( $...
Bind part if it s an concatenation
2,865
protected function bindVarSuperGlobal ( $ option , ServerRequestInterface $ request , & $ value ) { if ( preg_match ( '/^\$_(GET|POST|COOKIE)\[([^\[]*)\]$/i' , $ option , $ matches ) ) { list ( , $ var , $ key ) = $ matches ; $ var = strtolower ( $ var ) ; $ data = null ; if ( $ var === 'get' ) { $ data = $ request -> ...
Bind variable when option is a super global
2,866
protected function bindVarRequestHeader ( $ option , ServerRequestInterface $ request , & $ value ) { if ( preg_match ( '/^\$(?:HTTP_)?([A-Z_]+)$/' , $ option , $ matches ) ) { $ sentence = preg_replace ( '/[\W_]+/' , ' ' , $ matches [ 1 ] ) ; $ name = str_replace ( ' ' , '-' , ucwords ( $ sentence ) ) ; $ value = [ $ ...
Bind variable when option is a request header
2,867
protected function bindVarMultipleUrlParts ( $ option , $ type , array $ parts , & $ value ) { if ( substr ( $ option , - 3 ) === '...' && ctype_digit ( substr ( $ option , 1 , - 3 ) ) ) { $ i = ( int ) substr ( $ option , 1 , - 3 ) ; if ( $ type === 'assoc' ) { throw new \ InvalidArgumentException ( "Binding multiple ...
Bind variable when option contains multiple URL parts
2,868
protected function bindVarSingleUrlPart ( $ option , array $ parts , & $ value ) { if ( ctype_digit ( substr ( $ option , 1 ) ) ) { $ i = ( int ) substr ( $ option , 1 ) ; $ part = array_slice ( $ parts , $ i - 1 , 1 ) ; if ( ! empty ( $ part ) ) { $ value = $ part ; return true ; } } return false ; }
Bind variable when option contains a single URL part
2,869
public function addCondition ( ConditionAbstract $ condition ) { if ( $ condition instanceof SupportsCondition ) { $ this -> conditions [ ] = $ condition ; } else { throw new \ InvalidArgumentException ( "Invalid condition instance. Instance of 'SupportsCondition' expected." ) ; } return $ this ; }
Adds a supports condition .
2,870
protected function parseRuleString ( $ ruleString ) { $ ruleString = preg_replace ( '/^[ \r\n\t\f]*@supports[ \r\n\t\f]*/i' , '' , $ ruleString ) ; $ ruleString = trim ( $ ruleString , " \r\n\t\f" ) ; $ charset = $ this -> getCharset ( ) ; $ conditions = [ ] ; foreach ( Condition :: splitNestedConditions ( $ ruleString...
Parses the supports rule .
2,871
public function getUserRoles ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collUserRolesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUserRoles || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collUserRoles ) { $ this -> ...
Gets an array of ChildUserRole objects which contain a foreign key that references this object .
2,872
public function addUserRole ( ChildUserRole $ l ) { if ( $ this -> collUserRoles === null ) { $ this -> initUserRoles ( ) ; $ this -> collUserRolesPartial = true ; } if ( ! $ this -> collUserRoles -> contains ( $ l ) ) { $ this -> doAddUserRole ( $ l ) ; } return $ this ; }
Method called to associate a ChildUserRole object to this object through the ChildUserRole foreign key attribute .
2,873
public function getUserRolesJoinRole ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildUserRoleQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Role' , $ joinBehavior ) ; return $ this -> getUserRoles ( $ query , $ con ) ; }
If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this User is new it will return an empty collection ; or if this User has previously been saved it will retrieve related UserRoles from storage .
2,874
public function initRoles ( ) { $ this -> collRoles = new ObjectCollection ( ) ; $ this -> collRolesPartial = true ; $ this -> collRoles -> setModel ( '\Alchemy\Component\Cerberus\Model\Role' ) ; }
Initializes the collRoles collection .
2,875
public function addRole ( ChildRole $ role ) { if ( $ this -> collRoles === null ) { $ this -> initRoles ( ) ; } if ( ! $ this -> getRoles ( ) -> contains ( $ role ) ) { $ this -> collRoles -> push ( $ role ) ; $ this -> doAddRole ( $ role ) ; } return $ this ; }
Associate a ChildRole to this object through the user_role cross reference table .
2,876
public function removeRole ( ChildRole $ role ) { if ( $ this -> getRoles ( ) -> contains ( $ role ) ) { $ userRole = new ChildUserRole ( ) ; $ userRole -> setRole ( $ role ) ; if ( $ role -> isUsersLoaded ( ) ) { $ role -> getUsers ( ) -> removeObject ( $ this ) ; } $ userRole -> setUser ( $ this ) ; $ this -> removeU...
Remove role of this object through the user_role cross reference table .
2,877
private function throwException ( $ method ) { if ( isset ( $ this -> exceptions [ $ method ] ) && ! empty ( $ this -> exceptions [ $ method ] ) ) { $ exception = array_shift ( $ this -> exceptions [ $ method ] ) ; if ( $ exception != null ) { throw $ exception ; } } }
Dequeue an exception for a specific method invocation
2,878
public function setLock ( CacheKey $ key , Lock $ lock ) { $ this -> locks [ $ key -> hash ] = $ lock ; }
Locks a specific cache entry
2,879
public function emailOutput ( $ address ) { if ( is_null ( $ this -> _output ) || $ this -> _output == $ this -> getDefaultOutput ( ) ) { throw new InvalidCallException ( 'Must direct output to file in order to email results.' ) ; } $ address = is_array ( $ address ) ? $ address : func_get_args ( ) ; return $ this -> t...
Register the send email logic .
2,880
public function buildCommand ( ) { $ command = $ this -> command . ' >> ' . $ this -> _output . ' 2>&1 &' ; return $ this -> _user ? 'sudo -u ' . $ this -> _user . ' ' . $ command : $ command ; }
Build the execute command .
2,881
protected function sendEmail ( MailerInterface $ mailer , $ address ) { $ message = $ mailer -> compose ( ) ; $ message -> setTextBody ( file_get_contents ( $ this -> _output ) ) -> setSubject ( $ this -> getEmailSubject ( ) ) -> setTo ( $ address ) ; $ message -> send ( ) ; }
Send email logic .
2,882
private function getMigrationInstances ( array $ migration_class_file_path_map ) { $ result = [ ] ; foreach ( $ migration_class_file_path_map as $ migration_class => $ migration_file_path ) { if ( is_file ( $ migration_file_path ) ) { require_once $ migration_file_path ; if ( class_exists ( $ migration_class , false ) ...
Return an array of MigrationInterface instances indexed by class name .
2,883
public function getTableName ( ) { if ( $ this -> table_exists === null && ! in_array ( $ this -> table_name , $ this -> connection -> getTableNames ( ) ) ) { $ this -> connection -> execute ( 'CREATE TABLE ' . $ this -> connection -> escapeTableName ( $ this -> table_name ) . ' ( `id` int(10) unsigned N...
Return name of the table where we store info about executed migrations .
2,884
protected function format ( string $ timestamp , string $ levelstr , string $ msg ) { $ fmt = "[%s] %s: %s\n" ; return sprintf ( $ fmt , $ timestamp , $ levelstr , $ msg ) ; }
Log line formatter .
2,885
private function one_line ( string $ msg ) { $ msg = trim ( $ msg ) ; $ msg = str_replace ( [ "\t" , "\n" , "\r" , ] , [ '\t' , '\n' , '\r' , ] , $ msg ) ; return preg_replace ( '! +!' , ' ' , $ msg ) ; }
Write lines as single line with tab CR and LF written symbolically .
2,886
private function write ( string $ levelstr , string $ msg ) { $ timestamp = gmdate ( \ DateTime :: ATOM ) ; try { $ msg = $ this -> one_line ( $ msg ) ; $ line = $ this -> format ( $ timestamp , $ levelstr , $ msg ) ; fwrite ( $ this -> handle , $ line ) ; } catch ( \ Exception $ e ) { } }
Write to handle .
2,887
public function bootstrap ( ) { $ this -> registerBootstrapArguments ( ) ; $ this -> registerEventDispatcher ( ) ; $ this -> registerConfigLoader ( ) ; $ this -> registerConfig ( ) ; $ this -> registerPlugins ( ) ; $ this -> registerTaskDispatcherCollection ( ) ; $ this -> registerLogger ( ) ; $ this -> getContainer ( ...
Run bootstrap an register services to the DI container
2,888
public static function val ( $ value1 , $ value2 , $ _ = null ) { if ( ! static :: is ( $ value1 ) || ! static :: is ( $ value2 ) ) { throw new \ InvalidArgumentException ( "All parameters must be of type bool." ) ; } $ ret = ( $ value1 || $ value2 ) ; $ args = array_slice ( func_get_args ( ) , 2 ) ; while ( ! $ ret &&...
Applies the OR operation to the given values .
2,889
public static function enable2FA ( $ userUid , $ authenticationKey , $ verificationCode ) { $ request = array ( 'authenticationKey' => $ authenticationKey , 'verificationCode' => $ verificationCode ) ; return Pencepay_Util_HttpClient :: postArray ( "/user/$userUid/tfa_enable" , $ request ) ; }
Enables the two - factor authentication for this user .
2,890
public function register ( ) { $ file = $ this -> app -> make ( Filesystem :: class ) ; $ path = realpath ( __DIR__ . '/../Libraries' ) ; $ libraries = $ file -> glob ( $ path . '/*.php' ) ; foreach ( $ libraries as $ librarie ) { require_once ( $ librarie ) ; } $ libraries2 = $ file -> glob ( $ path . '/HuasituoApi/*....
Register the libraries services .
2,891
protected function isWantedContrib ( \ SplFileInfo $ dir ) { $ info_file = $ this -> cleanDirPath ( $ dir -> getPathName ( ) ) . DIRECTORY_SEPARATOR . $ this -> moduleName . '.info' ; return file_exists ( $ info_file ) ; }
Checks if the passed directory is the contrib module we are looking for .
2,892
public function isGlobbed ( $ string ) { $ segments = $ this -> parser -> parse ( $ string ) ; foreach ( $ segments as $ segment ) { if ( $ segment [ 1 ] & SelectorParser :: T_PATTERN ) { return true ; } } return false ; }
Return true if the given string is contains a glob pattern
2,893
public function load ( $ fileName ) { if ( ! file_exists ( $ fileName ) ) { throw new \ InvalidArgumentException ( 'File ' . $ fileName . ' does not exist' ) ; } $ lines = $ this -> readLinesFromFile ( $ fileName ) ; return $ this -> getArrayFromLines ( $ lines ) ; }
Returns array which consists of value array and map
2,894
public function getArrayFromLines ( array $ lines ) { $ array = [ ] ; $ map = [ ] ; $ i = 1 ; foreach ( $ lines as $ line ) { if ( $ this -> processor -> isEmptyLine ( $ line ) ) { $ map [ $ i ] = [ 'type' => 'empty' ] ; } elseif ( $ this -> processor -> isCommentLine ( $ line ) ) { $ map [ $ i ] = [ 'type' => 'comment...
Creates value and map array from string lines
2,895
public function processValue ( $ value ) { $ value = ltrim ( rtrim ( $ value ) ) ; if ( $ this -> processor -> isBool ( $ value ) ) { return $ this -> processor -> getBool ( $ value ) ; } if ( $ this -> processor -> isNumber ( $ value ) ) { return $ this -> processor -> getNumber ( $ value ) ; } if ( $ this -> processo...
Creates value from string
2,896
protected function getDefaultOptions ( array $ fields ) { $ fieldsUpdated = array ( ) ; foreach ( $ fields as $ fieldName => $ field ) { $ fieldsUpdated [ $ fieldName ] = $ this -> typeHandler -> getDefaultOptions ( $ field ) ; } return $ fieldsUpdated ; }
Get the default options for the fields for their type
2,897
public function setDefaultValues ( array $ defaultValues ) { foreach ( $ defaultValues as $ name => $ value ) { if ( isset ( $ this -> fields [ $ name ] ) ) { $ this -> data [ $ name ] = $ value ; } } }
Set the default values of matching fields
2,898
public function bindEntity ( $ entity , $ fields = null , $ validatable = true ) { if ( $ this -> submitted ) { throw new BadMethodCallException ( "Entities cannot be assigned after FormHandler::handleRequest has been called" ) ; } $ this -> entities [ ] = array ( 'entity' => $ entity , 'fields' => $ fields , 'validata...
Add an entity to the form . The entities values will be used to fill the form and the forms data will be assigned to the entity when saveToEntities is called
2,899
public function handleRequest ( $ request = null ) { $ this -> submitted = true ; $ requestData = $ this -> requestHandler -> handleRequest ( $ this , $ request ) ; $ validRequestData = $ this -> checkFieldsSubmitted ( $ this -> fields , $ requestData ) ; if ( $ this -> submitted === true && ! empty ( $ validRequestDat...
Use a request handler to get data from a request and store the values that match fields in the form blueprint