idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
2,500
|
public function toArray ( ) { $ schema = array ( 'name' => $ this -> _name , 'label' => $ this -> _label , 'description' => $ this -> _description , 'type' => $ this -> _type , 'store' => $ this -> _isStored , 'index' => $ this -> _isIndexd , 'multivalue' => $ this -> _isMultiValued , ) ; if ( isset ( $ this -> _size ) ) { $ schema [ 'size' ] = $ this -> _size ; } return $ schema ; }
|
Returns the array of field options .
|
2,501
|
public function addRule ( AbstractRule $ rule ) { if ( array_key_exists ( $ rule -> getName ( ) , $ this -> rules ) ) { throw new ParserException ( 'Rule with ' . $ rule -> getName ( ) . ' name already exists' ) ; } $ this -> rules [ $ rule -> getName ( ) ] = $ rule ; return $ this ; }
|
Add rule to parser
|
2,502
|
public function parse ( $ text , TokenList $ tokenList = null , $ recursive = false ) { if ( $ this -> startRule === null ) { throw new ParserException ( 'Start rule not set' ) ; } if ( $ this -> lexer === null ) { throw new ParserException ( 'Lexer not set' ) ; } uasort ( $ this -> rules , [ $ this , 'sortRulesByOrder' ] ) ; $ this -> connectRulesToLexer ( ) ; \ Event :: fire ( 'vikon.parser.before.parse' , [ & $ text ] ) ; $ tokenList = $ this -> lexer -> tokenize ( $ text , $ this -> startRule -> getName ( ) , $ tokenList ) ; foreach ( $ this -> rules as $ rule ) { $ rule -> finalize ( $ tokenList , $ recursive ) ; } return $ tokenList ; }
|
Parse text by provided rules
|
2,503
|
public function render ( $ text , $ skin ) { if ( $ this -> renderer === null ) { throw new ParserException ( 'Renderer not set' ) ; } $ tokenList = $ this -> parse ( $ text ) ; return $ this -> renderer -> render ( $ tokenList , $ skin ) ; }
|
Parse text by provided rules and try to render token list
|
2,504
|
protected function connectRulesToLexer ( ) { foreach ( $ this -> rules as $ childRule ) { $ childRule -> prepare ( $ this -> lexer ) ; if ( $ childRule -> getName ( ) === $ this -> startRule -> getName ( ) ) { continue ; } if ( $ this -> startRule -> acceptRule ( $ childRule -> getName ( ) ) ) { $ childRule -> embedInto ( $ this -> startRule -> getName ( ) , $ this -> lexer ) ; } $ childRule -> finish ( $ this -> lexer ) ; } }
|
Add rule patterns to lexer
|
2,505
|
protected function sortRulesByOrder ( AbstractRule $ a , AbstractRule $ b ) { if ( $ a -> getOrder ( ) === $ b -> getOrder ( ) ) { return 0 ; } return $ a -> getOrder ( ) < $ b -> getOrder ( ) ? - 1 : 1 ; }
|
Sort rules by order ASC
|
2,506
|
public function render_html_email ( Vulnerabilities $ vulnerabilities , CssToInlineStyles $ inliner = null ) { $ html = $ this -> template -> render ( 'emails/html/vulnerable.php' , [ 'action_url' => admin_url ( 'update-core.php' ) , 'vulnerabilities' => $ vulnerabilities , ] ) ; $ css = $ this -> template -> render ( 'emails/style.css' ) ; $ inliner = $ inliner ? : new CssToInlineStyles ( ) ; return $ inliner -> convert ( $ html , $ css ) ; }
|
Render the contents of the HTML email notification .
|
2,507
|
protected function getUserDefinedGlobals ( ) { if ( file_exists ( realpath ( __DIR__ . '/../../../../config/twig.php' ) ) ) { $ this -> config = require realpath ( __DIR__ . '/../../../../config/twig.php' ) ; } elseif ( file_exists ( realpath ( __DIR__ . '/../config/twig.php' ) ) ) { $ this -> config = require realpath ( __DIR__ . '/../config/twig.php' ) ; } return isset ( $ this -> config [ 'twig_global' ] ) ? $ this -> config [ 'twig_global' ] : [ ] ; }
|
Get the user defined global for twig templates .
|
2,508
|
public function notify ( Vulnerabilities $ vulnerabilities ) { if ( ! $ this -> should_notify ( $ vulnerabilities ) ) { return ; } foreach ( $ this -> notifiers as $ notifier ) { if ( $ notifier -> is_enabled ( ) ) { $ notifier -> notify ( $ vulnerabilities ) ; } } }
|
Invoke the notify method on all active notifiers .
|
2,509
|
protected function should_notify ( Vulnerabilities $ vulnerabilities ) { if ( $ vulnerabilities -> is_empty ( ) ) { return false ; } if ( $ this -> options -> should_nag ) { return true ; } return $ vulnerabilities -> hash ( ) !== $ this -> options -> last_scan_hash ; }
|
Determine whether a notifications should be sent .
|
2,510
|
public function hasHeader ( string $ key = null ) : bool { if ( $ key === null ) { return false ; } $ array = $ this -> getHeaders ( ) ; return isset ( $ array [ $ key ] ) || array_key_exists ( $ key , $ array ) ; }
|
Returns whether a header exists or not .
|
2,511
|
public function pushHeader ( string $ key , string $ value = null ) { $ headers = $ this -> getHeaders ( ) ; $ headers [ $ key ] = $ value ; $ this -> setHeaders ( $ headers ) ; return $ this ; }
|
Pushes a header value onto the headers array .
|
2,512
|
public function popHeader ( string $ key = null ) { $ value = $ this -> getHeader ( $ key ) ; if ( $ value !== null ) { unset ( $ this -> options [ 'headers' ] [ $ key ] ) ; } return $ value ; }
|
Pops a header value from the headers array .
|
2,513
|
public function handleBatch ( array $ records ) { foreach ( $ records as $ key => $ record ) { if ( $ this -> isHandling ( $ record ) ) { $ record = $ this -> processRecord ( $ record ) ; $ records [ 'records' ] [ ] = $ record ; } unset ( $ records [ $ key ] ) ; } $ records [ 'formatted' ] = $ this -> getFormatter ( ) -> formatBatch ( $ records [ 'records' ] ?? [ ] ) ; $ this -> write ( $ records ) ; return false === $ this -> bubble ; }
|
Handles a set of records at once .
|
2,514
|
protected function write ( array $ record ) { $ uri = $ this -> getUri ( ) ; if ( empty ( $ uri ) ) { return ; } $ request = $ this -> getMessageFactory ( ) -> createRequest ( $ this -> getMethod ( ) , $ this -> getUri ( ) , $ this -> getHeaders ( ) , $ record [ 'formatted' ] , $ this -> getProtocolVersion ( ) ) ; try { $ this -> getHttpClient ( ) -> sendRequest ( $ request ) ; } catch ( \ Exception $ e ) { return ; } }
|
Writes the record .
|
2,515
|
public function setHttpHeaders ( $ httpHeaders = null ) { if ( ! is_array ( $ httpHeaders ) || ! count ( $ httpHeaders ) ) { $ httpHeaders = $ _SERVER ; } $ this -> httpHeaders = array ( ) ; foreach ( $ httpHeaders as $ key => $ value ) { if ( substr ( $ key , 0 , 5 ) === 'HTTP_' ) { $ this -> httpHeaders [ $ key ] = $ value ; } } $ this -> setCfHeaders ( $ httpHeaders ) ; }
|
Set the HTTP Headers . Must be PHP - flavored . This method will reset existing headers .
|
2,516
|
public function getGroupIdCapabilitiesMap ( ) { $ groupIdCapabilitiesMap = array ( ) ; foreach ( $ this -> groupIdCapabilitiesNameMap as $ groupId => $ capabilitiesName ) { foreach ( $ capabilitiesName as $ capabilityName ) { $ groupIdCapabilitiesMap [ $ groupId ] [ $ capabilityName ] = $ this -> capabilities [ $ capabilityName ] ; } } return $ groupIdCapabilitiesMap ; }
|
Returns the capabilities by group name
|
2,517
|
public function copy ( Table $ src , Table $ dest ) { $ this -> copy_structure ( $ src , $ dest ) ; $ src_table = $ this -> database -> quote_identifier ( $ src -> name ( ) ) ; $ dest_table = $ this -> database -> quote_identifier ( $ dest -> name ( ) ) ; $ query = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}" ; return ( bool ) $ this -> database -> query ( $ query ) ; }
|
Duplicates a table structure with the complete content
|
2,518
|
protected function addInstability ( array $ metrics ) { if ( isset ( $ metrics [ 'ca' ] ) && isset ( $ metrics [ 'ce' ] ) ) { $ metrics [ 'i' ] = $ metrics [ 'ce' ] / ( ( $ metrics [ 'ce' ] + $ metrics [ 'ca' ] ) ? : 1 ) ; } return $ metrics ; }
|
pdepend . analyzer . dependency also calculates instability but not on a per - class level and defaulting to 0 instead of 1 .
|
2,519
|
public function load ( $ name , $ extension = 'html' ) { $ this -> view = $ this -> getViewFilePath ( $ name , $ extension ) ; if ( empty ( $ this -> view ) ) { throw new InvalidArgumentException ( __METHOD__ . sprintf ( ': The view file [%s] is a not valid view.' , $ this -> getViewFile ( $ name , $ extension ) ) ) ; } return $ this ; }
|
Load a view .
|
2,520
|
public function render ( ) { if ( empty ( $ this -> view ) ) { throw new InvalidArgumentException ( __METHOD__ . ': The view file given is a not valid view.' ) ; } $ this -> output = $ this -> executable ? include $ this -> view : file_get_contents ( $ this -> view ) ; $ this -> output = StringHelper :: interpolate ( $ this -> output , $ this -> parameters ) ; return $ this ; }
|
Render the view output .
|
2,521
|
private function getViewFolder ( $ name ) { return $ this -> viewsConfiguration -> getViewsPath ( $ this -> app -> getBasePath ( ) ) . DIRECTORY_SEPARATOR . $ name . '.view' ; }
|
Get the view s base folder .
|
2,522
|
private function getViewFilePath ( $ name , $ extension = 'html' ) { $ viewFile = $ this -> getViewFile ( $ name , $ extension ) ; if ( ! file_exists ( $ viewFile ) ) { $ viewBaseName = $ this -> getViewFolder ( $ name ) . DIRECTORY_SEPARATOR . 'view' ; $ viewFile = ( file_exists ( $ viewBaseName . '.php' ) ? $ viewBaseName . '.php' : $ viewBaseName . '.html' ) ; $ viewFile = ( file_exists ( $ viewFile ) ? $ viewFile : null ) ; } if ( preg_match ( '/\.php$/' , $ viewFile ) ) { $ this -> executable = true ; } return $ viewFile ; }
|
Get the view file to be rendered for output .
|
2,523
|
private function processAdministrator ( ) { $ sourceFolder = $ this -> getSourceFolder ( ) ; $ this -> processComponents ( $ sourceFolder . '/administrator/components' , $ this -> target . '/administrator' ) ; $ this -> processLanguage ( $ sourceFolder . '/administrator/language' , $ this -> target . '/administrator' ) ; $ this -> processModules ( $ sourceFolder . '/administrator/modules' , $ this -> target . '/administrator/modules' ) ; }
|
Process Administrator files
|
2,524
|
private function linkSubdirectories ( $ src , $ to ) { if ( is_dir ( $ src ) ) { $ dirHandle = opendir ( $ src ) ; while ( false !== ( $ element = readdir ( $ dirHandle ) ) ) { if ( substr ( $ element , 0 , 1 ) != '.' ) { if ( is_dir ( $ src . "/" . $ element ) ) { $ this -> symlink ( $ src . "/" . $ element , $ to . '/' . $ element ) ; } } } } }
|
Link subdirectories into folder
|
2,525
|
private function createInstaller ( ) { $ this -> say ( "Creating component installer" ) ; $ adminFolder = $ this -> getBuildFolder ( ) . "/administrator/components/com_" . $ this -> getExtensionName ( ) ; $ xmlFile = $ adminFolder . "/" . $ this -> getExtensionName ( ) . ".xml" ; $ configFile = $ adminFolder . "/config.xml" ; $ scriptFile = $ adminFolder . "/script.php" ; $ helperFile = $ adminFolder . "/helpers/defines.php" ; $ this -> replaceInFile ( $ xmlFile ) ; $ this -> replaceInFile ( $ scriptFile ) ; $ this -> replaceInFile ( $ configFile ) ; $ this -> replaceInFile ( $ helperFile ) ; if ( $ this -> hasAdmin ) { $ f = $ this -> generateFileList ( $ this -> getFiles ( 'backend' ) ) ; $ this -> taskReplaceInFile ( $ xmlFile ) -> from ( '##BACKEND_COMPONENT_FILES##' ) -> to ( $ f ) -> run ( ) ; $ f = $ this -> generateLanguageFileList ( $ this -> getFiles ( 'backendLanguage' ) ) ; $ this -> taskReplaceInFile ( $ xmlFile ) -> from ( '##BACKEND_LANGUAGE_FILES##' ) -> to ( $ f ) -> run ( ) ; } if ( $ this -> hasFront ) { $ f = $ this -> generateFileList ( $ this -> getFiles ( 'frontend' ) ) ; $ this -> taskReplaceInFile ( $ xmlFile ) -> from ( '##FRONTEND_COMPONENT_FILES##' ) -> to ( $ f ) -> run ( ) ; $ f = $ this -> generateLanguageFileList ( $ this -> getFiles ( 'frontendLanguage' ) ) ; $ this -> taskReplaceInFile ( $ xmlFile ) -> from ( '##FRONTEND_LANGUAGE_FILES##' ) -> to ( $ f ) -> run ( ) ; } if ( $ this -> hasMedia ) { $ f = $ this -> generateFileList ( $ this -> getFiles ( 'media' ) ) ; $ this -> taskReplaceInFile ( $ xmlFile ) -> from ( '##MEDIA_FILES##' ) -> to ( $ f ) -> run ( ) ; } }
|
Generate the installer xml file for the component
|
2,526
|
public function required ( ) { $ this -> validated = false ; $ this -> config [ self :: REQUIRED ] = true ; return $ this ; }
|
change the argument from optional to mandatory
|
2,527
|
public function name ( $ name ) { $ this -> config [ self :: NAME ] = $ name ; if ( ! self :: validateName ( $ name ) ) { throw new ArgumentConfigException ( 'illegal characters in name: ' . $ name ) ; } return $ this ; }
|
set the argument s name
|
2,528
|
public function defaultValue ( $ value ) { $ this -> validated = false ; $ this -> config [ self :: DEFAULT_VALUE ] = $ value ; return $ this ; }
|
set the argument s default value
|
2,529
|
public function get ( $ param = '' ) { $ this -> validate ( ) ; if ( $ param ) { if ( array_key_exists ( $ param , $ this -> config ) ) { return $ this -> config [ $ param ] ; } else { throw new ArgumentConfigException ( 'argument param not valid: ' . $ param ) ; } } return $ this -> config ; }
|
return full argument configuration or a specific parameter of the configuration
|
2,530
|
final public static function membersToBitmask ( $ members ) { $ mask = 0 ; foreach ( $ members as $ member ) { if ( ! is_integer ( $ member -> value ( ) ) ) { throw new Exception \ NonIntegerValueException ( $ member -> value ( ) ) ; } $ mask |= $ member -> value ( ) ; } return $ mask ; }
|
Generates a bitmask representing the suppled members .
|
2,531
|
public function valueMatchesBitmask ( $ mask ) { if ( ! is_integer ( $ this -> value ( ) ) ) { throw new Exception \ NonIntegerValueException ( $ this -> value ( ) ) ; } return $ this -> value ( ) === ( $ this -> value ( ) & $ mask ) ; }
|
Returns true if this constant s value matches the supplied bitmask .
|
2,532
|
public function denies ( $ policyName , $ subject , array $ addl = array ( ) ) { if ( ! is_array ( $ policyName ) ) { $ policyName = [ $ policyName ] ; } foreach ( $ policyName as $ name ) { if ( ! isset ( $ this -> policySet [ $ name ] ) ) { throw new \ InvalidArgumentException ( 'Policy name "' . $ name . '" not found' ) ; } $ result = $ this -> evaluate ( $ subject , $ this -> policySet [ $ name ] , $ addl ) ; if ( $ result === true ) { return false ; } } return true ; }
|
Locate a policy by name and evaluate if the subject is denied by matching against its properties
|
2,533
|
public function resolvePath ( $ type , $ subject , $ path ) { $ resolve = new Resolve ( $ subject ) ; $ resolvedSet = $ resolve -> execute ( $ path ) ; $ set = [ ] ; if ( is_array ( $ resolvedSet ) ) { foreach ( $ resolvedSet as $ item ) { $ set [ ] = $ this -> getPropertyValue ( $ type , $ item ) ; } } else { $ set = $ this -> getPropertyValue ( $ type , $ subject ) ; } return $ set ; }
|
Resolve the provided path using a Resolver object instance
|
2,534
|
public function call_function ( ) { $ args = func_get_args ( ) ; $ name = array_shift ( $ args ) ; return call_user_func_array ( trim ( $ name ) , $ args ) ; }
|
Call PHP function .
|
2,535
|
public function call_static ( ) { $ args = func_get_args ( ) ; $ class = array_shift ( $ args ) ; $ name = array_shift ( $ args ) ; return call_user_func_array ( [ $ class , $ name ] , $ args ) ; }
|
Call static method on class .
|
2,536
|
public static function getopts ( $ options ) { $ opts = getopt ( implode ( '' , array_keys ( $ options ) ) , $ options ) ; $ result = array ( ) ; foreach ( $ options as $ short => $ long ) { $ short = trim ( $ short , ':' ) ; $ long = trim ( $ long , ':' ) ; if ( isset ( $ opts [ $ short ] ) ) { $ result [ $ long ] = $ opts [ $ short ] ; } elseif ( isset ( $ opts [ $ long ] ) ) { $ result [ $ long ] = $ opts [ $ long ] ; } } return $ result ; }
|
getopts is very convenient but annoying how one has to check for both the long & short versions for values ; this will always return an array with the long opt as key even if the user passed it as short .
|
2,537
|
function archive ( $ id ) { $ this -> requestDecorator -> setId ( $ id . '/archived' ) ; $ result = $ this -> client -> put ( $ this -> requestDecorator -> makeResource ( ) , $ this -> requestDecorator -> makePayload ( ) , $ this -> requestDecorator -> makeHeaders ( ) ) ; $ this -> refresh ( ) ; return $ result ; }
|
Archive a record .
|
2,538
|
public function short ( $ short ) { $ this -> validated = false ; if ( ! self :: validateShort ( $ short ) ) { throw new OptionConfigException ( 'short option must be a single character: ' . $ short ) ; } $ this -> config [ self :: SHORT ] = $ short ; return $ this ; }
|
set the option s short name
|
2,539
|
public function long ( $ long ) { $ this -> validated = false ; if ( ! self :: validateLong ( $ long ) ) { throw new OptionConfigException ( 'invalid long option format: ' . $ long ) ; } $ this -> config [ self :: LONG ] = $ long ; return $ this ; }
|
set the option s long name
|
2,540
|
public function argument ( $ name ) { $ this -> validated = false ; if ( ! preg_match ( '#^[a-zA-Z0-9\-\_]+$#' , $ name ) ) { throw new OptionConfigException ( 'illegal characters in name: ' . $ name ) ; } $ this -> config [ self :: ARGUMENT ] = $ name ; return $ this ; }
|
let the option require an argument with the given name
|
2,541
|
public function get ( $ param = '' ) { $ this -> validate ( ) ; if ( $ param ) { if ( array_key_exists ( $ param , $ this -> config ) ) { return $ this -> config [ $ param ] ; } else { throw new OptionConfigException ( 'option param not valid: ' . $ param ) ; } } return $ this -> config ; }
|
return full option configuration or a specific parameter of the configuration
|
2,542
|
private function matchClientPreferences ( $ fromField , array $ clientPrefList , array $ matchingList ) { foreach ( $ clientPrefList as $ clientPref ) { $ matchingList = $ this -> matchSingleClientPreference ( $ fromField , $ clientPref , $ matchingList ) ; } return $ matchingList ; }
|
Match client variants to server variants .
|
2,543
|
private function matchSingleClientPreference ( $ fromField , PreferenceInterface $ clientPreference , array $ matchingList ) { foreach ( $ this -> matcherList as $ matcher ) { if ( $ matcher -> hasMatch ( $ fromField , $ matchingList , $ clientPreference ) ) { $ matchingList = $ matcher -> match ( $ fromField , $ matchingList , $ clientPreference ) ; break ; } } return $ matchingList ; }
|
Match a single client variant to the server variants .
|
2,544
|
public function actionIndex ( ) { $ searchModel = new Z1UserSearch ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ pageSize = intval ( trim ( Yii :: $ app -> request -> get ( 'per-page' ) ) ) ; if ( $ pageSize ) { $ dataProvider -> pagination -> pageSize = $ pageSize ; } return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
|
Lists all Z1User models .
|
2,545
|
public function compile ( Node $ node ) : string { $ this -> head = $ this -> body = '' ; $ node -> compile ( $ this ) ; return $ this -> getResult ( ) ; }
|
Compiles a node into a string
|
2,546
|
public function setRoles ( $ roles ) { $ widget = $ this -> widget ; $ newRoles = [ ] ; foreach ( $ this -> availableRoles as $ role ) { $ newRoles [ $ role ] = in_array ( $ role , $ roles ) ; } $ widget -> setOption ( 'roles' , $ newRoles ) ; }
|
This data comes from the form . It is the applicable roles list .
|
2,547
|
public function findApplicableRoles ( ) { $ widget = $ this -> widget ; $ array = [ ] ; foreach ( $ this -> availableRoles as $ role ) { if ( $ widget -> isApplicable ( $ role ) ) { $ array [ ] = $ role ; } } return $ array ; }
|
Find applicable roles .
|
2,548
|
public function find ( $ name ) { $ tags = $ this -> all ( ) ; $ found = array ( ) ; foreach ( $ tags as $ tag ) { if ( $ tag [ 'name' ] === $ name ) { $ found = $ tag ; break ; } } return $ found ; }
|
Find a tag by name
|
2,549
|
public function findAll ( array $ names ) { $ tags = $ this -> all ( ) ; $ transformTags = function ( $ array ) { $ newArray = array ( ) ; foreach ( $ array as $ entry ) { $ newArray [ $ entry [ 'name' ] ] = $ entry ; } return $ newArray ; } ; $ tagNames = $ transformTags ( $ tags ) ; $ found = array ( 'tags' => array ( ) , 'notFound' => array ( ) ) ; foreach ( $ names as $ name ) { if ( in_array ( $ name , array_keys ( $ tagNames ) ) ) { $ found [ 'tags' ] [ ] = $ tagNames [ $ name ] ; } else { $ found [ 'notFound' ] [ ] = $ name ; } } return $ found ; }
|
Find all tags by name
|
2,550
|
public function format ( $ tags , $ type ) { $ formattedTags = array ( ) ; if ( $ type === 'user' ) { $ formattedTags [ 'tags' ] = array ( ) ; foreach ( $ tags as $ tag ) { $ formattedTags [ 'tags' ] [ $ tag [ '_id' ] ] = array ( 'mode' => 'readWrite' ) ; } } else if ( $ type === 'other' ) { foreach ( $ tags as $ tag ) { $ formattedTags [ 'tags' ] [ ] = $ tag [ '_id' ] ; } } else { throw ErrorException ( "Only 'user' and 'other' are allowed types" ) ; } return $ formattedTags ; }
|
Format tags to be inserted
|
2,551
|
function addLanguage ( $ languageKey , $ content ) { if ( is_array ( $ this -> getLanguage ( $ languageKey ) ) ) { $ this -> languages [ $ languageKey ] [ ] = $ content [ 0 ] ; return ; } $ this -> languages [ $ languageKey ] = $ content ; return $ this ; }
|
Add a language to the field .
|
2,552
|
protected function parseContent ( $ content ) { if ( is_bool ( $ content ) ) { $ this -> addLanguage ( $ this -> language , $ content ) ; return ; } if ( ! $ content ) { return ; } if ( is_string ( $ content ) ) { $ this -> addLanguage ( $ this -> language , $ content ) ; return ; } foreach ( $ content as $ key => $ data ) { if ( ! empty ( $ data [ 0 ] [ 'sys' ] [ 'linkType' ] ) ) { foreach ( $ data as $ link ) { $ this -> addLink ( $ link [ 'id' ] , $ link [ 'linkType' ] , $ key ) ; } } else { if ( is_numeric ( $ key ) ) { $ this -> addLanguage ( $ this -> language , [ $ data ] ) ; } else { $ this -> addLanguage ( $ key , $ data ) ; } } } }
|
Parse loaded content . Tests to see if it s a link or if languages are provided and handle appropriately .
|
2,553
|
function make ( ) { if ( $ this -> links ) { return $ this -> links ; } elseif ( $ this -> link ) { return $ this -> link ; } return $ this -> languages ; }
|
Return the payload builder array part . If links are provided return them instead of languages .
|
2,554
|
public static function convertIxfObjectToArray ( $ values ) { $ results = array ( ) ; foreach ( $ values as $ k => $ v ) { if ( $ k [ 0 ] == '_' ) { continue ; } if ( $ v instanceof Object ) { $ results [ $ k ] = $ v -> __toArray ( true ) ; } elseif ( is_array ( $ v ) ) { $ results [ $ k ] = self :: convertIxfObjectToArray ( $ v ) ; } else { $ results [ $ k ] = $ v ; } } return $ results ; }
|
Recursively converts the PHP IXF object to an array .
|
2,555
|
public static function convertToIxfObject ( $ resp ) { if ( self :: isList ( $ resp ) ) { $ mapped = array ( ) ; foreach ( $ resp as $ k => $ i ) array_push ( $ mapped , self :: convertToIxfObject ( $ i ) ) ; return $ mapped ; } elseif ( is_array ( $ resp ) ) { $ type = null ; if ( isset ( $ resp [ '_id' ] ) ) $ type = substr ( $ resp [ '_id' ] , 0 , strpos ( $ resp [ '_id' ] , "." ) ) ; $ class = ApiResource :: resolveClassName ( $ type ) ; return Object :: scopedConstructFrom ( $ class , $ resp ) ; } else return $ resp ; }
|
Converts a response from the IXF API to the corresponding PHP object .
|
2,556
|
public function getProviders ( ) { $ hybridAuthProviders = $ this -> hybridAuth -> getProviders ( ) ; $ providerList = [ ] ; foreach ( $ hybridAuthProviders as $ providerName => $ config ) $ providerList [ ] = $ providerName ; $ providers = $ this -> makeProviders ( $ providerList ) ; return $ providers ; }
|
Returns all enabled provider from the config
|
2,557
|
public function getConnectedProviders ( ) { $ hybridAuthProviders = $ this -> hybridAuth -> getConnectedProviders ( ) ; $ providers = $ this -> makeProviders ( $ hybridAuthProviders ) ; return $ providers ; }
|
Returns only currently connected providers
|
2,558
|
public function dispatchEvent ( $ name , SearchEvent $ event , array $ context = array ( ) ) { $ log = $ this -> getLogger ( ) ; $ context [ 'event' ] = $ name ; $ log -> debug ( 'Throwing event' , $ context ) ; $ this -> getDispatcher ( ) -> dispatch ( $ name , $ event ) ; $ log -> debug ( 'Event thrown' , $ context ) ; }
|
Dispatches an event wraps with debug messages .
|
2,559
|
public function attachCollection ( CollectionAbstract $ collection ) { $ id = $ collection -> getId ( ) ; if ( isset ( $ this -> _collections [ $ id ] ) ) { throw new \ InvalidArgumentException ( 'Collection already attached: ' . $ id ) ; } $ this -> _collections [ $ id ] = $ collection ; $ this -> clearSchema ( ) ; $ this -> getLogger ( ) -> debug ( 'Collection attached' , array ( 'collection' => $ id ) ) ; return $ this ; }
|
Relates a collection to the object .
|
2,560
|
public function getCollection ( $ id ) { if ( ! isset ( $ this -> _collections [ $ id ] ) ) { throw new \ InvalidArgumentException ( 'Collection not attached: ' . $ id ) ; } return $ this -> _collections ; }
|
Returns a collection given it s unique identifier .
|
2,561
|
public function removeCollection ( $ id ) { unset ( $ this -> _collections [ $ id ] ) ; $ this -> clearSchema ( ) ; $ this -> getLogger ( ) -> debug ( 'Collection removed' , array ( 'collection' => $ id ) ) ; return $ this ; }
|
Removes a collection from this server .
|
2,562
|
public function getSchema ( ) { if ( ! isset ( $ this -> _schema ) ) { $ this -> _schema = $ this -> loadSchemata ( ) ; } return $ this -> _schema ; }
|
Returns the fused schema for all collections attached to this agent .
|
2,563
|
public function loadSchemata ( ) { $ fused_options = array ( ) ; foreach ( $ this -> _collections as $ collection ) { $ context = array ( 'collection' => $ collection -> getId ( ) ) ; $ schema_options = $ this -> loadCollectionSchema ( $ collection ) -> toArray ( ) ; if ( ! $ fused_options ) { $ fused_options = $ schema_options ; continue ; } if ( $ schema_options [ 'unique_field' ] != $ fused_options [ 'unique_field' ] ) { $ message = 'Collections must have the same unique field.' ; throw new \ InvalidArgumentException ( $ message ) ; } foreach ( $ schema_options [ 'fields' ] as $ field_id => $ field_options ) { if ( ! isset ( $ fused_options [ 'fields' ] [ $ field_id ] ) ) { $ fused_options [ 'fields' ] [ $ field_id ] = $ field_options ; } elseif ( $ fused_options [ 'fields' ] [ $ field_id ] != $ field_options ) { $ message = 'Field definitions for "' . $ field_id . '"must match.' ; throw new \ InvalidArgumentException ( $ message ) ; } } } $ schema = new Schema ( ) ; $ schema -> build ( $ fused_options ) ; foreach ( $ schema as $ id => $ field ) { $ this -> _fieldTypes [ $ id ] = $ field -> getType ( ) ; } return $ schema ; }
|
Loads and fuses the schemata for all collections attached to this agent .
|
2,564
|
public function fitText ( $ width , $ text = '' , $ padding = 0 ) { $ spaces = $ width - strlen ( $ text ) - $ padding ; return $ text . str_repeat ( ' ' , $ spaces < 0 ? 0 : $ spaces ) ; }
|
Append spaces to the string to fit the whole terminal window
|
2,565
|
public function getFormattedChoices ( array $ choices , $ position , $ selected ) { $ lines = [ ] ; foreach ( $ choices as $ index => $ choice ) { $ state = in_array ( $ choice , $ selected ) ? self :: CHOICE_SELECTED : self :: CHOICE_NORMAL ; $ cursor = $ index === $ position ? self :: CHOICE_HOVERED : self :: CHOICE_NORMAL ; $ line = $ this -> style [ $ state ] [ $ cursor ] ; $ choice = ' ' . unicode_to_string ( '\u25C9' ) . ' ' . $ choice ; $ lines [ ] = sprintf ( $ line , $ this -> fitText ( $ this -> window -> getWidth ( ) , $ choice ) ) ; } return $ lines ; }
|
Returns an array of styled options
|
2,566
|
public function drawWindow ( $ title , $ choices , $ position , $ answers ) { $ this -> window -> clearScreen ( ) ; $ this -> output -> writeln ( $ this -> getTitle ( $ title ) ) ; $ this -> output -> writeln ( "" ) ; $ lines = $ this -> getFormattedChoices ( $ choices , $ position , $ answers ) ; foreach ( $ lines as $ line ) { $ this -> output -> writeln ( $ line ) ; } return $ this ; }
|
Draw the window
|
2,567
|
public function get ( $ type ) { if ( strpos ( $ type , '#' ) !== false ) list ( $ type , $ string ) = explode ( '#' , $ type , 2 ) ; else $ string = '' ; if ( ! isset ( $ this -> info [ $ type ] ) ) { trigger_error ( 'Cannot retrieve undefined attribute type ' . $ type , E_USER_ERROR ) ; return ; } return $ this -> info [ $ type ] -> make ( $ string ) ; }
|
Retrieves a type
|
2,568
|
private function process ( DeviceIterator $ deviceIterator , array $ patchingDevices = array ( ) ) { $ usedPatches = array ( ) ; foreach ( $ deviceIterator as $ device ) { $ toPatch = isset ( $ patchingDevices [ $ device -> id ] ) ; if ( $ toPatch ) { $ device = $ this -> patchDevice ( $ device , $ patchingDevices [ $ device -> id ] ) ; $ usedPatches [ $ device -> id ] = $ device -> id ; } $ this -> classifyAndPersistDevice ( $ device ) ; } $ this -> classifyAndPersistNewDevices ( array_diff_key ( $ patchingDevices , $ usedPatches ) ) ; $ this -> persistClassifiedDevicesUserAgentMap ( ) ; }
|
Process device iterator
|
2,569
|
public function addOption ( $ name , Option $ opt = null ) { if ( isset ( $ this -> configOpts [ $ name ] ) || isset ( $ this -> configArgs [ $ name ] ) ) { throw new ConfigException ( 'option/argument already set: ' . $ name ) ; } if ( is_null ( $ opt ) ) { $ opt = new Option ( ) ; } $ this -> configOpts [ $ name ] = $ opt ; return $ opt ; }
|
add a new option
|
2,570
|
public function addArgument ( $ name , Argument $ arg = null ) { if ( isset ( $ this -> configOpts [ $ name ] ) || isset ( $ this -> configArgs [ $ name ] ) ) { throw new ConfigException ( 'option/argument already set: ' . $ name ) ; } if ( is_null ( $ arg ) ) { $ arg = new Argument ( ) ; } $ this -> configArgs [ $ name ] = $ arg ; return $ arg ; }
|
add a new argument
|
2,571
|
public function setHelpOptionLong ( $ str ) { if ( ! Option :: validateLong ( $ str ) ) { throw new ConfigException ( 'long help option has invalid format' ) ; } $ this -> helpLong = $ str ; return $ this ; }
|
set the long option for help handling
|
2,572
|
public function setHelpOptionShort ( $ str ) { if ( ! Option :: validateShort ( $ str ) ) { throw new ConfigException ( 'short help option must be a single character' ) ; } $ this -> helpShort = $ str ; return $ this ; }
|
set the short option for help handling
|
2,573
|
public function parse ( $ inputArgs = null ) { $ args = $ this -> getCommandLineArgs ( $ inputArgs ) ; if ( count ( $ args ) ) { $ this -> scriptName = array_shift ( $ args ) ; } $ helpOpt = false ; if ( $ this -> helpLong ) { $ helpOpt = new Option ( ) ; $ helpOpt -> long ( $ this -> helpLong ) ; } if ( $ this -> helpShort ) { if ( ! $ helpOpt ) { $ helpOpt = new Option ( ) ; } $ helpOpt -> short ( $ this -> helpShort ) ; } if ( $ helpOpt ) { $ this -> configOpts [ Parser :: HELP_OPTION_NAME ] = $ helpOpt ; } try { $ parser = new Parser ( $ this -> configOpts , $ this -> configArgs ) ; $ parser -> parse ( $ args ) ; } catch ( UsageException $ e ) { if ( $ this -> errorHandling ) { $ this -> handleUsageError ( $ e ) ; } else { throw $ e ; } } catch ( ShowHelpException $ e ) { $ this -> showHelp ( ) ; } $ this -> result = $ parser -> getResult ( ) ; }
|
parse arguments the first element in the array is treated as script name
|
2,574
|
public function getOptions ( ) { if ( is_null ( $ this -> result ) ) { $ this -> parse ( ) ; } return $ this -> result [ Parser :: RESULT_OPTIONS ] ; }
|
get the parsed options and their values
|
2,575
|
public function getArguments ( ) { if ( is_null ( $ this -> result ) ) { $ this -> parse ( ) ; } return $ this -> result [ Parser :: RESULT_ARGUMENTS ] ; }
|
get parsed argument values
|
2,576
|
public function render ( TokenList $ tokenList , $ skin = 'default' ) { if ( ! array_key_exists ( $ skin , $ this -> ruleRenderers ) ) { throw new ParserException ( 'Skin ' . $ skin . ' not found' ) ; } if ( ! array_key_exists ( $ skin , $ this -> tokenRenderers ) ) { $ this -> tokenRenderers [ $ skin ] = [ ] ; foreach ( $ this -> ruleRenderers [ $ skin ] as $ ruleRenderer ) { $ ruleRenderer -> register ( $ this ) ; } } \ Event :: fire ( 'vikon.parser.before.render' , [ $ tokenList ] ) ; $ output = '' ; foreach ( $ tokenList -> getTokens ( ) as $ token ) { \ Event :: fire ( 'vikon.parser.token.render.' . $ token -> getName ( ) , [ $ token , $ tokenList ] ) ; if ( array_key_exists ( $ token -> getName ( ) , $ this -> tokenRenderers [ $ skin ] ) ) { $ output .= $ this -> tokenRenderers [ $ skin ] [ $ token -> getName ( ) ] ( $ token , $ tokenList ) ; } else { $ output .= ( string ) $ token ; } } return $ output ; }
|
Render token list
|
2,577
|
public function load ( ) { $ log = $ this -> _agent -> getLogger ( ) ; $ context = array ( 'collection' => $ this -> _collection -> getId ( ) ) ; $ event = new SchemaLoaderEvent ( $ this -> _agent , $ this -> _collection ) ; $ this -> _agent -> dispatchEvent ( SearchEvents :: SCHEMA_LOAD , $ event ) ; if ( ! $ options = $ event -> getOptions ( ) ) { if ( $ conf_dir = $ this -> getConfDir ( ) ) { $ filename = $ this -> _collection -> getConfigBasename ( ) . '.yml' ; $ filepath = $ conf_dir . '/' . $ filename ; $ context [ 'filepath' ] = $ filepath ; $ log -> debug ( 'Attempting to parse schema configuration file' , $ context ) ; $ options = Yaml :: parse ( $ filepath ) ; $ log -> debug ( 'Schema options parsed from configuration file' , $ context ) ; } else { $ log -> notice ( 'Path to conf directory could not be resolved' , $ context ) ; } } else { $ log -> debug ( 'Schema configuration loaded from an external source.' , $ context ) ; } $ schema = new Schema ( ) ; $ schema -> build ( $ options ) ; return $ schema ; }
|
Parses configuration options from YAML configuration files related to the configurable object .
|
2,578
|
public function mailer ( $ phpMailer ) { if ( MAILER_SMTP ) { $ phpMailer -> isSMTP ( ) ; $ phpMailer -> SMTPAuth = true ; } $ phpMailer -> Host = MAILER_HOST ; $ phpMailer -> Port = MAILER_PORT ; $ phpMailer -> Username = MAILER_USERNAME ; $ phpMailer -> Password = MAILER_PASSWORD ; $ phpMailer -> SMTPSecure = MAILER_TRANSPORT ; $ phpMailer -> Sender = $ phpMailer -> From ; }
|
Configures the mailer according to the parameters in wp - config - custom . php .
|
2,579
|
private function registerFlash ( ) { $ this -> app -> singleton ( 'CodeZero\Flash\Flash' , function ( ) { $ config = config ( 'flash' ) ; $ session = app ( ) -> make ( 'CodeZero\Flash\SessionStore\SessionStore' ) ; $ translator = app ( ) -> make ( 'CodeZero\Flash\Translator\Translator' ) ; return new Flash ( $ config , $ session , $ translator ) ; } ) ; }
|
Register the Flash binding .
|
2,580
|
public function add_extension ( Twig_ExtensionInterface $ extension ) { $ env = $ this -> instance ( ) ; $ exts = $ env -> getExtensions ( ) ; if ( isset ( $ exts [ $ extension -> getName ( ) ] ) ) { return ; } try { $ env -> addExtension ( $ extension ) ; } catch ( LogicException $ e ) { return ; } }
|
Add extension if it don t exists .
|
2,581
|
private function boot ( ) { list ( $ locations , $ config ) = $ this -> get_engine_config ( ) ; $ loader = new Twig_Loader_Filesystem ( $ locations ) ; $ env = new Twig_Environment ( $ loader , $ config ) ; if ( defined ( 'WP_DEBUG' ) && WP_DEBUG ) { $ env -> addExtension ( new Twig_Extension_Debug ( ) ) ; } return $ env ; }
|
Boot Twig environment .
|
2,582
|
public function instance ( ) { if ( ! isset ( self :: $ environment ) ) { self :: $ environment = $ this -> boot ( ) ; } return self :: $ environment ; }
|
Get the Twig environment instance .
|
2,583
|
public function register_extensions ( ) { $ extensions = func_get_args ( ) ; foreach ( $ extensions as $ extension ) { if ( $ extension instanceof Twig_ExtensionInterface ) { $ this -> add_extension ( $ extension ) ; } else if ( is_string ( $ extension ) && class_exists ( $ extension ) ) { $ this -> add_extension ( new $ extension ) ; } else { foreach ( ( array ) $ extension as $ ext ) { $ this -> register_extensions ( $ ext ) ; } } } }
|
Register Twig extensions that use Twig_ExtensionInterface .
|
2,584
|
public function render ( $ view , array $ data = [ ] ) { if ( in_array ( $ view , $ this -> extensions ) ) { return '' ; } try { return $ this -> instance ( ) -> render ( $ view , $ data ) ; } catch ( Twig_Error $ e ) { do_action ( 'digster/twig_render_exception' , $ e ) ; $ this -> render_error ( $ e ) ; } }
|
Get the rendered view string .
|
2,585
|
protected function render_error ( Twig_Error $ e ) { $ title = 'Error' ; $ message = 'An error occurred while rendering the template for this page. Turn on the "debug" option for more information.' ; $ file = '' ; $ code = '' ; list ( $ locations , $ config ) = $ this -> get_engine_config ( ) ; if ( $ config [ 'debug' ] ) { $ template_file = $ e -> getTemplateFile ( ) ; foreach ( $ locations as $ location ) { if ( file_exists ( $ location . '/' . $ template_file ) ) { $ file = $ locations [ 0 ] . '/' . $ template_file ; break ; } } if ( ! file_exists ( $ file ) ) { throw $ e ; return ; } $ line = $ e -> getTemplateLine ( ) ; $ plus = 4 ; $ content = file_get_contents ( $ file ) ; $ lines = preg_split ( "/(\r\n|\n|\r)/" , $ content ) ; $ start = max ( 1 , $ line - $ plus ) ; $ limit = min ( count ( $ lines ) , $ line + $ plus ) ; $ excerpt = [ ] ; for ( $ i = $ start - 1 ; $ i < $ limit ; $ i ++ ) { $ attr = sprintf ( 'data-line="%d"' , ( $ i + 1 ) ) ; if ( $ i === $ line - 1 ) { $ excerpt [ ] = sprintf ( '<mark %s>%s</mark>' , $ attr , $ lines [ $ i ] ) ; continue ; } $ excerpt [ ] = sprintf ( '<span %s>%s</span>' , $ attr , $ lines [ $ i ] ) ; } $ title = get_class ( $ e ) ; $ message = $ e -> getMessage ( ) ; $ code = implode ( "\n" , $ excerpt ) ; $ file = $ file . ':' . $ line ; $ message = $ e -> getRawMessage ( ) ; } $ view = 'error.php' ; $ path = __DIR__ . '/../views/' ; $ path = rtrim ( $ path , '/' ) . '/' ; $ path = $ path . $ view ; $ path = apply_filters ( 'digster/twig_error_view' , $ path ) ; if ( file_exists ( $ path ) ) { require $ path ; die ; } throw $ e ; }
|
Render error view .
|
2,586
|
public static function fromArray ( array $ points ) { $ parsed_points = array_map ( function ( $ p ) { if ( ! is_array ( $ p ) or sizeof ( $ p ) != 2 ) throw new GeoSpatialException ( 'Error: array of array containing lat, lon expected.' ) ; return new Point ( $ p [ 0 ] , $ p [ 1 ] ) ; } , $ points ) ; return new static ( $ parsed_points ) ; }
|
A Linestring could be constructed with an array of points - array .
|
2,587
|
public static function fromString ( $ points , $ points_separator = "," , $ coords_separator = " " ) { if ( $ points_separator == $ coords_separator ) throw new GeoSpatialException ( "Error: separators must be different" ) ; $ parsed_points = array_map ( function ( $ p ) use ( $ coords_separator ) { return Point :: fromString ( $ p , $ coords_separator ) ; } , explode ( $ points_separator , trim ( $ points ) ) ) ; return new static ( $ parsed_points ) ; }
|
A Linestring could be instantiated using a string where points are divided by a and coordinates are divided by . Separators must be different . es . lat lon lat lon
|
2,588
|
public function isCircular ( ) { return count ( $ this -> points ) > 3 && $ this -> points [ 0 ] == $ this -> points [ count ( $ this -> points ) - 1 ] ; }
|
Check if the LineString is circular that is the first and the last Point are the same .
|
2,589
|
public function lenght ( $ provider = "haversine" ) { $ length = 0 ; for ( $ i = 0 ; $ i < count ( $ this ) - 2 ; $ i ++ ) { $ length += Point :: distance ( $ this -> points [ $ i ] , $ this -> points [ $ i + 1 ] , $ provider ) ; } return $ length ; }
|
Return the lenght of the linestring expressed in meters .
|
2,590
|
public function post ( $ travisConfiguration ) { $ headers = [ 'Accept: application/vnd.travis-ci.2+json' , 'Content-Type: text/yaml' , 'Content-Length: ' . strlen ( $ travisConfiguration ) , ] ; curl_setopt ( $ this -> curlChannel , CURLOPT_USERAGENT , self :: CURL_USERAGENT ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_CUSTOMREQUEST , 'POST' ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_CONNECTTIMEOUT , self :: CURL_TIMEOUT_IN_SECONDS ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_TIMEOUT , self :: CURL_TIMEOUT_IN_SECONDS ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_MAXREDIRS , 3 ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_POSTFIELDS , $ travisConfiguration ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_URL , self :: API_ENDPOINT ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> curlChannel , CURLOPT_SSL_VERIFYPEER , false ) ; $ lintResult = curl_exec ( $ this -> curlChannel ) ; $ responseInfo = curl_getinfo ( $ this -> curlChannel ) ; curl_close ( $ this -> curlChannel ) ; $ apiRequestStatusCode = intval ( $ responseInfo [ 'http_code' ] ) ; if ( $ apiRequestStatusCode >= 400 ) { $ message = 'Travis CI lint API request ' . " failed with HTTP Code '$apiRequestStatusCode'." ; throw new ConnectivityFailure ( $ message ) ; } $ lintResult = json_decode ( $ lintResult , true ) ; if ( ! isset ( $ lintResult [ 'lint' ] ) || ! isset ( $ lintResult [ 'lint' ] [ 'warnings' ] ) ) { $ message = 'Travis CI lint API responded ' . 'with a non expected structure.' ; throw new NonExpectedReponseStructure ( $ message ) ; } if ( count ( $ lintResult [ 'lint' ] [ 'warnings' ] ) === 0 ) { return new Result ; } if ( count ( $ lintResult [ 'lint' ] [ 'warnings' ] ) > 0 ) { $ lintWarningsMessages = PHP_EOL ; foreach ( $ lintResult [ 'lint' ] [ 'warnings' ] as $ warning ) { $ lintWarningsMessages .= ' - ' . $ warning [ 'message' ] . PHP_EOL ; } $ failure = 'Travis CI configuration is invalid. ' . 'Warnings:' . rtrim ( $ lintWarningsMessages ) ; return new Result ( false , $ failure ) ; } }
|
Posts the Travis CI configuration to the Travis CI Api .
|
2,591
|
function contentType ( $ contentType ) { $ this -> requestDecorator -> addHeader ( 'X-Contentful-Content-Type' , $ contentType ) ; $ this -> requestDecorator -> addParameter ( 'content_type' , '=' , $ contentType ) ; return $ this ; }
|
Target content type .
|
2,592
|
public function handlers ( ) { if ( $ this -> _handlers === null ) { $ this -> _handlers = Yii :: $ app -> cache -> lazy ( function ( ) { $ models = PropertyHandlers :: find ( ) -> orderBy ( [ 'sort_order' => SORT_ASC ] ) -> all ( ) ; $ handlers = [ ] ; foreach ( $ models as $ model ) { $ className = $ model -> class_name ; $ handlers [ $ model -> id ] = new $ className ( $ model -> default_config ) ; } return $ handlers ; } , 'AllPropertyHandlers' , 86400 , PropertyHandlers :: commonTag ( ) ) ; } return $ this -> _handlers ; }
|
Retrieves handlers from database . Uses lazy cache .
|
2,593
|
public function handlerById ( $ id ) { if ( isset ( $ this -> _handlers [ $ id ] ) ) { return $ this -> _handlers [ $ id ] ; } throw new \ Exception ( "Property handler with id {$id} not found" ) ; }
|
Returns handler by ID
|
2,594
|
public function handlerIdByClassName ( $ className ) { foreach ( $ this -> handlers ( ) as $ id => $ class ) { if ( $ class -> className ( ) === $ className ) { return $ id ; } } throw new Exception ( "Handler with classname {$className} not found." ) ; }
|
Returns handler id bu it s class name
|
2,595
|
public function drupal_add_library ( $ module = null , $ name = null , $ every_page = null ) { return drupal_add_library ( $ module , $ name , $ every_page ) ; }
|
Adds multiple JavaScript or CSS files at the same time .
|
2,596
|
public function format_date ( $ timestamp , $ type = 'medium' , $ format = '' , $ timezone = null , $ langcode = null ) { return format_date ( $ timestamp , $ type , $ format , $ timezone , $ langcode ) ; }
|
Formats a date using a date type or a custom date format string .
|
2,597
|
public function watchdog ( $ type , $ message , $ variables = array ( ) , $ severity = WATCHDOG_NOTICE , $ link = null ) { return watchdog ( $ type , $ message , $ variables , $ severity , $ link ) ; }
|
Logs a system message .
|
2,598
|
protected function convertToLookup ( $ string ) { $ array = explode ( '|' , str_replace ( ' ' , '' , $ string ) ) ; $ ret = array ( ) ; foreach ( $ array as $ i => $ k ) { $ ret [ $ k ] = true ; } return $ ret ; }
|
Converts a string list of elements separated by pipes into a lookup array .
|
2,599
|
public function consumeString ( $ delimiter , $ type ) { $ close = Utils :: balanceDelimiter ( $ delimiter ) ; $ balanced = $ close !== $ delimiter ; $ patterns = array ( '/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote ( $ close , '/' ) . ')/' ) ; if ( $ balanced ) { $ patterns [ ] = '/(?<!\\\\)((?:\\\\\\\\)*)(' . preg_quote ( $ delimiter , '/' ) . ')/' ; } $ stack = 1 ; $ start = $ this -> pos ( ) ; $ closeDelimiterMatch = null ; while ( $ stack ) { $ next = $ this -> getNext ( $ patterns ) ; if ( $ next [ 0 ] === - 1 ) { $ this -> terminate ( ) ; $ finish = $ this -> pos ( ) ; break ; } elseif ( $ balanced && $ next [ 1 ] [ 2 ] === $ delimiter ) { $ stack ++ ; $ finish = $ next [ 0 ] + strlen ( $ next [ 1 ] [ 0 ] ) ; } elseif ( $ next [ 1 ] [ 2 ] === $ close ) { $ stack -- ; if ( ! $ stack ) { $ closeDelimiterMatch = $ next [ 1 ] [ 2 ] ; } $ finish = $ next [ 0 ] + strlen ( $ next [ 1 ] [ 1 ] ) ; } else { assert ( 0 ) ; } $ this -> pos ( $ next [ 0 ] + strlen ( $ next [ 1 ] [ 0 ] ) ) ; } $ substr = substr ( $ this -> string ( ) , $ start , $ finish - $ start ) ; if ( $ type === 'SPLIT_STRING' ) { foreach ( preg_split ( '/(\s+)/' , $ substr , - 1 , PREG_SPLIT_DELIM_CAPTURE ) as $ token ) { if ( preg_match ( '/^\s/' , $ token ) ) { $ this -> record ( $ token , null ) ; } else { $ this -> record ( $ token , 'STRING' ) ; } } } else { $ this -> record ( $ substr , $ type ) ; } if ( $ closeDelimiterMatch !== null ) { $ this -> record ( $ closeDelimiterMatch , 'DELIMITER' ) ; } }
|
expects the initial opening delim to already have been consumed
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.