idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
22,100
private function getManagerName ( ContainerBuilder $ container ) { foreach ( $ this -> managerParameters as $ param ) { if ( $ container -> hasParameter ( $ param ) ) { $ name = $ container -> getParameter ( $ param ) ; if ( $ name ) { return $ name ; } } } throw new InvalidArgumentException ( sprintf ( 'Could not find...
Determine the manager name .
22,101
private function log ( $ id , $ domain , $ locale ) { if ( null === $ domain ) { $ domain = 'messages' ; } $ id = ( string ) $ id ; $ catalogue = $ this -> translator -> getCatalogue ( $ locale ) ; if ( $ catalogue -> defines ( $ id , $ domain ) ) { return ; } if ( $ catalogue -> has ( $ id , $ domain ) ) { $ this -> l...
Logs for missing translations .
22,102
public function getResource ( $ idx = 0 ) { if ( null === $ this -> results || $ idx >= \ count ( $ this -> results ) ) { return null ; } return $ this -> results [ $ idx ] ; }
Returns a LDAP search resource . If this query resulted in multiple searches only the first page will be returned .
22,103
private function resetPagination ( ) { $ con = $ this -> connection -> getResource ( ) ; ldap_control_paged_result ( $ con , 0 ) ; $ ctl = [ ] ; ldap_get_option ( $ con , LDAP_OPT_SERVER_CONTROLS , $ ctl ) ; if ( ! empty ( $ ctl ) ) { foreach ( $ ctl as $ idx => $ info ) { if ( static :: PAGINATION_OID == $ info [ 'oid...
Resets pagination on the current connection .
22,104
public function panelAction ( Request $ request , $ token ) { $ this -> denyAccessIfProfilerDisabled ( ) ; if ( null !== $ this -> cspHandler ) { $ this -> cspHandler -> disableCsp ( ) ; } $ panel = $ request -> query -> get ( 'panel' , 'request' ) ; $ page = $ request -> query -> get ( 'page' , 'home' ) ; if ( 'latest...
Renders a profiler panel for the given token .
22,105
public function toolbarAction ( Request $ request , $ token ) { if ( null === $ this -> profiler ) { throw new NotFoundHttpException ( 'The profiler must be enabled.' ) ; } if ( $ request -> hasSession ( ) && ( $ session = $ request -> getSession ( ) ) && $ session -> isStarted ( ) && $ session -> getFlashBag ( ) insta...
Renders the Web Debug Toolbar .
22,106
public function searchBarAction ( Request $ request ) { $ this -> denyAccessIfProfilerDisabled ( ) ; if ( null !== $ this -> cspHandler ) { $ this -> cspHandler -> disableCsp ( ) ; } if ( ! $ request -> hasSession ( ) ) { $ ip = $ method = $ statusCode = $ url = $ start = $ end = $ limit = $ token = null ; } else { $ s...
Renders the profiler search bar .
22,107
public function searchResultsAction ( Request $ request , $ token ) { $ this -> denyAccessIfProfilerDisabled ( ) ; if ( null !== $ this -> cspHandler ) { $ this -> cspHandler -> disableCsp ( ) ; } $ profile = $ this -> profiler -> loadProfile ( $ token ) ; $ ip = $ request -> query -> get ( 'ip' ) ; $ method = $ reques...
Renders the search results .
22,108
public function searchAction ( Request $ request ) { $ this -> denyAccessIfProfilerDisabled ( ) ; $ ip = preg_replace ( '/[^:\d\.]/' , '' , $ request -> query -> get ( 'ip' ) ) ; $ method = $ request -> query -> get ( 'method' ) ; $ statusCode = $ request -> query -> get ( 'status_code' ) ; $ url = $ request -> query -...
Narrows the search bar .
22,109
public function phpinfoAction ( ) { $ this -> denyAccessIfProfilerDisabled ( ) ; if ( null !== $ this -> cspHandler ) { $ this -> cspHandler -> disableCsp ( ) ; } ob_start ( ) ; phpinfo ( ) ; $ phpinfo = ob_get_clean ( ) ; return new Response ( $ phpinfo , 200 , [ 'Content-Type' => 'text/html' ] ) ; }
Displays the PHP info .
22,110
public function openAction ( Request $ request ) { if ( null === $ this -> baseDir ) { throw new NotFoundHttpException ( 'The base dir should be set.' ) ; } if ( $ this -> profiler ) { $ this -> profiler -> disable ( ) ; } $ file = $ request -> query -> get ( 'file' ) ; $ line = $ request -> query -> get ( 'line' ) ; $...
Displays the source of a file .
22,111
protected function getTemplateManager ( ) { if ( null === $ this -> templateManager ) { $ this -> templateManager = new TemplateManager ( $ this -> profiler , $ this -> twig , $ this -> templates ) ; } return $ this -> templateManager ; }
Gets the Template Manager .
22,112
public function authenticateWithToken ( TokenInterface $ token , Request $ request , string $ providerKey = null ) { $ this -> migrateSession ( $ request , $ token , $ providerKey ) ; $ this -> tokenStorage -> setToken ( $ token ) ; if ( null !== $ this -> dispatcher ) { $ loginEvent = new InteractiveLoginEvent ( $ req...
Authenticates the given token in the system .
22,113
protected function & resolveAttributePath ( $ name , $ writeContext = false ) { $ array = & $ this -> attributes ; $ name = ( 0 === strpos ( $ name , $ this -> namespaceCharacter ) ) ? substr ( $ name , 1 ) : $ name ; if ( ! $ name ) { return $ array ; } $ parts = explode ( $ this -> namespaceCharacter , $ name ) ; if ...
Resolves a path in attributes property and returns it as a reference .
22,114
protected function resolveKey ( $ name ) { if ( false !== $ pos = strrpos ( $ name , $ this -> namespaceCharacter ) ) { $ name = substr ( $ name , $ pos + 1 ) ; } return $ name ; }
Resolves the key from the name .
22,115
protected function getParameter ( string $ name ) { if ( ! $ this -> container -> has ( 'parameter_bag' ) ) { throw new ServiceNotFoundException ( 'parameter_bag' , null , null , [ ] , sprintf ( 'The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a...
Gets a container parameter by its name .
22,116
public function has ( $ key ) { if ( \ array_key_exists ( $ key , $ this -> data ) ) { return true ; } if ( null === $ this -> parent ) { return false ; } return $ this -> parent -> has ( $ key ) ; }
Tests if a data is visible from current scope .
22,117
public function get ( $ key , $ default = null ) { if ( \ array_key_exists ( $ key , $ this -> data ) ) { return $ this -> data [ $ key ] ; } if ( null === $ this -> parent ) { return $ default ; } return $ this -> parent -> get ( $ key , $ default ) ; }
Returns data visible from current scope .
22,118
private function getRegexp ( array $ patterns ) : string { $ regexps = [ ] ; foreach ( $ patterns as $ pattern ) { $ regex = preg_quote ( ltrim ( $ pattern , '\\' ) ) ; $ regex = strtr ( $ regex , [ '\\*\\*' => '.*?' , '\\*' => '[^\\\\]*?' ] ) ; if ( '\\' !== substr ( $ regex , - 1 ) ) { $ regex .= '$' ; } $ regexps [ ...
Builds a regexp to check if a class is auto - mapped .
22,119
public function start ( $ id , $ message , $ prefix = 'RUN' ) { $ this -> started [ $ id ] = [ 'border' => ++ $ this -> count % \ count ( $ this -> colors ) ] ; return sprintf ( "%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n" , $ this -> getBorder ( $ id ) , $ prefix , $ message ) ; }
Starts a debug formatting session .
22,120
public function progress ( $ id , $ buffer , $ error = false , $ prefix = 'OUT' , $ errorPrefix = 'ERR' ) { $ message = '' ; if ( $ error ) { if ( isset ( $ this -> started [ $ id ] [ 'out' ] ) ) { $ message .= "\n" ; unset ( $ this -> started [ $ id ] [ 'out' ] ) ; } if ( ! isset ( $ this -> started [ $ id ] [ 'err' ]...
Adds progress to a formatting session .
22,121
public function stop ( $ id , $ message , $ successful , $ prefix = 'RES' ) { $ trailingEOL = isset ( $ this -> started [ $ id ] [ 'out' ] ) || isset ( $ this -> started [ $ id ] [ 'err' ] ) ? "\n" : '' ; if ( $ successful ) { return sprintf ( "%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n" , $ trailingEOL , $ this ...
Stops a formatting session .
22,122
public function setRootNodeName ( $ name ) { @ trigger_error ( sprintf ( 'The "%s()" method is deprecated since Symfony 4.2, use the context instead.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ this -> defaultContext [ self :: ROOT_NODE_NAME ] = $ name ; }
Sets the root node name .
22,123
final protected function isElementNameValid ( string $ name ) : bool { return $ name && false === strpos ( $ name , ' ' ) && preg_match ( '#^[\pL_][\pL0-9._:-]*$#ui' , $ name ) ; }
Checks the name is a valid xml element name .
22,124
private function parseXml ( \ DOMNode $ node , array $ context = [ ] ) { $ data = $ this -> parseXmlAttributes ( $ node , $ context ) ; $ value = $ this -> parseXmlValue ( $ node , $ context ) ; if ( ! \ count ( $ data ) ) { return $ value ; } if ( ! \ is_array ( $ value ) ) { $ data [ '#' ] = $ value ; return $ data ;...
Parse the input DOMNode into an array or a string .
22,125
private function parseXmlAttributes ( \ DOMNode $ node , array $ context = [ ] ) : array { if ( ! $ node -> hasAttributes ( ) ) { return [ ] ; } $ data = [ ] ; $ typeCastAttributes = ( bool ) ( $ context [ self :: TYPE_CASE_ATTRIBUTES ] ?? $ this -> defaultContext [ self :: TYPE_CASE_ATTRIBUTES ] ) ; foreach ( $ node -...
Parse the input DOMNode attributes into an array .
22,126
private function appendNode ( \ DOMNode $ parentNode , $ data , string $ nodeName , string $ key = null ) : bool { $ node = $ this -> dom -> createElement ( $ nodeName ) ; if ( null !== $ key ) { $ node -> setAttribute ( 'key' , $ key ) ; } $ appendNode = $ this -> selectNodeType ( $ node , $ data ) ; if ( $ appendNode...
Selects the type of node to create and appends it to the parent .
22,127
private function selectNodeType ( \ DOMNode $ node , $ val ) : bool { if ( \ is_array ( $ val ) ) { return $ this -> buildXml ( $ node , $ val ) ; } elseif ( $ val instanceof \ SimpleXMLElement ) { $ child = $ this -> dom -> importNode ( dom_import_simplexml ( $ val ) , true ) ; $ node -> appendChild ( $ child ) ; } el...
Tests the value being passed and decide what sort of element to create .
22,128
private function createDomDocument ( array $ context ) : \ DOMDocument { $ document = new \ DOMDocument ( ) ; $ xmlOptions = [ self :: FORMAT_OUTPUT => 'formatOutput' , self :: VERSION => 'xmlVersion' , self :: ENCODING => 'encoding' , self :: STANDALONE => 'xmlStandalone' , ] ; foreach ( $ xmlOptions as $ xmlOption =>...
Create a DOM document taking serializer options into account .
22,129
public static function escapeWithDoubleQuotes ( string $ value ) : string { return sprintf ( '"%s"' , str_replace ( self :: $ escapees , self :: $ escaped , $ value ) ) ; }
Escapes and surrounds a PHP value with double quotes .
22,130
public function format ( \ DateTime $ dateTime ) { $ formatted = preg_replace_callback ( $ this -> regExp , function ( $ matches ) use ( $ dateTime ) { return $ this -> formatReplace ( $ matches [ 0 ] , $ dateTime ) ; } , $ this -> pattern ) ; return $ formatted ; }
Format a DateTime using ICU dateformat pattern .
22,131
public function parse ( \ DateTime $ dateTime , $ value ) { $ reverseMatchingRegExp = $ this -> getReverseMatchingRegExp ( $ this -> pattern ) ; $ reverseMatchingRegExp = '/^' . $ reverseMatchingRegExp . '$/' ; $ options = [ ] ; if ( preg_match ( $ reverseMatchingRegExp , $ value , $ matches ) ) { $ matches = $ this ->...
Parse a pattern based string to a timestamp value .
22,132
public function getReverseMatchingRegExp ( $ pattern ) { $ escapedPattern = preg_quote ( $ pattern , '/' ) ; $ escapedPattern = preg_replace ( '/\\\[\-|\/]/' , '[\/\-]' , $ escapedPattern ) ; $ reverseMatchingRegExp = preg_replace_callback ( $ this -> regExp , function ( $ matches ) { $ length = \ strlen ( $ matches [ ...
Retrieve a regular expression to match with a formatted value .
22,133
protected function buildCharsMatch ( $ specialChars ) { $ specialCharsArray = str_split ( $ specialChars ) ; $ specialCharsMatch = implode ( '|' , array_map ( function ( $ char ) { return $ char . '+' ; } , $ specialCharsArray ) ) ; return $ specialCharsMatch ; }
Builds a chars match regular expression .
22,134
protected function normalizeArray ( array $ data ) { $ ret = [ ] ; foreach ( $ data as $ key => $ value ) { if ( ! \ is_string ( $ key ) ) { continue ; } $ ret [ $ key [ 0 ] ] = [ 'value' => $ value , 'pattern' => $ key , ] ; } return $ ret ; }
Normalize a preg_replace match array removing the numeric keys and returning an associative array with the value and pattern values for the matched Transformer .
22,135
public function needsNormalization ( $ format , array $ context = [ ] ) { $ encoder = $ this -> getEncoder ( $ format , $ context ) ; if ( ! $ encoder instanceof NormalizationAwareInterface ) { return true ; } if ( $ encoder instanceof self ) { return $ encoder -> needsNormalization ( $ format , $ context ) ; } return ...
Checks whether the normalization is needed for the given format .
22,136
private function getEncoder ( string $ format , array $ context ) : EncoderInterface { if ( isset ( $ this -> encoderByFormat [ $ format ] ) && isset ( $ this -> encoders [ $ this -> encoderByFormat [ $ format ] ] ) ) { return $ this -> encoders [ $ this -> encoderByFormat [ $ format ] ] ; } foreach ( $ this -> encoder...
Gets the encoder supporting the format .
22,137
public function offsetGet ( $ position ) { if ( ! isset ( $ this -> errors [ $ position ] ) ) { throw new OutOfBoundsException ( 'The offset ' . $ position . ' does not exist.' ) ; } return $ this -> errors [ $ position ] ; }
Returns the element at a position in the iterator .
22,138
public function seek ( $ position ) { if ( ! isset ( $ this -> errors [ $ position ] ) ) { throw new OutOfBoundsException ( 'The offset ' . $ position . ' does not exist.' ) ; } reset ( $ this -> errors ) ; while ( $ position !== key ( $ this -> errors ) ) { next ( $ this -> errors ) ; } }
Sets the position of the iterator .
22,139
public function process ( NodeInterface $ configTree , array $ configs ) { $ currentConfig = [ ] ; foreach ( $ configs as $ config ) { $ config = $ configTree -> normalize ( $ config ) ; $ currentConfig = $ configTree -> merge ( $ currentConfig , $ config ) ; } return $ configTree -> finalize ( $ currentConfig ) ; }
Processes an array of configurations .
22,140
public function getNonces ( Request $ request , Response $ response ) { if ( $ request -> headers -> has ( 'X-SymfonyProfiler-Script-Nonce' ) && $ request -> headers -> has ( 'X-SymfonyProfiler-Style-Nonce' ) ) { return [ 'csp_script_nonce' => $ request -> headers -> get ( 'X-SymfonyProfiler-Script-Nonce' ) , 'csp_styl...
Returns an array of nonces to be used in Twig templates and Content - Security - Policy headers .
22,141
public function updateResponseHeaders ( Request $ request , Response $ response ) { if ( $ this -> cspDisabled ) { $ this -> removeCspHeaders ( $ response ) ; return [ ] ; } $ nonces = $ this -> getNonces ( $ request , $ response ) ; $ this -> cleanHeaders ( $ response ) ; $ this -> updateCspHeaders ( $ response , $ no...
Cleanup temporary headers and updates Content - Security - Policy headers .
22,142
private function updateCspHeaders ( Response $ response , array $ nonces = [ ] ) { $ nonces = array_replace ( [ 'csp_script_nonce' => $ this -> generateNonce ( ) , 'csp_style_nonce' => $ this -> generateNonce ( ) , ] , $ nonces ) ; $ ruleIsSet = false ; $ headers = $ this -> getCspHeaders ( $ response ) ; foreach ( $ h...
Updates Content - Security - Policy headers in a response .
22,143
private function generateCspHeader ( array $ directives ) { return array_reduce ( array_keys ( $ directives ) , function ( $ res , $ name ) use ( $ directives ) { return ( '' !== $ res ? $ res . '; ' : '' ) . sprintf ( '%s %s' , $ name , implode ( ' ' , $ directives [ $ name ] ) ) ; } , '' ) ; }
Converts a directive set array into Content - Security - Policy header .
22,144
private function parseDirectives ( $ header ) { $ directives = [ ] ; foreach ( explode ( ';' , $ header ) as $ directive ) { $ parts = explode ( ' ' , trim ( $ directive ) ) ; if ( \ count ( $ parts ) < 1 ) { continue ; } $ name = array_shift ( $ parts ) ; $ directives [ $ name ] = $ parts ; } return $ directives ; }
Converts a Content - Security - Policy header value into a directive set array .
22,145
private function authorizesInline ( array $ directivesSet , $ type ) { if ( isset ( $ directivesSet [ $ type ] ) ) { $ directives = $ directivesSet [ $ type ] ; } elseif ( isset ( $ directivesSet [ 'default-src' ] ) ) { $ directives = $ directivesSet [ 'default-src' ] ; } else { return false ; } return \ in_array ( '\'...
Detects if the unsafe - inline is prevented for a directive within the directive set .
22,146
private function willMakeFinalResponseUncacheable ( Response $ response ) { if ( $ response -> headers -> hasCacheControlDirective ( 'no-cache' ) || $ response -> headers -> getCacheControlDirective ( 'no-store' ) ) { return true ; } if ( \ in_array ( $ response -> getStatusCode ( ) , [ 200 , 203 , 300 , 301 , 410 ] ) ...
RFC2616 Section 13 . 4 .
22,147
private function getDefaultNormalizer ( ) { $ default = $ this -> getDefault ( ) ; $ regex = $ this -> trueAnswerRegex ; return function ( $ answer ) use ( $ default , $ regex ) { if ( \ is_bool ( $ answer ) ) { return $ answer ; } $ answerIsTrue = ( bool ) preg_match ( $ regex , $ answer ) ; if ( false === $ default )...
Returns the default answer normalizer .
22,148
private function buildDsnFromUrl ( $ dsnOrUrl ) { $ url = preg_replace ( '#^((?:pdo_)?sqlite3?):///#' , '$1://localhost/' , $ dsnOrUrl ) ; $ params = parse_url ( $ url ) ; if ( false === $ params ) { return $ dsnOrUrl ; } $ params = array_map ( 'rawurldecode' , $ params ) ; if ( isset ( $ params [ 'user' ] ) ) { $ this...
Builds a PDO DSN from a URL - like connection string .
22,149
private function beginTransaction ( ) { if ( ! $ this -> inTransaction ) { if ( 'sqlite' === $ this -> driver ) { $ this -> pdo -> exec ( 'BEGIN IMMEDIATE TRANSACTION' ) ; } else { if ( 'mysql' === $ this -> driver ) { $ this -> pdo -> exec ( 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED' ) ; } $ this -> pdo -> begin...
Helper method to begin a transaction .
22,150
private function commit ( ) { if ( $ this -> inTransaction ) { try { if ( 'sqlite' === $ this -> driver ) { $ this -> pdo -> exec ( 'COMMIT' ) ; } else { $ this -> pdo -> commit ( ) ; } $ this -> inTransaction = false ; } catch ( \ PDOException $ e ) { $ this -> rollback ( ) ; throw $ e ; } } }
Helper method to commit a transaction .
22,151
private function rollback ( ) { if ( $ this -> inTransaction ) { if ( 'sqlite' === $ this -> driver ) { $ this -> pdo -> exec ( 'ROLLBACK' ) ; } else { $ this -> pdo -> rollBack ( ) ; } $ this -> inTransaction = false ; } }
Helper method to rollback a transaction .
22,152
private function doAdvisoryLock ( string $ sessionId ) { switch ( $ this -> driver ) { case 'mysql' : $ lockId = \ substr ( $ sessionId , 0 , 64 ) ; $ stmt = $ this -> pdo -> prepare ( 'SELECT GET_LOCK(:key, 50)' ) ; $ stmt -> bindValue ( ':key' , $ lockId , \ PDO :: PARAM_STR ) ; $ stmt -> execute ( ) ; $ releaseStmt ...
Executes an application - level lock on the database .
22,153
private function getInsertStatement ( $ sessionId , $ sessionData , $ maxlifetime ) { switch ( $ this -> driver ) { case 'oci' : $ data = fopen ( 'php://memory' , 'r+' ) ; fwrite ( $ data , $ sessionData ) ; rewind ( $ data ) ; $ sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->...
Returns an insert statement supported by the database for writing session data .
22,154
public function isHTML ( $ isHtml = true ) { if ( $ isHtml ) { $ this -> ContentType = static :: CONTENT_TYPE_TEXT_HTML ; } else { $ this -> ContentType = static :: CONTENT_TYPE_PLAINTEXT ; } }
Sets message type to HTML or plain .
22,155
public function postSend ( ) { try { switch ( $ this -> Mailer ) { case 'sendmail' : case 'qmail' : return $ this -> sendmailSend ( $ this -> MIMEHeader , $ this -> MIMEBody ) ; case 'smtp' : return $ this -> smtpSend ( $ this -> MIMEHeader , $ this -> MIMEBody ) ; case 'mail' : return $ this -> mailSend ( $ this -> MI...
Actually send a message via the selected mechanism .
22,156
protected static function isShellSafe ( $ string ) { if ( escapeshellcmd ( $ string ) !== $ string or ! in_array ( escapeshellarg ( $ string ) , [ "'$string'" , "\"$string\"" ] ) ) { return false ; } $ length = strlen ( $ string ) ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ c = $ string [ $ i ] ; if ( ! ctype_alnum...
Fix CVE - 2016 - 10033 and CVE - 2016 - 10045 by disallowing potentially unsafe shell characters . Note that escapeshellarg and escapeshellcmd are inadequate for our purposes especially on Windows .
22,157
public function addrAppend ( $ type , $ addr ) { $ addresses = [ ] ; foreach ( $ addr as $ address ) { $ addresses [ ] = $ this -> addrFormat ( $ address ) ; } return $ type . ': ' . implode ( ', ' , $ addresses ) . static :: $ LE ; }
Create recipient headers .
22,158
protected function generateId ( ) { $ len = 32 ; if ( function_exists ( 'random_bytes' ) ) { $ bytes = random_bytes ( $ len ) ; } elseif ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ bytes = openssl_random_pseudo_bytes ( $ len ) ; } else { $ bytes = hash ( 'sha256' , uniqid ( ( string ) mt_rand ( ) , true )...
Create a unique ID to use for boundaries .
22,159
protected function cidExists ( $ cid ) { foreach ( $ this -> attachment as $ attachment ) { if ( 'inline' == $ attachment [ 6 ] and $ cid == $ attachment [ 7 ] ) { return true ; } } return false ; }
Check if an embedded attachment is present with this cid .
22,160
public function clearBCCs ( ) { foreach ( $ this -> bcc as $ bcc ) { unset ( $ this -> all_recipients [ strtolower ( $ bcc [ 0 ] ) ] ) ; } $ this -> bcc = [ ] ; $ this -> clearQueuedAddresses ( 'bcc' ) ; }
Clear all BCC recipients .
22,161
public function clearAllRecipients ( ) { $ this -> to = [ ] ; $ this -> cc = [ ] ; $ this -> bcc = [ ] ; $ this -> all_recipients = [ ] ; $ this -> RecipientsQueue = [ ] ; }
Clear all recipient types .
22,162
public function DKIM_QP ( $ txt ) { $ line = '' ; $ len = strlen ( $ txt ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ ord = ord ( $ txt [ $ i ] ) ; if ( ( ( 0x21 <= $ ord ) and ( $ ord <= 0x3A ) ) or $ ord == 0x3C or ( ( 0x3E <= $ ord ) and ( $ ord <= 0x7E ) ) ) { $ line .= $ txt [ $ i ] ; } else { $ line .= '=' . sp...
Quoted - Printable - encode a DKIM header .
22,163
protected function doCallback ( $ isSent , $ to , $ cc , $ bcc , $ subject , $ body , $ from , $ extra ) { if ( ! empty ( $ this -> action_function ) and is_callable ( $ this -> action_function ) ) { call_user_func ( $ this -> action_function , $ isSent , $ to , $ cc , $ bcc , $ subject , $ body , $ from , $ extra ) ; ...
Perform a callback .
22,164
protected function setError ( $ message , $ detail = '' , $ smtp_code = '' , $ smtp_code_ex = '' ) { $ this -> error = [ 'error' => $ message , 'detail' => $ detail , 'smtp_code' => $ smtp_code , 'smtp_code_ex' => $ smtp_code_ex , ] ; }
Set error messages and codes .
22,165
protected function errorHandler ( $ errno , $ errmsg , $ errfile = '' , $ errline = 0 ) { $ notice = 'Connection failed.' ; $ this -> setError ( $ notice , $ errmsg , ( string ) $ errno ) ; $ this -> edebug ( "$notice Error #$errno: $errmsg [$errfile line $errline]" , self :: DEBUG_CONNECTION ) ; }
Reports an error number and string .
22,166
public function getOauth64 ( ) { if ( null === $ this -> oauthToken or $ this -> oauthToken -> hasExpired ( ) ) { $ this -> oauthToken = $ this -> getToken ( ) ; } return base64_encode ( 'user=' . $ this -> oauthUserEmail . "\001auth=Bearer " . $ this -> oauthToken . "\001\001" ) ; }
Generate a base64 - encoded OAuth token .
22,167
public static function popBeforeSmtp ( $ host , $ port = false , $ timeout = false , $ username = '' , $ password = '' , $ debug_level = 0 ) { $ pop = new self ( ) ; return $ pop -> authorise ( $ host , $ port , $ timeout , $ username , $ password , $ debug_level ) ; }
Simple static wrapper for all - in - one POP before SMTP .
22,168
public function connect ( $ host , $ port = false , $ tval = 30 ) { if ( $ this -> connected ) { return true ; } set_error_handler ( [ $ this , 'catchWarning' ] ) ; if ( false === $ port ) { $ port = static :: DEFAULT_PORT ; } $ this -> pop_conn = fsockopen ( $ host , $ port , $ errno , $ errstr , $ tval ) ; restore_er...
Connect to a POP3 server .
22,169
protected function getResponse ( $ size = 128 ) { $ response = fgets ( $ this -> pop_conn , $ size ) ; if ( $ this -> do_debug >= 1 ) { echo 'Server -> Client: ' , $ response ; } return $ response ; }
Get a response from the POP3 server .
22,170
protected function sendString ( $ string ) { if ( $ this -> pop_conn ) { if ( $ this -> do_debug >= 2 ) { echo 'Client -> Server: ' , $ string ; } return fwrite ( $ this -> pop_conn , $ string , strlen ( $ string ) ) ; } return 0 ; }
Send raw data to the POP3 server .
22,171
public function administrators ( ) : BelongsToMany { $ pivotTable = config ( 'admin.database.role_users_table' ) ; $ relatedModel = config ( 'admin.database.users_model' ) ; return $ this -> belongsToMany ( $ relatedModel , $ pivotTable , 'role_id' , 'user_id' ) ; }
A role belongs to many users .
22,172
public function menus ( ) : BelongsToMany { $ pivotTable = config ( 'admin.database.role_menu_table' ) ; $ relatedModel = config ( 'admin.database.menu_model' ) ; return $ this -> belongsToMany ( $ relatedModel , $ pivotTable , 'role_id' , 'menu_id' ) ; }
A role belongs to many menus .
22,173
protected function initBranchCallback ( ) { if ( is_null ( $ this -> branchCallback ) ) { $ this -> branchCallback = function ( $ branch ) { $ key = $ branch [ $ this -> model -> getKeyName ( ) ] ; $ title = $ branch [ $ this -> model -> getTitleColumn ( ) ] ; return "$key - $title" ; } ; } }
Initialize branch callback .
22,174
public function variables ( ) { return [ 'id' => $ this -> elementId , 'tools' => $ this -> tools -> render ( ) , 'items' => $ this -> getItems ( ) , 'useCreate' => $ this -> useCreate , 'useSave' => $ this -> useSave , 'useRefresh' => $ this -> useRefresh , ] ; }
Variables in tree template .
22,175
public function loads ( $ fields = [ ] , $ sourceUrls = [ ] , $ idField = 'id' , $ textField = 'text' ) { $ fieldsStr = implode ( '.' , $ fields ) ; $ urlsStr = implode ( '^' , $ sourceUrls ) ; $ script = <<<EOTvar fields = '$fieldsStr'.split('.');var urls = '$urlsStr'.split('^');var refreshOptions = function(url, tar...
Load options for other selects on change .
22,176
public function ajax ( $ url , $ idField = 'id' , $ textField = 'text' ) { $ configs = array_merge ( [ 'allowClear' => true , 'placeholder' => $ this -> label , 'minimumInputLength' => 1 , ] , $ this -> config ) ; $ configs = json_encode ( $ configs ) ; $ configs = substr ( $ configs , 1 , strlen ( $ configs ) - 2 ) ; ...
Load options from ajax results .
22,177
public function setRows ( $ rows = [ ] ) { if ( Arr :: isAssoc ( $ rows ) ) { foreach ( $ rows as $ key => $ item ) { $ this -> rows [ ] = [ $ key , $ item ] ; } return $ this ; } $ this -> rows = $ rows ; return $ this ; }
Set table rows .
22,178
public function allPermissions ( ) : Collection { return $ this -> roles ( ) -> with ( 'permissions' ) -> get ( ) -> pluck ( 'permissions' ) -> flatten ( ) -> merge ( $ this -> permissions ) ; }
Get all permissions of user .
22,179
public function visible ( array $ roles = [ ] ) : bool { if ( empty ( $ roles ) ) { return true ; } $ roles = array_column ( $ roles , 'slug' ) ; return $ this -> inRoles ( $ roles ) || $ this -> isAdministrator ( ) ; }
If visible for roles .
22,180
public function getAction ( ) { if ( $ this -> action ) { return $ this -> action ; } if ( $ this -> isMode ( static :: MODE_EDIT ) ) { return $ this -> form -> resource ( ) . '/' . $ this -> id ; } if ( $ this -> isMode ( static :: MODE_CREATE ) ) { return $ this -> form -> resource ( - 1 ) ; } return '' ; }
Get Form action .
22,181
public function field ( $ name ) { return $ this -> fields ( ) -> first ( function ( Field $ field ) use ( $ name ) { return $ field -> column ( ) == $ name ; } ) ; }
Get specify field .
22,182
public function options ( $ options = [ ] ) { if ( empty ( $ options ) ) { return $ this -> options ; } $ this -> options = array_merge ( $ this -> options , $ options ) ; }
Add or get options .
22,183
public function hasFile ( ) { foreach ( $ this -> fields ( ) as $ field ) { if ( $ field instanceof Field \ File ) { return true ; } } return false ; }
Determine if form fields has files .
22,184
public function render ( ) { $ this -> removeReservedFields ( ) ; $ tabObj = $ this -> form -> getTab ( ) ; if ( ! $ tabObj -> isEmpty ( ) ) { $ script = <<<'SCRIPT'var hash = document.location.hash;if (hash) { $('.nav-tabs a[href="' + hash + '"]').tab('show');}// Change hash for page-reload$('.nav-tabs a').on('sho...
Render form .
22,185
protected function formatField ( Field $ field ) { $ jsonKey = $ field -> column ( ) ; $ elementName = $ elementClass = $ errorKey = [ ] ; if ( is_array ( $ jsonKey ) ) { foreach ( $ jsonKey as $ index => $ name ) { $ elementName [ $ index ] = "{$this->column}[$name]" ; $ errorKey [ $ index ] = "{$this->column}.$name" ...
Format form set element name error key and element class .
22,186
public function pushField ( Field $ field ) { $ field = $ this -> formatField ( $ field ) ; $ this -> fields -> push ( $ field ) ; return $ this ; }
Add a field to form .
22,187
public function getConstraints ( ) { if ( $ this -> relation instanceof HasMany ) { return [ $ this -> relation -> getForeignKeyName ( ) => $ this -> relation -> getParentKey ( ) , ] ; } return false ; }
Get constraints .
22,188
public function addConditions ( array $ conditions ) { foreach ( $ conditions as $ condition ) { call_user_func_array ( [ $ this , key ( $ condition ) ] , current ( $ condition ) ) ; } return $ this ; }
Add conditions to grid model .
22,189
protected function handleInvalidPage ( LengthAwarePaginator $ paginator ) { if ( $ paginator -> lastPage ( ) && $ paginator -> currentPage ( ) > $ paginator -> lastPage ( ) ) { $ lastPageUrl = Request :: fullUrlWithQuery ( [ $ paginator -> getPageName ( ) => $ paginator -> lastPage ( ) , ] ) ; Pjax :: respond ( redirec...
If current page is greater than last page then redirect to last page .
22,190
protected function setPaginate ( ) { $ paginate = $ this -> findQueryByMethod ( 'paginate' ) ; $ this -> queries = $ this -> queries -> reject ( function ( $ query ) { return $ query [ 'method' ] == 'paginate' ; } ) ; if ( ! $ this -> usePaginate ) { $ query = [ 'method' => 'get' , 'arguments' => [ ] , ] ; } else { $ q...
Set the grid paginate .
22,191
public function with ( $ relations ) { if ( is_array ( $ relations ) ) { if ( Arr :: isAssoc ( $ relations ) ) { $ relations = array_keys ( $ relations ) ; } $ this -> eagerLoads = array_merge ( $ this -> eagerLoads , $ relations ) ; } if ( is_string ( $ relations ) ) { if ( Str :: contains ( $ relations , '.' ) ) { $ ...
Set the relationships that should be eager loaded .
22,192
public function disableReset ( bool $ disable = true ) { if ( $ disable ) { array_delete ( $ this -> buttons , 'reset' ) ; } elseif ( ! in_array ( 'reset' , $ this -> buttons ) ) { array_push ( $ this -> buttons , 'reset' ) ; } return $ this ; }
Disable reset button .
22,193
public function disableViewCheck ( bool $ disable = true ) { if ( $ disable ) { array_delete ( $ this -> checkboxes , 'view' ) ; } elseif ( ! in_array ( 'view' , $ this -> checkboxes ) ) { array_push ( $ this -> checkboxes , 'view' ) ; } return $ this ; }
Disable View Checkbox .
22,194
public function render ( ) { $ this -> setupScript ( ) ; $ data = [ 'buttons' => $ this -> buttons , 'checkboxes' => $ this -> checkboxes , 'width' => $ this -> builder -> getWidth ( ) , ] ; return view ( $ this -> view , $ data ) -> render ( ) ; }
Render footer .
22,195
public function ajax ( $ resourceUrl , $ idField = 'id' , $ textField = 'text' ) { $ configs = array_merge ( [ 'allowClear' => true , 'placeholder' => trans ( 'admin.choose' ) , 'minimumInputLength' => 1 , ] , $ this -> config ) ; $ configs = json_encode ( $ configs ) ; $ configs = substr ( $ configs , 1 , strlen ( $ c...
Load options from ajax .
22,196
public function load ( $ target , $ resourceUrl , $ idField = 'id' , $ textField = 'text' ) : self { $ column = $ this -> filter -> getColumn ( ) ; $ script = <<<EOT$(document).off('change', ".{$this->getClass($column)}");$(document).on('change', ".{$this->getClass($column)}", function () { var target = $(this).clo...
Load options for other select when change .
22,197
public function add ( $ title , $ content , $ active = false ) { $ this -> data [ 'tabs' ] [ ] = [ 'id' => mt_rand ( ) , 'title' => $ title , 'content' => $ content , 'type' => static :: TYPE_CONTENT , ] ; if ( $ active ) { $ this -> data [ 'active' ] = count ( $ this -> data [ 'tabs' ] ) - 1 ; } return $ this ; }
Add a tab and its contents .
22,198
public function addLink ( $ title , $ href , $ active = false ) { $ this -> data [ 'tabs' ] [ ] = [ 'id' => mt_rand ( ) , 'title' => $ title , 'href' => $ href , 'type' => static :: TYPE_LINK , ] ; if ( $ active ) { $ this -> data [ 'active' ] = count ( $ this -> data [ 'tabs' ] ) - 1 ; } return $ this ; }
Add a link on tab .
22,199
public function dropDown ( array $ links ) { if ( is_array ( $ links [ 0 ] ) ) { foreach ( $ links as $ link ) { call_user_func ( [ $ this , 'dropDown' ] , $ link ) ; } return $ this ; } $ this -> data [ 'dropDown' ] [ ] = [ 'name' => $ links [ 0 ] , 'href' => $ links [ 1 ] , ] ; return $ this ; }
Set drop - down items .