idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
9,800
protected static function compact ( array $ lists , $ outerSep ) { $ consolidated = [ ] ; foreach ( $ lists as $ list ) { if ( ! $ list instanceof WrappedStringList ) { $ consolidated [ ] = $ list ; continue ; } if ( $ list -> sep === $ outerSep ) { $ consolidated = array_merge ( $ consolidated , self :: compact ( $ li...
Merge consecutive lists with the same separator .
9,801
public function generate ( int $ iterations = 1 , bool $ unwrapSingle = true ) { list ( $ this -> min , $ this -> max ) = $ this -> prepareMinMax ( ) ; $ this -> iterations = $ iterations = max ( 1 , $ iterations ) ; $ array = $ this -> performGenerate ( $ iterations ) ; if ( $ this -> unique ) { $ array = $ this -> fi...
Generates a new random Rut object
9,802
protected function performGenerate ( int $ iterations ) { switch ( $ this -> output ) { case 'raw' : $ array = $ this -> generateRaws ( $ iterations , $ this -> min , $ this -> max ) ; break ; case 'string' : $ array = $ this -> generateStrings ( $ iterations , $ this -> min , $ this -> max ) ; break ; case 'object' : ...
Performs the random generation of RUTs
9,803
protected function prepareMinMax ( ) { $ min = 1000000 ; $ max = RutHelper :: COMPANY_RUT_BASE ; if ( ! $ this -> person ) { $ min = $ max ; $ max = 100000000 ; } return [ $ min , $ max ] ; }
Prepare the Min and Max numbers to generate
9,804
protected function generateObjects ( int $ iterations , int $ min , int $ max ) { $ array = [ ] ; for ( $ i = 0 ; $ i < $ iterations ; ++ $ i ) { $ array [ ] = RutHelper :: rectify ( rand ( $ min , $ max ) ) ; } return $ array ; }
Generate a given number of random RUTs as Rut instances
9,805
protected function generateRaws ( int $ iterations , int $ min , int $ max ) { $ array = [ ] ; for ( $ i = 0 ; $ i < $ iterations ; ++ $ i ) { $ array [ ] = ( $ rut = rand ( $ min , $ max ) ) . RutHelper :: getVd ( $ rut ) ; } return $ array ; }
Generate a given number of random RUTs strings
9,806
protected function generateStrings ( int $ iterations , int $ min , int $ max ) { $ array = [ ] ; for ( $ i = 0 ; $ i < $ iterations ; ++ $ i ) { $ rut = rand ( $ min , $ max ) ; $ array [ ] = number_format ( $ rut , 0 , ',' , '.' ) . '-' . RutHelper :: getVd ( $ rut ) ; } return $ array ; }
Generates a given number of random RUTs formatted strings
9,807
protected function fillNonUniqueIterations ( array & $ array ) { $ array = array_unique ( $ array , SORT_REGULAR ) ; while ( $ this -> iterations > ( $ total = count ( $ array ) ) ) { array_push ( $ array , ... $ this -> performGenerate ( $ this -> iterations - $ total ) ) ; $ array = array_unique ( $ array , SORT_REGU...
Remove non unique values and replaces them with new ones
9,808
private function readMultValues ( Meta $ m , int $ id ) : array { $ data = [ ] ; $ read = new Read ( ) ; $ read -> exeRead ( PRE . $ this -> entity . "_" . $ m -> getColumn ( ) , "WHERE {$this->entity}_id = :id" , "id={$id}" ) ; if ( $ read -> getResult ( ) ) { foreach ( $ read -> getResult ( ) as $ item ) $ data [ ] =...
Busca por valores multiplos
9,809
public function getDataFullRead ( string $ column = null ) { if ( ! empty ( $ column ) ) return ( is_int ( $ column ) && isset ( $ this -> dicionario [ $ column ] ) ? $ this -> dicionario [ $ column ] -> getValue ( ) : ( ! empty ( $ value = $ this -> dicionario [ $ this -> searchValue ( $ column ) ] ) ? $ value -> getV...
Retorna o valor de uma meta de uma entidade
9,810
protected function generateRoute ( Language $ language , Page $ page ) { return sprintf ( '_%s_%s' , $ language -> getLanguageName ( ) , str_replace ( "-" , "_" , $ page -> getPageName ( ) ) ) ; }
Generates an internal route name from the language and the page
9,811
private function clearEntityManagers ( ) { foreach ( $ this -> managerRegistry -> getManagers ( ) as $ manager ) { if ( ! $ manager instanceof EntityManager ) { continue ; } $ manager -> clear ( ) ; if ( ! $ manager -> getConnection ( ) -> ping ( ) ) { $ manager -> getConnection ( ) -> close ( ) ; $ manager -> close ( ...
Clear entity managers and close broken managers .
9,812
protected function resolveAuth ( array $ parameters , array $ headers ) { isset ( $ parameters [ 'PHP_AUTH_USER' ] ) ? $ this -> resolvePHPAuth ( $ parameters , $ headers ) : $ this -> resolveHTTPAuth ( $ parameters , $ headers ) ; if ( isset ( $ headers [ 'PHP_AUTH_USER' ] ) ) { $ headers [ 'AUTHORIZATION' ] = 'basic ...
Resolves headers data
9,813
protected function resolveHTTPAuth ( array & $ parameters , array & $ headers ) { $ authorizationHeader = null ; if ( isset ( $ parameters [ 'HTTP_AUTHORIZATION' ] ) ) { $ authorizationHeader = $ parameters [ 'HTTP_AUTHORIZATION' ] ; } elseif ( isset ( $ parameters [ 'REDIRECT_HTTP_AUTHORIZATION' ] ) ) { $ authorizatio...
Resolves authorisation header from HTTP AUTH headers
9,814
protected function resolveLanguages ( ) { if ( ! $ this -> get ( 'accept_language' ) ) { return [ ] ; } $ codes = $ this -> extractHeaders ( ) ; $ languages = array ( ) ; foreach ( $ codes as $ lang ) { if ( strpos ( $ lang , '-' ) !== false ) { $ codes = explode ( '-' , $ lang ) ; $ lang = strtolower ( $ codes [ 0 ] )...
Retrieves language codes in quality order Builds array containing two letter language codes sorted by quality codes
9,815
protected function extractHeaders ( ) { $ codes = array ( ) ; $ header = array_filter ( explode ( ',' , ( string ) $ this -> get ( 'accept_language' ) ) ) ; foreach ( $ header as $ value ) { if ( preg_match ( '/;\s*(q=.*$)/' , $ value , $ match ) ) { $ quality = ( float ) substr ( trim ( $ match [ 1 ] ) , 2 ) * 10 ; $ ...
Extracts language codes from header
9,816
protected function getListingSource ( ) { $ sourceType = $ this -> effectiveSourceType ( ) ; if ( $ sourceType && $ this -> ListingSourceID ) { $ parentId = $ this -> ListingSourceID ; $ source = DataList :: create ( $ sourceType ) -> byID ( $ parentId ) ; $ newParent = null ; $ newParentId = 0 ; if ( $ this -> AllowDr...
Some subclasses will want to override this .
9,817
protected function getIdsFrom ( $ parent , $ depth ) { if ( $ depth >= $ this -> Depth ) { return ; } $ ids = array ( ) ; foreach ( $ parent -> Children ( ) as $ kid ) { $ ids [ ] = $ kid -> ID ; $ childIds = $ this -> getIdsFrom ( $ kid , $ depth + 1 ) ; if ( $ childIds ) { $ ids = array_merge ( $ ids , $ childIds ) ;...
Recursively find all the child items that need to be listed
9,818
public function getNonSkippedProperties ( ClassMetadata $ metadata ) : array { $ this -> assertInitialized ( ) ; $ properties = $ metadata -> getAttributesMetadata ( ) ; return \ array_filter ( $ properties , [ $ this , 'filterPropertyMetadata' ] ) ; }
Get the array of properties that should be serialized in an object .
9,819
private function _addExclusionStrategy ( ExclusionStrategyInterface $ strategy ) : void { if ( null === $ this -> exclusionStrategy ) { $ this -> exclusionStrategy = $ strategy ; return ; } if ( $ this -> exclusionStrategy instanceof DisjunctExclusionStrategy ) { $ this -> exclusionStrategy -> addStrategy ( $ strategy ...
Set or add exclusion strategy .
9,820
public function renderSubject ( $ template , array $ variables = [ ] , $ type = MailTypes :: TYPE_ALL ) { return $ this -> getMailRendered ( $ template , $ variables , $ type ) -> getSubject ( ) ; }
Render the subject of mail template .
9,821
public function renderHtml ( $ template , array $ variables = [ ] , $ type = MailTypes :: TYPE_ALL ) { return $ this -> getMailRendered ( $ template , $ variables , $ type ) -> getHtmlBody ( ) ; }
Render the mail template in html .
9,822
public function renderPlainText ( $ template , array $ variables = [ ] , $ type = MailTypes :: TYPE_ALL ) { return $ this -> getMailRendered ( $ template , $ variables , $ type ) -> getBody ( ) ; }
Render the mail template in plain text .
9,823
public function getMailRendered ( $ template , array $ variables = [ ] , $ type = MailTypes :: TYPE_ALL ) { $ id = $ this -> getCacheId ( $ template , $ variables , $ type ) ; if ( ! isset ( $ this -> cache [ $ template ] [ $ id ] ) ) { $ this -> cache [ $ template ] [ $ id ] = $ this -> getTemplater ( ) -> render ( $ ...
Render the mail template .
9,824
public function getTranslatedLayout ( $ layout ) { $ template = $ this -> layoutLoader -> load ( $ layout ) ; $ template = TranslationUtil :: translateLayout ( $ template , $ this -> getTemplater ( ) -> getLocale ( ) , $ this -> translator ) ; if ( ! $ template instanceof TwigLayout ) { $ msg = 'The "%s" layout is not ...
Get the translated layout .
9,825
protected function getCacheId ( $ template , array $ variables = [ ] , $ type = MailTypes :: TYPE_ALL ) { $ serialize = serialize ( $ variables ) ; return sha1 ( $ template . '&&' . $ serialize . '&&' . $ type ) ; }
Get the id for the cache .
9,826
protected function getTemplater ( ) { if ( null !== $ this -> container ) { $ this -> templater = $ this -> container -> get ( 'fxp_mailer.mail_templater' ) ; $ this -> container = null ; } return $ this -> templater ; }
Get the templater .
9,827
public static function explode ( $ value , string $ delimiter = ',' ) { self :: validateIfObjectIsAString ( $ value ) ; if ( empty ( $ delimiter ) ) { throw new \ InvalidArgumentException ( "Delimiter '" . var_export ( $ delimiter , true ) . "' is not a non-empty string" ) ; } return explode ( $ delimiter , $ value ) ;...
Explodes a string into an array using the given delimiter .
9,828
public static function translate ( string $ value , array $ valueMap ) : string { if ( ! array_key_exists ( $ value , $ valueMap ) ) { throw new FilterException ( "The value '{$value}' was not found in the translation map array." ) ; } return $ valueMap [ $ value ] ; }
This filter takes the given string and translates it using the given value map .
9,829
public static function compress ( string $ value = null , bool $ replaceVerticalWhitespace = false ) { if ( $ value === null ) { return null ; } $ pattern = $ replaceVerticalWhitespace ? '\s+' : '\h+' ; return trim ( preg_replace ( "/{$pattern}/" , ' ' , $ value ) ) ; }
This filter trims and removes superfluous whitespace characters from the given string .
9,830
public static function redact ( $ value , $ words , string $ replacement = '' ) { if ( $ value === null || $ value === '' ) { return $ value ; } $ stringValue = self :: filter ( $ value ) ; if ( is_callable ( $ words ) ) { $ words = $ words ( ) ; } if ( is_array ( $ words ) === false ) { throw new FilterException ( "Wo...
This filter replaces the given words with a replacement character .
9,831
public static function stripTags ( string $ value = null , string $ replacement = '' ) { if ( $ value === null ) { return null ; } if ( $ replacement === '' ) { return strip_tags ( $ value ) ; } $ findTagEntities = '/<[^>]+?>/' ; $ valueWithReplacements = preg_replace ( $ findTagEntities , $ replacement , $ value ) ; r...
Strip HTML and PHP tags from a string and optionally replace the tags with a string . Unlike the strip_tags function this method will return null if a null value is given . The native php function will return an empty string .
9,832
private function registerToView ( ) { $ view = $ this -> getView ( ) ; $ id = \ yii \ helpers \ Json :: encode ( $ this -> options [ 'id' ] ) ; $ editor_options = \ yii \ helpers \ Json :: encode ( $ this -> editorOptions ) ; $ view -> registerJs ( "CKEDITOR.replace({$id}, {$editor_options});" ) ; CoreAsset :: register...
Register the ckeditor files to the view
9,833
public function beforeValidate ( ) { $ this -> fileName = $ this -> owner -> getAttribute ( $ this -> fileField ) ; if ( ! is_string ( $ this -> fileName ) ) { $ this -> fileName = @ $ this -> owner -> oldAttributes [ $ this -> fileField ] ; } if ( ( ! $ files = UploadedFile :: getInstance ( $ this -> owner , $ this ->...
Attaches uploaded file to owner .
9,834
public function afterSave ( ) { if ( ! $ this -> files ) { return true ; } $ oldFileCount = $ this -> getFileCount ( ) ; foreach ( $ this -> files as $ key => $ file ) { $ this -> fileNumber = $ oldFileCount + $ key + 1 ; $ this -> fileName = $ this -> fileNumber . '_' . $ file -> name ; if ( $ this -> fileNumber == 1 ...
Saves attached file and sets db filename field makes thumbnails .
9,835
public function afterDelete ( ) { foreach ( $ this -> getAllFields ( ) as $ field ) { $ path = $ this -> getFilePath ( $ field , '' ) ; if ( file_exists ( $ path ) && is_dir ( $ path ) ) { FileHelper :: removeDirectory ( $ path ) ; } } }
Removes owner files .
9,836
public function getFilePath ( $ field = null , $ name = null ) { if ( $ this -> pathCallback ) { return call_user_func ( [ $ this -> owner , $ this -> pathCallback ] ) ; } if ( ( $ name === null ) && ( ! $ name = $ this -> getFirstFileName ( ) ) ) { return false ; } $ storage = is_callable ( $ this -> storage ) ? call_...
Gets file full path .
9,837
public function getFileLink ( $ field = null , $ name = null ) { $ root = realpath ( \ Yii :: getAlias ( '@webroot' ) ) ; return str_replace ( $ root , '' , $ this -> getFilePath ( $ field , $ name ) ) ; }
Gets url to file
9,838
public function getFileCount ( ) { if ( ! $ files = $ this -> getFileList ( ) ) { return 0 ; } $ lastName = end ( $ files ) ; return preg_match ( '/^(\d+)_.*$/' , $ lastName , $ matches ) ? $ matches [ 1 ] : count ( $ files ) ; }
Count of files
9,839
public function getFileList ( $ field = null ) { $ dir = $ this -> getFilePath ( $ field , '' ) ; if ( ! file_exists ( $ dir ) || ! is_dir ( $ dir ) ) { return [ ] ; } return array_diff ( scandir ( $ dir ) , [ '.' , '..' ] ) ; }
All files list for field
9,840
public function getFilePositionLink ( $ field = null , $ position = 0 ) { $ list = array_values ( $ this -> getFileList ( $ field ) ) ; return isset ( $ list [ $ position ] ) ? $ this -> getFileLink ( $ field , $ list [ $ position ] ) : null ; }
Url to a file from list
9,841
public function showFile ( $ field = null , $ name = null ) { $ file = $ this -> getFilePath ( $ field , $ name ) ; if ( ! file_exists ( $ file ) || ! is_file ( $ file ) ) { throw new NotFoundHttpException ; } header ( 'Content-Type: ' . FileHelper :: getMimeType ( $ file ) , true ) ; header ( 'Content-Length: ' . file...
Shows file to the browser .
9,842
public function sendFile ( $ field = null , $ name = null ) { if ( ! $ name && ( ! $ name = $ this -> getFirstFileName ( ) ) ) { return false ; } $ file = $ this -> getFilePath ( $ field , $ name ) ; if ( ! $ name || ! file_exists ( $ file ) ) { throw new NotFoundHttpException ; } \ Yii :: $ app -> response -> sendFile...
Sends file to user download .
9,843
public function deleteFile ( $ name = null ) { foreach ( $ this -> getAllFields ( ) as $ field ) { $ path = $ this -> getFilePath ( $ field , $ name ) ; if ( ! $ path || ! is_file ( $ path ) || ! file_exists ( $ path ) ) { continue ; } unlink ( $ path ) ; } if ( $ name == $ this -> owner -> getAttribute ( $ this -> fil...
Deletes file and all thumbnails by name
9,844
private function createFilePath ( $ path ) { $ dir = dirname ( $ path ) ; return file_exists ( $ dir ) || FileHelper :: createDirectory ( $ dir , 0775 , true ) ; }
Generates path recursively .
9,845
private function processImage ( $ field , $ options ) { $ originalPath = $ this -> getFilePath ( null , $ this -> fileName ) ; $ resultPath = $ this -> getFilePath ( $ field , $ this -> fileName ) ; $ this -> createFilePath ( $ resultPath ) ; switch ( $ options [ 'method' ] ) { case 'thumbnail' : \ yii \ imagine \ Imag...
Creates image copies processed with options
9,846
public function linkList ( $ field = null ) { $ result = [ ] ; foreach ( $ this -> getFileList ( ) as $ path ) { $ name = basename ( $ path ) ; $ result [ $ name ] = $ this -> getFileLink ( $ field , basename ( $ path ) ) ; } return $ result ; }
Gets links for all model files .
9,847
public function countAdvancedSearchData ( ) { $ parameters = [ ] ; $ parameters = Miscellaneous :: dataTableColumnFiltering ( $ this -> request , $ parameters , 'array' ) ; $ parameters [ 'order' ] = json_decode ( $ this -> request -> input ( 'order' ) , true ) ; $ parametersCount = $ parameters ; $ parametersCount [ '...
Function to count results to prevent export files without data
9,848
public function updateDynareas ( \ Zend \ EventManager \ Event $ e ) { $ dynareas = $ e -> getParam ( 'dynareas' ) ; $ gameService = $ e -> getTarget ( ) -> getServiceManager ( ) -> get ( 'playgroundgame_game_service' ) ; $ games = $ gameService -> getActiveGames ( false ) ; foreach ( $ games as $ game ) { $ array = ar...
This method get the games and add them as Dynareas to PlaygroundCms so that blocks can be dynamically added to the games .
9,849
public function populateCmsCategories ( \ Zend \ EventManager \ Event $ e ) { $ catsArray = $ e -> getParam ( 'categories' ) ; $ gameService = $ e -> getTarget ( ) -> getServiceManager ( ) -> get ( 'playgroundgame_game_service' ) ; $ games = $ gameService -> getActiveGames ( false ) ; foreach ( $ games as $ game ) { $ ...
This method add the games to the cms categories of pages not that satisfied neither
9,850
public function render ( ) { $ renderFunction = function ( & $ element , $ key ) { $ element = $ element -> render ( ) ; } ; array_walk ( $ this -> elements , $ renderFunction ) ; $ structuredElements = StructureManager :: buildStructure ( $ this -> elements , $ this -> structure ) ; return $ structuredElements ; }
Render structured element
9,851
public function onBeforeDeletePageCommit ( BeforeDeletePageCommitEvent $ event ) { if ( $ event -> isAborted ( ) ) { return ; } $ pageManager = $ event -> getContentManager ( ) ; $ pageRepository = $ pageManager -> getPageRepository ( ) ; try { $ languages = $ this -> languageRepository -> activeLanguages ( ) ; if ( co...
Deletes the page s contents for all the languages of the site
9,852
public static function jsonErrorToException ( $ json_error_code ) { switch ( $ json_error_code ) { case JSON_ERROR_DEPTH : return JsonEncodeDecodeException :: depth ( ) ; case JSON_ERROR_STATE_MISMATCH : return JsonEncodeDecodeException :: stateMismatch ( ) ; case JSON_ERROR_CTRL_CHAR : return JsonEncodeDecodeException...
Converts JSON decode error into exception .
9,853
function addCallable ( $ methodCallable , $ priority = 10 ) { if ( ! is_callable ( $ methodCallable ) ) throw new \ InvalidArgumentException ( 'Param must be callable' ) ; $ this -> _getPriorityQueue ( ) -> insert ( $ methodCallable , $ priority ) ; return $ this ; }
Add Callable Method
9,854
function addInitializer ( iContainerInitializer $ initializer , $ priority = null ) { $ priority = ( $ priority == null ) ? ( ( $ initializer -> getPriority ( ) !== null ) ? $ initializer -> getPriority ( ) : 10 ) : $ priority ; $ this -> _getPriorityQueue ( ) -> insert ( $ initializer , $ priority ) ; return $ this ; ...
Add Initializer Interface
9,855
public static function encode ( $ data , $ options = 0 ) : string { $ json = json_encode ( $ data , $ options ) ; if ( JSON_ERROR_NONE !== json_last_error ( ) ) { throw new JsonEncodeException ( json_last_error_msg ( ) ) ; } return $ json ; }
Encodes data as a JSON string representation .
9,856
public function max ( ... $ numbers ) { foreach ( $ numbers as $ number ) { if ( bccomp ( static :: validateInputNumber ( $ number ) , $ this -> number , $ this -> precision ) === 1 ) { $ this -> number = $ number ; } } return $ this ; }
returns the highest number among all arguments
9,857
public function min ( ... $ numbers ) { foreach ( $ numbers as $ number ) { if ( bccomp ( static :: validateInputNumber ( $ number ) , $ this -> number , $ this -> precision ) === - 1 ) { $ this -> number = $ number ; } } return $ this ; }
returns the smallest number among all arguments
9,858
public static function buildLinksArray ( array $ linkArray ) { $ links = array ( ) ; if ( is_array ( $ linkArray ) ) { foreach ( $ linkArray as $ link ) { $ links [ ] = $ link -> href ; } } return $ links ; }
Helper function used for building a links array .
9,859
public function setCurrentTable ( Table $ table ) { $ this -> fieldsCacheFile = $ this -> fieldsCacheDir . DIRECTORY_SEPARATOR . '.table.' . $ table -> getFullTableName ( ) . '.cache' ; if ( file_exists ( $ this -> fieldsCacheFile ) ) { try { $ this -> fieldsCache = include $ this -> fieldsCacheFile ; $ this -> fieldsC...
Set current table and current cache file and cache fields .
9,860
private function swishFails ( ) { return function ( $ isAjax , $ code ) { if ( $ code == 404 ) throw new NotFoundHttpException ( $ isAjax , $ code ) ; throw new ClientErrorsException ( $ isAjax , $ code ) ; } ; }
Handle swish fail event
9,861
private function swishBefore ( ) { $ self = $ this ; return function ( $ route , $ callback ) use ( $ self ) { $ route -> variables = ( new Reflect ) -> handle ( $ callback , $ route -> variables , $ route ) ; if ( is_array ( $ callback ) && isset ( $ callback [ 0 ] -> middleware ) ) { $ method = $ callback [ 1 ] ; if ...
Handle swish before event
9,862
private function swishAfter ( ) { $ events = $ this ; return function ( $ route ) use ( $ events ) { $ events -> handleResponse ( $ route -> response ) ; return Events :: trigger ( 'routes.handle' , [ $ route ] ) ; } ; }
Handle swish after event
9,863
private function modelVision ( Model $ model , $ where , $ value , $ name , $ querymap = null ) : Model { if ( strpos ( $ where , '__' ) !== false ) { $ querymap = explode ( '__' , $ where ) [ 1 ] ; $ field = explode ( '__' , $ where ) [ 0 ] ; } if ( isset ( HttpFoundation :: $ routeModelBinding [ 'model' ] [ $ queryma...
Run route model binding for models
9,864
private function groupableVision ( Groupable $ group , $ where , $ value , $ name , $ querymap = null ) : Groupable { if ( strpos ( $ where , '__' ) !== false ) { $ querymap = explode ( '__' , $ where ) [ 1 ] ; $ field = explode ( '__' , $ where ) [ 0 ] ; } if ( isset ( HttpFoundation :: $ routeModelBinding [ 'groupabl...
Run route model binding for groupables
9,865
public static function isResponseWithoutBody ( int $ code ) : bool { switch ( $ code ) { case self :: NO_CONTENT : case self :: NOT_MODIFIED : return true ; } return ( $ code >= 100 && $ code < 200 ) ; }
Check if the given response status indicates no body will be sent .
9,866
public static function getStatusLine ( int $ code , string $ protocol = 'HTTP/1.1' ) : string { if ( \ preg_match ( "'^[1-9]+\\.[0-9]+$'" , $ protocol ) ) { $ protocol = 'HTTP/' . $ protocol ; } return $ protocol . ' ' . $ code . \ rtrim ( ' ' . static :: getReason ( $ code , '' ) ) ; }
Arrange an HTTP response status line using the given data .
9,867
public function lockResource ( $ userId , $ resourceName ) { $ resource = $ this -> lockedResourceRepository -> fromResourceNameByUser ( $ userId , $ resourceName ) ; if ( null === $ resource ) { if ( ! $ this -> isResourceFree ( $ resourceName ) ) { throw new ResourceNotFreeException ( 'exception_resource_locked' ) ; ...
Locks a resource for the current user when it is free or updates the expiring time when it is locked by the same user
9,868
public function getProperty ( $ propertyName ) { if ( $ this -> getPropertyMap ( ) -> hasKey ( $ propertyName ) ) { return $ this -> getPropertyMap ( ) -> get ( $ propertyName ) ; } return $ this -> attachProperty ( new Property ( $ this , $ propertyName ) ) ; }
get form property
9,869
public function sign ( Request $ request ) : Request { $ algorithmHeader = $ this -> configuration -> getAlgorithmHeader ( ) ; $ signatureHeader = $ this -> configuration -> getSignatureHeader ( ) ; $ algorithm = $ this -> configuration -> getSigningAlgorithm ( ) ; $ key = $ this -> configuration -> getSigningKey ( ) ;...
Signs and returns the request .
9,870
public function getIndexNameFromContext ( \ DateTime $ date , array $ context ) : string { return $ context [ 'index_name' ] ?? $ this -> indexPrefix . $ this -> getIndexIntervalSuffix ( $ date ) ; }
Returns the name of the index that should be used when only a date and context is available . Typically this is when deleting events and you don t have a search request or an event and can t derive the index from the usual methods .
9,871
public function getIndexNameForWrite ( Indexed $ event ) : string { $ occurredAt = $ event -> get ( 'occurred_at' ) -> toDateTime ( ) ; return $ this -> indexPrefix . $ this -> getIndexIntervalSuffix ( $ occurredAt ) ; }
Returns the name of the index that the event should be written to .
9,872
public function getIndexIntervalSuffix ( \ DateTime $ date ) : string { $ quarter = ceil ( $ date -> format ( 'n' ) / 3 ) ; return $ date -> format ( 'Y' ) . 'q' . $ quarter ; }
Returns the suffix that should be used for routing writes and search requests for a given date .
9,873
final public function updateTemplate ( Client $ client , string $ name ) : void { $ fakeIndex = new Index ( $ client , $ name ) ; $ mappings = [ ] ; foreach ( $ this -> createMappings ( ) as $ typeName => $ mapping ) { $ mapping -> setType ( new Type ( $ fakeIndex , $ typeName ) ) ; $ mappings [ $ typeName ] = $ mappin...
Creates an index template in elastic search .
9,874
final public function updateIndex ( Client $ client , string $ name ) : void { $ index = new Index ( $ client , $ name ) ; foreach ( $ this -> createMappings ( ) as $ typeName => $ mapping ) { try { $ mapping -> setType ( new Type ( $ index , $ typeName ) ) ; $ mapping -> send ( ) ; } catch ( \ Throwable $ e ) { if ( f...
Updates an existing index settings and all of its mappings . The index template handles this for any newly created indices but the existing ones need to be updated directly .
9,875
protected function updateAnalyzers ( Index $ index , string $ name ) { $ settings = $ index -> getSettings ( ) ; $ customAnalyzers = $ this -> getCustomAnalyzers ( ) ; $ missingAnalyzers = [ ] ; try { foreach ( $ customAnalyzers as $ id => $ analyzer ) { if ( ! $ settings -> get ( "analysis.analyzer.{$id}" ) ) { $ miss...
Checks if an existing index is missing any custom analyzers and if it is updates settings to include them .
9,876
protected function updateNormalizers ( Index $ index , string $ name ) { $ settings = $ index -> getSettings ( ) ; $ customNormalizers = $ this -> getCustomNormalizers ( ) ; $ missingNormalizers = [ ] ; try { foreach ( $ customNormalizers as $ id => $ normalizer ) { if ( ! $ settings -> get ( "analysis.normalizer.{$id}...
Checks if an existing index is missing any custom normalizers and if it is updates settings to include them .
9,877
public function add ( string $ id , array $ data = [ ] ) : bool { try { $ this -> setFile ( $ id ) ; if ( $ this -> file ) { if ( ! file_exists ( $ this -> file ) ) { if ( $ this -> versionamento ) { $ data [ 'created' ] = strtotime ( "now" ) ; $ data [ 'updated' ] = strtotime ( "now" ) ; parent :: deleteVerion ( $ thi...
Adiciona arquivo Json
9,878
public function update ( string $ id , array $ dadosUpdate , int $ recursiveVersion = 99 ) : bool { $ this -> setFile ( $ id ) ; if ( $ this -> file && file_exists ( $ this -> file ) ) { if ( isset ( $ dadosUpdate [ 'updated' ] ) ) $ dadosUpdate [ 'updated' ] = strtotime ( "now" ) ; $ dadosAtuais = $ this -> get ( $ id...
Atualiza arquivo Json
9,879
public function delete ( string $ id ) { $ this -> setFile ( $ id ) ; if ( file_exists ( $ this -> file ) ) { if ( $ this -> versionamento ) { $ dadosAtuais = $ this -> get ( $ id ) ; $ dadosAtuais [ 'userlogin-action' ] = "delete" ; unset ( $ dadosAtuais [ 'id' ] ) ; parent :: createVerion ( $ this -> file , $ dadosAt...
Deleta um arquivo json
9,880
private function setFile ( string $ id ) { if ( ! $ this -> id || $ id != $ this -> id ) { $ this -> id = $ id ; $ id = Check :: name ( $ id , [ "#" ] ) ; $ this -> file = ( preg_match ( "/^" . preg_quote ( PATH_HOME , '/' ) . "/i" , $ id ) ? $ id : PATH_HOME . "_cdn/" . parent :: getFolder ( ) . "/{$id}" ) ; if ( ! pr...
Seta o caminho do arquivo Json a ser trabalhado
9,881
public function getValue028Attribute ( $ value ) { if ( $ this -> data_type_type_028 == 'array' ) $ value = explode ( ',' , $ value ) ; else settype ( $ value , $ this -> data_type_type_028 ) ; return $ value ; }
Accessor function when call value_028 set cast to value
9,882
public function process ( ContainerBuilder $ container ) { $ manager = $ container -> findDefinition ( self :: MANAGER_ID ) ; $ serviceIds = $ container -> findTaggedServiceIds ( self :: WORKER_RUNNER_TAG ) ; foreach ( $ serviceIds as $ serviceId => $ tags ) { $ this -> addManagerCalls ( $ container , $ manager , $ ser...
Process all services tagged as worker runners and add them to runner manager service .
9,883
private function addManagerCalls ( ContainerBuilder $ container , Definition $ manager , $ serviceId , array $ tags ) { foreach ( $ tags as $ tag ) { $ this -> addManagerCall ( $ container , $ manager , $ serviceId , $ tag ) ; } }
Parse single tagged service .
9,884
private function addManagerCall ( ContainerBuilder $ container , Definition $ manager , $ serviceId , array $ tag ) { $ this -> assertCorrectName ( $ tag ) ; $ this -> assertCorrectService ( $ container , $ serviceId ) ; $ options = ! empty ( $ tag [ 'options' ] ) ? json_decode ( $ tag [ 'options' ] , true ) : array ( ...
Parse single tagged service tag .
9,885
private function assertCorrectService ( ContainerBuilder $ container , $ serviceId ) { $ definition = $ container -> findDefinition ( $ serviceId ) ; $ reflection = new ReflectionClass ( $ definition -> getClass ( ) ) ; if ( ! $ reflection -> implementsInterface ( WorkerRunnerInterface :: class ) ) { throw new InvalidA...
Assert valid tagged service .
9,886
protected function transformData ( Scope $ scope , $ data ) : array { $ transformer = $ scope -> transformer ( ) ; if ( empty ( $ transformer ) ) { return ( array ) $ data ; } if ( \ is_callable ( $ transformer ) ) { return ( array ) $ transformer ( $ data ) ; } if ( ! ( $ transformer instanceof TransformerInterface ) ...
Apply transformation to the item data .
9,887
protected function executeTransformerInclude ( Scope $ scope , $ includeKey , $ includeDefinition , $ data ) { $ transformer = $ scope -> transformer ( ) ; $ method = $ includeDefinition [ 'method' ] ; if ( method_exists ( $ transformer , $ method ) ) { return $ transformer -> $ method ( $ data , $ scope ) ; } return $...
Execute the transformer .
9,888
protected function resolveTransformerForResource ( $ resource ) { $ transformer = null ; if ( $ this -> transformerResolver !== null ) { $ transformer = $ this -> transformerResolver -> resolve ( $ resource ) ; } return $ transformer ; }
Resolve the transformer to be used for a resource . Returns an interface callable or null when a transformer cannot be resolved .
9,889
public static function getLocalPath ( $ path , $ webDir , $ hostPattern = '/(.*)+/' ) { if ( false !== strpos ( $ path , '://' ) ) { $ url = parse_url ( $ path ) ; if ( isset ( $ url [ 'host' ] , $ url [ 'path' ] ) && preg_match ( $ hostPattern , $ url [ 'host' ] , $ matches ) ) { $ path = static :: getExistingPath ( $...
Get the local path of file .
9,890
protected static function getExistingPath ( $ path , $ webDir , $ fallbackPath = null ) { return file_exists ( $ webDir . '/' . $ path ) ? realpath ( $ webDir . '/' . $ path ) : ( null !== $ fallbackPath ? $ fallbackPath : $ path ) ; }
Get the the absolute path if file exists .
9,891
public function setView ( $ sRenderer , $ sNamespace , $ sViewName , array $ aViewData = array ( ) ) { $ this -> sRenderer = trim ( $ sRenderer ) ; $ this -> sNamespace = trim ( $ sNamespace ) ; $ this -> sViewName = trim ( $ sViewName ) ; $ this -> aViewData = array_merge ( $ this -> aViewData , $ aViewData ) ; }
Set the view to be rendered with optional data
9,892
protected function isKeyValue ( array $ arguments ) { $ result = true ; foreach ( array_keys ( $ arguments ) as $ key ) { $ result = $ result && ! is_numeric ( $ key ) ; } return $ result ; }
Returns if the given arguments are key = > value when keys are not numbers .
9,893
public function setPaths ( $ paths ) { $ paths = ( array ) $ paths ; $ paths [ ] = realpath ( __DIR__ . '/../../views' ) ; $ this -> paths = $ paths ; return $ this ; }
Set view paths
9,894
public static function fetch ( $ name , $ data = [ ] , $ paths = [ ] ) { if ( empty ( $ paths ) ) { $ paths = config ( 'view.path' ) ; if ( empty ( $ paths ) ) { $ paths = [ appPath ( 'Views' ) ] ; } } $ view = new static ( $ paths ) ; $ bladeFile = $ view -> getFilePath ( $ name , '.blade.php' ) ; if ( $ bladeFile ) {...
Fetch content of a view
9,895
public function getFilePath ( $ name , $ extension = '.php' ) { $ filename = trim ( dotToPath ( $ name ) , '/' ) . $ extension ; $ file = null ; foreach ( $ this -> paths as $ dir ) { $ realName = nPath ( $ dir , $ filename ) ; if ( file_exists ( $ realName ) ) { $ file = $ realName ; break ; } } return $ file ; }
Get full path to view file
9,896
private function getContent ( $ file , $ data = [ ] ) { $ path = fixPath ( $ file ) ; if ( file_exists ( $ path ) ) { ob_start ( ) ; extract ( $ data ) ; require $ path ; return ob_get_clean ( ) ; } else { throw new Exception ( "View $path not found" ) ; } }
Get view content for the given file
9,897
public function jsonSerialize ( ) { $ jsonArray = $ this -> getArrayCopy ( ) ; unset ( $ jsonArray [ 'inputFilter' ] ) ; unset ( $ jsonArray [ '__initializer__' ] ) ; unset ( $ jsonArray [ '__cloner__' ] ) ; unset ( $ jsonArray [ '__isInitialized__' ] ) ; unset ( $ jsonArray [ 'game' ] ) ; unset ( $ jsonArray [ 'cards'...
Convert the object to json .
9,898
public static function getUploadFolder ( ContainerInterface $ container ) { $ request = $ container -> get ( 'request' ) ; $ baseUrl = dirname ( $ request -> getBaseUrl ( ) ) ; $ baseUrl = substr ( $ baseUrl , 1 ) ; if ( ! empty ( $ baseUrl ) ) { $ baseUrl .= '/' ; } return $ baseUrl . $ container -> getParameter ( 're...
Returns the upload folder path
9,899
public static function getAbsoluteUploadFolder ( ContainerInterface $ container ) { $ uploaderFolder = self :: getUploadFolder ( $ container ) ; $ uploaderFolder = ( empty ( $ uploaderFolder ) ) ? '/' : '/' . $ uploaderFolder ; return $ uploaderFolder ; }
Returns the upload folder absolute path