idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
28,800
private function assertEscapeType ( $ type ) { if ( ! in_array ( $ type , array_keys ( $ this -> escapeTypes ) , true ) ) { throw new Exception \ InvalidEscaperException ( 'Invalid escape type provided' ) ; } }
Assert that a given escape type is valid .
28,801
public static function make ( $ objectkey = 'index' ) { $ objectkey = filter_var ( $ objectkey , FILTER_SANITIZE_SPECIAL_CHARS ) ; $ website_id = Website :: currentWebsiteId ( ) ; $ cache_key = 'vobject__' . $ website_id . '__' . $ objectkey ; if ( Cache :: has ( $ cache_key ) ) { return Cache :: get ( $ cache_key ) ; } $ object = static :: where ( 'objectkey' , '=' , $ objectkey ) -> join ( 'vobject_website' , 'vobjects.id' , '=' , 'vobject_website.vobject_id' ) -> where ( 'vobject_website.website_id' , '=' , $ website_id ) -> select ( 'vobjects.id AS id' , 'vobjects.content AS content' , 'vobjects.updated_at AS updated_at' ) -> first ( ) ; if ( ! empty ( $ object ) ) { $ fluent = $ object -> toFluent ( ) ; Cache :: put ( $ cache_key , $ fluent , 60 ) ; return $ fluent ; } $ object = static :: where ( 'objectkey' , '=' , $ objectkey ) -> leftJoin ( 'vobject_website' , 'vobjects.id' , '=' , 'vobject_website.vobject_id' ) -> whereNull ( 'vobject_website.website_id' ) -> select ( 'vobjects.id AS id' , 'vobjects.content AS content' , 'vobjects.updated_at AS updated_at' ) -> first ( ) ; if ( empty ( $ object ) ) { return null ; } $ fluent = $ object -> toFluent ( ) ; Cache :: put ( $ cache_key , $ fluent , 60 ) ; return $ fluent ; }
Fetch a object by objectkey or url .
28,802
protected function _oauthRequest ( $ url , $ params ) { if ( ! isset ( $ params [ 'access_token' ] ) ) { $ params [ 'access_token' ] = $ this -> getAccessToken ( ) ; } if ( isset ( $ params [ 'access_token' ] ) ) { $ params [ 'appsecret_proof' ] = $ this -> getAppSecretProof ( $ params [ 'access_token' ] ) ; } foreach ( $ params as $ key => $ value ) { if ( ! is_string ( $ value ) && ! ( $ value instanceof CURLFile ) ) { $ params [ $ key ] = json_encode ( $ value ) ; } } return $ this -> makeRequest ( $ url , $ params ) ; }
Make a OAuth Request .
28,803
public function setSuffix ( $ suffix ) { $ suffix = ltrim ( ( string ) $ suffix , '.' ) ; $ this -> suffix = '.' . $ suffix ; return $ this ; }
Set file suffix
28,804
public function addTemplatePath ( $ templatePath , $ namespace = null ) { if ( ! is_dir ( $ templatePath ) ) { throw new Exception \ InvalidTemplatePathException ( sprintf ( '%s expects a valid path to a directory; received "%s"' , __METHOD__ , $ templatePath ) ) ; } if ( null !== $ namespace && ! is_string ( $ namespace ) ) { throw new Exception \ InvalidNamespaceException ( 'Namespace must be a string' ) ; } $ namespace = $ namespace ? : self :: DEFAULT_NAMESPACE ; $ templatePath = rtrim ( ( string ) $ templatePath , '/\\' ) ; $ this -> getTemplatePath ( $ namespace ) -> push ( $ templatePath ) ; return $ this ; }
Add a template path .
28,805
public function getTemplatePath ( $ namespace = null ) { if ( null !== $ namespace && ! is_string ( $ namespace ) ) { throw new Exception \ InvalidNamespaceException ( 'Namespace must be a string' ) ; } $ namespace = $ namespace ? : self :: DEFAULT_NAMESPACE ; if ( ! array_key_exists ( $ namespace , $ this -> paths ) ) { $ this -> paths [ $ namespace ] = new SplStack ; } return $ this -> paths [ $ namespace ] ; }
Get value for templatePath
28,806
public function getNamespaces ( ) { $ namespaces = [ ] ; foreach ( $ this -> paths as $ namespace => $ paths ) { if ( count ( $ paths ) ) { $ namespaces [ ] = $ namespace ; } } return $ namespaces ; }
Return a list of registered namespaces .
28,807
public function resolve ( $ template ) { $ namespace = self :: DEFAULT_NAMESPACE ; if ( preg_match ( '#^(?P<namespace>[^:]+)::(?P<template>.*)$#' , $ template , $ matches ) ) { $ namespace = $ matches [ 'namespace' ] ; $ template = $ matches [ 'template' ] ; } $ segments = explode ( $ this -> getSeparator ( ) , $ template ) ; $ template = implode ( '/' , $ segments ) . $ this -> getSuffix ( ) ; $ path = $ this -> fetchTemplateForNamespace ( $ template , $ namespace ) ; if ( $ path !== false || $ namespace === self :: DEFAULT_NAMESPACE ) { return $ path ; } return $ this -> fetchTemplateForNamespace ( $ template , self :: DEFAULT_NAMESPACE ) ; }
Resolve a template to its file
28,808
private function fetchTemplateForNamespace ( $ template , $ namespace ) { foreach ( $ this -> getTemplatePath ( $ namespace ) as $ path ) { if ( ! empty ( $ path ) ) { $ path .= '/' ; } $ filename = $ path . $ template ; if ( file_exists ( $ filename ) ) { return file_get_contents ( $ filename ) ; } } return false ; }
Attempt to retrieve a template for a given namespace .
28,809
public function setMap ( array $ map ) { $ lengths = array_map ( 'strlen' , array_keys ( $ map ) ) ; array_multisort ( $ lengths , SORT_DESC , $ map ) ; $ this -> map = $ map ; }
Sets a map of prefixes to objects implementing HttpKernelInterface
28,810
public static function pack ( ParticleInterface $ particle ) : AbstractLoader { $ obj = new FieldsLoader ; $ obj -> fields = [ ] ; $ fields = [ ] ; $ obj -> cargo -> fields = self :: fetchArray ( $ particle ) ; return $ obj ; }
Sets up fields .
28,811
public static function formataCPFCNPJ ( $ str ) { $ str = preg_replace ( '![^\d]!' , '' , $ str ) ; if ( 11 == strlen ( $ str ) || 14 > strlen ( $ str ) ) { $ str = CPF :: formatar ( $ str ) ; } elseif ( 14 <= strlen ( $ str ) ) { $ str = CNPJ :: formatar ( $ str ) ; } return $ str ; }
Retorna CPF ou CNPJ formatado
28,812
public static function formataCOSIF ( $ cosif ) { if ( 8 == strlen ( $ cosif ) ) { $ ret = substr ( $ cosif , 0 , 1 ) . '.' . substr ( $ cosif , 1 , 1 ) . '.' . substr ( $ cosif , 2 , 1 ) . '.' . substr ( $ cosif , 3 , 2 ) . '.' . substr ( $ cosif , 5 , 2 ) . '-' . substr ( $ cosif , 7 , 1 ) ; } else { $ ret = false ; } return $ ret ; }
Retorna COSIF em seu formato correto
28,813
public static function formataCEP ( $ cep ) { if ( 8 == strlen ( $ cep ) ) { $ ret = substr ( $ cep , 0 , 2 ) . '.' . substr ( $ cep , 2 , 3 ) . '-' . substr ( $ cep , 5 , 3 ) ; } else { $ ret = false ; } return $ ret ; }
Retorna o cep no formato correto
28,814
public static function formataFone ( $ str ) { $ str = preg_replace ( "/[^0-9]/" , '' , $ str ) ; if ( ! $ str ) { return '' ; } if ( '0800' == substr ( $ str , 0 , 4 ) ) { $ srt = substr ( $ str , - 11 , - 7 ) . ' ' . substr ( $ str , - 7 , - 4 ) . '-' . substr ( $ str , - 4 ) ; } elseif ( 11 == strlen ( $ str ) ) { $ srt = '(' . substr ( $ str , - 11 , - 9 ) . ') ' . substr ( $ str , - 9 , - 4 ) . '-' . substr ( $ str , - 4 ) ; } else { $ srt = '(' . substr ( $ str , - 10 , - 8 ) . ') ' . substr ( $ str , - 8 , - 4 ) . '-' . substr ( $ str , - 4 ) ; } return $ srt ; }
Retorna o telefone no formato correto
28,815
public static function formataMoeda ( $ value , $ clean = true ) { $ value = ( double ) $ value ; return ( $ value || ! $ clean ) ? number_format ( $ value , 2 , ',' , '.' ) : '' ; }
Retorna valor no formato 000 . 000 00
28,816
protected function parseAuthorizationRequest ( IRequest $ request , IUser $ user ) { $ clientId = $ request -> query ( 'client_id' ) ; if ( ! $ clientId ) { throw new InvalidRequestException ( 'Client id is missing.' ) ; } $ client = $ this -> clientStorage -> get ( $ clientId ) ; if ( ! $ client ) { throw new InvalidClientException ( 'Invalid client.' ) ; } if ( ! $ client -> isAllowedToUse ( $ this ) ) { throw new UnauthorizedClientException ( 'Client can not use this grant type.' ) ; } $ redirectUri = $ request -> query ( 'redirect_uri' ) ; $ clientRedirectUri = $ client -> getRedirectUri ( ) ; if ( $ redirectUri ) { $ parsedUrl = parse_url ( $ redirectUri ) ; if ( $ parsedUrl === false || isset ( $ parsedUrl [ 'fragment' ] ) ) { throw new InvalidRequestException ( 'Redirect URI is invalid.' ) ; } if ( ! $ this -> compareUris ( $ redirectUri , $ clientRedirectUri ) ) { throw new InvalidRequestException ( 'Redirect URI does not match.' ) ; } } else { if ( ! $ clientRedirectUri ) { throw new InvalidRequestException ( 'Redirect URI was not supplied or registered.' ) ; } $ redirectUri = $ clientRedirectUri ; } $ requestedScopes = $ request -> query ( 'scope' ) ; $ availableScopes = $ user -> getScopes ( ) ; if ( ! $ availableScopes ) { $ availableScopes = $ this -> scopeResolver -> getDefaultScopes ( ) ; } if ( empty ( $ availableScopes ) ) { throw new InvalidScopeException ( 'Scope parameter has to be specified.' ) ; } $ scopes = $ this -> scopeResolver -> intersect ( $ requestedScopes , $ availableScopes ) ; return [ 'client' => $ client , 'redirect_uri' => $ redirectUri , 'state' => $ request -> query ( 'state' ) , 'scopes' => $ scopes ] ; }
Parses authorization request
28,817
public function getColumnStyle ( $ columnIndex ) { if ( isset ( $ this -> columnStyles [ $ columnIndex ] ) ) { return $ this -> columnStyles [ $ columnIndex ] ; } return $ this -> getStyle ( ) ; }
Gets the current style for a column .
28,818
private function getCellWidth ( array $ row , $ column ) { $ cellWidth = 0 ; if ( isset ( $ row [ $ column ] ) ) { $ cell = $ row [ $ column ] ; $ cellWidth = Console :: strlenWithoutDecoration ( $ this -> output -> getFormatter ( ) , $ cell ) ; } $ columnWidth = isset ( $ this -> columnWidths [ $ column ] ) ? $ this -> columnWidths [ $ column ] : 0 ; return max ( $ cellWidth , $ columnWidth ) ; }
Gets cell width .
28,819
public function getBody ( ) : string { return $ this -> cipher -> getCipherText ( ) -> getRawBytes ( ) . $ this -> cipher -> getAuthenticationTag ( ) -> getRawBytes ( ) ; }
Get message body .
28,820
private function loadCacheMetaData ( ) { if ( isset ( $ this -> metaData ) ) { return ; } $ metaFile = $ this -> cacheDirectory . '/cache.meta' ; $ this -> metaData = array ( ) ; if ( file_exists ( $ metaFile ) ) { $ this -> metaData = unserialize ( file_get_contents ( $ metaFile ) ) ; } }
Load cache meta data
28,821
public function convertToUnixTimestamp ( $ dateTime ) { if ( preg_match ( '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:|\.\d+)(Z|[+-]\d{2}:\d{2})$/' , $ dateTime , $ matches ) ) { $ timestamp = gmmktime ( $ matches [ 4 ] , $ matches [ 5 ] , $ matches [ 6 ] , $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] ) ; if ( $ matches [ 7 ] !== 'Z' ) { preg_match ( '/^([+-])(\d{2}):(\d{2})$/' , $ matches [ 7 ] , $ matches ) ; $ offset = ( $ matches [ 1 ] === '-' ? - 1 : 1 ) * ( $ matches [ 2 ] * 60 + $ matches [ 3 ] ) * 60 ; $ timestamp -= $ offset ; } } return $ timestamp ; }
Convert RFC 3339 timestamp string to Unix timestamp
28,822
public function read ( $ key ) { if ( ! isset ( $ this -> cacheDirectory ) ) { return ; } $ this -> loadCacheMetaData ( ) ; return unserialize ( file_get_contents ( $ this -> cacheDirectory . '/' . $ key ) ) ; }
Read content from cache
28,823
public function write ( $ key , $ content , $ timestamp = null ) { if ( ! isset ( $ this -> cacheDirectory ) ) { return ; } $ this -> loadCacheMetaData ( ) ; $ this -> metaData [ $ key ] = $ timestamp ; $ this -> dirty = true ; if ( ! is_dir ( $ this -> cacheDirectory ) ) { mkdir ( $ this -> cacheDirectory , 0775 , true ) ; } file_put_contents ( $ this -> cacheDirectory . '/' . $ key , serialize ( $ content ) ) ; }
Write content to cache
28,824
protected function dumpToString ( array $ dump ) : string { return collect ( $ dump ) -> map ( function ( $ item , $ key ) { return str_pad ( $ key . ':' , 15 , ' ' ) . ( is_scalar ( $ item ) ? $ item : json_encode ( $ item ) ) ; } ) -> prepend ( "\n" ) -> implode ( "\n" ) ; }
Convert dump array to string .
28,825
public function getAccountHistory ( RequestAccountPaginated $ account ) { return $ this -> get ( [ 'accounts' , $ account -> getId ( ) , 'ledger' ] , ResponseLedger :: class , $ account -> toArray ( ) ) ; }
List account activity . Account activity either increases or decreases your account balance . Items are paginated and sorted latest first . See the Pagination section for retrieving additional entries after the first page .
28,826
public function getAccountHolds ( RequestAccountPaginated $ account ) { return $ this -> get ( [ 'accounts' , $ account -> getId ( ) , 'holds' ] , ResponseHold :: class , $ account -> toArray ( ) ) ; }
Holds are placed on an account for any active orders or pending withdraw requests . As an order is filled the hold amount is updated . If an order is canceled any remaining hold is removed . For a withdraw once it is completed the hold is removed .
28,827
public function getFills ( RequestFill $ fill = null ) { return $ this -> get ( [ 'fills' ] , ResponseFill :: class , ( $ fill !== null ) ? $ fill -> toArray ( ) : [ ] ) ; }
Get a list of recent fills .
28,828
protected function registerHipSupportOnlineCommand ( ) { $ hipsupport = $ this -> initHipSupport ( ) ; $ this -> app [ 'hipsupport.online' ] = $ this -> app -> share ( function ( $ app ) use ( $ hipsupport ) { return new HipSupportOnlineCommand ( $ hipsupport ) ; } ) ; }
Register hipsupport . online
28,829
protected function registerHipSupportOfflineCommand ( ) { $ hipsupport = $ this -> initHipSupport ( ) ; $ this -> app [ 'hipsupport.offline' ] = $ this -> app -> share ( function ( $ app ) use ( $ hipsupport ) { return new HipSupportOfflineCommand ( $ hipsupport ) ; } ) ; }
Register hipsupport . offline
28,830
protected function parseTags ( $ tags ) { $ tags = trim ( $ tags ) ; if ( ! empty ( $ tags ) ) { $ result = [ ] ; foreach ( explode ( "\n" , $ tags ) as $ line ) { if ( $ this -> isTagLine ( $ line ) || count ( $ result ) == 0 ) { $ result [ ] = $ line ; } else { $ result [ count ( $ result ) - 1 ] .= PHP_EOL . $ line ; } } if ( count ( $ result ) ) { $ this -> tags -> clear ( ) ; foreach ( $ result as $ line ) { $ this -> tags -> add ( $ this -> parseTag ( $ line ) ) ; } } } }
Parses the tags
28,831
protected function parseTag ( $ line ) { $ matches = [ ] ; if ( ! preg_match ( '/^@(' . self :: REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us' , $ line , $ matches ) ) { throw new \ InvalidArgumentException ( 'Invalid tag line detected: ' . $ line ) ; } $ tagName = $ matches [ 1 ] ; $ content = isset ( $ matches [ 2 ] ) ? $ matches [ 2 ] : '' ; return TagFactory :: create ( $ tagName , $ content ) ; }
Parses an individual tag line
28,832
public function hasTag ( $ tagName ) { return $ this -> tags -> search ( $ tagName , function ( AbstractTag $ tag , $ query ) { return $ tag -> getTagName ( ) == $ query ; } ) ; }
Checks whether a tag is present
28,833
public function getSortedTags ( ) { if ( $ this -> comparator === null ) { $ this -> comparator = new TagNameComparator ( ) ; } $ group = new Map ( ) ; foreach ( $ this -> tags as $ tag ) { if ( ! $ group -> has ( $ tag -> getTagName ( ) ) ) { $ group -> set ( $ tag -> getTagName ( ) , new ArrayList ( ) ) ; } $ group -> get ( $ tag -> getTagName ( ) ) -> add ( $ tag ) ; } $ group -> sortKeys ( new TagNameComparator ( ) ) ; $ sorted = new ArrayList ( ) ; foreach ( $ group -> values ( ) as $ tags ) { $ sorted -> addAll ( $ tags ) ; } return $ sorted ; }
A list of tags sorted by tag - name
28,834
public function isEmpty ( ) { return empty ( $ this -> shortDescription ) && empty ( $ this -> longDescription ) && $ this -> tags -> size ( ) == 0 ; }
Returns true when there is no content in the docblock
28,835
public function toString ( ) { $ docblock = "/**\n" ; $ short = trim ( $ this -> shortDescription ) ; if ( ! empty ( $ short ) ) { $ docblock .= $ this -> writeLines ( explode ( "\n" , $ short ) ) ; } $ long = trim ( $ this -> longDescription ) ; if ( ! empty ( $ long ) ) { $ docblock .= $ this -> writeLines ( explode ( "\n" , $ long ) , ! empty ( $ short ) ) ; } $ tags = $ this -> getSortedTags ( ) -> map ( function ( $ tag ) { return $ tag -> toString ( ) ; } ) ; if ( ! $ tags -> isEmpty ( ) ) { $ docblock .= $ this -> writeLines ( $ tags -> toArray ( ) , ! empty ( $ short ) || ! empty ( $ long ) ) ; } $ docblock .= ' */' ; return $ docblock ; }
Returns the string version of the docblock
28,836
public function saveGridPage ( ) { if ( ! isset ( Yii :: $ app -> session [ $ this -> sessionVarName ] ) ) { Yii :: $ app -> session [ $ this -> sessionVarName ] = 0 ; } if ( ! isset ( Yii :: $ app -> session [ $ this -> sessionPageSizeName ] ) ) Yii :: $ app -> session [ $ this -> sessionPageSizeName ] = 10 ; if ( Yii :: $ app -> request -> get ( $ this -> getVarName ) !== null ) { Yii :: $ app -> session [ $ this -> sessionVarName ] = ( int ) Yii :: $ app -> request -> get ( $ this -> getVarName ) - 1 ; } if ( Yii :: $ app -> request -> get ( $ this -> getPageSizeName ) !== null ) Yii :: $ app -> session [ $ this -> sessionPageSizeName ] = ( int ) Yii :: $ app -> request -> get ( $ this -> getPageSizeName ) ; }
Saves the grid s current active page index .
28,837
public function where ( ) : ContextInterface { if ( is_null ( $ this -> current_context ) ) { $ this -> enter ( $ this -> context ( ) ) ; } return $ this -> current_context ; }
Returns which context the Actor is currently operating
28,838
public static function handle ( Exception $ e ) { if ( $ e instanceof AtomikHttpException ) { header ( 'Location: ' , false , $ e -> getCode ( ) ) ; if ( $ e -> getCode ( ) === 404 ) { header ( 'Content-type: text/html' ) ; if ( $ output = Atomik :: render ( self :: $ config [ '404_view' ] , array ( 'exception' => $ e ) ) ) { echo $ output ; } else { echo '<h1>Page not found</h1>' ; } } } else { header ( 'Location: ' , false , 500 ) ; if ( self :: $ config [ 'catch_errors' ] ) { if ( $ output = Atomik :: render ( self :: $ config [ 'error_view' ] , array ( 'exception' => $ e ) ) ) { echo $ output ; } else { echo self :: render ( $ e ) ; } } else if ( self :: $ config [ 'throw_errors' ] ) { throw $ e ; } } }
Handles an exception according to the config
28,839
public static function render ( Exception $ exception , $ return = false ) { $ attributes = self :: $ config [ 'error_report_attrs' ] ; $ html = '<div ' . $ attributes [ 'atomik-error' ] . '>' . '<span ' . $ attributes [ 'atomik-error-title' ] . '>' . $ exception -> getMessage ( ) . '</span>' . '<br />An error of type <strong>' . get_class ( $ exception ) . '</strong> ' . 'was caught at <strong>line ' . $ exception -> getLine ( ) . '</strong><br />' . 'in file <strong>' . $ exception -> getFile ( ) . '</strong>' . '<p>' . $ exception -> getMessage ( ) . '</p>' . '<table ' . $ attributes [ 'atomik-error-lines' ] . '>' ; $ lines = file ( $ exception -> getFile ( ) ) ; $ start = $ exception -> getLine ( ) - 7 ; $ start = $ start < 0 ? 0 : $ start ; $ end = $ exception -> getLine ( ) + 7 ; $ end = $ end > count ( $ lines ) ? count ( $ lines ) : $ end ; for ( $ i = $ start ; $ i < $ end ; $ i ++ ) { if ( $ i == $ exception -> getLine ( ) - ( get_class ( $ exception ) != 'ErrorException' ? 1 : 0 ) ) { $ html .= '<tr ' . $ attributes [ 'atomik-error-line-error' ] . '><td>' ; } else { $ html .= '<tr ' . $ attributes [ 'atomik-error-line' ] . '>' . '<td ' . $ attributes [ 'atomik-error-line-number' ] . '>' ; } $ html .= $ i . '</td><td ' . $ attributes [ 'atomik-error-line-text' ] . '>' . ( isset ( $ lines [ $ i ] ) ? htmlspecialchars ( $ lines [ $ i ] ) : '' ) . '</td></tr>' ; } $ html .= '</table>' . '<strong>Stack:</strong><p ' . $ attributes [ 'atomik-error-stack' ] . '>' . nl2br ( $ exception -> getTraceAsString ( ) ) . '</p></div>' ; return $ html ; }
Renders an exception
28,840
public function view ( UserPolicy $ user , Job $ job ) { if ( $ user -> canDo ( 'career.job.view' ) && $ user -> isAdmin ( ) ) { return true ; } return $ job -> user_id == user_id ( ) && $ job -> user_type == user_type ( ) ; }
Determine if the given user can view the job .
28,841
public function destroy ( UserPolicy $ user , Job $ job ) { return $ job -> user_id == user_id ( ) && $ job -> user_type == user_type ( ) ; }
Determine if the given user can delete the given job .
28,842
public function render ( array $ tokenStruct , $ view , array $ options , Mustache $ mustache ) { $ subView = $ this -> getValue ( $ tokenStruct [ 1 ] , $ view ) ; if ( ! $ subView instanceof SubView ) { return ; } $ template = $ subView -> getTemplate ( ) ; $ localView = $ subView -> getView ( ) ; if ( null === $ localView ) { $ localView = $ view ; } return $ mustache -> render ( $ template , $ localView ) ; }
Render a sub view variable .
28,843
public function json ( ) : string { return json_encode ( [ 'title' => $ this -> title , 'body' => $ this -> body , 'url' => $ this -> url , 'icon' => $ this -> icon , ] ) ; }
Convert the push notification into a json string .
28,844
public static function fieldExists ( FieldsCargo $ cargo , string $ name ) : bool { return array_key_exists ( $ name , $ cargo -> fields ) ; }
Checks if there is such a field in the given particle .
28,845
public static function findFieldName ( FieldsCargo $ cargo , string $ name ) : string { $ name = \ Stringy \ StaticStringy :: upperCamelize ( $ name ) ; if ( self :: fieldExists ( $ cargo , $ name ) ) return $ name ; throw new \ Exception ( "Cannot resolve field name." ) ; }
Given the uppercamelized field name find its normalized version in the fields section .
28,846
public static function pickSingular ( ? array $ elements ) { if ( ! is_null ( $ elements ) && is_array ( $ elements ) && count ( $ elements ) >= 1 ) return $ elements [ 0 ] ; return $ elements ; }
A helper method to pick a single element only .
28,847
public static function pack ( ParticleInterface $ particle ) : AbstractLoader { $ obj = new IncomingEdgeLoader ( $ particle -> getRegisteredIncomingEdges ( ) ) ; foreach ( $ obj -> cargo -> classes as $ class ) { $ class = str_replace ( "ObjectOut" , "ObjOut" , $ class ) ; $ class_ref = new \ ReflectionClass ( $ class ) ; $ check = false ; foreach ( $ class_ref -> getConstant ( "SETTABLES" ) as $ head_node_type ) { $ check |= is_a ( $ particle , $ head_node_type ) ; } if ( $ class_ref -> getConstant ( "SETTABLES_EXTRA" ) !== false ) { foreach ( $ class_ref -> getConstant ( "SETTABLES_EXTRA" ) as $ head_node_type ) { $ check |= is_a ( $ particle , $ head_node_type ) ; } } if ( $ check ) { $ method = $ class_ref -> getConstant ( "TAIL_LABELS" ) ; $ obj -> cargo -> labels [ ] = \ Stringy \ StaticStringy :: camelize ( $ method ) ; $ obj -> cargo -> label_class_pairs [ $ method ] = $ class ; $ method = $ class_ref -> getConstant ( "TAIL_LABEL" ) ; $ obj -> cargo -> singularLabels [ ] = \ Stringy \ StaticStringy :: camelize ( $ method ) ; $ obj -> cargo -> singularLabel_class_pairs [ $ method ] = $ class ; } if ( $ class_ref -> hasConstant ( "HEAD_CALLABLE_LABELS" ) ) { $ callable = $ class_ref -> getConstant ( "HEAD_CALLABLE_LABELS" ) ; $ obj -> cargo -> callable_edge_labels [ ] = \ Stringy \ StaticStringy :: camelize ( $ callable ) ; $ obj -> cargo -> callable_edge_label_class_pairs [ $ callable ] = $ class ; $ callable = $ class_ref -> getConstant ( "HEAD_CALLABLE_LABEL" ) ; $ obj -> cargo -> callable_edge_singularLabels [ ] = \ Stringy \ StaticStringy :: camelize ( $ callable ) ; $ obj -> cargo -> callable_edge_singularLabel_class_pairs [ $ callable ] = $ class ; } } return $ obj ; }
Sets up incoming edges .
28,848
private function readChunk ( ) { $ splits = $ this -> blockSize ; $ this -> blockStart -= $ splits ; if ( $ this -> blockStart < 0 ) { $ splits += $ this -> blockStart ; $ this -> blockStart = 0 ; } if ( $ splits === 0 ) { return FALSE ; } fseek ( $ this -> fileHandle , $ this -> blockStart , SEEK_SET ) ; $ buff = fread ( $ this -> fileHandle , $ splits ) ; return $ buff ; }
Fetch chunk of data from file . Each time this function is called will it fetch a chunk of data from the file . It starts from the end of the file and work towards the beginning of the file .
28,849
public function getPreviousLine ( ) { if ( count ( $ this -> content ) === 0 || $ this -> readPointer < 1 ) { do { $ buff = $ this -> readChunk ( ) ; if ( $ buff !== FALSE ) { $ eolPos = strpos ( $ buff , "\n" ) ; } else { if ( strlen ( $ this -> remainder ) > 0 ) { $ buff = $ this -> remainder ; $ this -> remainder = '' ; break ; } else { return FALSE ; } } if ( $ eolPos === FALSE ) { $ this -> remainder = $ buff . $ this -> remainder ; $ buff = '' ; } elseif ( $ eolPos !== 0 ) { $ buff .= $ this -> remainder ; $ this -> remainder = substr ( $ buff , 0 , $ eolPos ) ; $ buff = substr ( $ buff , $ eolPos + 1 ) ; } elseif ( $ eolPos === 0 ) { $ buff .= $ this -> remainder ; $ buff = substr ( $ buff , 1 ) ; $ this -> remainder = '' ; } } while ( ( $ buff !== FALSE ) && ( $ eolPos === FALSE ) ) ; $ this -> content = explode ( "\n" , $ buff ) ; $ this -> readPointer = count ( $ this -> content ) ; } if ( count ( $ this -> content ) > 0 ) { return $ this -> content [ -- $ this -> readPointer ] ; } else { return FALSE ; } }
Get one line of data from the file starting from the end of the file .
28,850
public function getFrame ( int $ index ) : StackFrame { if ( $ index < 0 || ! isset ( $ this -> frames [ $ index ] ) ) { throw new Exception ( 'Frame index is out of range' ) ; } return $ this -> frames [ $ index ] ; }
Returns a StackFrame at a particular index .
28,851
private function parse ( \ ReflectionClass $ clazz ) { $ content = file_get_contents ( $ clazz -> getFileName ( ) ) ; $ tokens = token_get_all ( $ content ) ; $ doc = null ; $ isConst = false ; foreach ( $ tokens as $ token ) { @ list ( $ tokenType , $ tokenValue ) = $ token ; switch ( $ tokenType ) { case T_WHITESPACE : case T_COMMENT : break ; case T_DOC_COMMENT : $ doc = $ tokenValue ; break ; case T_CONST : $ isConst = true ; break ; case T_STRING : if ( $ isConst ) { $ this -> docComments [ $ tokenValue ] = self :: clean ( $ doc ) ; } $ doc = null ; $ isConst = false ; break ; default : $ doc = null ; $ isConst = false ; break ; } } }
Parses the class for constant DocComments .
28,852
private static function clean ( $ doc ) { if ( $ doc === null ) { return null ; } $ result = null ; $ lines = preg_split ( '/\r/' , $ doc ) ; foreach ( $ lines as $ line ) { $ line = preg_replace ( '/^\s*\* /' , '' , trim ( $ line , "\n/* \t\x0B\0" ) ) ; if ( $ line === '' ) { continue ; } if ( $ result != null ) { $ result .= ' ' ; } $ result .= $ line ; } return $ result ; }
Cleans the doc comment . Returns null if the doc comment is null .
28,853
private function getIssue ( $ resource ) { if ( strncmp ( $ resource , 'jira:' , 5 ) === 0 ) { return substr ( $ resource , 5 ) ; } return $ this -> jiraService -> getIssue ( $ resource ) ; }
Get issue ID from resource
28,854
private function parseFeature ( $ issue ) { $ body = $ this -> getFeature ( $ issue ) ; $ url = $ this -> jiraService -> getUrl ( $ issue -> key ) . '#' ; $ feature = $ this -> gherkinParser -> parse ( $ body , $ url ) ; if ( isset ( $ issue -> assignee ) ) { $ feature -> addTag ( 'assignee:' . str_replace ( array ( ' ' , '@' ) , '_' , $ issue -> assignee ) ) ; } if ( isset ( $ issue -> fixVersions ) ) { foreach ( $ issue -> fixVersions as $ fixVersion ) { $ feature -> addTag ( 'fixVersion:' . str_replace ( array ( ' ' , '@' ) , '_' , $ fixVersion -> name ) ) ; } } return $ feature ; }
Parse feature from issue
28,855
private function getFeature ( $ issue ) { $ arrayIssue = ( array ) $ issue ; if ( array_key_exists ( $ this -> featureField , $ arrayIssue ) ) { return $ this -> extractFeatureFromString ( $ arrayIssue [ $ this -> featureField ] ) ; } $ customFields = $ arrayIssue [ 'customFieldValues' ] ; foreach ( $ customFields as $ customField ) { if ( $ this -> featureField == $ customField -> customfieldId ) { $ value = current ( $ customField -> values ) ; return $ this -> extractFeatureFromString ( $ value ) ; } } return '' ; }
Gets the feature from the defined field
28,856
private function parseFeatures ( $ issues ) { $ features = array ( ) ; foreach ( $ issues as $ issue ) { $ feature = $ this -> parseFeature ( $ issue ) ; if ( $ feature instanceof FeatureNode ) { $ features [ $ issue -> key ] = $ feature ; $ timestamp = $ this -> cacheService -> convertToUnixTimestamp ( $ issue -> updated ) ; $ this -> cacheService -> write ( $ issue -> key , $ feature , $ timestamp ) ; } } return $ features ; }
Parse features from issues
28,857
private function createFeature ( $ issue ) { $ issue = $ this -> jiraService -> fetchIssue ( $ issue ) ; $ feature = $ this -> parseFeature ( $ issue ) ; if ( $ feature instanceof FeatureNode ) { return array ( $ feature ) ; } return array ( ) ; }
Create single feature feature suite
28,858
private function createFeatures ( ) { $ timestamp = $ this -> cacheService -> getLatestTimestamp ( ) ; $ issues = $ this -> jiraService -> fetchIssues ( $ timestamp ) ; $ features = $ this -> parseFeatures ( $ issues ) ; $ keys = $ this -> cacheService -> getKeys ( ) ? : array ( ) ; foreach ( $ keys as $ key ) { if ( ! array_key_exists ( $ key , $ features ) ) { $ features [ $ key ] = $ this -> cacheService -> read ( $ key ) ; } } return $ features ; }
Create features from issues
28,859
public function supports ( $ resource ) { return $ resource === '' || $ this -> getIssue ( $ resource ) || $ this -> jiraService -> urlMatches ( $ resource ) ; }
Is this resource supported?
28,860
protected static function saveField ( ParticleInterface $ particle , string $ field_name , $ field_value , bool $ defer_persist , FieldHelper $ helper ) : void { if ( ! $ defer_persist ) { $ particle -> attributes ( ) -> $ field_name = $ field_value ; return ; } $ particle -> attributes ( ) -> quietSet ( $ field_name , $ field_value ) ; }
Helper method to save the field
28,861
public function __isset ( $ property ) { if ( array_key_exists ( $ property , $ this -> properties ) || in_array ( $ property , self :: $ specialProperties ) ) { return true ; } return false ; }
Check if document property is set
28,862
protected function fromResponse ( phpillowResponse $ response ) { $ revision = new StdClass ( ) ; $ revision -> _date = time ( ) ; foreach ( $ this -> properties as $ property => $ v ) { if ( isset ( $ response -> $ property ) ) { $ this -> storage -> $ property = $ response -> $ property ; $ revision -> $ property = $ response -> $ property ; } } $ this -> storage -> _rev = $ response -> _rev ; $ this -> storage -> _id = $ response -> _id ; if ( isset ( $ response -> _attachments ) ) { $ this -> storage -> _attachments = $ response -> _attachments ; } if ( $ this -> versioned ) { if ( isset ( $ response -> revisions ) ) { $ this -> storage -> revisions = $ response -> revisions ; } $ this -> storage -> revisions [ ] = ( array ) $ revision ; } $ this -> modified = false ; $ this -> newDocument = false ; }
Set values from a response object
28,863
public function fetchById ( $ id ) { if ( empty ( $ id ) ) { throw new phpillowResponseNotFoundErrorException ( array ( 'error' => 'not_found' , 'reason' => 'No document ID specified.' , ) ) ; } $ db = $ this -> getConnection ( ) ; $ response = $ db -> get ( $ this -> getDatabase ( ) . urlencode ( $ id ) ) ; $ this -> checkTypeOfResponse ( $ response ) ; $ this -> fromResponse ( $ response ) ; return $ this ; }
Get document by ID
28,864
public function checkTypeOfResponse ( phpillowResponse $ response ) { if ( $ response -> type != $ this -> getType ( ) ) { throw new phpillowResponseNotFoundErrorException ( array ( 'error' => 'mismatch' , 'reason' => 'Type does not match: ' . $ response -> type . ' != ' . $ this -> getType ( ) , ) ) ; } }
Verifies that the fetched document is of the given type
28,865
public static function createNew ( $ docType = null ) { if ( ( $ docType === null ) && function_exists ( 'get_called_class' ) ) { $ docType = get_called_class ( ) ; } elseif ( $ docType === null ) { throw new phpillowRuntimeException ( 'Invalid docType provided to createNew.' ) ; } return new $ docType ( ) ; }
Create a new instance of the document class
28,866
public function checkRequirements ( ) { $ errors = array ( ) ; foreach ( $ this -> requiredProperties as $ property ) { if ( ! isset ( $ this -> storage -> $ property ) || ( $ this -> storage -> $ property === null ) ) { $ errors [ ] = $ property ; } } if ( $ errors === array ( ) ) { return true ; } return $ errors ; }
Check if all requirements are met
28,867
public function save ( ) { $ type = $ this -> getType ( ) ; if ( $ this -> checkRequirements ( ) !== true ) { throw new phpillowRuntimeException ( 'Requirements not checked before storing the document.' ) ; } if ( ( $ this -> modified === false ) && ( $ this -> newDocument !== true ) ) { return false ; } if ( $ this -> newDocument === true ) { $ this -> storage -> _id = $ this -> getDocumentId ( $ type , $ this -> generateId ( ) ) ; } if ( ! isset ( $ this -> storage -> _attachments ) || ! count ( $ this -> storage -> _attachments ) ) { unset ( $ this -> storage -> _attachments ) ; } $ db = $ this -> getConnection ( ) ; if ( $ this -> storage -> _id === null ) { unset ( $ this -> storage -> _id ) ; $ response = $ db -> post ( $ this -> getDatabase ( ) , json_encode ( $ this -> storage ) ) ; } else { $ response = $ db -> put ( $ this -> getDatabase ( ) . urlencode ( $ this -> _id ) , json_encode ( $ this -> storage ) ) ; } $ this -> storage -> _rev = $ response -> rev ; if ( ! isset ( $ this -> storage -> _attachments ) ) { $ this -> storage -> _attachments = array ( ) ; } $ this -> newDocument = false ; return $ this -> storage -> _id = $ response -> id ; }
Save the document
28,868
public function delete ( ) { $ db = $ this -> getConnection ( ) ; return $ db -> delete ( $ this -> getDatabase ( ) . urlencode ( $ this -> _id ) . '?rev=' . $ this -> _rev ) ; }
Deletes the current document
28,869
protected function stringToId ( $ string , $ replace = '_' ) { $ string = iconv ( 'UTF-8' , 'ASCII//TRANSLIT' , $ string ) ; $ string = preg_replace ( '([^A-Za-z0-9.-]+)' , $ replace , $ string ) ; return strtolower ( $ string ) ; }
Get ID string from arbitrary string
28,870
public function attachFile ( $ fileName , $ name = false , $ mimeType = false ) { $ name = ( $ name === false ? basename ( $ fileName ) : $ name ) ; $ this -> attachMemoryFile ( file_get_contents ( $ fileName ) , $ name , $ mimeType ) ; }
Attach file to document
28,871
public function attachMemoryFile ( $ data , $ name , $ mimeType = false ) { $ this -> storage -> _attachments [ $ name ] = array ( 'type' => 'base64' , 'data' => base64_encode ( $ data ) , 'content_type' => $ mimeType === false ? 'application/octet-stream' : $ mimeType , ) ; $ this -> modified = true ; }
Attach file from memory to document
28,872
public function process ( ) { if ( ! isset ( $ this -> settings [ "directives" ] ) ) return $ this -> value ; $ directives = $ this -> settings [ "directives" ] ; $ isDirectiveEnabled = function ( string $ param ) use ( $ directives ) : bool { return ( isset ( $ directives [ $ param ] ) && $ directives [ $ param ] ) ; } ; if ( $ isDirectiveEnabled ( "index" ) ) { $ this -> with_index = true ; } if ( $ isDirectiveEnabled ( "unique" ) ) { $ this -> is_unique = true ; } if ( $ isDirectiveEnabled ( "sha1" ) ) { return sha1 ( $ this -> value ) ; } elseif ( $ isDirectiveEnabled ( "md5" ) ) { return md5 ( $ this -> value ) ; } return $ this -> value ; }
Applies directives to the value to return
28,873
public function probe ( ) : void { if ( ! isset ( $ this -> settings [ "constraints" ] ) ) return ; $ constraints = $ this -> settings [ "constraints" ] ; foreach ( $ constraints as $ constraint => $ constraint_val ) { if ( is_null ( $ constraint_val ) ) continue ; switch ( $ constraint ) { case "format" : if ( ! in_array ( $ constraint_val , [ "numeric" , "ip" , "email" , "url" , "creditCard" , "alpha" , "alphaNum" ] ) ) { throw new \ InvalidArgumentException ; } $ v = new Validator ( [ "field" => $ this -> value ] ) ; $ v -> rule ( $ constraint_val , "field" ) ; if ( ! $ v -> validate ( ) ) { throw new \ InvalidArgumentException ; } break ; case "dateBefore" : case "dateAfter" : $ v = new Validator ( [ "field" => $ this -> value ] ) ; $ v -> rule ( $ constraint , "field" , $ constraint_val ) ; if ( ! $ v -> validate ( ) ) { throw new \ InvalidArgumentException ; } break ; case "minLength" : case "maxLength" : case "greaterThan" : case "lessThan" : Assert :: $ constraint ( $ this -> value , $ constraint_val ) ; break ; case "id" : try { ID :: fromString ( $ this -> value ) ; } catch ( LibGraph \ Exceptions \ MalformedIDException $ e ) { throw new \ InvalidArgumentException ; } break ; case "regex" : Assert :: $ constraint ( $ this -> value , $ constraint_val ) ; break ; } } }
Checks if the field meets the requirements of the constraints in the particle s FIELDS constant .
28,874
public function load_meta ( ) { if ( empty ( $ this -> attributes ) ) return ; foreach ( get_post_meta ( $ this -> attributes [ 'ID' ] ) as $ key => $ value ) { if ( ! preg_match ( '/_wp_/' , $ key ) || in_array ( 'meta_' . $ key , $ this -> aliases ) ) { $ value = $ value [ 0 ] ; $ this -> meta [ $ key ] = is_string ( $ value ) ? ( preg_match ( '/_wp_/' , $ key ) ? $ value : json_decode ( $ value ) ) : ( is_integer ( $ value ) ? intval ( $ value ) : floatval ( $ value ) ) ; } } }
Loads meta values into objet .
28,875
public function save_meta_all ( ) { foreach ( $ this -> meta as $ key => $ value ) { $ this -> save_meta ( $ key , $ value , false ) ; } }
Saves all meta values .
28,876
protected function pageHook ( Vpage $ page ) { if ( ! empty ( $ this -> adminPageCategory ) ) { $ page -> category ( ) -> associate ( $ this -> adminPageCategory ) ; $ page -> save ( ) ; } }
Page creation hook .
28,877
public function set ( NameValue $ name , Data $ value , int $ attributes = PropertyAttribute :: NONE ) : void { }
Adds a property to each instance created by this template .
28,878
public function validate ( $ input ) { if ( ! is_array ( $ input ) ) { throw new phpillowValidationException ( "Field is not an array" , array ( ) ) ; } foreach ( $ input as $ key => $ object ) { $ input [ $ key ] = parent :: validate ( $ object ) ; } return $ input ; }
Validate input to be an array of objects
28,879
public function getReferenceRepository ( ) { if ( ! $ this -> referenceRepository ) { $ this -> referenceRepository = new ProxyReferenceRepository ( $ this -> entityManager ) ; } return $ this -> referenceRepository ; }
Returns the reference repository while loading the fixtures .
28,880
private function getFixtureLoader ( ) { $ container = $ this -> kernel -> getContainer ( ) ; $ loader = class_exists ( 'Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader' ) ? new DataFixturesLoader ( $ container ) : ( class_exists ( 'Doctrine\Bundle\FixturesBundle\Common\DataFixtures\Loader' ) ? new DoctrineFixturesLoader ( $ container ) : new SymfonyFixturesLoader ( $ container ) ) ; return $ loader ; }
Retrieve Data fixtures loader
28,881
private function generateHash ( $ migrations , $ fixtures ) { if ( $ migrations ) { array_walk ( $ migrations , function ( & $ migration ) { $ migration .= '@' . filemtime ( $ migration ) ; } ) ; } $ classNames = array_map ( 'get_class' , $ fixtures ) ; foreach ( $ classNames as & $ className ) { $ class = new \ ReflectionClass ( $ className ) ; $ fileName = $ class -> getFileName ( ) ; $ className .= ':' . $ fileName . '@' . filemtime ( $ fileName ) ; } sort ( $ classNames ) ; return sha1 ( serialize ( array ( $ migrations , $ classNames ) ) ) ; }
Calculate hash on data fixture class names class file names and modification timestamps
28,882
private function getBundleFixtureDirectories ( ) { return array_filter ( array_map ( function ( $ bundle ) { $ path = $ bundle -> getPath ( ) . '/DataFixtures/ORM' ; return is_dir ( $ path ) ? $ path : null ; } , $ this -> kernel -> getBundles ( ) ) ) ; }
Get bundle fixture directories
28,883
private function loadFixtureClass ( $ className ) { $ fixture = new $ className ( ) ; if ( $ this -> loader -> hasFixture ( $ fixture ) ) { unset ( $ fixture ) ; return ; } $ this -> loader -> addFixture ( new $ className ( ) ) ; if ( $ fixture instanceof DependentFixtureInterface ) { foreach ( $ fixture -> getDependencies ( ) as $ dependency ) { $ this -> loadFixtureClass ( $ dependency ) ; } } }
Load a data fixture class .
28,884
private function fetchFixturesFromClasses ( $ classNames ) { foreach ( $ classNames as $ className ) { if ( substr ( $ className , 0 , 1 ) !== '\\' ) { $ className = '\\' . $ className ; } if ( ! class_exists ( $ className , false ) ) { $ this -> loadFixtureClass ( $ className ) ; } } }
Fetch fixtures from classes
28,885
private function fetchMigrations ( ) { if ( ! isset ( $ this -> migrations ) ) { return null ; } if ( empty ( $ this -> migrations ) ) { return array ( ) ; } $ migrations = array ( ) ; $ connection = $ this -> entityManager -> getConnection ( ) ; $ driver = $ connection -> getDatabasePlatform ( ) -> getName ( ) ; foreach ( $ this -> migrations as $ migration ) { $ files = glob ( $ migration . '/*.sql' ) ; if ( empty ( $ files ) ) { $ files = glob ( $ migration . '/' . $ driver . '/*.sql' ) ; if ( empty ( $ files ) ) { continue ; } } foreach ( $ files as $ file ) { $ version = basename ( $ file , '.sql' ) ; if ( preg_match ( '~^[vV]([^_]+)_~' , $ version , $ matches ) ) { $ version = $ matches [ 1 ] ; } $ migrations [ $ version ] = $ file ; } } uksort ( $ migrations , 'version_compare' ) ; return $ migrations ; }
Fetch SQL migrations
28,886
private function loadFixtures ( ) { $ em = $ this -> entityManager ; $ this -> dispatchEvent ( $ em , 'preTruncate' ) ; $ purger = new ORMPurger ( $ em ) ; $ purger -> setPurgeMode ( ORMPurger :: PURGE_MODE_TRUNCATE ) ; $ executor = new ORMExecutor ( $ em , $ purger ) ; $ executor -> setReferenceRepository ( $ this -> getReferenceRepository ( ) ) ; if ( ! $ this -> useBackup ) { $ executor -> purge ( ) ; } $ this -> runMigrations ( ) ; $ executor -> execute ( $ this -> fixtures , true ) ; $ this -> dispatchEvent ( $ em , 'postTruncate' ) ; }
Load fixtures into database
28,887
private function createDatabase ( ) { $ em = $ this -> entityManager ; $ metadata = $ em -> getMetadataFactory ( ) -> getAllMetadata ( ) ; $ schemaTool = new SchemaTool ( $ em ) ; $ schemaTool -> createSchema ( $ metadata ) ; }
Create database using doctrine schema tool
28,888
public function cacheFixtures ( ) { $ this -> init ( ) ; $ this -> migrations = $ this -> fetchMigrations ( ) ; $ this -> fixtures = $ this -> fetchFixtures ( ) ; if ( $ this -> useBackup && ! $ this -> hasBackup ( ) ) { $ this -> dropDatabase ( ) ; } }
Cache data fixtures
28,889
public function reloadFixtures ( ) { if ( ! $ this -> useBackup ) { $ this -> loadFixtures ( ) ; return ; } if ( $ this -> hasBackup ( ) ) { $ this -> restoreBackup ( ) ; $ this -> getReferenceRepository ( ) -> load ( $ this -> getBackupFile ( ) ) ; return ; } if ( $ this -> migrations === null ) { $ this -> dropDatabase ( ) ; $ this -> createDatabase ( ) ; } $ this -> loadFixtures ( ) ; $ this -> createBackup ( ) ; $ this -> getReferenceRepository ( ) -> save ( $ this -> getBackupFile ( ) ) ; }
Reload data fixtures
28,890
public function flush ( ) { $ em = $ this -> entityManager ; $ em -> flush ( ) ; $ em -> clear ( ) ; $ this -> referenceRepository = null ; $ cacheDriver = $ em -> getMetadataFactory ( ) -> getCacheDriver ( ) ; if ( $ cacheDriver ) { $ cacheDriver -> deleteAll ( ) ; } }
Flush entity manager
28,891
protected function getBoundary ( ) { do { $ boundary = '==' . md5 ( microtime ( ) ) . '==' ; } while ( in_array ( $ boundary , self :: $ boundaries ) ) ; return self :: $ boundaries [ ] = $ boundary ; }
Get unique boudary
28,892
public function writeDocument ( array $ document ) { fwrite ( $ this -> stream , "--" . $ this -> boundary . "\r\n" ) ; if ( isset ( $ document [ '_attachments' ] ) ) { $ this -> writeMultipartDocument ( $ document ) ; } else { $ this -> writeSimpleDocument ( $ document ) ; } }
Write document to stream
28,893
public function preTruncate ( LifecycleEventArgs $ args ) { $ connection = $ args -> getObjectManager ( ) -> getConnection ( ) ; $ platform = $ connection -> getDatabasePlatform ( ) ; if ( $ platform instanceof MySqlPlatform ) { $ connection -> exec ( 'SET foreign_key_checks = 0;' ) ; } }
Pre - truncate
28,894
public function authenticate ( IRequest $ request ) { foreach ( $ this -> clientAuthenticationMethods as $ clientAuthenticationMethod ) { if ( $ clientAuthenticationMethod -> match ( $ request ) ) { return $ clientAuthenticationMethod -> authenticate ( $ request ) ; } } throw new InvalidClientException ( 'Invalid client authentication method.' ) ; }
Authenticates client using credentials from request
28,895
public function saveGridOrder ( ) { if ( ! isset ( Yii :: $ app -> session [ $ this -> sessionVarName ] ) ) { Yii :: $ app -> session [ $ this -> sessionVarName ] = '' ; } if ( Yii :: $ app -> request -> get ( $ this -> getVarName ) !== null ) { Yii :: $ app -> session [ $ this -> sessionVarName ] = Yii :: $ app -> request -> get ( $ this -> getVarName ) ; } }
Saves the grid s current order criteria .
28,896
public function getGridOrder ( ) { $ criteria = Yii :: $ app -> session [ $ this -> sessionVarName ] ; return self :: convertGridSort ( $ criteria ) ; }
Return the grid s current order criteria that was saved before .
28,897
public function setAttributes ( array $ attributes ) : Tag { foreach ( $ attributes as $ name => $ value ) { $ this -> attributes [ strtolower ( $ name ) ] = ( string ) $ value ; } return $ this ; }
Sets several attributes .
28,898
public function setHtmlContent ( string $ content ) : Tag { if ( $ this -> isVoid ) { throw new \ LogicException ( 'Void elements cannot have any contents.' ) ; } $ this -> content = $ content ; return $ this ; }
Sets the HTML content of this tag .
28,899
public function appendTextContent ( string $ content ) : Tag { if ( $ this -> isVoid ) { throw new \ LogicException ( 'Void elements cannot have any contents.' ) ; } $ this -> content .= htmlspecialchars ( $ content , ENT_NOQUOTES | ENT_HTML5 ) ; return $ this ; }
Appends text content to this tag .