idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
60,200
public function with ( $ key , $ value ) { $ this -> hasData = true ; $ this -> session -> create ( $ key , $ value ) ; return $ this ; }
To store data in a session
60,201
public function backWith ( $ key , $ value ) { $ this -> with ( $ key , $ value ) ; $ url = $ this -> session -> get ( 'previous_uri' ) ; header ( 'location: ' . $ url ) ; exit ( ) ; }
To redirect back with value
60,202
public static function createRingRequest ( RequestInterface $ request ) { $ options = $ request -> getConfig ( ) -> toArray ( ) ; $ url = $ request -> getUrl ( ) ; $ qs = ( $ pos = strpos ( $ url , '?' ) ) ? substr ( $ url , $ pos + 1 ) : null ; return [ 'scheme' => $ request -> getScheme ( ) , 'http_method' => $ reque...
Creates a Ring request from a request object .
60,203
public static function prepareRingRequest ( Transaction $ trans ) { $ trans -> exception = null ; $ request = self :: createRingRequest ( $ trans -> request ) ; if ( $ trans -> request -> getEmitter ( ) -> hasListeners ( 'progress' ) ) { $ emitter = $ trans -> request -> getEmitter ( ) ; $ request [ 'client' ] [ 'progr...
Creates a Ring request from a request object AND prepares the callbacks .
60,204
public static function completeRingResponse ( Transaction $ trans , array $ response , MessageFactoryInterface $ messageFactory ) { $ trans -> state = 'complete' ; $ trans -> transferInfo = isset ( $ response [ 'transfer_stats' ] ) ? $ response [ 'transfer_stats' ] : [ ] ; if ( ! empty ( $ response [ 'status' ] ) ) { $...
Handles the process of processing a response received from a ring handler . The created response is added to the transaction and the transaction stat is set appropriately .
60,205
public static function fromRingRequest ( array $ request ) { $ options = [ ] ; if ( isset ( $ request [ 'version' ] ) ) { $ options [ 'protocol_version' ] = $ request [ 'version' ] ; } if ( ! isset ( $ request [ 'http_method' ] ) ) { throw new \ InvalidArgumentException ( 'No http_method' ) ; } return new Request ( $ r...
Creates a Guzzle request object using a ring request array .
60,206
protected function objectToArray ( $ obj ) : array { if ( $ obj instanceof \ stdClass ) { $ obj = json_decode ( json_encode ( $ obj ) , true ) ; } return ( array ) $ obj ; }
Helper method to convert a \ stdClass into an array
60,207
public static function createView ( $ sCtrlName = null , $ sActionName ) { $ sViewsRoot = AppHelper :: getInstance ( ) -> getComponentRoot ( 'views' ) ; $ sAddPath = '' ; if ( ! empty ( $ sCtrlName ) ) { $ sAddPath .= DIRECTORY_SEPARATOR . strtolower ( $ sCtrlName ) ; } $ sViewFile = $ sViewsRoot . $ sAddPath . DIRECTO...
The method creates a view object assigned with the specific controller and action in it . If controller name is empty it means a markup file determined only with action name . It doesn t physically consist into the direcory named as controller it s in the root of the view directory .
60,208
public static function createLayout ( $ sLayoutName , View $ oView ) { $ sLayoutsRoot = AppHelper :: getInstance ( ) -> getComponentRoot ( 'layouts' ) ; $ sLayoutFile = $ sLayoutsRoot . DIRECTORY_SEPARATOR . strtolower ( $ sLayoutName ) . '.php' ; if ( is_readable ( $ sLayoutFile ) ) { return new Layout ( $ sLayoutFile...
It creates a layout object .
60,209
public static function createSnippet ( $ sSnptName ) { $ sSnptRoot = AppHelper :: getInstance ( ) -> getComponentRoot ( 'snippets' ) ; $ SnptFile = $ sSnptRoot . DIRECTORY_SEPARATOR . strtolower ( $ sSnptName ) . '.php' ; if ( is_readable ( $ SnptFile ) ) { return new Snippet ( $ SnptFile ) ; } return null ; }
The method creates a snippet - object .
60,210
public function addStylesheetGoogleFonts ( ) { $ str = '' ; foreach ( $ this -> fonts as $ url ) { $ str .= sprintf ( '<link href="%s" rel="stylesheet">' , $ url ) ; } return $ str ; }
Build the stylesheet links of google fonts .
60,211
private function setAppNamespace ( $ oldNamespace , $ newNamespace ) { $ files = $ this -> filesystem -> files ( app_path ( ) ) ; foreach ( $ files as $ file ) { $ content = $ this -> filesystem -> get ( $ file ) ; $ this -> filesystem -> create ( $ file , preg_replace ( "/\\b" . $ oldNamespace . "\\b/" , $ newNamespac...
To set app directory files namespace
60,212
private function setBootstrapNamespace ( $ oldNamespace , $ newNamespace ) { $ files = $ this -> filesystem -> files ( base_path ( ) . '/bootstrap' ) ; foreach ( $ files as $ file ) { $ content = $ this -> filesystem -> get ( $ file ) ; $ this -> filesystem -> create ( $ file , str_replace ( $ oldNamespace . '\Controll...
To set bootstrap file namespace
60,213
private function setConfigNamespace ( $ oldNamespace , $ newNamespace ) { $ files = $ this -> filesystem -> files ( base_path ( ) . '/config' ) ; foreach ( $ files as $ file ) { $ content = $ this -> filesystem -> get ( $ file ) ; $ this -> filesystem -> create ( $ file , preg_replace ( "/\\b" . $ oldNamespace . "\\b/"...
To set config directory files namespace
60,214
private function setComposerNamespace ( $ oldNamespace , $ newNamespace ) { $ files = $ this -> filesystem -> files ( base_path ( ) . '/vendor/composer' ) ; foreach ( $ files as $ file ) { $ content = $ this -> filesystem -> get ( $ file ) ; $ this -> filesystem -> create ( $ file , preg_replace ( "/\\b" . $ oldNamespa...
To set composer namespace
60,215
protected function loadCliOptions ( array $ opts ) { $ map = [ 'c' => 'conf_file' , 's' => 'servers' , 'n' => 'workerNum' , 'u' => 'user' , 'g' => 'group' , 'l' => 'logFile' , 'p' => 'pidFile' , 'r' => 'maxRunTasks' , 'x' => 'maxLifetime' , 't' => 'timeout' , ] ; if ( isset ( $ opts [ 'h' ] ) || isset ( $ opts [ 'help'...
load the command line options
60,216
public function _transform ( array $ array = null ) { if ( empty ( $ array ) ) return ; foreach ( $ array as $ param ) { if ( strpos ( $ param , '=' ) > 0 ) { $ tmp = explode ( Generic :: ASSIGNMENT_OPERATOR , $ param ) ; $ this -> $ tmp [ 0 ] = $ tmp [ 1 ] ; } } return ; }
adapted transform method for the argv we need a different approach ofc
60,217
public function render ( array $ notifications , $ type = 'info' ) { if ( in_array ( $ type , $ this -> supportedTypes ) === false ) { $ type = 'info' ; } if ( empty ( $ notifications ) === true ) { return '' ; } $ html = $ this -> createHtmlByType ( $ notifications , $ type ) ; return $ html ; }
Renders all messages as part of the notification stack beneath the defined identifier as HTML
60,218
private function createHtmlByType ( array $ notifications , $ type ) { $ html = "<div class='alert-box {$type} radius' data-alert>" ; foreach ( $ notifications as $ notification ) { $ html .= "{$notification}" ; if ( end ( $ notifications ) !== $ notification ) { $ html .= "<br />" ; } } $ html .= "<a href='#' class='c...
Create and return html string .
60,219
public static function random ( $ size = 32 ) { $ bytes = openssl_random_pseudo_bytes ( $ size , $ strong ) ; if ( $ bytes !== false && $ strong !== false ) { $ string = '' ; while ( ( $ len = strlen ( $ string ) ) < $ size ) { $ length = $ size - $ len ; $ string .= substr ( str_replace ( [ '/' , '+' , '=' ] , '' , ba...
To generate random string
60,220
public function getJobInfo ( $ Job ) : void { $ uptimeSeconds = time ( ) - $ this -> startupTime ; $ uptimeSeconds = ( $ uptimeSeconds === 0 ) ? 1 : $ uptimeSeconds ; $ avgJobsMin = $ this -> jobsTotal / ( $ uptimeSeconds / 60 ) ; $ avgJobsMin = round ( $ avgJobsMin , 2 ) ; $ response = [ 'jobs_total' => $ this -> jobs...
Returns information about jobs handled .
60,221
public function updatePidFile ( ) : void { $ pidFolder = $ this -> getRunPath ( $ this -> poolName ) ; if ( ! file_exists ( $ pidFolder ) ) { mkdir ( $ pidFolder , 0755 , true ) ; } $ pidFile = $ pidFolder . '/' . $ this -> workerName . '.pid' ; $ pid = getmypid ( ) ; if ( file_put_contents ( $ pidFile , $ pid ) === fa...
Updates PID file for the worker .
60,222
public function getSubParsers ( ) { $ result = array ( ) ; $ dir = __DIR__ . '/DynamicItem' ; if ( is_dir ( $ dir ) && is_readable ( $ dir ) ) { $ matches = null ; foreach ( scandir ( $ dir ) as $ item ) { if ( ( $ item [ 0 ] !== '.' ) && preg_match ( '/^(.+)\.php$/i' , $ item , $ matches ) && ( $ matches [ 1 ] !== 'Dy...
Returns the fully - qualified class names of all the sub - parsers .
60,223
public function injectActionHandles ( EventInterface $ event ) { $ handles = $ this -> getActionHandles ( $ event ) ; foreach ( $ handles as $ handle ) { $ this -> updater -> addHandle ( $ handle ) ; } }
Callback handler invoked when the dispatch event is triggered .
60,224
protected function getActionHandles ( EventInterface $ event ) { $ routeMatch = $ event -> getRouteMatch ( ) ; $ controller = $ event -> getTarget ( ) ; if ( is_object ( $ controller ) ) { $ controller = get_class ( $ controller ) ; } $ routeMatchController = $ routeMatch -> getParam ( 'controller' , '' ) ; if ( ! $ co...
Retrieve the action handles from the matched route .
60,225
public function _generateLine ( $ string , $ start = 5 ) { if ( $ this -> options [ 'trace' ] [ 'enabled' ] ) { $ trace = $ this -> _stackString ( $ this -> options [ 'trace' ] [ 'depth' ] , $ start + $ this -> options [ 'trace' ] [ 'offset' ] , $ this -> options [ 'separator' ] ) ; } else { $ trace = "" ; } $ result =...
Common method for generating the main logging line .
60,226
public function _toFile ( $ file = null ) { $ file = $ file ? : sys_get_temp_dir ( ) . '/belt_trace.log' ; $ this -> options [ 'printer' ] = 'file://' . $ file ; return $ this ; }
Use file based output . Useful to work around nginx s log swallowing annoyingness .
60,227
public static function dump ( $ dirs , $ file , $ blackList = null ) { $ maps = array ( ) ; foreach ( $ dirs as $ dir ) { $ maps = array_merge ( $ maps , static :: createMap ( $ dir , null , null , $ blackList ) ) ; } file_put_contents ( $ file , sprintf ( '<?php return %s;' , var_export ( $ maps , true ) ) ) ; }
Generate a class map file .
60,228
private static function pathMatchesRegex ( $ path , $ blackList ) { foreach ( $ blackList as $ item ) { $ match = '#' . strtr ( $ item , '#' , '\#' ) . '#' ; if ( preg_match ( $ match , $ path ) ) { return true ; } } return false ; }
Test path against blacklist regex list .
60,229
private static function extractClasses ( $ contents , $ extraTypes ) { $ contents = preg_replace ( '{<<<\s*(\'?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\2(?=\r\n|\n|\r|;)}s' , 'null' , $ contents ) ; $ contents = preg_replace ( '{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s' , 'null' , $ co...
Prepare the file contents .
60,230
private static function buildClassList ( $ matches ) { if ( array ( ) === $ matches ) { return array ( ) ; } $ classes = array ( ) ; $ namespace = '' ; for ( $ i = 0 , $ len = count ( $ matches [ 'type' ] ) ; $ i < $ len ; $ i ++ ) { if ( ! empty ( $ matches [ 'ns' ] [ $ i ] ) ) { $ namespace = str_replace ( array ( ' ...
Build the class list from the passed matches .
60,231
public function optimize ( stdClass $ data ) { $ data -> modelDirectory = str_replace ( '/http/controllers' , '/models' , $ data -> controllerDestination ) ; $ data -> modelNamespace = str_replace ( '\\http\\controllers' , '\\models' , $ data -> controllerNamespace ) ; foreach ( $ data -> database as $ dbItem ) { $ dbI...
Optimizing configuration for models
60,232
private function getTableColumns ( string $ tableName ) { $ columns = DB :: getSchemaBuilder ( ) -> getColumnListing ( $ tableName ) ; if ( ! count ( $ columns ) ) $ this -> abort ( "Table not found: " . $ tableName ) ; else $ columns = DB :: select ( DB :: raw ( 'SHOW COLUMNS FROM ' . $ tableName ) ) ; return $ column...
Getting table columns
60,233
private function getColumnsFillable ( array $ columns , bool $ translations = false ) { $ names = [ ] ; foreach ( $ columns as $ column ) { if ( $ translations ) { if ( ! in_array ( $ column -> Field , $ this -> getTranslationsAutoFill ( ) ) ) array_push ( $ names , $ column -> Field ) ; } else if ( ! in_array ( $ colu...
Get models fillable fields
60,234
public function shareData ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ variableName => $ variableValue ) { $ this -> templateRenderer -> setData ( $ variableName , $ variableValue ) ; } return $ this ; } $ this -> templateRenderer -> setData ( $ key , $ value ) ; return $ this ; }
Shares data with package template files .
60,235
public function ignorePath ( $ path ) { if ( is_array ( $ path ) ) { foreach ( $ path as $ pathToIgnore ) { $ this -> ignorePath ( $ pathToIgnore ) ; } return $ this ; } $ this -> ignoredPaths [ ] = $ path ; return $ this ; }
Adds a path to the ignore list .
60,236
public static function filtered ( $ classes = array ( ) , $ files = array ( ) , & $ stack = null ) { $ skip_self_trace = 0 ; if ( $ stack === null ) { $ stack = debug_backtrace ( ) ; } $ classes = array_merge ( ( array ) $ classes , array ( __CLASS__ ) ) ; $ files = array_merge ( ( array ) $ files , array ( __FILE__ ) ...
Generates a stack trace while skipping internal and self calls .
60,237
public function getLevel ( ) { if ( $ page = $ this -> getCurrentPage ( Page :: class ) ) { if ( ! $ page -> Children ( ) -> exists ( ) ) { $ parent = $ page -> getParent ( ) ; while ( $ parent && ! $ parent -> Children ( ) -> exists ( ) ) { $ parent = $ parent -> getParent ( ) ; } return $ parent ; } return $ page ; }...
Answers the page object at the current level .
60,238
public function batchRun ( $ is_hook , $ method_name , array $ params = NULL ) { if ( $ params == NULL ) { $ params = array ( ) ; } $ results = array ( ) ; if ( ! $ this -> modules ) $ this -> modules = array ( ) ; foreach ( $ this -> modules as $ name => $ module ) { if ( method_exists ( $ module , $ method_name ) ) {...
Batch runs a method on all modules .
60,239
public function deserialize ( $ serializedPayload ) { $ xpath = $ this -> _helper -> getPayloadAsXPath ( $ serializedPayload , $ this -> _getXmlNamespace ( ) ) ; $ this -> _deserializeExtractionPaths ( $ xpath ) -> _deserializeOptionalExtractionPaths ( $ xpath ) -> _deserializeBooleanExtractionPaths ( $ xpath ) -> _des...
Fill out this payload object with data from the supplied string .
60,240
protected function _deserializeOptionalExtractionPaths ( DOMXPath $ xpath ) { foreach ( $ this -> _optionalExtractionPaths as $ setter => $ path ) { $ foundNode = $ xpath -> query ( $ path ) -> item ( 0 ) ; if ( $ foundNode ) { $ this -> $ setter ( $ foundNode -> nodeValue ) ; } } return $ this ; }
When optional nodes are not included in the serialized data they should not be set in the payload . Fortunately these are all string values so no additional type conversion is necessary .
60,241
protected function _deserializeBooleanExtractionPaths ( DOMXPath $ xpath ) { foreach ( $ this -> _booleanExtractionPaths as $ setter => $ path ) { $ value = $ xpath -> evaluate ( $ path ) ; $ this -> $ setter ( $ this -> _helper -> convertStringToBoolean ( $ value ) ) ; } return $ this ; }
boolean values have to be handled specially
60,242
protected function _deserializeDateTimeExtractionPaths ( DOMXPath $ xpath ) { foreach ( $ this -> _dateTimeExtractionPaths as $ setter => $ path ) { $ value = $ xpath -> evaluate ( $ path ) ; if ( $ value ) { $ this -> $ setter ( new DateTime ( $ value ) ) ; } } return $ this ; }
Ensure any date time string is instantiate
60,243
protected function _serializeRootAttributes ( ) { $ rootAttributes = $ this -> _getRootAttributes ( ) ; $ qualifyAttributes = function ( $ name ) use ( $ rootAttributes ) { return sprintf ( '%s="%s"' , $ name , $ rootAttributes [ $ name ] ) ; } ; $ qualifiedAttributes = array_map ( $ qualifyAttributes , array_keys ( $ ...
Serialize Root Attributes
60,244
protected function _serializeNode ( $ nodeName , $ value ) { return sprintf ( '<%s>%s</%1$s>' , $ nodeName , $ this -> xmlEncode ( $ this -> _helper -> escapeHtml ( $ value ) ) ) ; }
Serialize the value as an xml element with the given node name .
60,245
protected function _serializeBooleanNode ( $ nodeName , $ value ) { if ( ! $ this -> _helper -> convertStringToBoolean ( $ value ) ) { return sprintf ( '<%s>0</%1$s>' , $ nodeName ) ; } else { return sprintf ( '<%s>%s</%1$s>' , $ nodeName , $ this -> _helper -> convertStringToBoolean ( $ value ) ) ; } }
Serialize the boolean value as an xml element with the given node name .
60,246
protected function _serializeOptionalValue ( $ nodeName , $ value ) { return ( ! is_null ( $ value ) && $ value !== '' ) ? $ this -> _serializeNode ( $ nodeName , $ value ) : '' ; }
Serialize the value as an xml element with the given node name . When given an empty value returns an empty string instead of an empty element .
60,247
protected function _serializeOptionalAmount ( $ nodeName , $ amount , $ currencyCode = null ) { if ( $ currencyCode ) { return ( ! is_null ( $ amount ) && ! is_nan ( $ amount ) ) ? "<$nodeName currencyCode=\"$currencyCode\">{$this->_helper->formatAmount($amount)}</$nodeName>" : '' ; } else { return ( ! is_null ( $ amou...
Serialize the currency amount as an XML node with the provided name . When the amount is not set returns an empty string .
60,248
public function store_notifications ( $ queue_id , array $ notifications , Strategy $ strategy = null ) { $ all = get_option ( $ this -> bucket , array ( ) ) ; $ found = empty ( $ all ) ? false : true ; if ( empty ( $ notifications ) ) { return $ this -> clear_notifications ( $ queue_id ) ; } $ all [ $ queue_id ] = arr...
Store a set of notifications .
60,249
public function get_notifications ( $ queue_id ) { $ all = get_option ( $ this -> bucket , array ( ) ) ; if ( isset ( $ all [ $ queue_id ] [ 'notifications' ] ) ) { return $ all [ $ queue_id ] [ 'notifications' ] ; } else { return null ; } }
Get a set of notifications .
60,250
public function get_notifications_strategy ( $ queue_id ) { $ all = get_option ( $ this -> bucket , array ( ) ) ; if ( isset ( $ all [ $ queue_id ] [ 'strategy' ] ) ) { return $ all [ $ queue_id ] [ 'strategy' ] ; } else { return null ; } }
Get the strategy for a set of notifications .
60,251
public function clear_notifications ( $ queue_id ) { $ all = get_option ( $ this -> bucket , array ( ) ) ; if ( ! isset ( $ all [ $ queue_id ] ) ) { return false ; } unset ( $ all [ $ queue_id ] ) ; if ( empty ( $ all ) ) { delete_option ( $ this -> bucket ) ; } else { update_option ( $ this -> bucket , $ all ) ; } ret...
Clear a set of notifications .
60,252
public function clear_notification ( $ queue_id , Notification $ notification ) { $ notifications = $ this -> get_notifications ( $ queue_id ) ; $ notification = array_search ( $ notification , $ notifications ) ; if ( false === $ notification ) { return false ; } unset ( $ notifications [ $ notification ] ) ; return $...
Clear a single notification from storage .
60,253
public static function commandIsAvailable ( $ command ) { static $ cache = array ( ) ; if ( ! isset ( $ cache [ $ command ] ) ) { $ cache [ $ command ] = false ; $ safeMode = @ ini_get ( 'safe_mode' ) ; if ( empty ( $ safeMode ) ) { if ( function_exists ( 'exec' ) ) { if ( ! in_array ( 'exec' , array_map ( 'trim' , exp...
Checks if a gettext command is available .
60,254
protected function html ( Crawler $ crawler , $ removables = array ( ) ) { $ converter = new Converter ; $ html = trim ( $ converter -> convert ( $ crawler -> html ( ) ) ) ; foreach ( ( array ) $ removables as $ keyword ) { $ html = str_replace ( $ keyword , '' , $ html ) ; } $ html = str_replace ( ' ' , ' ' , ( strin...
Returns the HTML format of the body from the crawler .
60,255
protected function prepare ( $ link ) { $ response = Client :: request ( ( string ) $ link ) ; $ response = str_replace ( '<strong> </strong>' , ' ' , $ response ) ; $ this -> crawler = new Crawler ( $ response ) ; }
Initializes the crawler instance .
60,256
protected function remove ( $ elements ) { $ callback = function ( $ crawler ) { $ node = $ crawler -> getNode ( ( integer ) 0 ) ; $ node -> parentNode -> removeChild ( $ node ) ; } ; foreach ( ( array ) $ elements as $ removable ) { $ this -> crawler -> filter ( $ removable ) -> each ( $ callback ) ; } }
Removes specified HTML tags from body .
60,257
protected function replace ( Crawler $ crawler , $ element , $ callback ) { $ function = function ( Crawler $ crawler ) use ( $ callback ) { $ node = $ crawler -> getNode ( 0 ) ; $ html = $ node -> ownerDocument -> saveHtml ( $ node ) ; $ text = $ callback ( $ crawler , ( string ) $ html ) ; return array ( ( string ) $...
Replaces a specified HTML tag based from the given callback .
60,258
protected function title ( $ element , $ removable = '' ) { $ converter = new Converter ; $ crawler = $ this -> crawler -> filter ( $ element ) ; $ html = $ crawler -> first ( ) -> html ( ) ; $ html = str_replace ( $ removable , '' , $ html ) ; return $ converter -> convert ( ( string ) $ html ) ; }
Returns the title text based from given HTML tag .
60,259
public function remoteDirectory ( $ directory , $ physical = false ) { $ this -> remoteDir = $ directory ; $ this -> physicalRemoteDir = $ physical ; return $ this ; }
Sets the remote directory .
60,260
protected function commandCallback ( $ callback ) { return ( function ( $ output ) use ( $ callback ) { $ this -> output .= $ output ; if ( is_callable ( $ callback ) ) { return call_user_func ( $ callback , $ output ) ; } } ) ; }
Wrap the callback so we can print the output .
60,261
protected function parseXml ( SplFileInfo $ file ) { $ dom = XmlUtils :: loadFile ( $ file , realpath ( dirname ( __DIR__ ) . DS . 'Schema' . DS . 'smarty_filter.xsd' ) ) ; $ xml = simplexml_import_dom ( $ dom , '\\Symfony\\Component\\DependencyInjection\\SimpleXMLElement' ) ; $ parsedConfig = [ ] ; foreach ( $ xml -> ...
Get config from xml file
60,262
protected function applyConfig ( array $ moduleConfiguration ) { foreach ( $ moduleConfiguration [ 'smarty_filter' ] as $ smartyFilterData ) { if ( SmartyFilterQuery :: create ( ) -> findOneByCode ( $ smartyFilterData [ 'code' ] ) === null ) { $ smartyFilter = ( new SmartyFilter ( ) ) -> setCode ( $ smartyFilterData [ ...
Save new smarty filter to database
60,263
protected function isValid ( ) { if ( ! $ this -> request -> ajax ( ) ) { return false ; } $ search = $ this -> request -> input ( 'search' ) ; if ( ! is_string ( $ search ) or strlen ( $ this -> request -> input ( 'search' ) ) <= 0 ) { return false ; } $ token = $ this -> request -> header ( 'search-protection' ) ; if...
validates submitted data from search form
60,264
private function validateToken ( $ token = null ) { if ( is_null ( $ token ) ) { return false ; } $ decrypted = Crypt :: decrypt ( $ token ) ; $ args = unserialize ( $ decrypted ) ; if ( ! isset ( $ args [ 'protection_string' ] ) or $ args [ 'protection_string' ] !== config ( 'antares/search::protection_string' ) ) { r...
validates protection token
60,265
public function boot ( ) { if ( ! $ this -> isValid ( ) ) { return false ; } $ serviceProvider = new \ Antares \ Customfields \ CustomFieldsServiceProvider ( app ( ) ) ; $ serviceProvider -> register ( ) ; $ serviceProvider -> boot ( ) ; $ query = e ( $ this -> request -> input ( 'search' ) ) ; $ cacheKey = 'search_' ....
Boots search query in lucene indexes
60,266
protected function getDatatableInstance ( $ classname ) { if ( ! class_exists ( $ classname ) ) { return false ; } $ datatable = app ( $ classname ) ; $ reflection = new ReflectionClass ( $ datatable ) ; if ( ( $ filename = $ reflection -> getFileName ( ) ) && ! str_contains ( $ filename , 'core' ) ) { if ( ! app ( 'an...
Gets instance of datatable
60,267
protected function _getStoreId ( ) { $ storeEnv = Mage :: app ( ) -> getStore ( ) ; if ( $ storeEnv -> isAdmin ( ) ) { $ quoteSession = $ this -> _orderHelper -> getAdminQuoteSessionModel ( ) ; $ storeEnv = $ quoteSession -> getStore ( ) ; } return $ storeEnv -> getId ( ) ; }
Get the store id for the order . In non - admin stores can use the current store . In admin stores must get the order the quote is actually being created in .
60,268
public function getNextId ( ) { $ last = $ this -> _orderHelper -> removeOrderIncrementPrefix ( $ this -> getLastId ( ) ) ; return $ this -> format ( bcadd ( $ last , 1 ) ) ; }
Get the next increment id by incrementing the last id
60,269
protected function getDependencyMapping ( ) { $ constructor = ( new ReflectionClass ( $ this -> className ) ) -> getConstructor ( ) ; $ dependencies = [ ] ; if ( ! is_null ( $ constructor ) ) { foreach ( $ constructor -> getParameters ( ) as $ param ) { $ dependencies [ $ param -> getClass ( ) -> getName ( ) ] = $ para...
Get a mapping of class name = > member name dependencies .
60,270
protected function mockDependencies ( ) { $ dependencies = $ this -> getDependencyMapping ( ) ; foreach ( $ dependencies as $ interface => $ memberName ) { if ( ! isset ( $ this -> $ memberName ) ) { $ this -> $ memberName = Mockery :: mock ( $ interface ) ; } $ dependencies [ $ interface ] = $ this -> $ memberName ; }...
Mock all dependencies that were not set yet
60,271
public function download ( Application $ application , string $ commit , string $ targetFile ) : bool { $ username = $ application -> parameter ( 'gh.owner' ) ; $ repository = $ application -> parameter ( 'gh.repo' ) ; if ( ! $ username || ! $ repository ) { throw new VCSException ( self :: ERR_APP_MISCONFIGURED ) ; } ...
Get content of archives in a repository
60,272
static function auth ( ProviderInterface $ provider ) { if ( ! require_get ( "code" , false ) ) { redirect ( $ provider -> getAuthorizationUrl ( ) ) ; return false ; } else { if ( ! \ Openclerk \ Events :: trigger ( 'oauth2_auth' , $ provider ) ) { throw new UserAuthenticationException ( "Login was cancelled by the sys...
Execute OAuth2 authentication and return the user .
60,273
static function removeIdentity ( \ Db \ Connection $ db , User $ user , $ provider , $ uid ) { if ( ! $ user ) { throw new \ InvalidArgumentException ( "No user provided." ) ; } $ q = $ db -> prepare ( "DELETE FROM user_oauth2_identities WHERE user_id=? AND provider=? AND uid=? LIMIT 1" ) ; return $ q -> execute ( arra...
Remove the given OAuth2 identity from the given user .
60,274
public static function select ( array $ columns = [ '*' ] , ... $ joinsColumns ) { $ query = new static ( Query \ Type :: SELECT ) ; $ query -> columns [ 't' ] = $ columns ; $ alias = 'j1' ; foreach ( $ joinsColumns as $ joinColumns ) { $ query -> columns [ $ alias ] = ( array ) $ joinColumns ; $ alias ++ ; } return $ ...
Creates instance of select - type Query .
60,275
protected function getTmpPath ( ) { $ tmpDir = sys_get_temp_dir ( ) ; if ( ! empty ( $ this -> prefix ) ) { $ tmpDir .= DIRECTORY_SEPARATOR . $ this -> prefix ; } $ tmpDir .= DIRECTORY_SEPARATOR . uniqid ( 'run-' , true ) ; return $ tmpDir ; }
Get path to temp directory
60,276
public function createTmpFile ( $ suffix = null , $ preserve = false ) { $ this -> initRunFolder ( ) ; $ file = uniqid ( ) ; if ( $ suffix ) { $ file .= '-' . $ suffix ; } $ fileInfo = new \ SplFileInfo ( $ this -> tmpRunFolder . DIRECTORY_SEPARATOR . $ file ) ; $ this -> filesystem -> touch ( $ fileInfo ) ; $ this -> ...
Create empty file in TMP directory
60,277
public function createFile ( $ fileName , $ preserve = false ) { $ this -> initRunFolder ( ) ; $ fileInfo = new \ SplFileInfo ( $ this -> tmpRunFolder . DIRECTORY_SEPARATOR . $ fileName ) ; $ this -> filesystem -> touch ( $ fileInfo ) ; $ this -> files [ ] = array ( 'file' => $ fileInfo , 'preserve' => $ preserve ) ; $...
Creates named temporary file
60,278
public function processUpdate ( array $ data ) { $ set = $ this -> formatCmd ( 'set' ) ; $ data [ $ set ] = isset ( $ data [ $ set ] ) ? $ data [ $ set ] : [ ] ; foreach ( $ data as $ index => $ value ) { if ( substr ( $ index , 0 , 1 ) !== $ this -> cmd ) { $ data [ $ set ] [ $ index ] = $ value ; unset ( $ data [ $ i...
Process update data
60,279
public function processCondition ( array $ conditions , $ depth = 0 ) { if ( empty ( $ conditions ) ) { return [ ] ; } $ parsed = [ ] ; foreach ( $ conditions as $ key => $ condition ) { if ( is_int ( $ key ) ) { if ( $ depth > 0 && is_array ( $ condition ) ) { throw new InvalidArgumentException ( 'Too deep sets of con...
Process sets of conditions and merges them by AND operator
60,280
private function parseCondition ( $ condition , $ parameters = [ ] ) { if ( strpos ( $ condition , ' ' ) ) { $ match = preg_match ( '~^ (.+)\s ## identifier ( (?:\$\w+) | ## $mongoOperator (?:[A-Z]+(?:_[A-Z]+)*) | ## NAMED_OPERATOR or (?:[\<\>\!]?\=|\>|\<\...
Parses single condition
60,281
private function parseDeepCondition ( array $ parameters , $ toArray = FALSE ) { $ opcond = [ ] ; foreach ( $ parameters as $ key => $ param ) { $ ccond = is_int ( $ key ) ? $ this -> parseCondition ( $ param ) : $ this -> parseCondition ( $ key , $ param ) ; if ( $ toArray ) { $ opcond [ ] = $ ccond ; } else { reset (...
Parses inner conditions
60,282
public function processData ( array $ data , $ expand = FALSE ) { $ return = [ ] ; foreach ( $ data as $ key => $ item ) { list ( $ modified , $ key ) = $ this -> doubledModifier ( $ key , '%' ) ; if ( $ modified && preg_match ( '#^(.*)%(\w+(?:\[\])?)$#' , $ key , $ parts ) ) { $ key = $ parts [ 1 ] ; $ item = $ this -...
Formats data types by modifiers
60,283
protected function processLikeOperator ( $ value ) { $ value = preg_quote ( $ value ) ; $ value = substr ( $ value , 0 , 1 ) === '%' ? ( substr ( $ value , - 1 , 1 ) === '%' ? substr ( $ value , 1 , - 1 ) : substr ( $ value , 1 ) . '$' ) : ( substr ( $ value , - 1 , 1 ) === '%' ? '^' . substr ( $ value , 0 , - 1 ) : $ ...
Converts SQL LIKE to MongoRegex
60,284
protected function processArray ( $ modifier , array & $ values ) { foreach ( $ values as & $ item ) { $ item = $ this -> processModifier ( $ modifier , $ item ) ; } }
Applies modifier to the inner array via reference
60,285
public function getDependencyConfig ( ) : array { return [ 'aliases' => [ SessionManager :: class => ManagerInterface :: class , ] , 'factories' => [ ConfigInterface :: class => SessionConfigFactory :: class , ManagerInterface :: class => SessionManagerFactory :: class , StorageInterface :: class => StorageFactory :: c...
Merge our config with Zend Session dependencies
60,286
public function & SetView ( \ MvcCore \ IView & $ view ) { parent :: SetView ( $ view ) ; if ( self :: $ appRoot === NULL ) self :: $ appRoot = $ this -> request -> GetAppRoot ( ) ; if ( self :: $ basePath === NULL ) self :: $ basePath = $ this -> request -> GetBasePath ( ) ; if ( self :: $ scriptName === NULL ) self :...
Insert a \ MvcCore \ View in each helper constructing
60,287
public function CssJsFileUrl ( $ path = '' ) { $ result = '' ; if ( self :: $ assetsUrlCompletion ) { $ result = $ this -> view -> AssetUrl ( $ path ) ; } else { $ result = self :: $ basePath . $ path ; } return $ result ; }
Completes CSS or JS file url .
60,288
protected function filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems ( $ items ) { $ itemsToRenderMinimized = [ ] ; $ itemsToRenderSeparately = [ ] ; foreach ( $ items as & $ item ) { $ itemArr = array_merge ( ( array ) $ item , [ ] ) ; unset ( $ itemArr [ 'path' ] ) ; if ( isset ( $ itemArr [ 'render' ] ) ) un...
Look for every item to render if there is any doNotMinify record to render item separately
60,289
protected function addFileModificationImprintToHrefUrl ( $ url , $ path ) { $ questionMarkPos = strpos ( $ url , '?' ) ; $ separator = ( $ questionMarkPos === FALSE ) ? '?' : '&' ; $ strippedUrl = $ questionMarkPos !== FALSE ? substr ( $ url , $ questionMarkPos ) : $ url ; $ srcPath = $ this -> getAppRoot ( ) . substr ...
Add to href URL file modification param by original file
60,290
protected function getIndentString ( $ indent = 0 ) { $ indentStr = '' ; if ( is_numeric ( $ indent ) ) { $ indInt = intval ( $ indent ) ; if ( $ indInt > 0 ) { $ i = 0 ; while ( $ i < $ indInt ) { $ indentStr .= "\t" ; $ i += 1 ; } } } else if ( is_string ( $ indent ) ) { $ indentStr = $ indent ; } return $ indentStr ...
Get indent string
60,291
protected function getTmpDir ( ) { if ( ! self :: $ tmpDir ) { $ tmpDir = $ this -> getAppRoot ( ) . self :: $ globalOptions [ 'tmpDir' ] ; if ( ! \ MvcCore \ Application :: GetInstance ( ) -> GetCompiled ( ) ) { if ( ! is_dir ( $ tmpDir ) ) mkdir ( $ tmpDir , 0777 , TRUE ) ; if ( ! is_writable ( $ tmpDir ) ) { try { @...
Return and store application document root from controller view request object
60,292
protected function saveFileContent ( $ fullPath = '' , & $ fileContent = '' ) { $ toolClass = \ MvcCore \ Application :: GetInstance ( ) -> GetToolClass ( ) ; $ toolClass :: SingleProcessWrite ( $ fullPath , $ fileContent ) ; @ chmod ( $ fullPath , 0766 ) ; }
Save atomically file content in full path by 1 MB to not overflow any memory limits
60,293
protected function log ( $ msg = '' , $ logType = 'debug' ) { if ( self :: $ loggingAndExceptions ) { \ MvcCore \ Debug :: Log ( $ msg , $ logType ) ; } }
Log any render messages with optional log file name
60,294
protected function warning ( $ msg ) { if ( self :: $ loggingAndExceptions ) { \ MvcCore \ Debug :: BarDump ( '[' . get_class ( $ this ) . '] ' . $ msg , \ MvcCore \ IDebug :: DEBUG ) ; } }
Throw exception with given message with actual helper class name before
60,295
protected function getTmpFileFullPathByPartFilesInfo ( $ filesGroupInfo = [ ] , $ minify = FALSE , $ extension = '' ) { return implode ( '' , [ $ this -> getTmpDir ( ) , '/' . ( $ minify ? 'minified' : 'rendered' ) . '_' . $ extension . '_' , md5 ( implode ( ',' , $ filesGroupInfo ) . '_' . $ minify ) , '.' . $ extensi...
Complete items group tmp directory file name by group source files info
60,296
public function run ( $ jobs ) { $ lenTab = count ( $ jobs ) ; for ( $ i = 0 ; $ i < $ lenTab ; $ i ++ ) { $ jobID = rand ( 0 , 100 ) ; while ( count ( $ this -> currentJobs ) >= $ this -> maxProcesses ) { sleep ( $ this -> sleepTime ) ; } $ launched = $ this -> launchJobProcess ( $ jobID , "Jobs" , $ jobs [ $ i ] ) ; ...
Run the Daemon
60,297
protected function launchJob ( $ jobID ) { $ pid = pcntl_fork ( ) ; if ( $ pid == - 1 ) { error_log ( 'Could not launch new job, exiting' ) ; echo 'Could not launch new job, exiting' ; return false ; } else if ( $ pid ) { $ this -> currentJobs [ $ pid ] = $ jobID ; if ( isset ( $ this -> signalQueue [ $ pid ] ) ) { $ t...
Launch a job from the job queue
60,298
protected function getTableNames ( ) : array { $ dbName = $ this -> config [ DbItf :: DB_CFG_DATABASE ] ; $ resp = $ this -> dbRunQuery ( sprintf ( 'SHOW FULL TABLES FROM `%s`' , $ dbName ) ) ; $ tableAndViewNames = [ ] ; while ( $ row = $ resp -> fetch_assoc ( ) ) { $ tableAndViewNames [ ] = array_change_key_case ( $ ...
Return table and view names form the database .
60,299
public static function slashDirname ( $ dirname = null ) { if ( is_null ( $ dirname ) || empty ( $ dirname ) ) { return '' ; } return rtrim ( $ dirname , '/ ' . DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; }
Get a dirname with one and only trailing slash