idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
58,900
public function execute ( Query $ query , MapInterface $ variables ) : SetInterface { return ( $ this -> makeEntity ) ( $ this -> connection -> execute ( $ query ) , $ variables ) ; }
Execute the given query
58,901
private function extractIdentity ( object $ entity ) : Identity { $ identity = ( $ this -> metadata ) ( get_class ( $ entity ) ) -> identity ( ) -> property ( ) ; return ReflectionObject :: of ( $ entity ) -> extract ( $ identity ) -> get ( $ identity ) ; }
Extract the identity object from the given entity
58,902
public function validate ( Model $ obj ) { $ fieldset = static :: set_fields ( $ obj ) ; $ val = $ fieldset -> validation ( ) ; $ is_new = $ obj -> is_new ( ) ; $ allow_partial = $ is_new ? false : array ( ) ; $ input = array ( ) ; foreach ( array_keys ( $ obj -> properties ( ) ) as $ p ) { if ( ! in_array ( $ p , $ obj -> primary_key ( ) ) and ( $ is_new or $ obj -> is_changed ( $ p ) ) ) { $ input [ $ p ] = $ obj -> { $ p } ; is_array ( $ allow_partial ) and $ allow_partial [ ] = $ p ; } } if ( ! empty ( $ input ) and $ val -> run ( $ input , $ allow_partial , array ( $ obj ) ) === false ) { throw new ValidationFailed ( $ val -> show_errors ( ) , 0 , null , $ fieldset ) ; } else { foreach ( $ input as $ k => $ v ) { $ obj -> { $ k } = $ val -> validated ( $ k ) ; } } }
Validate the model
58,903
public function makeHelpMessage ( string $ className , string $ domain , bool $ global = false ) : void { $ domainSynop = $ this -> lHelper -> getDomainSynopsis ( $ className ) ; $ this -> helpMessageHeader ( $ domain , $ domainSynop ) ; if ( ! $ global ) { $ methodsList = $ this -> lHelper -> getClassPublicMethods ( $ className , $ domain ) ; $ actions = $ this -> lHelper -> getEnabledActionsAnnotations ( $ methodsList ) ; $ this -> helpMessageBody ( $ domain , $ actions ) ; return ; } $ this -> helpMessageGlobalBody ( $ this -> lHelper -> getSynopsisFromDomains ( ) ) ; }
Generates different messages according to the global param
58,904
private function validateKey ( ) { $ app = \ Slim \ Slim :: getInstance ( ) ; $ key = $ app -> request -> params ( 'auth' ) ; if ( ! $ key ) { $ app -> redirect ( '/notkey' ) ; } else { if ( $ key != $ this -> _key ) { $ app -> redirect ( '/invalidkey' ) ; } } }
Validate Sent Key
58,905
public function compile ( ) { if ( $ this -> table === false || $ this -> type === false ) { throw ( new \ Exception ( 'Query compilation failure: missing table or type' ) ) ; } switch ( $ this -> type ) { case 'UPDATE' : return $ this -> generateUPDATEStatement ( ) ; case 'INSERT' : return $ this -> generateINSERTStatement ( ) ; case 'DELETE' : return $ this -> generateDELETEStatement ( ) ; default : return $ this -> generateSELECTStatement ( ) ; } }
WHERE THE MAGIC HAPPENS
58,906
private function newUpdateEntry ( $ column , $ param ) { if ( ! empty ( $ this -> columnwhitelist ) ) { if ( ! in_array ( $ column , $ this -> columnwhitelist ) ) { throw ( new \ Exception ( 'Column in update list not found in white list' ) ) ; } } $ newupdate = new \ stdClass ( ) ; $ newupdate -> column = $ column ; $ newupdate -> param = $ this -> newBindEntry ( $ param , ':up' ) ; $ this -> updates [ ] = $ newupdate ; }
PARSING AND VALIDATION FUNCTIONS
58,907
private static function validateTimestamp ( $ timestamp ) { $ check = ( is_int ( $ timestamp ) || is_float ( $ timestamp ) ) ? $ timestamp : ( string ) ( int ) $ timestamp ; return ( $ check === $ timestamp ) AND ( ( int ) $ timestamp <= PHP_INT_MAX ) AND ( ( int ) $ timestamp >= ~ PHP_INT_MAX ) ; }
Checks if a string is a valid timestamp .
58,908
public function resolve ( $ tsdns ) { $ this -> getTransport ( ) -> sendLine ( $ tsdns ) ; $ repl = $ this -> getTransport ( ) -> readLine ( ) ; $ this -> getTransport ( ) -> disconnect ( ) ; if ( $ repl -> section ( ":" , 0 ) -> toInt ( ) == 404 ) { throw new TeamSpeak3_Adapter_TSDNS_Exception ( "unable to resolve TSDNS hostname (" . $ tsdns . ")" ) ; } TeamSpeak3_Helper_Signal :: getInstance ( ) -> emit ( "tsdnsResolved" , $ tsdns , $ repl ) ; return $ repl ; }
Queries the TSDNS server for a specified virtual hostname and returns the result .
58,909
public function get ( string $ path , MiddlewareInterface $ middleware , string $ name ) : Route { return $ this -> add ( $ path , $ middleware , $ name , 'GET' ) ; }
Add a route associate to the get http method .
58,910
public function url ( string $ name , array $ params = [ ] ) : string { if ( ! isset ( $ this -> namedRoutes [ $ name ] ) ) { throw new RouterException ( 'No route matches this name' ) ; } return $ this -> namedRoutes [ $ name ] -> getURl ( $ params ) ; }
Get the named route s URL and matching param s values .
58,911
public static function prepare ( $ view , $ data , $ closure ) { $ mailer = new self ( ) ; $ closure ( $ mailer ) ; $ mailer -> view ( $ view , $ data ) ; $ mailer -> transport ( ) ; }
The send function .
58,912
private function checkView ( ) { exception_if ( ( is_null ( $ this -> mailable -> get ( '_view' ) ) && is_null ( $ this -> mailable -> get ( '_text' ) ) ) , MailViewNotFoundException :: class ) ; }
Get the view to send .
58,913
private function transport ( ) { $ this -> transport = Transport :: newInstance ( $ this -> smtp -> get ( 'host' ) , $ this -> smtp -> get ( 'port' ) , $ this -> smtp -> get ( 'encryption' ) ) -> setUsername ( $ this -> smtp -> get ( 'username' ) ) -> setPassword ( $ this -> smtp -> get ( 'password' ) ) ; return $ this -> transport ; }
Set the SMTP transport .
58,914
private function subject ( ) { $ subject = is_null ( $ this -> mailable -> get ( '_subject' ) ) ? config ( 'mail.subject' ) : $ this -> mailable -> get ( '_subject' ) ; $ this -> message -> setSubject ( $ subject ) ; }
Set the mail subject .
58,915
public static function to ( ) { $ args = func_get_args ( ) ; $ receivers = [ ] ; foreach ( $ args as $ arg ) { if ( is_string ( $ arg ) ) { $ receivers [ ] = $ arg ; } elseif ( is_array ( $ arg ) ) { foreach ( $ arg as $ value ) { $ receivers [ ] = $ value ; } } } $ mail = new self ( ) ; $ mail -> setDestination ( $ receivers ) ; return $ mail ; }
To add reciever adresses .
58,916
protected function setDestination ( array $ mails ) { $ this -> recievers = $ mails ; $ this -> message -> setTo ( $ this -> recievers ) ; return $ this ; }
Set email destination .
58,917
public function send ( Mailable $ mailable ) { $ this -> mailable = $ mailable ; $ this -> mailable -> build ( ) ; $ this -> checkView ( ) ; $ this -> subject ( ) ; $ view = $ this -> mailable -> get ( '_view' ) ; $ this -> message -> setBody ( $ view -> get ( ) , $ this -> mailable -> get ( '_type' ) ) ; $ this -> message -> setFrom ( [ $ this -> smtp -> get ( 'sender_email' ) ] , $ this -> smtp -> get ( 'sender_name' ) ) ; $ this -> setAttachments ( ) ; $ this -> setCC ( ) ; $ this -> setCCI ( ) ; return $ this -> mailer -> send ( $ this -> message ) ; }
Set the mailable class to send .
58,918
private function setAttachments ( ) { $ attachments = $ this -> mailable -> get ( '_attachments' ) ; if ( ! is_null ( $ attachments ) ) { foreach ( $ attachments as $ attachment ) { if ( in_array ( 'name' ) ) { $ this -> message -> attach ( Attachment :: fromPath ( $ attachment [ 'file' ] ) -> setFilename ( $ attachment [ 'name' ] ) ) ; } else { $ this -> message -> attach ( Attachment :: fromPath ( $ attachment [ 'file' ] ) ) ; } } } }
Set the files on mail surface .
58,919
private function setCC ( ) { $ cc = $ this -> mailable -> get ( '_cc' ) ; if ( ! is_null ( $ cc ) ) { foreach ( $ cc as $ mail ) { $ this -> message -> setCC ( $ mail ) ; } } }
Set the CC mails .
58,920
private function setCCI ( ) { $ cci = $ this -> mailable -> get ( '_cci' ) ; if ( ! is_null ( $ cci ) ) { foreach ( $ cci as $ mail ) { $ this -> message -> setBcc ( $ mail ) ; } } }
Set the CCI mails .
58,921
public function addEntry ( $ filesystem , $ mountPoint , $ type , $ options = 'ro' , $ dump = null , $ pass = null ) { $ line = $ this -> lineFactory -> makeLine ( ) ; $ line -> setFileSystem ( $ filesystem ) -> setMountPoint ( $ mountPoint ) -> setFileSystemType ( $ type ) -> setOptions ( $ options ) -> setDump ( $ dump !== null ? $ dump : 0 ) -> setPass ( $ pass !== null ? $ pass : 0 ) ; try { $ this -> setLine ( $ line ) ; } catch ( UnusableFileException $ e ) { throw new FstabException ( 'Unable to add an entry to the fstab file because it is unusable.' , null , $ e ) ; } return $ this ; }
Queue a new fstab entry or an update to an fstab entry to be later written to an fstab file .
58,922
public function setNetwork ( Transaction \ NetworkType $ network ) { if ( $ this -> isTransacted ( ) || $ this -> parent ) { return ; } $ this -> network = $ network ; }
Sets the network
58,923
public function createChild ( Transaction \ TransactionType $ type , $ amount = null ) { $ child = new Transaction ( $ this ) ; $ child -> setType ( $ type ) ; $ child -> setAmount ( $ amount ? : $ this -> amount ) ; $ this -> children -> add ( $ child ) ; return $ child ; }
Creates a new child transaction
58,924
public function setAccount ( AbstractAccount $ account ) { if ( $ this -> isTransacted ( ) || $ this -> parent ) { return ; } $ this -> account = $ account ; }
Sets the associated account
58,925
public function setCredentials ( Credentials $ credentials ) { if ( $ this -> isTransacted ( ) || $ this -> parent ) { return ; } $ this -> credentials = $ credentials ; }
Sets the associated credentials
58,926
public function isRefunded ( ) { if ( $ this -> parent ) { return $ this -> parent -> isRefunded ( ) ; } return $ this -> children -> exists ( function ( $ key , Transaction $ child ) { return $ child -> getType ( ) == Transaction \ TransactionType :: REFUND && $ child -> getStatus ( ) == Result \ ResultStatus :: APPROVED ; } ) ; }
Returns true if the transaction has been refunded
58,927
public function isVoided ( ) { if ( $ this -> parent ) { return $ this -> parent -> isVoided ( ) ; } return $ this -> children -> exists ( function ( $ key , Transaction $ child ) { return $ child -> getType ( ) == Transaction \ TransactionType :: VOID && $ child -> getStatus ( ) == Result \ ResultStatus :: APPROVED ; } ) ; }
Returns true if the transaction has been voided
58,928
private function getImplementations ( ) { foreach ( $ this -> _implementations as $ extension => $ loaded ) { if ( $ loaded ) { continue ; } if ( extension_loaded ( $ extension ) ) { $ this -> _implementations [ $ extension ] = true ; } } }
Finds out what implementations are available
58,929
public function registerPlugin ( $ pluginName , $ implementation ) { if ( ! array_key_exists ( $ pluginName , $ this -> _registry ) && $ this -> isValidImplementation ( $ implementation ) ) { $ this -> _registry [ $ pluginName ] = array ( 'loaded' => false , 'implementation' => $ implementation ) ; return true ; } return false ; }
Registers a plugin in the registry
58,930
public function getPluginRegistry ( $ implementation ) { $ returnArray = array ( ) ; foreach ( $ this -> _registry as $ plugin => $ meta ) { if ( $ meta [ 'implementation' ] == 'n/a' || $ meta [ 'implementation' ] == $ implementation ) { $ returnArray [ $ plugin ] = $ meta ; } } return $ returnArray ; }
Returns the plugin registry for the supplied implementation
58,931
public function getSet ( $ key , callable $ value , $ partition = null , $ time = 14400 ) { $ temp = $ this -> get ( $ key , null , $ partition ) ; if ( $ temp !== null ) { return $ temp ; } $ this -> prepare ( $ key , $ partition ) ; try { $ value = call_user_func ( $ value ) ; return $ this -> set ( $ key , $ value , $ partition , $ time ) ; } catch ( CacheException $ e ) { return $ value ; } catch ( \ Exception $ e ) { $ this -> delete ( $ key , $ partition ) ; throw $ e ; } }
Get a cached value if it exists if not - invoke a callback store the result in cache and return it .
58,932
public function onFlush ( \ Doctrine \ ORM \ Event \ OnFlushEventArgs $ eventArgs ) { $ reCacheEntities = [ ] ; $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { $ reCacheEntities [ get_class ( $ entity ) ] = true ; } foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { $ reCacheEntities [ get_class ( $ entity ) ] = true ; } foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { $ reCacheEntities [ get_class ( $ entity ) ] = true ; } foreach ( $ uow -> getScheduledCollectionDeletions ( ) as $ col ) { $ reCacheEntities [ get_class ( $ entity ) ] = true ; } foreach ( $ uow -> getScheduledCollectionUpdates ( ) as $ col ) { $ reCacheEntities [ get_class ( $ entity ) ] = true ; } foreach ( $ reCacheEntities as $ entityNamespace => $ flag ) { $ this -> recache ( $ entityNamespace ) ; } }
Doctrine - Event to clear cache on changes
58,933
public function parseElements ( array $ elements , ElementInterface $ parent = null ) { foreach ( $ elements as & $ element ) { $ element = $ this -> applyStyles ( $ element ) ; } return parent :: parseElements ( $ elements , $ parent ) ; }
Parse view elements
58,934
protected function applyStyles ( $ element ) { if ( ! $ this -> style ) return $ element ; if ( array_key_exists ( 'class' , $ element [ 'attributes' ] ) ) { $ classes = explode ( ' ' , $ element [ 'attributes' ] [ 'class' ] ) ; $ element = $ this -> applyStylesToElement ( $ element , $ this -> style -> getByClasses ( $ classes ) ) ; } if ( array_key_exists ( 'id' , $ element [ 'attributes' ] ) ) { $ element = $ this -> applyStylesToElement ( $ element , $ this -> style -> getById ( $ element [ 'attributes' ] [ 'id' ] ) ) ; } $ element = $ this -> applyStylesToElement ( $ element , $ this -> style -> getByElement ( $ element [ 'name' ] ) ) ; return $ element ; }
Apply the styles to the element
58,935
protected function applyStylesToElement ( $ element , $ styles ) { foreach ( $ styles as $ tag => $ data ) { $ element [ 'attributes' ] [ $ tag ] = $ data ; } return $ element ; }
Apply styles to the attributes tag
58,936
public static function node ( $ id ) { $ id = intval ( $ id ) ; if ( empty ( $ id ) ) return null ; if ( ! static :: $ caching || empty ( static :: $ _nodes [ $ id ] ) ) { $ result = static :: findOne ( $ id ) ; if ( static :: $ caching ) { static :: $ _nodes [ $ id ] = $ result ; } else { return $ result ; } } return static :: $ _nodes [ $ id ] ; }
Quick get content node without i18n
58,937
public static function nodePath ( $ id ) { $ node = static :: node ( $ id ) ; if ( empty ( $ node ) ) return '' ; if ( empty ( $ node -> nodePath ) ) { $ node -> nodePath = static :: nodePath ( $ node -> parent_id ) . '/' . $ node -> slug ; } return $ node -> nodePath ; }
Get node s path collected from slugs
58,938
public static function nodeChildren ( $ parentId ) { $ parentId = intval ( $ parentId ) ; if ( ! static :: $ caching || empty ( static :: $ _children [ $ parentId ] ) ) { $ query = static :: find ( ) -> where ( [ 'parent_id' => $ parentId ] ) -> orderBy ( static :: $ defaultOrderBy ) ; $ childList = $ query -> all ( ) ; if ( static :: $ caching ) { static :: $ _children [ $ parentId ] = $ childList ; } else { return $ childList ; } } return static :: $ _children [ $ parentId ] ; }
Get node children
58,939
public static function getNodePath ( $ node ) { $ result = '' ; if ( $ node instanceof static ) { $ result = $ node -> slug ; if ( ! empty ( $ node -> parent_id ) ) { $ parent = static :: node ( $ node -> parent_id ) ; if ( ! empty ( $ parent ) ) { $ result = static :: getNodePath ( $ parent ) . '/' . $ result ; } } } return $ result ; }
Get path to node in content tree .
58,940
public function importFromUrlsXml ( ) { $ urls = $ this -> _parseUrlsXml ( ) ; foreach ( $ urls as $ url ) { $ this -> addUrl ( $ url ) ; } }
Add URLs automatically from urls . xml
58,941
public function ping ( $ uri ) { $ parsed_url = parse_url ( $ uri ) ; if ( ! $ parsed_url || ! is_array ( $ parsed_url ) ) { return false ; } $ http = new \ GuzzleHttp \ Client ( array ( 'base_uri' => $ parsed_url [ 'host' ] ) ) ; $ res = $ http -> get ( $ parsed_url [ 'path' ] . '?' . $ parsed_url [ 'query' ] ) ; if ( 200 !== $ res -> getStatusCode ( ) ) { return false ; } $ content = $ res -> getBody ( ) ; return true ; }
Submitting a sitemap by sending an HTTP request
58,942
protected function _parseUrlsXml ( ) { $ urls = array ( ) ; $ conf = & jApp :: config ( ) -> urlengine ; $ significantFile = $ conf [ 'significantFile' ] ; $ basePath = $ conf [ 'basePath' ] ; $ epExt = ( $ conf [ 'multiview' ] ? '.php' : '' ) ; $ file = jApp :: tempPath ( 'compiled/urlsig/' . $ significantFile . '.creationinfos_15.php' ) ; if ( file_exists ( $ file ) ) { require $ file ; foreach ( $ GLOBALS [ 'SIGNIFICANT_CREATEURL' ] as $ selector => $ createinfo ) { if ( $ createinfo [ 0 ] != 1 && $ createinfo [ 0 ] != 4 ) { continue ; } if ( $ createinfo [ 0 ] == 4 ) { foreach ( $ createinfo as $ k => $ createinfo2 ) { if ( $ k == 0 ) continue ; if ( $ createinfo2 [ 2 ] == true || count ( $ createinfo2 [ 3 ] ) ) { continue ; } $ urls [ ] = $ basePath . ( $ createinfo2 [ 1 ] ? $ createinfo2 [ 1 ] . $ epExt : '' ) . $ createinfo2 [ 5 ] ; } } else if ( $ createinfo [ 2 ] == true || count ( $ createinfo [ 3 ] ) ) { continue ; } else { $ urls [ ] = $ basePath . ( $ createinfo [ 1 ] ? $ createinfo [ 1 ] . $ epExt : '' ) . $ createinfo [ 5 ] ; } } } return $ urls ; }
Parse urls . xml and return pathinfo URLs
58,943
public function getAttribute ( $ key ) { if ( isset ( $ this -> attributes [ $ key ] ) ) { return $ this -> attributes [ $ key ] ; } else { return NULL ; } }
Devuelve un atributo si existe y si no devuelve NULL
58,944
public function showValidationProblems ( ConstraintViolationList $ problems , GeneratorInterface $ generator ) { if ( ! $ this -> bound ( ) ) { throw new OutputNotAvailableException ( "Tried to show validation errors, however no output channel available" ) ; } $ block = ValidationProblemFormatter :: format ( $ problems , $ generator , $ this -> getHelper ( 'formatter' ) ) ; $ this -> getOutput ( ) -> writeln ( $ block ) ; }
Displays output results of validation problems .
58,945
public function get ( $ handle ) { $ this -> setting = $ this -> items -> where ( 'handle' , $ handle ) -> first ( ) ; return $ this -> setting ; }
Get a setting by its handle .
58,946
public function label ( $ handle = null ) { if ( $ handle ) { return $ this -> get ( $ handle ) -> label ; } return $ this -> setting -> label ; }
Get setting s label .
58,947
public function description ( $ handle = null ) { if ( $ handle ) { return $ this -> get ( $ handle ) -> description ; } return $ this -> setting -> description ; }
Get setting s description .
58,948
public function value ( $ handle = null , $ default = '' ) { if ( $ handle && ! $ this -> get ( $ handle ) ) { return $ default ; } if ( $ handle ) { return $ this -> get ( $ handle ) -> value ? : $ this -> defaultValue ( $ handle ) ; } return $ this -> setting -> value ? : $ this -> setting -> default ; }
Get setting s value .
58,949
public function value ( $ options = [ ] , $ content = '' ) { if ( ! is_array ( $ options ) ) { $ options = [ 'value' => $ options ] ; } $ this -> values [ ] = new Option ( $ this -> form -> expression ( 'option' ) , $ options , $ content ) ; return $ this ; }
add a new option value
58,950
public static function googleRecaptcha ( $ value , $ context ) { $ httpClient = new Client ( ) ; $ googleReponse = $ httpClient -> post ( 'https://www.google.com/recaptcha/api/siteverify' , [ 'secret' => Configure :: read ( 'Google.Recaptcha.secret' ) , 'response' => $ value , 'remoteip' => Router :: getRequest ( ) -> clientIp ( ) ] ) ; $ result = json_decode ( $ googleReponse -> body ( ) , true ) ; if ( ! empty ( $ result [ 'error-codes' ] ) ) { Log :: error ( 'Google Recaptcha: ' . $ result [ 'error-codes' ] [ 0 ] ) ; } return ( bool ) $ result [ 'success' ] ; }
Validate a google recaptcha .
58,951
public static function source_method ( $ class , $ name ) { if ( ! method_exists ( $ class , $ name ) ) { return FALSE ; } $ refl = new ReflectionMethod ( $ class , $ name ) ; $ file = fopen ( $ refl -> getFileName ( ) , 'r' ) ; $ line = 0 ; $ range = array ( 'start' => $ refl -> getStartLine ( ) , 'end' => $ refl -> getEndLine ( ) ) ; $ format = '% ' . strlen ( $ range [ 'end' ] ) . 'd' ; $ source = '' ; while ( ( $ row = fgets ( $ file ) ) !== FALSE ) { if ( ++ $ line > $ range [ 'end' ] ) break ; if ( $ line >= $ range [ 'start' ] ) { $ row = htmlspecialchars ( $ row , ENT_NOQUOTES , Kohana :: $ charset ) ; $ row = '<span class="number">' . sprintf ( $ format , $ line ) . '</span> ' . $ row ; $ row = '<span class="line">' . $ row . '</span>' ; $ source .= $ row ; } } fclose ( $ file ) ; return '<pre class="source"><code>' . $ source . '</code></pre>' ; }
Returns an HTML string highlighting a specific line of a file with some number of lines padded above and below .
58,952
protected function notify ( $ title , $ message , $ icon = null ) { $ icon = is_string ( $ icon ) ? $ icon : $ this -> icon ; $ this -> execute ( "notify-send -t 2000 -i {$icon} '{$title}' '$message'" ) ; }
Notify with notify - send .
58,953
public function callTagCompiler ( $ tag , $ args , $ param1 = null , $ param2 = null , $ param3 = null ) { if ( isset ( self :: $ _tag_objects [ $ tag ] ) ) { return self :: $ _tag_objects [ $ tag ] -> compile ( $ args , $ this , $ param1 , $ param2 , $ param3 ) ; } $ class_name = 'Smarty_Internal_Compile_' . $ tag ; if ( $ this -> smarty -> loadPlugin ( $ class_name ) ) { if ( ! isset ( $ this -> smarty -> security_policy ) || $ this -> smarty -> security_policy -> isTrustedTag ( $ tag , $ this ) ) { self :: $ _tag_objects [ $ tag ] = new $ class_name ; return self :: $ _tag_objects [ $ tag ] -> compile ( $ args , $ this , $ param1 , $ param2 , $ param3 ) ; } } return false ; }
lazy loads internal compile plugin for tag and calls the compile methode
58,954
public function trigger_template_error ( $ args = null , $ line = null ) { if ( ! isset ( $ line ) ) { $ line = $ this -> lex -> line ; } $ match = preg_split ( "/\n/" , $ this -> lex -> data ) ; $ error_text = 'Syntax Error in template "' . $ this -> template -> source -> filepath . '" on line ' . $ line . ' "' . htmlspecialchars ( trim ( preg_replace ( '![\t\r\n]+!' , ' ' , $ match [ $ line - 1 ] ) ) ) . '" ' ; if ( isset ( $ args ) ) { $ error_text .= $ args ; } else { $ error_text .= ' - Unexpected "' . $ this -> lex -> value . '"' ; if ( count ( $ this -> parser -> yy_get_expected_tokens ( $ this -> parser -> yymajor ) ) <= 4 ) { foreach ( $ this -> parser -> yy_get_expected_tokens ( $ this -> parser -> yymajor ) as $ token ) { $ exp_token = $ this -> parser -> yyTokenName [ $ token ] ; if ( isset ( $ this -> lex -> smarty_token_names [ $ exp_token ] ) ) { $ expect [ ] = '"' . $ this -> lex -> smarty_token_names [ $ exp_token ] . '"' ; } else { $ expect [ ] = $ this -> parser -> yyTokenName [ $ token ] ; } } $ error_text .= ', expected one of: ' . implode ( ' , ' , $ expect ) ; } } throw new SmartyCompilerException ( $ error_text ) ; }
display compiler error messages without dying
58,955
protected function setUp ( $ baseFileDir = null ) { $ locator = new FileLocator ( $ baseFileDir ) ; $ resolver = new LoaderResolver ( array ( new PhpArrayFileLoader ( $ locator ) , new JsonFileLoader ( $ locator ) , new YamlFileLoader ( $ locator ) ) ) ; $ this -> fileLoader = new DelegatingLoader ( $ resolver ) ; }
Setup the objects that locate and load our files .
58,956
public function bind ( $ abstract , $ concrete = null , $ shared = false ) { if ( $ concrete == null ) { $ concrete = $ abstract ; } if ( ! ( $ concrete instanceof Closure ) ) { $ concrete = function ( $ container , $ args = [ ] ) use ( $ abstract , $ concrete ) { $ method = ( $ abstract == $ concrete || is_object ( $ concrete ) ) ? 'build' : 'make' ; return $ container -> $ method ( $ concrete , $ args ) ; } ; } $ this -> bindings [ $ abstract ] = [ 'concrete' => $ concrete , 'shared' => $ shared ] ; }
Bind concrete class to an abstract one
58,957
public function bindIf ( $ abstract , $ concrete , $ shared = false ) { if ( ! isset ( $ this -> bindings [ $ abstract ] ) && ! isset ( $ this -> instances [ $ abstract ] ) ) { $ this -> bind ( $ abstract , $ concrete , $ shared ) ; } }
Register a binding if it was not registered already
58,958
public function make ( $ abstract , $ args = [ ] ) { $ abstract = isset ( $ this -> aliases [ $ abstract ] ) ? $ this -> aliases [ $ abstract ] : $ abstract ; if ( isset ( $ this -> instances [ $ abstract ] ) ) { return $ this -> instances [ $ abstract ] ; } $ concrete = isset ( $ this -> bindings [ $ abstract ] ) ? $ this -> bindings [ $ abstract ] [ 'concrete' ] : $ abstract ; if ( $ abstract == $ concrete || $ concrete instanceof Closure ) { $ object = $ this -> build ( $ concrete , $ args ) ; } else { $ object = $ this -> make ( $ concrete , $ args ) ; } if ( $ this -> isShared ( $ abstract ) ) { $ this -> instances [ $ abstract ] = $ object ; } return $ object ; }
Create object by the abstract name
58,959
public function build ( $ concrete , $ args = [ ] ) { if ( $ concrete instanceof Closure ) { return $ concrete ( $ this , $ args ) ; } $ reflectionClass = new ReflectionClass ( $ concrete ) ; if ( ! $ reflectionClass -> isInstantiable ( ) ) { throw new Exception ( sprintf ( '`s` type is not instantiable !' , $ concrete ) ) ; } $ constructor = $ reflectionClass -> getConstructor ( ) ; if ( $ constructor === null ) { return new $ concrete ( ) ; } $ dependencies = $ this -> getMethodDependencies ( $ constructor , $ args ) ; return $ reflectionClass -> newInstanceArgs ( $ dependencies ) ; }
Build concrete class to object
58,960
public function resolveMethod ( $ class , $ method , array $ args = [ ] ) { if ( ! is_object ( $ class ) ) { throw new Exception ( 'Container::makeMethod except a object as the first parameter!' ) ; } $ reflectionMethod = new ReflectionMethod ( $ class , $ method ) ; $ dependencies = $ this -> getMethodDependencies ( $ reflectionMethod , $ args ) ; return $ reflectionMethod -> invokeArgs ( $ class , $ dependencies ) ; }
Execute method by injecting the dependencies
58,961
public function resolveClosure ( Closure $ closure , array $ args = [ ] ) { $ closureRef = new ReflectionFunction ( $ closure ) ; $ dependencies = $ this -> getMethodDependencies ( $ closureRef , $ args ) ; return $ closureRef -> invokeArgs ( $ dependencies ) ; }
Resolve closure and return its result
58,962
protected function getMethodDependencies ( ReflectionFunctionAbstract $ method , array $ primitives = [ ] ) { $ params = $ method -> getParameters ( ) ; $ resolvedParams = [ ] ; $ i = 0 ; foreach ( $ params as $ param ) { if ( $ class = $ param -> getClass ( ) ) { $ resolvedParams [ ] = $ this -> make ( $ class -> getName ( ) ) ; } else if ( isset ( $ primitives [ $ i ] ) ) { $ resolvedParams [ ] = $ primitives [ $ i ++ ] ; } } return $ resolvedParams ; }
Get dependencies for php method
58,963
public static function parse ( string $ uri ) : URI { if ( $ uri == '' ) { return new static ( ) ; } $ parts = parse_url ( $ uri ) ; if ( $ parts === false ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot parse malformed uri "%s".' , $ uri ) ) ; } if ( ! isset ( $ parts [ 'scheme' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Missing scheme in uri "%s".' , $ uri ) ) ; } if ( count ( $ parts ) == 1 && isset ( $ parts [ 'scheme' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Missing hierarchical segment in uri "%s".' , $ uri ) ) ; } $ defaults = [ 'scheme' => '' , 'host' => '' , 'user' => '' , 'pass' => '' , 'port' => null , 'path' => '' , 'query' => '' , 'fragment' => '' , ] ; $ parts = array_merge ( $ defaults , $ parts ) ; return new static ( $ parts [ 'scheme' ] , $ parts [ 'host' ] , $ parts [ 'path' ] , $ parts [ 'query' ] , $ parts [ 'fragment' ] , $ parts [ 'user' ] , $ parts [ 'pass' ] , $ parts [ 'port' ] ) ; }
Parses the given URI string and returns a new URI instance .
58,964
public function getAuthority ( ) : string { if ( $ this -> host == '' ) { return '' ; } $ authority = $ this -> host ; if ( $ this -> user != '' ) { $ authority = $ this -> user . '@' . $ authority ; } if ( $ this -> port !== null && ! $ this -> isDefaultPort ( $ this -> scheme , $ this -> port ) ) { $ authority .= ':' . $ this -> port ; } return $ authority ; }
Returns the authority component of the URI .
58,965
public function getPort ( ) { return $ this -> port === null || $ this -> isDefaultPort ( $ this -> scheme , $ this -> port ) ? null : $ this -> port ; }
Returns the port component of the URI .
58,966
public function withScheme ( string $ scheme ) : URI { $ result = clone $ this ; $ result -> scheme = $ this -> filterScheme ( $ scheme ) ; return $ result ; }
Returns a new instance with the specified scheme .
58,967
public function withUserInfo ( string $ username , $ password = null ) : URI { $ result = clone $ this ; $ result -> user = $ username . ( ( string ) $ password != '' ? ':' . ( string ) $ password : '' ) ; return $ result ; }
Returns a new instance with the specified username and password .
58,968
public function withHost ( string $ host ) : URI { $ result = clone $ this ; $ result -> host = $ this -> filterHost ( $ host ) ; return $ result ; }
Returns a new instance with the specified host .
58,969
public function withPort ( $ port ) : URI { $ result = clone $ this ; $ result -> port = $ this -> filterPort ( $ port ) ; return $ result ; }
Returns a new instance with the specified port .
58,970
public function withPath ( string $ path ) : URI { $ result = clone $ this ; $ result -> path = $ this -> filterPath ( $ path ) ; return $ result ; }
Returns a new instance with the specified path .
58,971
public function withQuery ( string $ query ) : URI { $ result = clone $ this ; $ result -> query = $ this -> filterQuery ( $ query ) ; return $ result ; }
Returns a new instance with the specified query .
58,972
public function withFragment ( string $ fragment ) : URI { $ result = clone $ this ; $ result -> fragment = $ this -> filterFragment ( $ fragment ) ; return $ result ; }
Returns a new instance with the specified fragment .
58,973
private function isDefaultPort ( string $ scheme , int $ port ) : bool { return isset ( self :: $ knownPorts [ $ scheme ] ) && self :: $ knownPorts [ $ scheme ] == $ port ; }
Checks if the port is the default port for the scheme .
58,974
private function filterHost ( string $ host ) : string { return preg_replace_callback ( '/(?:[^' . self :: UNRESERVED . self :: SUB_DELIMS . ':%\[\]]+|%(?![A-Fa-f0-9]{2}))/' , function ( array $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ host ) ; }
Filters the host to ensure it is properly encoded .
58,975
private function filterPort ( $ port ) { if ( $ port === null ) { return $ port ; } if ( ! preg_match ( '#^[0-9]+$#' , ( string ) $ port ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid port "%s".' , $ port ) ) ; } return ( int ) $ port ; }
Filters the port to ensure it is a valid port .
58,976
private function filterPath ( string $ path ) : string { if ( $ path == '' ) { return $ path ; } $ result = preg_replace_callback ( '/(?:[^' . self :: UNRESERVED . self :: SUB_DELIMS . ':@%~\/]+|%(?![A-Za-f0-9]{2}))/' , function ( array $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ path ) ; if ( $ result [ 0 ] != '/' ) { return $ result ; } return '/' . ltrim ( $ result , '/' ) ; }
Filters the path to ensure it is properly encoded .
58,977
private function filterQuery ( string $ query ) : string { if ( trim ( $ query ) == '' ) { return '' ; } if ( $ query [ 0 ] == '?' ) { $ query = substr ( $ query , 1 ) ; } $ parts = explode ( '&' , $ query ) ; foreach ( $ parts as $ index => $ part ) { $ data = explode ( '=' , $ part ) ; $ key = array_shift ( $ data ) ; if ( count ( $ data ) == 0 ) { $ parts [ $ index ] = $ this -> encodeQuery ( $ key ) ; continue ; } $ value = implode ( '=' , $ data ) ; $ parts [ $ index ] = $ this -> encodeQuery ( $ key ) . '=' . $ this -> encodeQuery ( $ value ) ; } return implode ( '&' , $ parts ) ; }
Filters the query to ensure it is properly encoded .
58,978
private function filterFragment ( string $ fragment ) : string { if ( trim ( $ fragment ) == '' ) { return '' ; } if ( $ fragment [ 0 ] == '#' ) { $ fragment = substr ( $ fragment , 1 ) ; } return preg_replace_callback ( '/(?:[^' . self :: UNRESERVED . self :: SUB_DELIMS . ':@%~\/\[\]\?]+|%(?![A-Fa-f0-9]{2}))/' , function ( array $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ fragment ) ; }
Filters the fragment value to ensure it is properly encoded .
58,979
private function encodeQuery ( string $ value ) : string { return preg_replace_callback ( '/(?:[^' . self :: UNRESERVED . self :: SUB_DELIMS . ':@%~\/\[\]\?]+|%(?![A-Fa-f0-9]{2}))/' , function ( array $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ value ) ; }
Percent - encodes all necessary characters of the given query .
58,980
public function report ( $ parameters = [ ] ) { $ query = [ 'username' => $ this -> config -> get ( 'username' ) , 'password' => $ this -> config -> get ( 'password' ) , ] ; if ( isset ( $ parameters [ 'id' ] ) ) { $ query [ 'msg_id' ] = $ parameters [ 'id' ] ; } if ( isset ( $ parameters [ 'from' ] ) ) { $ query [ 'from' ] = $ parameters [ 'from' ] ; } if ( isset ( $ parameters [ 'to' ] ) ) { $ query [ 'to' ] = $ parameters [ 'to' ] ; } $ result = $ this -> client -> request ( 'GET' , 'dlr.php' , [ 'query' => $ query , 'verify' => false ] ) ; if ( $ result -> getStatusCode ( ) != 200 ) { throw new \ Exception ( 'Response code: ' . $ result -> getStatusCode ( ) ) ; } $ resultContent = $ result -> getBody ( ) -> getContents ( ) ; $ xml = simplexml_load_string ( $ resultContent ) ; $ result = [ ] ; foreach ( $ xml -> message as $ message ) { $ result [ ] = [ 'id' => isset ( $ message [ 'id' ] ) ? ( int ) $ message [ 'id' ] : '' , 'sent' => isset ( $ message [ 'sentdate' ] ) ? ( string ) $ message [ 'sentdate' ] : '' , 'done' => isset ( $ message [ 'donedate' ] ) ? ( string ) $ message [ 'donedate' ] : '' , 'status' => isset ( $ message [ 'status' ] ) ? ( string ) $ message [ 'status' ] : '' , ] ; } return $ result ; }
Get one or more SMS status
58,981
protected function isPathMatching ( SimpleXmlElement $ node , $ name ) { $ pathPattern = $ this -> getPathRegex ( ) ; $ childPath = $ node -> getPath ( ) . '/' . $ name ; if ( ! $ pathPattern ) { return false ; } return ( bool ) preg_match ( $ pathPattern , $ childPath ) ; }
Check if path is matching for the requested element
58,982
public function setPathRegex ( $ regex ) { if ( $ regex === null ) { $ this -> pathRegex = null ; return $ this ; } $ this -> pathRegex = $ regex ; return $ this ; }
Set path expression
58,983
public function getWidgetForPath ( $ path ) { $ this -> log -> info ( 'Getting widget for path: ' . $ path ) ; $ widget = null ; if ( ! isset ( $ this -> paths [ $ path ] ) ) { $ largest = 0 ; foreach ( $ this -> paths as $ pathReg => $ widgetItem ) { if ( ( $ match = strstr ( $ path , $ pathReg ) ) !== false && strpos ( $ path , $ pathReg ) == 0 ) { if ( strlen ( $ pathReg ) > $ largest ) { $ largest = strlen ( $ pathReg ) ; $ widget = $ widgetItem ; } } } } else { $ widget = $ this -> paths [ $ path ] ; } return $ widget ; }
Determines the Widget that should be used for the specified Http - Request by the Pathname that is called .
58,984
public function edit ( Request $ request ) { return view ( 'gzero-core::account.edit' , [ 'isUserEmailSet' => strpos ( $ request -> user ( ) -> email , '@' ) , 'timezones' => $ this -> timezones -> getAvailableTimezones ( ) ] ) ; }
Edit account settings
58,985
public function welcome ( Request $ request ) { if ( session ( ) -> has ( 'showWelcomePage' ) ) { session ( ) -> forget ( 'showWelcomePage' ) ; return view ( 'gzero-core::account.welcome' , [ 'method' => $ request -> get ( 'method' ) ] ) ; } return redirect ( ) -> to ( routeMl ( 'home' ) ) ; }
Show welcome page for registered user .
58,986
public function regenerateAction ( Request $ request ) { $ userSession = $ this -> get ( 'qcm_core.controller.user_session' ) -> findOr404 ( $ request ) ; $ generator = $ this -> get ( 'qcm_core.question.generator' ) ; $ userSession -> getConfiguration ( ) -> eraseQuestions ( ) ; $ generator -> generate ( $ userSession ) ; $ configuration = clone $ userSession -> getConfiguration ( ) ; $ userSession -> setConfiguration ( $ configuration ) ; $ manager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ manager -> persist ( $ userSession ) ; $ manager -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'qcm_admin_user_session_show' , array ( 'id' => $ userSession -> getId ( ) ) ) ) ; }
Regenerate questionnaire action
58,987
protected function encodeField ( $ label , $ value , array $ context ) { $ convertedLabel = $ this -> convertEncoding ( $ label , $ context ) ; $ strict = $ context [ 'strict' ] ; if ( $ strict ) { $ this -> assertLabel ( $ convertedLabel ) ; } if ( $ value === null ) { $ value = '' ; } if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { $ value = "$value" ; } if ( is_scalar ( $ value ) ) { $ convertedValue = $ this -> convertEncoding ( $ value , $ context ) ; if ( $ strict ) { $ this -> assertValue ( $ convertedValue ) ; } return sprintf ( '%s%s%s' , $ convertedLabel , static :: DELIMITER , $ convertedValue ) ; } throw new \ RuntimeException ( sprintf ( 'Could not serialize LTSV value of label:%s.' , $ label ) ) ; }
Serialize LTSV field .
58,988
protected function resolveEngine ( $ template ) { $ reference = $ this -> resolver -> resolve ( $ template ) ; $ engine = $ reference -> get ( 'engine' ) ; $ engineService = 'templating.engine.' . $ engine ; if ( ! $ this -> container -> has ( $ engineService ) ) { throw new \ RuntimeException ( sprintf ( 'Template engine "%s" does not exist or is not registered as a service.' , $ engineService ) ) ; } $ engine = $ this -> container -> get ( $ engineService ) ; if ( ! $ engine instanceof EngineInterface ) { throw new \ RuntimeException ( sprintf ( 'Service "%s" is not a valid template engine.' , $ name ) ) ; } return $ engine ; }
Resolve template engine from name .
58,989
protected function getUser ( $ userId ) { $ user = $ this -> users -> read ( $ userId ) ; if ( isset ( $ user ) ) { $ user [ 'roles' ] = $ this -> getRoles ( $ userId ) ; } return $ user ; }
Return user array with roles
58,990
protected function getRoles ( $ userId ) { $ roles = [ ] ; $ result = $ this -> userRoles -> query ( new RqlQuery ( new EqNode ( $ this -> config [ 'userIdInUserRoles' ] , $ userId ) ) ) ; foreach ( $ result as $ item ) { $ role = $ this -> roles -> read ( $ item [ $ this -> config [ 'roleIdInUserRoles' ] ] ) ; if ( isset ( $ role [ $ this -> config [ 'roleName' ] ] ) ) { $ roles [ ] = $ role [ $ this -> config [ 'roleName' ] ] ; } } return $ roles ; }
Return array with user s roles
58,991
private function createArrayLines ( array $ data , $ prefix = '' ) { $ content = '' ; foreach ( $ data as $ key => $ value ) { $ newKey = "{$prefix}[$key]" ; if ( is_array ( $ value ) ) { $ content .= $ this -> createArrayLines ( $ value , $ newKey ) ; continue ; } $ content .= $ this -> createPropertyLine ( $ newKey , $ value ) ; } return $ content ; }
Create flat data array
58,992
public function write ( $ file ) { $ content = '' ; if ( $ this -> section ) { $ content .= "[{$this->section}]\n" ; } foreach ( $ this -> data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ content .= $ this -> createArrayLines ( $ value , $ key ) ; continue ; } $ content .= $ this -> createPropertyLine ( $ key , $ value ) ; } if ( file_put_contents ( $ file , $ content ) === false ) { throw new RuntimeException ( 'Failed to write config file: ' . $ file ) ; } return $ this ; }
Write config file
58,993
public function argumentModeRequired ( $ name , $ description , $ defaultValue = null ) { $ mode = InputArgument :: REQUIRED ; return [ $ name , $ mode , $ description , $ defaultValue ] ; }
Build required argument rule
58,994
public function argumentModeOptional ( $ name , $ description , $ defaultValue = null ) { $ mode = InputArgument :: OPTIONAL ; return [ $ name , $ mode , $ description , $ defaultValue ] ; }
Build optional argument rule
58,995
public function optionModeRequired ( $ name , $ description , $ defaultValue = null ) { $ shortcut = null ; $ mode = InputOption :: VALUE_REQUIRED ; return [ $ name , $ shortcut , $ mode , $ description , $ defaultValue ] ; }
Build required option rule
58,996
public function optionModeOptional ( $ name , $ description , $ defaultValue = null ) { $ shortcut = null ; $ mode = InputOption :: VALUE_OPTIONAL ; return [ $ name , $ shortcut , $ mode , $ description , $ defaultValue ] ; }
Build optional option rule
58,997
public function setRedirect ( FormEvent $ event ) { $ targetPath = $ this -> getTargetPath ( $ event -> getRequest ( ) ) ; if ( $ targetPath ) { $ event -> setResponse ( new RedirectResponse ( $ targetPath ) ) ; return ; } $ this -> setRedirecToLogin ( $ event ) ; }
Redirect the user to the target path or default to the login .
58,998
protected function setRedirecToLogin ( Event $ event ) { $ url = $ this -> router -> generate ( 'fos_user_security_login' ) ; $ event -> setResponse ( new RedirectResponse ( $ url ) ) ; }
Sets the response to a redirect to the login page .
58,999
protected function getTargetPath ( Request $ request ) { $ targetPath = $ request -> request -> get ( 'target_path' ) ; if ( ! $ targetPath ) { $ targetPath = $ request -> query -> get ( 'target_path' ) ; } return $ targetPath ; }
Find the target path in the POST or GET .