idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
233,700
public function stopQuery ( ) { $ this -> queries [ $ this -> counter ] [ 'time' ] = ( time ( ) + microtime ( true ) - $ this -> timer ) ; $ this -> counter ++ ; $ this -> timer = 0 ; }
Stops timer and logs query information
233,701
public function startConnection ( $ queryString ) { $ this -> connections [ $ this -> counterConnections ] = array ( 'query' => $ queryString ) ; $ this -> timer = time ( ) + microtime ( true ) ; }
Start timer for connection
233,702
public function stopConnection ( ) { $ this -> connections [ $ this -> counterConnections ] [ 'time' ] = ( time ( ) + microtime ( true ) - $ this -> timer ) ; $ this -> counterConnections ++ ; $ this -> timer = 0 ; }
Stops timer and logs connection information
233,703
public function reset ( ) { $ this -> timer = 0 ; $ this -> counter = 0 ; $ this -> counterConnections = 0 ; $ this -> queries = array ( ) ; $ this -> connections = array ( ) ; }
Clear all logged data
233,704
public function with ( array $ data ) : SmartyView { foreach ( $ data as $ k => $ v ) { $ this -> smarty -> assign ( $ k , $ v ) ; } return $ this ; }
Assigns data to Smarty
233,705
public function login ( $ username , $ password , $ data ) { if ( ! password_verify ( $ password , $ this -> getStoredPassword ( $ username ) ) ) { throw new \ Exception ( 'Incorrect username or password' , 401 ) ; } return $ this -> app -> tokens -> create ( $ data ) ; }
Attempts to start a session
233,706
public function getField ( $ field , $ token = null ) { $ session = $ this -> app -> tokens -> get ( $ token ) ; return ( $ session && isset ( $ session [ $ field ] ) ) ? $ session [ $ field ] : null ; }
Gets a session field
233,707
public function update ( $ token = null , $ data = [ ] ) { return $ this -> app -> tokens -> update ( $ token , $ data ) ; }
Updates a session
233,708
private function getStoredPassword ( $ username ) { $ db = $ this -> app -> db -> reset ( ) -> table ( $ this -> table ) ; $ user = $ db -> select ( $ this -> passwordColumn ) -> limit ( 1 ) -> where ( $ this -> usernameColumn , $ username ) -> getOne ( ) ; if ( ! is_array ( $ user ) || ! isset ( $ user [ $ this -> pas...
Gets an stored password for a user
233,709
public function withJsonBody ( $ data , SerializationContext $ context = null ) { if ( is_string ( $ data ) ) { $ json = $ data ; } else { $ json = SerializerBuilder :: create ( ) -> build ( ) -> serialize ( $ data , 'json' , $ context ) ; } $ this -> withBody ( $ json ) ; return $ this ; }
Create json with given data using serialization
233,710
public function withXMLBody ( $ data , SerializationContext $ context = null ) { if ( is_string ( $ data ) ) { $ xml = $ data ; } else { $ xml = SerializerBuilder :: create ( ) -> build ( ) -> serialize ( $ data , 'xml' , $ context ) ; } $ this -> addHeader ( 'Content-Type' , 'text/xml; charset=utf-8' ) ; $ this -> wit...
Create xml with given data using serialization
233,711
public function onConsoleCommand ( ConsoleCommandEvent $ event ) { if ( ! $ this -> processRepository -> createSchemaIfNotExists ( ) ) { throw new Exception ( 'Cannot create schema for ConsoleProcessManagerBundle' ) ; } $ argv = $ _SERVER [ 'argv' ] ; unset ( $ argv [ 0 ] ) ; $ command = implode ( ' ' , $ argv ) ; if (...
Run on console command start
233,712
public function onConsoleException ( ConsoleExceptionEvent $ event ) { $ call = $ this -> callRepository -> find ( $ _REQUEST [ 'call_id' ] ) ; $ call -> setStatus ( Call :: STATUS_FAILED ) -> setOutput ( $ event -> getException ( ) ) ; $ this -> callRepository -> update ( $ call ) ; $ this -> registerError ( $ call ) ...
Run on console command exception
233,713
public function onConsoleTerminate ( ConsoleTerminateEvent $ event ) { $ call = $ this -> callRepository -> find ( $ _REQUEST [ 'call_id' ] ) ; if ( ! $ call -> getStatus ( ) ) { $ call -> setStatus ( Call :: STATUS_SUCCESS ) ; } if ( $ event -> getExitCode ( ) ) { $ call -> setStatus ( Call :: STATUS_ABORTED ) ; $ cal...
Run on console command ends
233,714
public function getEventBus ( ) { if ( $ this -> eventBus ) { return $ this -> eventBus ; } if ( isset ( static :: $ staticEventBus ) && static :: $ staticEventBus ) { return static :: $ staticEventBus ; } if ( ! $ this -> eventBus ) { $ this -> eventBus = Bus :: instance ( ) ; } return $ this -> eventBus ; }
Return the single instance of resource bus
233,715
public function get ( string $ key , $ default = null ) { if ( array_key_exists ( $ key , $ this -> input ) ) { return $ this -> input [ $ key ] ; } elseif ( array_key_exists ( $ key , $ this -> cache ) ) { return $ this -> cache [ $ key ] ; } if ( false === strpos ( $ key , '.' ) ) { return $ this -> default ( $ defau...
Returns an item using dot notation
233,716
public function has ( string $ key ) { if ( array_key_exists ( $ key , $ this -> input ) ) { return true ; } try { $ this -> find ( $ this -> input , $ key ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Checks whether the dotted key exists
233,717
protected function find ( array $ array , string $ key ) { $ item = $ array ; foreach ( explode ( '.' , $ key ) as $ segment ) { if ( is_array ( $ item ) && array_key_exists ( $ segment , $ item ) ) { $ item = $ item [ $ segment ] ; } else { throw new \ Exception ( ) ; } } $ this -> cache [ $ key ] = & $ item ; return ...
Find a value with its dotted key in an array
233,718
public function set ( string $ key , $ value ) { $ array = & $ this -> input ; $ keys = explode ( '.' , $ key ) ; while ( count ( $ keys ) > 1 ) { $ k = array_shift ( $ keys ) ; if ( ! isset ( $ array [ $ k ] ) || ! is_array ( $ array [ $ k ] ) ) { $ array [ $ k ] = [ ] ; } $ array = & $ array [ $ k ] ; } $ array [ arr...
Sets a value using dot notation
233,719
public function unset ( string $ key ) { if ( array_key_exists ( $ key , $ this -> input ) ) { unset ( $ this -> input [ $ key ] ) ; unset ( $ this -> cache [ $ key ] ) ; } $ item = & $ this -> input ; foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! isset ( $ item [ $ segment ] ) ) { return ; } if ( ! is_arra...
Unsets a dotted key
233,720
public function import ( $ input ) { if ( false !== ( $ array = $ this -> getImportableArray ( $ input ) ) ) { $ this -> input = array_replace_recursive ( $ this -> input , $ array ) ; $ this -> cache = [ ] ; } }
Import an array ArrayAccess
233,721
public function createAction ( $ actionID ) { if ( $ actionID === '' ) $ actionID = $ this -> defaultAction ; if ( Yii :: app ( ) -> request -> getRequestType ( ) != 'GET' && $ actionID != 'error' ) $ actionID .= Yii :: app ( ) -> request -> getRequestType ( ) ; if ( method_exists ( $ this , 'action' . $ actionID ) && ...
Method overload allows clearer separation of controller actions in relation to REQUEST_TYPE
233,722
public function beforeAction ( $ action ) { try { @ Yii :: app ( ) -> newRelic -> setTransactionName ( $ this -> id , $ action -> id ) ; } catch ( Exception $ e ) { } if ( ! Yii :: app ( ) -> getRequest ( ) -> isSecureConnection && Cii :: getConfig ( 'forceSecureSSL' , false ) ) $ this -> redirect ( 'https://' . Yii ::...
BeforeAction validates that there is a valid response body
233,723
public function actionError ( ) { $ response = array ( ) ; $ this -> message = Yii :: t ( 'Api.Controller' , 'An unexpected error occured.' ) ; if ( $ error = Yii :: app ( ) -> errorHandler -> error ) { $ this -> status = $ error [ 'code' ] ; $ this -> message = $ error [ 'message' ] ; if ( YII_DEBUG ) $ response = $ e...
Default Error Handler . Yii automatically magics the response when renderOutput is called . This just updates the necessary components for us
233,724
public function renderOutput ( $ response = array ( ) , $ status = NULL , $ message = NULL ) { http_response_code ( $ status != NULL ? $ status : $ this -> status ) ; header ( 'Content-Type: application/json' ) ; header ( "Access-Control-Allow-Origin: *" ) ; header ( "Access-Control-Allow-Headers: x-auth-token, x-auth-...
Outputs the data as JSON
233,725
public function returnError ( $ status , $ message = NULL , $ response ) { header ( 'HTTP/1.1 ' . $ status ) ; $ this -> status = $ status ; if ( $ message === NULL ) $ this -> message = Yii :: t ( 'Api.main' , 'Failed to set model attributes.' ) ; else $ this -> message = $ message ; if ( $ response == false ) return ...
Performs an error dump with the given status code
233,726
protected function getRole ( $ role ) { if ( ! isset ( $ this -> user ) ) return false ; if ( isset ( $ this -> user -> role ) ) return $ this -> user -> role -> hasPermission ( $ role ) ; return false ; }
Helper function to get the user s role
233,727
public function getValueByName ( string $ name , $ default = null ) { if ( isset ( $ this -> values [ $ name ] ) ) { return $ this -> parseType ( $ this -> values [ $ name ] ) ; } return $ default ; }
returns a value by its name
233,728
private function parseType ( string $ value ) { if ( ( substr ( $ value , 0 , 1 ) === '"' && substr ( $ value , - 1 ) === '"' ) || ( substr ( $ value , 0 , 1 ) === "'" && substr ( $ value , - 1 ) === "'" ) ) { return substr ( $ value , 1 , strlen ( $ value ) - 2 ) ; } return Parse :: toType ( $ value ) ; }
parses value to correct type
233,729
protected function loadConfigurationRecursive ( ContainerBuilder $ container , array $ configuration ) { foreach ( $ configuration as $ values ) { $ loader = new XmlFileLoader ( $ container , new FileLocator ( $ values [ 'path' ] ) ) ; foreach ( $ values [ 'configFiles' ] as $ configFile ) { $ loader -> load ( $ config...
Loads the them configuration recursively
233,730
private function addPoolsSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'pools' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'method' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> variableNode ( 'templates' ) -> defaultValue ( [ '_form.html' => 'EkynaPaymentBundle:Admin/...
Adds admin pool sections .
233,731
public function getIterator ( IteratorFilter $ filter = null ) { if ( is_null ( $ filter ) ) { $ filter = new IteratorFilter ( ) ; } $ param = [ ] ; $ formatter = new IteratorFilterSqlFormatter ( ) ; $ sql = $ formatter -> getFilter ( $ filter -> getRawFilters ( ) , $ param ) ; $ query = Query :: getInstance ( ) -> tab...
Get the users database information based on a filter .
233,732
public function removeByLoginField ( $ login ) { $ user = $ this -> getByLoginField ( $ login ) ; if ( $ user !== null ) { return $ this -> removeUserById ( $ user -> getUserid ( ) ) ; } return false ; }
Remove the user based on his user login .
233,733
public function removeUserById ( $ userId ) { $ updtableProperties = Updatable :: getInstance ( ) -> table ( $ this -> getUserPropertiesDefinition ( ) -> table ( ) ) -> where ( "{$this->getUserPropertiesDefinition()->getUserid()} = :id" , [ "id" => $ userId ] ) ; $ this -> propertiesRepository -> deleteByQuery ( $ updt...
Remove the user based on his user id .
233,734
public function removeProperty ( $ userId , $ propertyName , $ value = null ) { $ user = $ this -> getById ( $ userId ) ; if ( $ user !== null ) { $ updateable = Updatable :: getInstance ( ) -> table ( $ this -> getUserPropertiesDefinition ( ) -> table ( ) ) -> where ( "{$this->getUserPropertiesDefinition()->getUserid(...
Remove a specific site from user Return True or false
233,735
protected function setPropertiesInUser ( UserModel $ userRow ) { $ query = Query :: getInstance ( ) -> table ( $ this -> getUserPropertiesDefinition ( ) -> table ( ) ) -> where ( "{$this->getUserPropertiesDefinition()->getUserid()} = :id" , [ 'id' => $ userRow -> getUserid ( ) ] ) ; $ userRow -> setProperties ( $ this ...
Return all property s fields from this user
233,736
public function searchServer ( Connection $ connection , string $ searchTerm ) : \ Generator { $ serverMetadata = ( new MetadataFactory ( ) ) -> getServerMetadata ( $ connection ) ; foreach ( $ serverMetadata -> getAllDatabaseMetadata ( ) as $ databaseMetadata ) { $ resultList = $ this -> searchDatabase ( $ connection ...
Performs a search across databases on a server .
233,737
public function searchDatabase ( Connection $ connection , string $ databaseName , string $ searchTerm ) : \ Generator { $ databaseMetadata = ( new MetadataFactory ( ) ) -> getDatabaseMetadata ( $ connection , $ databaseName ) ; foreach ( $ databaseMetadata -> getAllTableMetadata ( ) as $ tableMetadata ) { $ resultList...
Performs a search across tables in a database .
233,738
public function searchTable ( Connection $ connection , string $ databaseName , string $ tableName , string $ searchTerm ) : \ Generator { $ tableMetadata = ( new MetadataFactory ( ) ) -> getTableMetadata ( $ connection , $ databaseName , $ tableName ) ; if ( ! $ tableMetadata -> hasStringTypeColumn ( ) ) { return ; } ...
Performs a search on the provided table .
233,739
public static function slash ( string ... $ sections ) { $ count = count ( $ sections ) ; if ( 1 === $ count ) { return $ sections [ 0 ] ; } elseif ( 0 >= $ count || empty ( $ sections ) ) { return null ; } elseif ( 2 === $ count ) { $ compiled = sprintf ( "%s%s%s" , trim ( $ sections [ 0 ] ) , DIRECTORY_SEPARATOR , tr...
Combine strings with a directory separator .
233,740
public static function resolve ( string $ path , bool $ absolute = false ) { $ path = static :: normalize ( $ path ) ; if ( strpos ( $ path , DIRECTORY_SEPARATOR ) === 0 ) { $ absolute = true ; } $ parts = array_filter ( explode ( DIRECTORY_SEPARATOR , $ path ) , 'strlen' ) ; $ absolutes = array ( ) ; foreach ( $ parts...
Naively resolve paths .
233,741
public static function resolveReal ( string $ path , string $ workingDir = null ) { if ( null === $ workingDir && file_exists ( $ real = Filesystem :: resolve ( $ path ) ) ) { return $ real ; } elseif ( null !== $ workingDir ) { $ fullPath = Filesystem :: slash ( $ workingDir , $ path ) ; $ real = Filesystem :: resolve...
Resolve paths to real locations .
233,742
public static function recursiveRemove ( string $ dir , bool $ complete = true ) { $ di = new \ RecursiveDirectoryIterator ( $ dir , \ FilesystemIterator :: SKIP_DOTS ) ; $ ri = new \ RecursiveIteratorIterator ( $ di , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ ri as $ file ) { $ file -> isDir ( ) ? rmd...
Removes all files and directories in a directory . BE CAREFUL!
233,743
public function getPaginationPath ( $ route , $ page , $ extraParams = array ( ) ) { $ params = array ( $ this -> getActionParameterName ( ) => $ this -> getPageActionParameterName ( ) , $ this -> getDatagridParameterName ( ) => $ this -> getName ( ) , $ this -> getPageParameterName ( ) => $ page , ) ; return $ this ->...
Generate pagination route
233,744
public function getResetPath ( $ route , $ extraParams = array ( ) ) { $ params = array ( $ this -> getActionParameterName ( ) => $ this -> getResetActionParameterName ( ) , $ this -> getDatagridParameterName ( ) => $ this -> getName ( ) , ) ; return $ this -> container -> get ( 'router' ) -> generate ( $ route , array...
Generate reset route for the button view
233,745
public function getSortPath ( $ route , $ column , $ order , $ extraParams = array ( ) ) { $ params = array ( $ this -> getActionParameterName ( ) => $ this -> getSortActionParameterName ( ) , $ this -> getDatagridParameterName ( ) => $ this -> getName ( ) , $ this -> getSortColumnParameterName ( ) => $ column , $ this...
Generate sorting route for a given column to be displayed in view
233,746
public function validate ( $ value ) { return is_scalar ( $ value ) ? Ok :: unit ( ) : Error :: unit ( [ Error :: NON_SCALAR ] ) ; }
Tells if a given value is a valid scalar .
233,747
public function validateObjectFieldValue ( $ value , $ fieldName , $ targetObject , & $ validatorParams , $ validatorKey ) { if ( sizeof ( $ validatorParams ) < ( $ this -> mode == self :: MODE_RANGE ? 2 : 1 ) ) { throw new MisconfiguredValidatorException ( $ validatorKey , $ fieldName , $ targetObject ) ; } if ( ! $ v...
Validate a range object
233,748
protected function applyStrategies ( \ Jb \ Bundle \ TagCloudBundle \ Model \ TagCloud $ tagCloud ) { foreach ( $ this -> strategies as $ strategy ) { $ strategy -> process ( $ tagCloud ) ; } }
Apply all registered strategies
233,749
public function migrateCkeditorBlocks ( ) { $ legacyBlocks = $ this -> getLegacyCkeditorBlocks ( ) ; foreach ( $ legacyBlocks as $ legacyBlock ) { $ legacyBlock -> setType ( 'cms.block.ckeditor' ) ; $ settings = $ legacyBlock -> getSettings ( ) ; if ( isset ( $ settings [ 'contenu' ] ) ) { $ settings [ 'content' ] = $ ...
Function of migration of included blocks .
233,750
protected function exists ( $ url ) { $ shortener = Shortener :: where ( 'hash' , hash ( 'sha512' , $ url ) ) -> first ( ) ; if ( is_null ( $ shortener ) ) { return false ; } return route ( 'shortener.show' , [ 'url' => $ this -> hashids -> encode ( $ shortener -> getKey ( ) ) , ] ) ; }
Returns shorten url if exists or false .
233,751
public function decode ( $ short ) { $ ids = $ this -> hashids -> decode ( $ short ) ; if ( empty ( $ ids ) ) { throw new \ InvalidArgumentException ; } return Shortener :: findOrFail ( reset ( $ ids ) ) -> getAttribute ( 'url' ) ; }
Get the origin url .
233,752
public static function label ( $ status ) { $ statuses = [ SeoChecker :: STATUS_DANGER => 'danger' , SeoChecker :: STATUS_GOOD => 'success' , SeoChecker :: STATUS_WARNING => 'warning' , ] ; return Arr :: get ( $ statuses , $ status , 'default' ) ; }
Get the label class for the given status .
233,753
protected static function check ( $ value , $ min , $ max ) { $ length = strlen ( $ value ) ; if ( $ length < $ min ) return self :: STATUS_WARNING ; if ( $ min <= $ length && $ length <= $ max ) return self :: STATUS_GOOD ; return self :: STATUS_DANGER ; }
Check the value with min & max length .
233,754
public function save ( ) { if ( $ this -> id ) { throw new Exception ( 'Can\'t save this server because it is already stored' ) ; } $ server = $ this -> _post ( 'servers' , $ this -> dirty_values ) ; $ this -> mergeValues ( $ server ) ; }
Saves a server
233,755
public function verify ( $ token = null ) { if ( ! $ token ) { $ data = $ this -> requestVerificationToken ( ) ; $ token = $ data [ 'token' ] ; } return $ this -> _post ( 'servers/' . $ this -> id . '/verify' , [ 'token' => $ token ] ) ; }
Verifies the server with the verification token
233,756
public function allSoftware ( $ scopes = [ ] ) { if ( ! $ this -> id ) { throw new Exception ( "The server has no ID, can\'t get software" ) ; } $ software = new Software ( $ this -> patrol ) ; $ software -> defaults ( [ 'server_id' => $ this -> id ] ) ; return $ software -> all ( $ scopes ) ; }
Gets all installed software from this server
233,757
public function software ( $ id , $ scopes = [ ] ) { if ( ! $ this -> id ) { throw new Exception ( "The server has no ID, can\'t get software" ) ; } $ software = new Software ( $ this -> patrol ) ; $ software -> defaults ( [ 'server_id' => $ this -> id ] ) ; return $ software -> find ( $ id , $ scopes ) ; }
Gets a single installed software from this server
233,758
public function buckets ( ) { if ( ! $ this -> id ) { throw new Exception ( "The server has no ID, can\'t get buckets" ) ; } $ bucket = new Bucket ( $ this -> patrol ) ; $ bucket -> defaults ( [ 'server_id' => $ this -> id ] ) ; return $ bucket -> all ( ) ; }
Gets all software buckets from this server
233,759
public function bucket ( $ key = null ) { if ( ! $ this -> id ) { throw new Exception ( "The server has no ID, can\'t get buckets" ) ; } $ bucket = new Bucket ( $ this -> patrol ) ; $ bucket -> defaults ( [ 'server_id' => $ this -> id ] ) ; if ( is_null ( $ key ) ) { return $ bucket ; } try { return $ bucket -> find ( ...
Gets a single software bucket If no key is set an empty Bucket object will be returned which will act as a repository
233,760
public static function cleanFilename ( $ filename ) { return preg_replace ( '/[^A-Za-z0-9_\-]/' , '_' , htmlentities ( pathinfo ( $ filename , PATHINFO_FILENAME ) ) ) . '.' . preg_replace ( '/[^A-Za-z0-9_\-]/' , '_' , htmlentities ( pathinfo ( $ filename , PATHINFO_EXTENSION ) ) ) ; }
White list scrub of file name .
233,761
public static function encrypt ( $ name , $ location , $ destination , $ publicKeyLocation ) { $ publicKey = openssl_get_publickey ( file_get_contents ( $ publicKeyLocation ) ) ; $ data = file_get_contents ( $ location ) ; $ info = json_encode ( [ 'name' => $ name ] ) ; openssl_seal ( gzcompress ( $ data ) , $ encrypte...
Encrypt a specified file .
233,762
public function getPointEvent ( $ typeId = null ) { $ this -> buildQuery ( ) ; $ query = $ this -> eventQuery ; if ( ! is_null ( $ typeId ) ) { $ query -> where ( 'point_event_type_id' , $ typeId ) ; } return $ this -> doQuery ( ) ; }
get user point event
233,763
public function getPointEventByType ( $ isIncrease = true ) { $ query = PointEventType :: select ( 'id' ) ; $ isIncrease ? $ query -> where ( 'is_increase' , $ isIncrease ) : $ query -> where ( 'is_deduction' ) ; $ eventType = $ query -> get ( ) ; $ this -> eventQuery = PointEvent :: with ( 'activities' ) -> whereIn ( ...
get point event by type
233,764
public function validateElfinder ( $ attribute , $ value , $ parameters , $ validator ) { if ( ! File :: exists ( $ value ) ) { return false ; } if ( count ( $ parameters ) > 0 ) { return in_array ( File :: extension ( $ value ) , $ parameters ) ; } return true ; }
validator elfinder file
233,765
public function validateElfinderMax ( $ attribute , $ value , $ parameters , $ validator ) { $ size = $ parameters [ 0 ] * 1024 ; if ( File :: size ( $ value ) > $ size ) { return false ; } return true ; }
validator elfinder max size file
233,766
public function validateVideoLink ( $ attribute , $ value , $ parameters , $ validator ) { return preg_match ( $ this -> youtubeRegex , $ value ) || preg_match ( $ this -> vimeoRegex , $ value ) ; }
validator youtube link
233,767
public function send ( $ method , $ endpoint , $ data = [ ] ) { try { $ request = $ this -> client -> createRequest ( $ method , $ endpoint , [ 'body' => json_encode ( $ data ) ] ) ; return new Response ( $ this -> client -> send ( $ request ) ) ; } catch ( GuzzleExceptions \ RequestException $ e ) { return $ this -> h...
Wraps HTTP call into a good mould
233,768
private function handleError ( $ e ) { if ( ! $ e -> hasResponse ( ) ) { throw new Errors \ NetworkError ; } $ response = $ e -> getResponse ( ) ; $ body = $ response -> json ( ) ; switch ( $ response -> getStatusCode ( ) ) { case 400 : throw new Errors \ InvalidRequestError ( $ body [ 'error' ] [ 'message' ] , $ body ...
Handles the error by throwing proper exception
233,769
private function handleUnknownError ( $ e ) { $ response = $ e -> getResponse ( ) ; $ body = $ response -> json ( ) ; switch ( floor ( $ response -> getStatusCode ( ) / 100 ) ) { case 4 : throw new Errors \ InvalidRequestError ( $ body [ 'error' ] [ 'message' ] , $ body [ 'error' ] [ 'code' ] , $ body [ 'error' ] [ 'ty...
Handles unknown errors by checking the kind of HTTP status code
233,770
public function getSourceFile ( $ page ) { $ path = realpath ( $ this -> generator -> getInputDirectory ( ) . '/' . $ page . '.xml' ) ; return new SourceFile ( $ page , $ path ) ; }
Loads a source file .
233,771
protected function validateParams ( array & $ params , $ rules = null , $ clean = false ) { if ( ! is_null ( $ rules ) ) { $ validator = $ this -> newValidator ( $ params , $ rules , $ clean ) ; $ this -> setValidator ( $ validator ) ; } $ validator = $ this -> getValidator ( ) ; $ rules = $ validator -> getRules ( ) ;...
Validate params by given rules
233,772
public function formatShippingAddress ( ClientShippingAddressInterface $ address , $ lineSeparator = self :: LINES_SEPARATOR ) { $ lines = [ ] ; $ lines [ ] = sprintf ( '%s %s' , $ address -> getFirstName ( ) , $ address -> getLastName ( ) ) ; if ( '' !== $ address -> getCompanyName ( ) ) { $ lines [ ] = $ address -> g...
Formats the shipping address
233,773
public function formatContactDetails ( ClientContactDetailsInterface $ details , $ lineSeparator = self :: LINES_SEPARATOR ) { $ lines = [ ] ; $ lines [ ] = sprintf ( '%s %s' , $ details -> getFirstName ( ) , $ details -> getLastName ( ) ) ; $ lines [ ] = sprintf ( '%s %s' , $ details -> getPhone ( ) , $ details -> get...
Formats the contact details
233,774
public function frm ( $ txt , $ att = '' , $ a = '' , $ m = '' , $ e = '' ) { $ attList = array ( ) ; if ( ! empty ( $ a ) ) { $ attList [ 'action' ] = $ a ; } if ( ! empty ( $ m ) ) { $ attList [ 'method' ] = $ m ; } if ( ! empty ( $ e ) ) { $ attList [ 'enctype' ] = $ e ; } $ newatt = $ this -> addAttributes ( $ attL...
complex tags predefined to simplify coding
233,775
public function setConfig ( $ param , $ value ) { $ dn = new DotNotation ( $ this -> configs ) ; $ dn -> set ( $ param , $ value ) ; $ this -> configs = $ dn -> getValues ( ) ; }
Set configuration parameter .
233,776
public function getConfig ( $ param , $ defaultValue = null ) { $ dn = new DotNotation ( $ this -> configs ) ; return $ dn -> get ( $ param , $ defaultValue ) ; }
Get Configuration Value .
233,777
protected function loadProviders ( $ providers ) { foreach ( ( array ) $ providers as $ provider ) { $ provider = $ this -> container -> get ( $ provider ) ; if ( ! $ provider instanceof ServiceProviderInterface ) { $ providerName = get_class ( $ provider ) ; throw new \ Exception ( "$providerName does not implement re...
Register Providers into the Application .
233,778
protected function loadEvents ( $ appEvents ) { foreach ( ( array ) $ appEvents as $ appEventType => $ events ) { foreach ( $ events as $ event ) { $ this -> eventDispatcher -> addListener ( $ appEventType , $ this -> container -> get ( $ event ) ) ; } } }
Register Event Listeners .
233,779
protected function getSuperGlobalValue ( $ name ) { $ pos = strpos ( $ name , $ this -> field_splitter ) ; if ( false !== $ pos ) { $ pref = substr ( $ name , 0 , $ pos ) ; $ suff = substr ( $ name , $ pos + 1 ) ; if ( isset ( $ GLOBALS [ $ pref ] [ $ suff ] ) ) { return $ GLOBALS [ $ pref ] [ $ suff ] ; } } else { $ p...
Get super global value
233,780
protected function exceptionIfNotString ( $ key ) { if ( ! is_string ( $ key ) ) { throw new InvalidArgumentException ( Message :: get ( Message :: CONFIG_KEY_INVALID , $ key ) , Message :: CONFIG_KEY_INVALID ) ; } }
Throw exception if not a string
233,781
static function GatherParams ( $ url ) { $ reader = new StringReader ( $ url ) ; $ param = '' ; $ params = array ( ) ; $ start = false ; while ( false !== ( $ ch = $ reader -> ReadChar ( ) ) ) { if ( $ ch == '{' ) { $ start = true ; } else if ( $ ch == '}' && $ start ) { $ params [ ] = $ param ; $ param = '' ; $ start ...
Gathers the obligatory parameters from the url
233,782
static function PageUrl ( Page $ page , array $ params = array ( ) , $ fragment = '' ) { $ siteUrl = $ page -> GetSite ( ) -> GetUrl ( ) ; $ pageUrl = $ page -> GetUrl ( ) ; if ( $ pageUrl == 'index.html' ) { $ url = $ siteUrl ; } else { $ url = Path :: Combine ( $ siteUrl , $ pageUrl ) ; } $ oblParams = self :: Gather...
Returns the url of a page with parameters and fragment
233,783
static function Url ( PageUrl $ pageUrl , array $ additionalParameters = array ( ) ) { $ list = new PageParamListProvider ( $ pageUrl ) ; $ params = $ list -> ToArray ( ) ; foreach ( $ additionalParameters as $ key => $ value ) { $ params [ $ key ] = $ value ; } return self :: PageUrl ( $ pageUrl -> GetPage ( ) , $ par...
Gets the url for a page url entity
233,784
private static function AttachObligatoryParams ( $ url , array $ oblParams , array $ params ) { foreach ( $ oblParams as $ oblParam ) { $ value = '' ; if ( ! array_key_exists ( $ oblParam , $ params ) ) { $ value = Request :: GetData ( $ oblParam ) ; } else { $ value = $ params [ $ oblParam ] ; } if ( $ value ) { $ url...
Attaches obligatory parameters
233,785
private static function AttachMoreParams ( $ url , array $ oblParams , array $ params ) { $ moreParams = array ( ) ; foreach ( $ params as $ key => $ value ) { if ( ! in_array ( $ key , $ oblParams ) ) { $ moreParams [ $ key ] = $ value ; } } if ( count ( $ moreParams ) ) { $ url .= '?' . http_build_query ( $ moreParam...
Attaches none oblique url paramters
233,786
static function Page404 ( Site $ site ) { $ sql = Access :: SqlBuilder ( ) ; $ tblPage = Page :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblPage -> Field ( 'Type' ) , $ sql -> Value ( ( string ) PageType :: NotFound ( ) ) ) -> And_ ( $ sql -> Equals ( $ tblPage -> Field ( 'Site' ) , $ sql -> Value ( $ s...
Finds the 404 page for a site
233,787
protected function getPattern ( ) { if ( is_null ( $ this -> reference_pattern ) ) { if ( '' === $ this -> reference_start || is_null ( $ this -> reference_end ) ) { $ this -> reference_pattern = '' ; } else { $ this -> reference_pattern = '~(' . preg_quote ( $ this -> reference_start ) . '([a-zA-Z_][a-zA-Z0-9._]*+)' ....
Get the reference pattern
233,788
protected function deReferenceArray ( array & $ dataArray , $ clearCache = false ) { if ( '' === $ this -> getPattern ( ) ) { return ; } if ( $ clearCache ) { $ this -> loop_detect = [ ] ; } try { foreach ( $ dataArray as $ idx => & $ data ) { if ( is_array ( $ data ) ) { $ this -> dereferenceArray ( $ data ) ; } elsei...
Derefence all references in an array
233,789
static function BundleFolder ( $ bundleName ) { $ packageBundles = self :: PackageBundles ( ) ; if ( isset ( $ packageBundles [ $ bundleName ] ) ) { return $ packageBundles [ $ bundleName ] ; } return Path :: Combine ( self :: AppBundlesFolder ( ) , $ bundleName ) ; }
Gets the folder for the bundle
233,790
static function Modules ( $ bundleName , ModuleLocation $ location ) { $ result = array ( ) ; $ modulesFolder = Path :: Combine ( self :: BundleFolder ( $ bundleName ) , 'Modules' ) ; $ folder = Path :: Combine ( $ modulesFolder , ( string ) $ location ) ; if ( ! Folder :: Exists ( $ folder ) ) { return $ result ; } $ ...
Gets all modules in a bundle
233,791
static function BundleTranslationsFile ( ModuleBase $ module , $ lang ) { $ moduleTransFolder = self :: ModuleTranslationsFolder ( $ module ) ; $ bundleTransFolder = Path :: Directory ( $ moduleTransFolder ) ; $ file = Path :: Combine ( $ bundleTransFolder , $ lang ) ; return Path :: AddExtension ( $ file , 'php' ) ; }
Gets the bundle translations file
233,792
static function ModuleTranslationsFolder ( ModuleBase $ module ) { $ class = new \ ReflectionClass ( $ module ) ; $ classFile = Str :: Replace ( '\\' , '/' , $ class -> getFileName ( ) ) ; return Str :: Replace ( '/Modules/' , '/Translations/' , Path :: RemoveExtension ( $ classFile ) ) ; }
Gets the translations folder for a module
233,793
static function ModuleTranslationsFile ( ModuleBase $ module , $ lang ) { $ folder = self :: ModuleTranslationsFolder ( $ module ) ; $ file = Path :: Combine ( $ folder , $ lang ) ; return Path :: AddExtension ( $ file , 'php' ) ; }
Gets the translations file for a module
233,794
static function ModuleCustomTemplatesFolder ( TemplateModule $ module ) { $ parentFolder = Path :: Combine ( PHINE_PATH , 'App/Phine/ModuleTemplates' ) ; $ bundleFolder = Path :: Combine ( $ parentFolder , $ module -> MyBundle ( ) ) ; return Path :: Combine ( $ bundleFolder , $ module -> MyName ( ) ) ; }
Gets the folder for
233,795
static function LayoutTemplate ( Layout $ layout ) { $ folder = Path :: Combine ( PHINE_PATH , 'App/Phine/LayoutTemplates' ) ; $ file = Path :: Combine ( $ folder , $ layout -> GetName ( ) ) ; return Path :: AddExtension ( $ file , 'phtml' ) ; }
The template file for a page layout
233,796
static function SitemapCacheFile ( Site $ site ) { $ cacheFolder = Path :: Combine ( PHINE_PATH , 'App/Phine/Cache/Sitemap' ) ; $ filename = Path :: AddExtension ( $ site -> GetID ( ) , 'xml' ) ; return Path :: Combine ( $ cacheFolder , $ filename ) ; }
The name of the cache file of the
233,797
static function ContentCacheFile ( FrontendModule $ module ) { $ file = $ module -> Content ( ) -> GetID ( ) ; $ cacheKey = $ module -> CacheKey ( ) ; if ( $ cacheKey ) { if ( ! ctype_alnum ( $ cacheKey ) ) { throw new \ Exception ( Trans ( 'Core.CacheKey.Error.NotAlphaNumeric' ) ) ; } $ file .= '-' . $ cacheKey ; } $ ...
The name of the cache file
233,798
public function process ( $ file ) { ob_start ( ) ; extract ( $ this -> viewmodel -> getVariables ( ) , EXTR_REFS ) ; include ( $ file ) ; $ this -> output = ob_get_clean ( ) ; return $ this ; }
Converts template code to output string
233,799
public function escapeJs ( $ string , $ encoding = 'utf-8' ) { $ current = Escape :: getEncoding ( ) ; Escape :: setEncoding ( $ encoding ) ; $ result = Escape :: js ( $ string ) ; Escape :: setEncoding ( $ current ) ; return $ result ; }
Escape a string for the Javascript context .