idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
18,900
public function getUrl ( $ image , $ imageQuery = NULL ) { if ( $ imageQuery && Strings :: startsWith ( $ imageQuery , '//' ) ) { $ imageQuery = Strings :: substring ( $ imageQuery , 2 ) ; $ imageUrl = $ this -> getPictureGeneratorUrl ( $ image , $ imageQuery ) ; if ( $ this -> isUrlRelative ) { if ( $ this -> websiteUrl ) { return $ this -> websiteUrl . $ imageUrl ; } else { return '//' . $ _SERVER [ 'SERVER_ADDR' ] . $ imageUrl ; } } else { return $ imageUrl ; } } return $ this -> getPictureGeneratorUrl ( $ image , $ imageQuery ) ; }
Get url to image with specified image query string Supports absolute picture url when is relative generator url set
18,901
protected function getPictureGeneratorUrl ( $ image , $ imageQuery = NULL ) { if ( ! is_null ( $ imageQuery ) ) { $ image .= '@' . $ imageQuery ; } return $ this -> generator -> loadPicture ( $ image ) -> getUrl ( ) ; }
Get url to image with specified image query string from generator
18,902
public function serverResponse ( ) { try { $ this -> generator -> serverResponse ( ) ; } catch ( \ Exception $ exception ) { if ( $ this -> handleExceptions ) { if ( is_string ( $ this -> handleExceptions ) ) { Debugger :: log ( $ exception -> getMessage ( ) , $ this -> handleExceptions ) ; } else { Debugger :: log ( $ exception , 'palette' ) ; } } else { throw $ exception ; } $ fallbackImage = $ this -> generator -> getFallbackImage ( ) ; if ( $ fallbackImage ) { $ paletteQuery = preg_replace ( '/.*@(.*)/' , $ fallbackImage . '@$1' , $ _GET [ 'imageQuery' ] ) ; $ picture = $ this -> generator -> loadPicture ( $ paletteQuery ) ; $ savePath = $ this -> generator -> getPath ( $ picture ) ; if ( ! file_exists ( $ savePath ) ) { $ picture -> save ( $ savePath ) ; } $ picture -> output ( ) ; } } }
Execute palette service generator backend
18,903
public function get ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_GET , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a GET route to be handled by the application .
18,904
public function post ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_POST , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a POST route to be handled by the application .
18,905
public function put ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_PUT , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a PUT route to be handled by the application .
18,906
public function patch ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_PATCH , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a PATCH route to be handled by the application .
18,907
public function delete ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_DELETE , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a DELETE route to be handled by the application .
18,908
public function options ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_OPTIONS , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a OPTIONS route to be handled by the application .
18,909
public function head ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_HEAD , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a HEAD route to be handled by the application .
18,910
public function purge ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_PURGE , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a PURGE route to be handled by the application .
18,911
public function trace ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_TRACE , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a TRACE route to be handled by the application .
18,912
public function connect ( string $ pattern , $ stages ) : void { $ pipeline = new HttpPipeline ( RequestMethodInterface :: METHOD_CONNECT , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add a CONNECT route to be handled by the application .
18,913
public function map ( string $ pattern , array $ verbs , $ stages ) : void { $ pipeline = new HttpPipeline ( $ verbs , $ this -> prefix . $ pattern , $ this -> routerStages ) ; $ pipeline -> pipe ( $ stages ) ; $ this -> pipelineCollection -> add ( $ pipeline ) ; }
Add multiple verb to a pattern and stages .
18,914
protected function fetch ( $ url , array $ params = [ ] , array $ curl_options = [ ] ) { $ requestOptions = new RequestOptions ; $ requestOptions -> curl_options = $ curl_options ; $ requestOptions -> ca_info = $ this -> ca_info ; return ( new Request ( $ requestOptions ) ) -> fetch ( new URL ( $ url , $ params ) ) ; }
Embed stuff from anywhere!
18,915
public function setDelimiter ( $ delimiter ) { if ( ! is_string ( $ delimiter ) || strlen ( $ delimiter ) < 1 ) { throw new \ InvalidArgumentException ( "Invalid delimiter specified, must be a string at least 1 character long" ) ; } $ this -> delimiter = $ delimiter ; return $ this ; }
Set the character to use for delimitation .
18,916
public function setLineEnding ( $ lineEnding ) { if ( ! is_string ( $ lineEnding ) || strlen ( $ lineEnding ) < 1 ) { throw new \ InvalidArgumentException ( "Invalid line ending specified, must be a string at least 1 character long" ) ; } $ this -> lineEnding = $ lineEnding ; return $ this ; }
Set the character to use for line endings .
18,917
public function addRow ( array $ row ) { if ( is_array ( $ this -> fields ) ) { $ assoc = $ row ; $ row = [ ] ; foreach ( $ this -> fields as $ field ) { $ row [ ] = isset ( $ assoc [ $ field ] ) ? $ assoc [ $ field ] : "" ; } } $ this -> data [ ] = $ row ; return $ this ; }
Add a row to the csv .
18,918
public function asString ( ) { $ tmp = new \ SplTempFileObject ; foreach ( $ this -> data as $ row ) { $ tmp -> fputcsv ( $ row , $ this -> delimiter ) ; if ( $ this -> lineEnding !== "\n" ) { $ tmp -> fseek ( - 1 , \ SEEK_CUR ) ; $ tmp -> fwrite ( $ this -> lineEnding ) ; } } $ length = $ tmp -> ftell ( ) ; if ( $ length < 1 ) { return "" ; } $ tmp -> fseek ( 0 ) ; return $ tmp -> fread ( $ length ) ; }
Get the csv file as a string .
18,919
public static function getContents ( $ filename ) { $ file = fopen ( $ filename , "r" ) ; if ( $ file === false ) { throw new \ RuntimeException ( "Cannot read the file: {$filename}" ) ; } $ data = [ ] ; while ( $ row = fgetcsv ( $ file ) ) { $ data [ ] = $ row ; } fclose ( $ file ) ; return $ data ; }
Read the contents of a csv file and throw a RuntimeException if it cannot be done .
18,920
public static function putContents ( $ filename , array $ data ) { $ csv = new static ( ) ; foreach ( $ data as $ row ) { $ csv -> addRow ( $ row ) ; } $ csv -> write ( $ filename ) ; }
Write a csv file and throw a RuntimeException if it cannot be done .
18,921
protected function redirectToAction ( $ action ) { return $ this -> response -> redirect ( [ 'for' => $ this -> router -> getMatchedRoute ( ) -> getName ( ) , 'action' => $ action ] ) ; }
Redirect to specific action in the same controller .
18,922
protected function beforeCreate ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: BEFORE_CREATE , $ this ) ; $ this -> beforeSave ( ) ; }
Method invoked on the beginning of the createAction after checking request validity .
18,923
protected function afterCreate ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: AFTER_CREATE , $ this ) ; return $ this -> afterSave ( ) ; }
Method invoked on the end of the successful createAction before picking view .
18,924
protected function beforeUpdate ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: BEFORE_UPDATE , $ this ) ; $ this -> beforeSave ( ) ; }
Method invoked on the beginning of the updateAction after checking request validity .
18,925
protected function afterUpdate ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: AFTER_UPDATE , $ this ) ; return $ this -> afterSave ( ) ; }
Method invoked on the end of the successful updateAction before picking view .
18,926
protected function afterDelete ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: AFTER_DELETE , $ this ) ; return $ this -> redirectToAction ( 'index' ) ; }
Method invoked on the end of the deleteAction .
18,927
protected function afterDeleteException ( ) { $ this -> dispatcher -> getEventsManager ( ) -> fire ( Events :: AFTER_DELETE_EXCEPTION , $ this ) ; return $ this -> redirectToAction ( 'index' ) ; }
Method invoked on the end of the deleteAction failure before picking view .
18,928
public function addMapping ( $ attributeName , $ mappings ) { if ( ! is_array ( $ mappings ) ) { $ mappings = [ $ mappings ] ; } if ( ! $ this -> hasMapping ( $ attributeName ) ) { $ this -> mappingsContainer [ $ attributeName ] = [ ] ; } if ( $ this -> mappingsContainer [ $ attributeName ] !== null ) { foreach ( $ mappings as $ mapping ) { $ this -> mappingsContainer [ $ attributeName ] [ ] = $ mapping ; } } return $ this ; }
Adds mapping for indicated attribute
18,929
public function removeMapping ( $ attributeName ) { if ( $ this -> hasMapping ( $ attributeName ) ) { $ this -> mappingsContainer [ $ attributeName ] = null ; } return $ this ; }
Removes mapping from indicated attribute
18,930
public function resolveMapping ( $ attributeName , $ value ) { if ( ! $ this -> hasMapping ( $ attributeName ) ) { return $ value ; } $ mappings = $ this -> mappingsContainer [ $ attributeName ] ; if ( is_array ( $ mappings ) ) { foreach ( $ mappings as $ mappingResolver ) { if ( ! $ mappingResolver instanceof MappingInterface ) { $ mappingResolver = MappingManager :: find ( $ mappingResolver ) ; } $ mappingResolver -> resolve ( $ value ) ; } } return $ value ; }
Filter value of indicated attribute by applying defined mappings
18,931
protected function buildUrl ( $ type = 'email' , $ value ) { $ type = trim ( strtolower ( $ type ) ) ; if ( ! in_array ( $ type , [ 'ip' , 'email' , 'username' ] ) ) { throw new \ InvalidArgumentException ( 'Type of ' . $ type . ' is not supported by the API' ) ; } $ url = $ this -> apiUrl . '?' . $ type . '=' . urlencode ( $ value ) . '&f=json' ; return $ url ; }
Builds the URL for the spam check with given type email|ip|username and value for it return full api url .
18,932
protected function sendRequest ( $ url ) { $ response = null ; if ( $ this -> curlEnabled ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ response = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; } else { $ response = file_get_contents ( $ url ) ; } return $ response ; }
Sends a GET request to a URL and returns the response .
18,933
public function isSpam ( $ type = 'email' , $ value ) { $ fullApiUrl = $ this -> buildUrl ( $ type , $ value ) ; $ response = $ this -> sendRequest ( $ fullApiUrl ) ; if ( ! $ response ) { throw new \ Exception ( 'API Check Unsuccessful on url: ' . $ fullApiUrl ) ; } $ result = json_decode ( $ response ) ; if ( ! isset ( $ result -> success ) || ! isset ( $ result -> { $ type } -> appears ) || ! isset ( $ result -> { $ type } -> frequency ) ) { logger ( $ response ) ; if ( is_array ( $ response ) ) { $ response = implode ( ', ' , $ response ) ; } throw new \ Exception ( 'Response has wrong format: ' . $ response ) ; } if ( $ result -> success == 1 && $ result -> { $ type } -> appears == 1 ) { return $ result -> { $ type } -> frequency >= $ this -> frequency ; } return false ; }
Checked the StopForumSpam API for given type email|ip|username and return true if it is registered as a spam .
18,934
protected function platformPrepareLikeStatement ( $ prefix = null , $ column , $ not = null , $ bind , $ caseSensitive = false ) { $ likeStatement = "{$prefix} {$column} {$not} LIKE :{$bind}" ; if ( $ caseSensitive === true ) { $ likeStatement = "{$prefix} LOWER({$column}) {$not} LIKE :{$bind}" ; } return $ likeStatement ; }
Platform independent LIKE statement builder .
18,935
protected function createHandle ( ) { if ( ! empty ( $ this -> stack ) ) { $ url = array_shift ( $ this -> stack ) ; if ( $ url instanceof URL ) { $ curl = curl_init ( $ url -> mergeParams ( ) ) ; curl_setopt_array ( $ curl , $ this -> curl_options ) ; curl_multi_add_handle ( $ this -> curl_multi , $ curl ) ; if ( $ this -> options -> sleep ) { usleep ( $ this -> options -> sleep ) ; } } else { $ this -> createHandle ( ) ; } } }
creates a new cURL handle
18,936
protected function processStack ( ) { do { do { $ status = curl_multi_exec ( $ this -> curl_multi , $ active ) ; } while ( $ status === CURLM_CALL_MULTI_PERFORM ) ; while ( $ state = curl_multi_info_read ( $ this -> curl_multi ) ) { $ url = $ this -> multiResponseHandler -> handleResponse ( new MultiResponse ( $ state [ 'handle' ] ) ) ; if ( $ url instanceof URL ) { $ this -> stack [ ] = $ url ; } curl_multi_remove_handle ( $ this -> curl_multi , $ state [ 'handle' ] ) ; curl_close ( $ state [ 'handle' ] ) ; $ this -> createHandle ( ) ; } if ( $ active ) { curl_multi_select ( $ this -> curl_multi , $ this -> options -> timeout ) ; } } while ( $ active && $ status === CURLM_OK ) ; }
processes the requests
18,937
public static function fromPlain ( $ aPlainPassword , UserPasswordEncoder $ anEncoder , $ salt = null ) { if ( null === $ salt ) { $ salt = base_convert ( sha1 ( uniqid ( mt_rand ( ) , true ) ) , 16 , 36 ) ; } $ encodedPassword = $ anEncoder -> encode ( $ aPlainPassword , $ salt ) ; return new self ( $ encodedPassword , $ salt ) ; }
Named static constructor with the given plain password and encoder .
18,938
public function readRef ( $ fieldName ) { $ oRef = $ this -> readNestedAttribute ( $ fieldName ) ; if ( ! \ MongoDBRef :: isRef ( $ oRef ) ) { throw new InvalidReferenceException ( ) ; } if ( isset ( $ this -> dbRefs ) && isset ( $ this -> dbRefs [ $ fieldName ] ) ) { $ modelInstance = $ this -> instantiateModel ( $ this -> dbRefs [ $ fieldName ] ) ; } else if ( $ this -> getDI ( ) -> has ( 'mongoMapper' ) ) { $ modelInstance = $ this -> getDI ( ) -> get ( 'mongoMapper' ) -> resolveModel ( $ oRef [ '$ref' ] ) ; } else { return $ oRef ; } return forward_static_call ( array ( $ modelInstance , 'findById' ) , $ oRef [ '$id' ] ) ; }
Returns corresponding object indicated by MongoDBRef
18,939
public static function load ( ) { $ configFile = MODULES_DIR . DS . RouteController :: $ currentModule . '/Config/config.php' ; if ( ! file_exists ( $ configFile ) ) { $ configFile = BASE_DIR . '/config/config.php' ; if ( ! file_exists ( $ configFile ) ) { throw new \ Exception ( ExceptionMessages :: CONFIG_FILE_NOT_FOUND ) ; } } if ( empty ( self :: $ configs ) ) { self :: $ configs = require_once $ configFile ; } }
Finds and loads configuration
18,940
public static function import ( $ filename ) { $ configFile = BASE_DIR . '/config/' . $ filename . '.php' ; if ( ! file_exists ( $ configFile ) ) { throw new \ Exception ( ExceptionMessages :: CONFIG_FILE_NOT_FOUND ) ; } $ allConfigs = self :: getAll ( ) ; foreach ( $ allConfigs as $ key => $ config ) { if ( $ filename == $ key ) { throw new \ Exception ( ExceptionMessages :: CONFIG_COLLISION ) ; } } self :: $ configs [ $ filename ] = require_once BASE_DIR . '/config/' . $ filename . '.php' ; }
Imports libraries helpers and other classes
18,941
public static function get ( $ key , $ default = NULL ) { if ( isset ( self :: $ configs [ $ key ] ) ) return self :: $ configs [ $ key ] ; return $ default ; }
Gets a config item
18,942
private function getCustomParamsArray ( ) { $ customParams = $ this -> customParams ; ksort ( $ customParams ) ; foreach ( $ customParams as $ key => $ value ) { $ customParams [ $ this -> customParamsPrefix . $ key ] = $ value ; unset ( $ customParams [ $ key ] ) ; } return $ customParams ; }
Returns custom parameters for url query .
18,943
private function getCustomParamsString ( ) { $ customParams = $ this -> getCustomParamsArray ( ) ; foreach ( $ customParams as $ key => $ value ) { $ customParams [ $ key ] = $ key . '=' . $ value ; } return implode ( ':' , $ customParams ) ; }
Returns custom parameters for signature .
18,944
public function publishAction ( ) { $ this -> putText ( "Copying Vegas CMF assets..." ) ; $ this -> copyCmfAssets ( ) ; $ this -> putText ( "Copying vendor assets:" ) ; $ this -> copyVendorAssets ( ) ; $ this -> putSuccess ( "Done." ) ; }
Publishes assets provided by vegas - libraries installed via composer
18,945
private function copyCmfAssets ( ) { $ vegasCmfPath = APP_ROOT . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'vegas-cmf' ; $ publicAssetsDir = $ this -> getOption ( 'd' , APP_ROOT . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'assets' ) ; $ handle = opendir ( $ vegasCmfPath ) ; if ( $ handle ) { while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( $ entry == "." || $ entry == ".." ) { continue ; } $ assetsDir = $ vegasCmfPath . DIRECTORY_SEPARATOR . $ entry . DIRECTORY_SEPARATOR . 'assets' ; if ( file_exists ( $ assetsDir ) ) { $ this -> copyRecursive ( $ assetsDir , $ publicAssetsDir ) ; } } closedir ( $ handle ) ; } }
Copies all assets from vegas - cmf libraries
18,946
private function copyVendorAssets ( ) { $ modules = [ ] ; $ moduleLoader = new Loader ( $ this -> di ) ; $ moduleLoader -> dumpModulesFromVendor ( $ modules ) ; $ publicAssetsDir = $ this -> getOption ( 'd' , APP_ROOT . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'assets' ) ; if ( $ modules ) { foreach ( $ modules as $ moduleName => $ module ) { $ assetsDir = dirname ( $ module [ 'path' ] ) . '/../assets' ; if ( file_exists ( $ assetsDir ) ) { $ this -> putText ( "- " . $ moduleName . "..." ) ; $ this -> copyRecursive ( $ assetsDir , $ publicAssetsDir ) ; } } } }
Copies all assets vendor modules
18,947
public function setupOptions ( ) { $ action = new Action ( 'publish' , 'Publish all assets' ) ; $ dir = new Option ( 'dir' , 'd' , 'Assets directory. Usage vegas:assets publish -d /path/to/assets' ) ; $ action -> addOption ( $ dir ) ; $ this -> addTaskAction ( $ action ) ; }
Task s available options
18,948
public function assignAccountToParty ( Account $ account , AbstractParty $ party ) { if ( $ party -> getAccounts ( ) -> contains ( $ account ) ) { return ; } $ party -> addAccount ( $ account ) ; $ accountIdentifier = $ this -> persistenceManager -> getIdentifierByObject ( $ account ) ; $ this -> accountsInPartyRuntimeCache [ $ accountIdentifier ] = $ this -> persistenceManager -> getIdentifierByObject ( $ party ) ; }
Assigns an Account to a Party
18,949
public function getAssignedPartyOfAccount ( Account $ account ) { $ accountIdentifier = $ this -> persistenceManager -> getIdentifierByObject ( $ account ) ; if ( ! array_key_exists ( $ accountIdentifier , $ this -> accountsInPartyRuntimeCache ) ) { $ party = $ this -> partyRepository -> findOneHavingAccount ( $ account ) ; $ this -> accountsInPartyRuntimeCache [ $ accountIdentifier ] = $ party === null ? null : $ this -> persistenceManager -> getIdentifierByObject ( $ party ) ; return $ party ; } if ( $ this -> accountsInPartyRuntimeCache [ $ accountIdentifier ] !== null ) { $ partyIdentifier = $ this -> accountsInPartyRuntimeCache [ $ accountIdentifier ] ; return $ this -> persistenceManager -> getObjectByIdentifier ( $ partyIdentifier , AbstractParty :: class ) ; } return null ; }
Gets the Party having an Account assigned
18,950
public function articleTitle ( ) { $ title = $ this -> getTitle ( ) ; $ search = [ '{{ noun }}' , '{{ verb }}' , '{{ adjective }}' , '{{ adverb }}' , ] ; $ replace = [ $ this -> getNoun ( ) , $ this -> getVerb ( ) , $ this -> getAdjective ( ) , $ this -> getAdverb ( ) , ] ; $ title = ucfirst ( str_replace ( $ search , $ replace , $ title ) ) ; return $ title ; }
Generates an article title using real words
18,951
public function articleContent ( ) { $ content = $ this -> getHtmlTemplate ( ) ; $ search = [ '{{ title }}' , '{{ paragraph }}' , '{{ paragraphs }}' , '{{ words }}' , '{{ image }}' , '{{ sentence }}' , ] ; $ replace = [ self :: articleTitle ( ) , $ this -> generator -> paragraph ( ) , nl2br ( $ this -> generator -> paragraphs ( rand ( 5 , 10 ) , true ) ) , $ this -> generator -> sentence ( rand ( 3 , 5 ) ) , $ this -> generator -> imageUrl ( ) , $ this -> generator -> sentence ( ) , ] ; $ content = str_replace ( $ search , $ replace , $ content ) ; return $ content ; }
Generates article content with in HTML
18,952
public function articleContentMarkdown ( ) { $ content = $ this -> getMarkdownTemplate ( ) ; $ search = [ '{{ title }}' , '{{ paragraph }}' , '{{ paragraphs }}' , '{{ words }}' , '{{ image }}' , '{{ sentence }}' , ] ; $ replace = [ self :: articleTitle ( ) , $ this -> generator -> paragraph ( ) , $ this -> generator -> paragraphs ( rand ( 5 , 10 ) , true ) , $ this -> generator -> sentence ( rand ( 3 , 5 ) ) , $ this -> generator -> imageUrl ( ) , $ this -> generator -> sentence ( ) , ] ; $ content = str_replace ( $ search , $ replace , $ content ) ; return $ content ; }
Generates article content in Markdown format based on some templates
18,953
public function dump ( $ inputDirectory , $ outputDirectory ) { $ servicesList = array ( ) ; $ directoryIterator = new \ DirectoryIterator ( $ inputDirectory ) ; foreach ( $ directoryIterator as $ fileInfo ) { if ( $ fileInfo -> isDot ( ) ) continue ; $ servicesList [ $ fileInfo -> getBasename ( '.php' ) ] = $ fileInfo -> getPathname ( ) ; } FileWriter :: writeObject ( $ outputDirectory . self :: SERVICES_STATIC_FILE , $ servicesList , true ) ; ksort ( $ servicesList ) ; return $ servicesList ; }
Dumps services to source file
18,954
public function autoload ( $ inputDirectory , $ outputDirectory ) { if ( ! file_exists ( $ outputDirectory . self :: SERVICES_STATIC_FILE ) || $ this -> di -> get ( 'environment' ) != Constants :: DEFAULT_ENV ) { $ services = self :: dump ( $ inputDirectory , $ outputDirectory ) ; } else { $ services = require ( $ outputDirectory . self :: SERVICES_STATIC_FILE ) ; } self :: setupServiceProvidersAutoloader ( $ inputDirectory , $ services ) ; $ dependencies = array ( ) ; $ servicesProviders = array ( ) ; foreach ( $ services as $ serviceProviderName => $ path ) { $ reflectionClass = new \ ReflectionClass ( $ serviceProviderName ) ; $ serviceProviderInstance = $ reflectionClass -> newInstance ( ) ; $ serviceDependencies = $ serviceProviderInstance -> getDependencies ( ) ; $ serviceName = $ reflectionClass -> getConstant ( 'SERVICE_NAME' ) ; if ( ! isset ( $ dependencies [ $ serviceName ] ) ) { $ dependencies [ $ serviceName ] = 0 ; } array_walk ( $ serviceDependencies , function ( $ dependency , $ key ) use ( & $ dependencies ) { if ( ! isset ( $ dependencies [ $ dependency ] ) ) { $ dependencies [ $ dependency ] = 0 ; } $ dependencies [ $ dependency ] ++ ; } ) ; $ servicesProviders [ $ serviceName ] = $ serviceProviderInstance ; } uasort ( $ dependencies , function ( $ a , $ b ) { return $ b - $ a ; } ) ; foreach ( $ dependencies as $ serviceProviderName => $ dependency ) { $ servicesProviders [ $ serviceProviderName ] -> register ( $ this -> di ) ; } }
Creates services autoloader
18,955
private function setupServiceProvidersAutoloader ( $ inputDirectory , array $ services ) { $ loader = new Loader ( ) ; foreach ( $ services as $ className => $ path ) { if ( ! $ path ) { $ services [ $ className ] = $ inputDirectory . sprintf ( '%s.php' , $ className ) ; } } $ loader -> registerClasses ( $ services , true ) ; $ loader -> register ( ) ; }
Registers classes that contains services providers
18,956
public function initDispatcher ( ) { $ this -> di -> set ( 'dispatcher' , function ( ) { $ dispatcher = new Dispatcher ( ) ; $ eventsManager = $ this -> di -> getShared ( 'eventsManager' ) ; $ eventsManager -> attach ( 'dispatch:beforeException' , ( new ExceptionListener ( ) ) -> beforeException ( ) ) ; $ dispatcher -> setEventsManager ( $ eventsManager ) ; return $ dispatcher ; } ) ; }
Registers default dispatcher
18,957
public function setup ( ) { $ this -> di -> set ( 'config' , $ this -> config ) ; $ this -> initEnvironment ( $ this -> config ) ; $ this -> initErrorHandler ( $ this -> config ) ; $ this -> initLoader ( $ this -> config ) ; $ this -> initModules ( $ this -> config ) ; $ this -> initRoutes ( $ this -> config ) ; $ this -> initServices ( $ this -> config ) ; $ this -> initDispatcher ( ) ; $ this -> application -> setDI ( $ this -> di ) ; DI :: setDefault ( $ this -> di ) ; return $ this ; }
Executes all bootstrap initialization methods This method can be overloaded to load own initialization method .
18,958
protected function getDateTimeInstance ( string $ time = "now" , \ DateTimeZone $ timezone = null ) : DateTime { $ result = new self :: $ _dateTimeClassName ( $ time , $ timezone ) ; return $ result ; }
Returns a new DateTime instance
18,959
public function getOAuthToken ( ) { if ( ! $ this -> isStateless ( ) ) { return \ Cache :: get ( 'oauth.temp' ) ; } else { $ temp = unserialize ( \ Cache :: get ( 'oauth_temp' ) ) ; return $ temp -> getIdentifier ( ) ; } }
Returns oauth token used in last authorization process .
18,960
public function add ( $ mappingClass ) { try { if ( $ mappingClass instanceof MappingInterface ) { $ mappingClassInstance = $ mappingClass ; } else { $ reflectionClass = new \ ReflectionClass ( $ mappingClass ) ; $ mappingClassInstance = $ reflectionClass -> newInstance ( ) ; if ( ! $ mappingClassInstance instanceof MappingInterface ) { throw new InvalidMappingClassException ( 'Mapping class must be an instance of MappingInterface' ) ; } } self :: $ container [ $ mappingClassInstance -> getName ( ) ] = $ mappingClassInstance ; } catch ( \ Exception $ ex ) { throw new InvalidMappingClassException ( $ ex -> getMessage ( ) ) ; } return $ this ; }
Adds new mapping class
18,961
public static function find ( $ mappingName ) { if ( ! array_key_exists ( $ mappingName , self :: $ container ) ) { throw new MappingClassNotFoundException ( $ mappingName ) ; } return self :: $ container [ $ mappingName ] ; }
Finds the mapper by its name
18,962
public static function getSessionHandler ( ) { $ sessionDriver = get_config ( 'session_driver' ) ; self :: $ sessionDriver = $ sessionDriver ? $ sessionDriver : 'native' ; if ( self :: $ sessionDriver ) { switch ( self :: $ sessionDriver ) { case 'native' : self :: $ sessionHandler = new Session ( get_config ( 'session_timeout' ) ) ; break ; case 'database' : self :: $ sessionHandler = new DbSession ( get_config ( 'session_timeout' ) ) ; break ; } } if ( self :: $ sessionHandler ) { return self :: $ sessionHandler ; } else { throw new \ Exception ( ExceptionMessages :: MISCONFIGURED_SESSION_HANDLER ) ; } }
Get session handler
18,963
public function create ( $ cacheFilePath = null ) { $ map = [ ] ; if ( $ cacheFilePath ) { $ map = $ this -> resolveCachedMap ( $ cacheFilePath ) ; } if ( ! is_array ( $ map ) ) { $ map = $ this -> createMap ( ) ; if ( $ cacheFilePath ) { $ this -> cacheMap ( $ cacheFilePath , $ map ) ; } } $ this -> map = $ map ; return $ map ; }
Setups Mongo collections map If cache file already exists then map is read directly from this file
18,964
public function resolveModel ( $ collectionName ) { if ( ! array_key_exists ( $ collectionName , $ this -> map ) ) { throw new CannotResolveModelException ( $ collectionName ) ; } $ modelClassName = $ this -> map [ $ collectionName ] ; try { if ( ! array_key_exists ( $ modelClassName , $ this -> modelInstances ) ) { $ reflectionClass = new \ ReflectionClass ( $ modelClassName ) ; $ modelInstance = $ reflectionClass -> newInstance ( ) ; $ this -> modelInstances [ $ modelClassName ] = $ modelInstance ; } return $ this -> modelInstances [ $ modelClassName ] ; } catch ( \ Exception $ e ) { throw new CannotResolveModelException ( $ collectionName ) ; } }
Resolves model class name for given collection name
18,965
private function createMap ( ) { $ map = [ ] ; $ directoryIterator = new \ RecursiveDirectoryIterator ( $ this -> inputDirectory ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directoryIterator ) ; foreach ( $ iterator as $ file ) { if ( $ file -> getFileName ( ) == '.' || $ file -> getFileName ( ) == '..' ) { continue ; } if ( ! preg_match ( $ this -> modelClassPattern , $ file -> getPathname ( ) ) ) { continue ; } $ className = $ this -> resolveFileClassName ( $ file ) ; try { $ classInstance = $ this -> instantiateClass ( $ className ) ; if ( $ classInstance instanceof \ Phalcon \ Mvc \ Collection ) { $ map [ $ classInstance -> getSource ( ) ] = $ className ; } } catch ( \ Exception $ e ) { continue ; } } return $ map ; }
Creates map by traversing input directory
18,966
private function cacheMap ( $ cacheFilePath , $ map ) { if ( ! file_exists ( dirname ( $ cacheFilePath ) ) ) { mkdir ( dirname ( $ cacheFilePath ) , 0777 , true ) ; } return FileWriter :: writeObject ( $ cacheFilePath , $ map , true ) ; }
Saves generated map to file
18,967
protected function resolveFileClassName ( \ SplFileInfo $ fileInfo ) { $ relativeFilePath = str_replace ( $ this -> inputDirectory , '' , $ fileInfo -> getPath ( ) ) . DIRECTORY_SEPARATOR . $ fileInfo -> getBasename ( '.' . $ fileInfo -> getExtension ( ) ) ; $ splitPath = explode ( DIRECTORY_SEPARATOR , $ relativeFilePath ) ; $ namespace = implode ( '\\' , array_map ( function ( $ item ) { return ucfirst ( $ item ) ; } , $ splitPath ) ) ; return $ namespace ; }
Resolves name of class inside given file
18,968
public function matchParam ( $ paramName ) { return ( 0 == strcasecmp ( $ this -> name , $ paramName ) ) || ( 0 == strcasecmp ( $ this -> shortName , $ paramName ) ) ; }
Checks if parameter name matches to long or short name of option
18,969
public function validate ( $ value ) { $ result = ! $ this -> isRequired ; if ( $ this -> isRequired ( ) ) { $ result = ! empty ( $ value ) ; } if ( is_callable ( $ this -> validator ) ) { $ result = call_user_func ( $ this -> validator , $ value ) ; } return $ result ; }
Validates option value
18,970
public function getValue ( $ args , $ default = null ) { if ( isset ( $ args [ $ this -> name ] ) ) { return $ args [ $ this -> name ] ; } if ( isset ( $ args [ $ this -> shortName ] ) ) { return $ args [ $ this -> shortName ] ; } return $ default ; }
Looks for value of option in specified arguments array . When option is not found then returns default value .
18,971
public function prepare ( $ text , $ length = 100 , $ endString = '...' ) { $ substring = strip_tags ( preg_replace ( '/<br.?\/?>/' , ' ' , $ text ) ) ; $ textLength = mb_strlen ( $ substring ) ; if ( $ textLength > $ length ) { $ lastWordPosition = mb_strpos ( $ substring , ' ' , $ length ) ; if ( $ lastWordPosition ) { $ substring = mb_substr ( $ substring , 0 , $ lastWordPosition ) ; } else { $ substring = mb_substr ( $ substring , 0 , $ length ) ; } $ substring .= $ endString ; } return $ substring ; }
Cuts text to specified length and appends end string .
18,972
public static function permissionList ( $ permissionListStr ) { $ permissionList = Json :: decode ( $ permissionListStr ) ; foreach ( $ permissionList as $ permission ) { if ( ! \ is_string ( $ permission ) ) { throw new InputValidationException ( 'invalid "permissionList"' ) ; } } return $ permissionList ; }
Make sure the input string is valid JSON array containing just strings .
18,973
public function dumpAction ( ) { $ this -> putText ( "Dumping modules & services files..." ) ; if ( $ this -> isConfigured ( ) ) { $ config = $ this -> getDI ( ) -> get ( 'config' ) ; $ moduleLoader = new \ Vegas \ Mvc \ Module \ Loader ( $ this -> getDI ( ) ) ; $ moduleLoader -> dump ( $ config -> application -> moduleDir , $ config -> application -> configDir ) ; $ serviceProviderLoader = new \ Vegas \ DI \ ServiceProviderLoader ( $ this -> getDI ( ) ) ; $ serviceProviderLoader -> autoload ( $ config -> application -> serviceDir , $ config -> application -> configDir ) ; $ this -> putSuccess ( "Done." ) ; } }
Dumps modules & services files used for application autoloading
18,974
public function skip ( $ by = 1 ) { $ i = 0 ; while ( $ this -> cursor -> valid ( ) && $ i < $ by ) { $ this -> cursor -> next ( ) ; $ i ++ ; } return $ this ; }
Method for moving cursor by specified amount of record
18,975
public static function getContents ( $ filename ) { $ contents = file_get_contents ( $ filename ) ; if ( $ contents === false ) { throw new \ RuntimeException ( "Cannot read the file: " . $ filename ) ; } return $ contents ; }
Read the contents of a file and throw a RuntimeException if it cannot be done .
18,976
public static function putContents ( $ filename , $ contents ) { $ result = file_put_contents ( $ filename , $ contents , \ LOCK_EX | \ LOCK_NB ) ; if ( $ result === false ) { throw new \ RuntimeException ( "Cannot write the file: " . $ filename ) ; } }
Write to a file and throw a RuntimeException if it cannot be done .
18,977
public static function appendContents ( $ filename , $ contents ) { $ result = file_put_contents ( $ filename , $ contents , \ LOCK_EX | \ LOCK_NB | \ FILE_APPEND ) ; if ( $ result === false ) { throw new \ RuntimeException ( "Cannot append to the file: " . $ filename ) ; } }
Append to a file and throw a RuntimeException if it cannot be done .
18,978
public function pipe ( $ stages ) : void { if ( $ stages instanceof PipelineInterface ) { $ stages = $ stages -> stages ( ) ; } if ( ! \ is_array ( $ stages ) ) { $ this -> stages [ ] = $ stages ; return ; } foreach ( $ stages as $ stage ) { $ this -> pipe ( $ stage ) ; } }
Add a stage to the Pipeline .
18,979
public function keywords ( $ keywords = [ ] ) { $ args = func_get_args ( ) ; $ this -> mergeKeywords = ( is_bool ( end ( $ args ) ) || is_int ( end ( $ args ) ) ) ? array_pop ( $ args ) : false ; $ keywords = is_array ( $ keywords ) ? $ keywords : $ args ; array_walk ( $ keywords , function ( & $ value ) { $ value = is_object ( $ value ) ? get_class ( $ value ) : $ value ; } ) ; $ this -> keywords = array_unique ( $ keywords ) ; return $ this ; }
Fluently selects keywords .
18,980
protected function writeCacheRecord ( $ method , $ args ) { $ this -> checkReservedKeyPattern ( $ args [ 'key' ] ) ; call_user_func_array ( [ $ this , 'storeKeywords' ] , array_only ( $ args , [ 'key' , 'minutes' , 'keywords' ] ) ) ; if ( ! $ this -> operatingOnKeywords ( ) ) { $ this -> resetCurrentKeywords ( ) ; } call_user_func_array ( [ 'parent' , $ method ] , array_values ( $ args ) ) ; }
Store an item in the cache using the specified method and arguments .
18,981
protected function fetchDefaultCacheRecord ( $ method , $ args ) { if ( is_null ( $ value = parent :: get ( $ args [ 'key' ] ) ) ) { $ this -> checkReservedKeyPattern ( $ args [ 'key' ] ) ; call_user_func_array ( [ $ this , 'storeKeywords' ] , array_only ( $ args , [ 'key' , 'minutes' , 'keywords' ] ) ) ; $ this -> setKeywordsOperation ( true ) ; $ value = call_user_func_array ( [ 'parent' , $ method ] , array_values ( $ args ) ) ; $ this -> setKeywordsOperation ( false ) ; } if ( ! $ this -> operatingOnKeywords ( ) ) { $ this -> resetCurrentKeywords ( ) ; } return $ value ; }
Fetch or store a default item in the cache using the specified method and arguments .
18,982
protected function determineKeywordsState ( $ key , array $ newKeywords = [ ] , array $ oldKeywords = [ ] ) { $ this -> setKeywordsOperation ( true ) ; static $ state = [ ] ; if ( ! isset ( $ state [ $ key ] ) || func_num_args ( ) > 1 ) { $ old = empty ( $ oldKeywords ) ? parent :: get ( $ this -> generateInverseIndexKey ( $ key ) , [ ] ) : $ oldKeywords ; $ new = $ this -> mergeKeywords ? array_unique ( array_merge ( $ old , $ newKeywords ) ) : $ newKeywords ; $ state [ $ key ] = [ 'old' => $ old , 'new' => $ new , 'obsolete' => array_diff ( $ old , $ new ) , ] ; } $ this -> setKeywordsOperation ( false ) ; return $ state [ $ key ] ; }
Assembles a comparison of the provided keywords against the current state for a given key .
18,983
protected function storeKeywords ( $ key , $ minutes = null , array $ keywords = [ ] ) { $ keywords = empty ( $ keywords ) ? $ this -> keywords : $ keywords ; $ this -> determineKeywordsState ( $ key , $ keywords ) ; $ this -> updateKeywordIndex ( $ key ) ; $ this -> updateInverseIndex ( $ key , $ minutes ) ; }
Stores the defined keywords for the provided key .
18,984
protected function updateKeywordIndex ( $ key ) { $ this -> setKeywordsOperation ( true ) ; $ keywordsState = $ this -> determineKeywordsState ( $ key ) ; foreach ( array_merge ( $ keywordsState [ 'new' ] , $ keywordsState [ 'obsolete' ] ) as $ keyword ) { $ indexKey = $ this -> generateIndexKey ( $ keyword ) ; $ oldIndex = parent :: pull ( $ indexKey , [ ] ) ; $ newIndex = in_array ( $ keyword , $ keywordsState [ 'obsolete' ] ) ? array_values ( array_diff ( $ oldIndex , [ $ key ] ) ) : array_values ( array_unique ( array_merge ( $ oldIndex , [ $ key ] ) ) ) ; if ( ! empty ( $ newIndex ) ) { parent :: forever ( $ indexKey , $ newIndex ) ; } } $ this -> setKeywordsOperation ( false ) ; }
Updates keyword indices for the given cache key .
18,985
protected function updateInverseIndex ( $ key , $ minutes = null ) { $ this -> setKeywordsOperation ( true ) ; $ keywordsState = $ this -> determineKeywordsState ( $ key ) ; $ inverseIndexKey = $ this -> generateInverseIndexKey ( $ key ) ; if ( empty ( $ keywordsState [ 'new' ] ) ) { parent :: forget ( $ inverseIndexKey ) ; } elseif ( $ keywordsState [ 'old' ] != $ keywordsState [ 'new' ] ) { $ newInverseIndex = array_values ( $ keywordsState [ 'new' ] ) ; is_null ( $ minutes ) ? parent :: forever ( $ inverseIndexKey , $ newInverseIndex ) : parent :: put ( $ inverseIndexKey , $ newInverseIndex , $ minutes ) ; } $ this -> setKeywordsOperation ( false ) ; }
Updates the inverse index for the given cache key .
18,986
protected function trackEcommerce ( $ type = self :: ECOMMERCE_TRANSACTION , array $ options = [ ] ) { $ this -> addItem ( "ga('require', 'ecommerce');" ) ; $ item = "ga('ecommerce:{$type}', { " ; $ item .= $ this -> assembleParameters ( $ options ) ; $ item = rtrim ( $ item , ', ' ) . " });" ; $ this -> addItem ( $ item ) ; $ this -> addItem ( "ga('ecommerce:send');" ) ; }
Track an ecommerce item .
18,987
public function getForumPostsAll ( $ searchCriteria ) { $ allPosts = [ ] ; $ currentPage = 1 ; do { $ response = $ this -> getForumPostsByPage ( $ searchCriteria , $ currentPage ) ; $ allPosts = array_merge ( $ allPosts , $ response -> results ) ; $ currentPage ++ ; } while ( $ currentPage <= $ response -> totalPages ) ; return $ allPosts ; }
Fetch all forum posts that match the given search criteria
18,988
public function createForumPost ( $ topicID , $ authorID , $ post , $ extra = [ ] ) { $ data = [ "topic" => $ topicID , "author" => $ authorID , "post" => $ post ] ; $ data = array_merge ( $ data , $ extra ) ; $ validator = \ Validator :: make ( $ data , [ "topic" => "required|numeric" , "author" => "required|numeric" , "post" => "required|string" , "author_name" => "required_if:author,0|string" , "date" => "date_format:YYYY-mm-dd H:i:s" , "ip_address" => "ip" , "hidden" => "in:-1,0,1" , ] ) ; if ( $ validator -> fails ( ) ) { $ message = head ( array_flatten ( $ validator -> messages ( ) ) ) ; throw new Exceptions \ InvalidFormat ( $ message ) ; } return $ this -> postRequest ( "forums/posts" , $ data ) ; }
Create a forum post with the given data .
18,989
public function updateForumPost ( $ postId , $ data = [ ] ) { $ validator = \ Validator :: make ( $ data , [ "author" => "numeric" , "author_name" => "required_if:author,0|string" , "post" => "string" , "hidden" => "in:-1,0,1" , ] ) ; if ( $ validator -> fails ( ) ) { $ message = head ( array_flatten ( $ validator -> messages ( ) ) ) ; throw new Exceptions \ InvalidFormat ( $ message ) ; } return $ this -> postRequest ( "forums/posts/" . $ postId , $ data ) ; }
Update a forum post with the given ID .
18,990
public function getPaymentMethodGroups ( ) { $ response = $ this -> sendRequest ( $ this -> serviceBaseUrl . 'GetPaymentMethods' , [ 'MerchantLogin' => $ this -> auth -> getMerchantLogin ( ) , 'Language' => $ this -> culture ] , $ this -> requestMethod ) ; $ sxe = simplexml_load_string ( $ response ) ; $ this -> parseError ( $ sxe ) ; if ( ! $ sxe -> Methods -> Method ) { return [ ] ; } $ methods = [ ] ; foreach ( $ sxe -> Methods -> Method as $ method ) { $ methods [ ( string ) $ method -> attributes ( ) -> Code ] = ( string ) $ method -> attributes ( ) -> Description ; } return $ methods ; }
Returns the list of available payment method groups .
18,991
public function getRates ( $ shopSum , $ paymentMethod = '' , $ culture = null ) { if ( null === $ culture ) { $ culture = $ this -> culture ; } $ response = $ this -> sendRequest ( $ this -> serviceBaseUrl . 'GetRates' , [ 'MerchantLogin' => $ this -> auth -> getMerchantLogin ( ) , 'IncCurrLabel' => $ paymentMethod , 'OutSum' => $ shopSum , 'Language' => $ culture ] , $ this -> requestMethod ) ; $ sxe = simplexml_load_string ( $ response ) ; $ this -> parseError ( $ sxe ) ; if ( ! $ sxe -> Groups -> Group ) { return [ ] ; } $ groups = [ ] ; foreach ( $ sxe -> Groups -> Group as $ i => $ group ) { $ items = [ ] ; foreach ( $ group -> Items -> Currency as $ item ) { $ clientSum = ( double ) $ item -> Rate -> attributes ( ) -> IncSum ; $ item = ( array ) $ item ; $ items [ ] = $ item [ '@attributes' ] + [ 'ClientSum' => $ clientSum ] ; } $ groups [ ] = [ 'Code' => ( string ) $ group -> attributes ( ) -> Code , 'Description' => ( string ) $ group -> attributes ( ) -> Description , 'Items' => $ items , ] ; } return $ groups ; }
Returns the sums with commission and some addition data .
18,992
public function getInvoice ( $ invoiceId = null ) { $ signature = $ this -> auth -> getSignatureHash ( '{ml}:{ii}:{vp}' , [ 'ml' => $ this -> auth -> getMerchantLogin ( ) , 'ii' => $ invoiceId , 'vp' => $ this -> auth -> getValidationPassword ( ) , ] ) ; $ response = $ this -> sendRequest ( $ this -> serviceBaseUrl . 'OpState' , [ 'MerchantLogin' => $ this -> auth -> getMerchantLogin ( ) , 'InvoiceID' => $ invoiceId , 'Signature' => $ signature ] , $ this -> requestMethod ) ; $ sxe = simplexml_load_string ( $ response ) ; $ this -> parseError ( $ sxe ) ; return [ 'InvoiceId' => ( int ) $ invoiceId , 'StateCode' => ( int ) $ sxe -> State -> Code , 'RequestDate' => new \ DateTime ( ( string ) $ sxe -> State -> RequestDate ) , 'StateDate' => new \ DateTime ( ( string ) $ sxe -> State -> StateDate ) , 'PaymentMethod' => ( string ) $ sxe -> Info -> IncCurrLabel , 'ClientSum' => ( float ) $ sxe -> Info -> IncSum , 'ClientAccount' => ( string ) $ sxe -> Info -> IncAccount , 'PaymentMethodCode' => ( string ) $ sxe -> Info -> PaymentMethod -> Code , 'PaymentMethodDescription' => ( string ) $ sxe -> Info -> PaymentMethod -> Description , 'Currency' => ( string ) $ sxe -> Info -> OutCurrLabel , 'ShopSum' => ( float ) $ sxe -> Info -> OutSum , ] ; }
Returns detailed information on the current status and payment details .
18,993
protected function sendRequest ( $ url , array $ params , $ method ) { $ method = strtolower ( $ method ) ; $ options = [ CURLOPT_RETURNTRANSFER => true , ] ; if ( self :: REQUEST_METHOD_GET === $ method ) { $ url .= '?' . http_build_query ( $ params ) ; } else { $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = http_build_query ( $ params ) ; } $ ch = curl_init ( $ url ) ; curl_setopt_array ( $ ch , $ options ) ; $ response = curl_exec ( $ ch ) ; if ( ! $ response ) { throw new \ RuntimeException ( 'cURL: ' . curl_error ( $ ch ) , curl_errno ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ response ; }
Send request and return response .
18,994
public function clear ( $ key = null ) { if ( isset ( $ key ) ) { if ( isset ( $ this -> data [ $ key ] ) ) { unset ( $ this -> data [ $ key ] ) ; } } else { $ this -> data = [ ] ; } }
Clear a key within the cache data or call without an argument to clear all the cached data .
18,995
private function createFakeRequest ( ServerRequestInterface $ psrRequest ) : Request { $ server = [ ] ; $ uri = $ psrRequest -> getUri ( ) ; if ( $ uri instanceof UriInterface ) { $ server [ 'SERVER_NAME' ] = $ uri -> getHost ( ) ; $ server [ 'SERVER_PORT' ] = $ uri -> getPort ( ) ; $ server [ 'REQUEST_URI' ] = $ uri -> getPath ( ) ; $ server [ 'QUERY_STRING' ] = $ uri -> getQuery ( ) ; } $ server [ 'REQUEST_METHOD' ] = $ psrRequest -> getMethod ( ) ; $ server = \ array_replace ( $ server , $ psrRequest -> getServerParams ( ) ) ; $ parsedBody = $ psrRequest -> getParsedBody ( ) ; $ parsedBody = \ is_array ( $ parsedBody ) ? $ parsedBody : [ ] ; $ request = new Request ( $ psrRequest -> getQueryParams ( ) , $ parsedBody , $ psrRequest -> getAttributes ( ) , $ psrRequest -> getCookieParams ( ) , [ ] , $ server , '' ) ; $ request -> headers -> replace ( $ psrRequest -> getHeaders ( ) ) ; return $ request ; }
Create a fake Symfony request without files and without body to match .
18,996
protected function verifyExpiration ( array $ tokenData ) { if ( ! isset ( $ tokenData [ 'expirationDateTime' ] ) ) { return ; } $ expirationDateTime = \ DateTime :: createFromFormat ( \ DateTime :: ISO8601 , $ tokenData [ 'expirationDateTime' ] ) ; if ( $ this -> now instanceof DependencyProxy ) { $ this -> now -> _activateDependency ( ) ; } if ( $ expirationDateTime < $ this -> now ) { throw new AccessDeniedException ( sprintf ( 'Token expired!%sThis token expired at "%s"' , chr ( 10 ) , $ expirationDateTime -> format ( \ DateTime :: ISO8601 ) ) , 1429697439 ) ; } }
Checks whether the token is expired
18,997
protected function verifySecurityContextHash ( array $ tokenData , HttpRequest $ httpRequest ) { if ( ! isset ( $ tokenData [ 'securityContextHash' ] ) ) { return ; } $ actionRequest = $ this -> objectManager -> get ( ActionRequest :: class , $ httpRequest ) ; $ this -> securityContext -> setRequest ( $ actionRequest ) ; if ( $ tokenData [ 'securityContextHash' ] !== $ this -> securityContext -> getContextHash ( ) ) { $ this -> emitInvalidSecurityContextHash ( $ tokenData , $ httpRequest ) ; throw new AccessDeniedException ( sprintf ( 'Invalid security hash!%sThis request is signed for a security context hash of "%s", but the current hash is "%s"' , chr ( 10 ) , $ tokenData [ 'securityContextHash' ] , $ this -> securityContext -> getContextHash ( ) ) , 1429705633 ) ; } }
Checks whether the current request has the same security context hash as the one of the token
18,998
protected function getElapsedTime ( $ start ) { if ( $ this -> elapsedTimeMethod === null ) { $ reflection = new ReflectionClass ( $ this -> getConnect ( ) ) ; $ this -> elapsedTimeMethod = $ reflection -> getMethod ( 'getElapsedTime' ) ; $ this -> elapsedTimeMethod -> setAccessible ( true ) ; } return $ this -> elapsedTimeMethod -> invoke ( $ this -> getConnect ( ) , $ start ) ; }
Get the elapsed time since a given starting point .
18,999
protected function cleanupPackages ( Storage $ storage ) { $ this -> outputLine ( ) ; $ this -> outputLine ( 'Cleanup packages ...' ) ; $ this -> outputLine ( '--------------------' ) ; $ count = $ this -> importer -> cleanupPackages ( $ storage , function ( NodeInterface $ package ) { $ this -> outputLine ( sprintf ( '%s deleted' , $ package -> getLabel ( ) ) ) ; } ) ; if ( $ count > 0 ) { $ this -> outputLine ( sprintf ( ' Deleted %d package(s)' , $ count ) ) ; } }
Remove packages that don t exist on Packagist