idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
241,100
private function getCropPoints ( $ optimalWidth , $ optimalHeight , $ newWidth , $ newHeight ) { $ cropPoints = array ( ) ; $ vertical_start = arrayGet ( $ this -> config , 'crop_vertical_start_point' ) ; $ horizontal_start = arrayGet ( $ this -> config , 'crop_horizontal_start_point' ) ; switch ( $ vertical_start ) { ...
Gets the crop points based on the configuration either set in the file or overridden by user in their own config file or on the fly .
241,101
public static function toRavelryPostFile ( $ value , Parameter $ parameter ) { if ( is_string ( $ value ) ) { $ value = fopen ( $ value , 'r' ) ; } if ( ! ( $ value instanceof StreamInterface ) ) { $ value = \ GuzzleHttp \ Stream \ create ( $ value ) ; } if ( $ value instanceof MetadataStreamInterface ) { $ filename = ...
This is duplicating logic from GuzzleHttp \ Post \ PostFile in order to patch odd API server behavior . It also makes sure the value is a proper stream reference .
241,102
public function getPostType ( ) { global $ wp_query ; if ( isset ( $ wp_query -> post ) && $ wp_query -> post -> post_type ) { return $ wp_query -> post -> post_type ; } if ( isset ( $ wp_query -> query ) && isset ( $ wp_query -> query [ 'post_type' ] ) ) { return $ wp_query -> query [ 'post_type' ] ; } else if ( isset...
Return the post type slug if available
241,103
public function getTax ( ) { global $ wp_query ; if ( isset ( $ wp_query -> tax_query ) && ! empty ( $ wp_query -> tax_query ) ) { return reset ( $ wp_query -> tax_query -> queries ) [ 'taxonomy' ] ; } return false ; }
Return the taxonomy slug if available
241,104
public function getTerm ( ) { global $ wp_query ; if ( isset ( $ wp_query -> tax_query ) && ! empty ( $ wp_query -> tax_query ) ) { $ first = reset ( $ wp_query -> tax_query -> queries ) ; return is_array ( $ first ) ? reset ( $ first [ 'terms' ] ) : false ; } return false ; }
Return the taxonomy term if available
241,105
public function watch ( $ command , $ interval = 500 ) { $ count = 0 ; $ activeTime = time ( ) ; $ maxTime = ( int ) $ this -> config [ 'max_watch_time' ] ; $ intervalUs = $ interval * 1000 ; while ( true ) { $ count ++ ; $ result = $ this -> command ( $ command ) ; if ( 0 === strpos ( $ result , 'ERR' ) ) { echo "$res...
watch a command
241,106
public function interactive ( ) { echo "welcome! please input command('quit' or 'exit' to Quit).\n " ; while ( true ) { echo '> ' ; if ( $ cmd = trim ( fgets ( \ STDIN ) ) ) { if ( $ cmd === 'quit' || $ cmd === 'exit' ) { echo "Quit. Bye\n" ; break ; } echo $ this -> command ( $ cmd ) . PHP_EOL ; } usleep ( 50000 ) ; }...
into interactive environment
241,107
public function setSmartyFilter ( ChildSmartyFilter $ v = null ) { if ( $ v === null ) { $ this -> setId ( null ) ; } else { $ this -> setId ( $ v -> getId ( ) ) ; } $ this -> aSmartyFilter = $ v ; if ( $ v !== null ) { $ v -> addSmartyFilterI18n ( $ this ) ; } return $ this ; }
Declares an association between this object and a ChildSmartyFilter object .
241,108
public function getSmartyFilter ( ConnectionInterface $ con = null ) { if ( $ this -> aSmartyFilter === null && ( $ this -> id !== null ) ) { $ this -> aSmartyFilter = ChildSmartyFilterQuery :: create ( ) -> findPk ( $ this -> id , $ con ) ; } return $ this -> aSmartyFilter ; }
Get the associated ChildSmartyFilter object
241,109
public static function getMonthsRange ( $ startData , $ endDate ) { $ time1 = strtotime ( $ startData ) ; $ time2 = strtotime ( $ endDate ) ; $ year1 = date ( 'Y' , $ time1 ) ; $ year2 = date ( 'Y' , $ time2 ) ; $ years = range ( $ year1 , $ year2 ) ; $ months = Array ( ) ; foreach ( $ years as $ year ) { $ months [ $ ...
Cria um intervalo de Meses de acordo com a data inicial e final
241,110
protected function createEntry ( array $ data ) { return Entity \ AccountNode :: fromNode ( parent :: createEntry ( $ data ) , $ this -> getConnection ( ) -> getConfiguration ( ) ) ; }
Creates the data structure for the given entry data
241,111
public function sendTemplateMessageByType ( $ touser , $ type , $ data , $ url = null ) { return isset ( $ this -> templates [ $ type ] ) && $ this -> sendTemplateMessage ( $ touser , $ this -> templates [ $ type ] , $ data , $ url ) ; }
Send template by type
241,112
public function setTemplateIndustry ( $ industry_id1 , $ industry_id2 ) { $ data = $ this -> getData ( '/cgi-bin/template/api_set_industry' , [ 'access_token' => $ this -> getAccessToken ( ) , ] , Json :: encode ( [ 'industry_id1' => $ industry_id1 , 'industry_id2' => $ industry_id2 , ] ) ) ; return $ this -> errcode =...
Set template industry
241,113
public function delete ( $ key ) : Blob { if ( $ this -> offsetExists ( $ key ) ) { $ this -> offsetUnset ( $ key ) ; } return $ this ; }
Delete value for key in Blob .
241,114
final protected function doCommandImportSetUp ( ) { $ this -> writeln ( 'Executing <info>setup</info> tasks' , true ) ; $ this -> importManager -> setUp ( ) ; $ this -> writeln ( 'Startup tasks complete.' , true , true ) ; }
Performs startup tasks
241,115
final protected function doCommandImport ( ) { $ this -> writeln ( 'Starting Import' , true , true ) ; $ this -> indent ( ) ; foreach ( $ this -> importManager -> getConfiguration ( ) -> getSegments ( ) as $ segment ) { $ this -> importSegment ( $ segment ) ; } $ this -> outdent ( ) ; $ this -> writeln ( '<info>Import ...
The main import loop
241,116
final protected function doCommandImportTearDown ( ) { $ this -> writeln ( 'Executing <info>teardown</info> tasks' , false , true ) ; $ this -> indent ( ) ; $ this -> subscriberPass ( ) ; $ this -> outdent ( ) ; $ this -> writeln ( 'Teardown tasks complete.' , false , true ) ; }
Performs teardown tasks
241,117
public function listen ( Listener $ listener ) { if ( isset ( $ this -> listeners [ $ listener -> get_tag ( ) ] ) ) { return false ; } $ this -> listeners [ $ listener -> get_tag ( ) ] = $ listener ; return true ; }
Listen for a template tag .
241,118
public function get_listener ( $ tag ) { return isset ( $ this -> listeners [ $ tag ] ) ? $ this -> listeners [ $ tag ] : new Null_Listener ( ) ; }
Get a listener for a certain tag .
241,119
public function render_tags ( array $ data_sources ) { $ replaced = array ( ) ; foreach ( $ this -> get_listeners ( ) as $ tag => $ listener ) { $ params = $ listener -> get_callback_reflection ( ) -> getParameters ( ) ; $ args = array ( ) ; foreach ( $ params as $ param ) { $ found = false ; foreach ( $ data_sources a...
Return an array of the rendered tags .
241,120
public static function create ( $ dir , $ chmod = null ) { if ( ! file_exists ( $ dir ) ) { if ( $ chmod === null ) { $ chmod = self :: $ defaultChmod ; } mkdir ( $ dir , $ chmod , true ) ; chmod ( $ dir , $ chmod ) ; return true ; } return false ; }
create a directory .
241,121
public static function remove ( $ path , $ deleteDir = true ) { if ( $ path == '' || $ path == '/' || $ path == DIRECTORY_SEPARATOR ) { throw new \ InvalidArgumentException ( 'The root cannot be removed !!' ) ; } if ( ! file_exists ( $ path ) ) { return true ; } $ dir = new \ DirectoryIterator ( $ path ) ; foreach ( $ ...
Recursive function deleting a directory .
241,122
public static function removeExcept ( $ path , $ except , $ deleteDir = true ) { if ( ! is_array ( $ except ) || ! count ( $ except ) ) { throw new \ InvalidArgumentException ( 'list of exception is not an array or is empty' ) ; } if ( $ path == '' || $ path == '/' || $ path == DIRECTORY_SEPARATOR ) { throw new \ Inval...
Recursive function deleting all files into a directory except those indicated .
241,123
static function copy ( $ srcDir , $ destDir , $ overwrite = true ) { Directory :: create ( $ destDir ) ; $ dir = new \ DirectoryIterator ( $ srcDir ) ; foreach ( $ dir as $ dirContent ) { if ( $ dirContent -> isFile ( ) || $ dirContent -> isLink ( ) ) { $ target = $ destDir . '/' . $ dirContent -> getFilename ( ) ; if ...
Copy a content directory into an other
241,124
private function isAutoWirable ( $ id ) : bool { if ( is_string ( $ id ) && class_exists ( $ id ) ) { if ( count ( $ this -> interfaces ) > 0 ) { return ( bool ) array_intersect ( $ this -> interfaces , class_implements ( $ id ) ) ; } return true ; } return false ; }
Return whether the given id is an auto wirable class .
241,125
private function make ( string $ class ) { if ( ! array_key_exists ( $ class , $ this -> instances ) ) { try { return $ this -> instances [ $ class ] = ( $ this -> factory ) ( $ class ) -> value ( $ this ) ; } catch ( ResolvingExceptionInterface $ e ) { throw new ReflectionContainerException ( $ class , $ e ) ; } } ret...
Return an instance of the given class name . Cache the created instance so the same one is returned on multiple calls .
241,126
public function exportDataSets ( $ dataSetConfig = null ) { $ response = [ ] ; foreach ( $ this -> getDataSets ( ) as $ set ) { if ( $ set instanceof DataSet ) { $ response [ ] = $ set -> export ( $ dataSetConfig ) ; } else { $ response [ ] = $ set ; } } return $ response ; }
Export Data Sets
241,127
protected function changeOwner ( $ path , $ newOwner ) { $ ownerUid = fileowner ( $ path ) ; $ ownerData = posix_getpwuid ( $ ownerUid ) ; $ oldOwner = $ ownerData [ 'name' ] ; if ( $ oldOwner !== $ this -> user ) { if ( ! @ chown ( $ path , $ newOwner ) ) { throw new CException ( sprintf ( 'Unable to change owner for ...
Changes the owner for a directory .
241,128
protected function changeGroup ( $ path , $ newGroup ) { $ groupGid = filegroup ( $ path ) ; $ groupData = posix_getgrgid ( $ groupGid ) ; $ oldGroup = $ groupData [ 'name' ] ; if ( $ oldGroup !== $ newGroup ) { if ( ! @ chgrp ( $ path , $ newGroup ) ) { throw new CException ( sprintf ( 'Unable to change group for %s, ...
Changes the group for a directory .
241,129
protected function changeMode ( $ path , $ mode ) { $ oldPermission = substr ( sprintf ( '%o' , fileperms ( $ path ) ) , - 4 ) ; $ newPermission = sprintf ( '%04o' , $ mode ) ; if ( $ oldPermission !== $ newPermission ) { if ( ! @ chmod ( $ path , $ mode ) ) { throw new CException ( sprintf ( "Unable to change mode for...
Changes the mode for a directory .
241,130
public function with ( $ key , $ value ) { $ this -> hasData = true ; $ this -> session -> create ( $ key , $ value ) ; return $ this ; }
To store data in a session
241,131
public function backWith ( $ key , $ value ) { $ this -> with ( $ key , $ value ) ; $ url = $ this -> session -> get ( 'previous_uri' ) ; header ( 'location: ' . $ url ) ; exit ( ) ; }
To redirect back with value
241,132
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 .
241,133
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 .
241,134
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 .
241,135
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 .
241,136
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
241,137
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 .
241,138
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 .
241,139
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 .
241,140
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 .
241,141
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
241,142
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
241,143
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
241,144
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
241,145
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
241,146
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
241,147
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
241,148
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 .
241,149
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
241,150
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 .
241,151
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 .
241,152
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 .
241,153
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 .
241,154
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 .
241,155
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 .
241,156
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 .
241,157
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 .
241,158
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 .
241,159
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 .
241,160
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 .
241,161
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
241,162
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
241,163
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
241,164
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 .
241,165
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 .
241,166
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 .
241,167
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 .
241,168
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 .
241,169
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 .
241,170
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 .
241,171
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
241,172
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
241,173
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
241,174
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 .
241,175
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 .
241,176
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 .
241,177
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 .
241,178
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 .
241,179
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 .
241,180
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 .
241,181
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 .
241,182
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 .
241,183
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 .
241,184
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 .
241,185
protected function prepare ( $ link ) { $ response = Client :: request ( ( string ) $ link ) ; $ response = str_replace ( '<strong> </strong>' , ' ' , $ response ) ; $ this -> crawler = new Crawler ( $ response ) ; }
Initializes the crawler instance .
241,186
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 .
241,187
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 .
241,188
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 .
241,189
public function remoteDirectory ( $ directory , $ physical = false ) { $ this -> remoteDir = $ directory ; $ this -> physicalRemoteDir = $ physical ; return $ this ; }
Sets the remote directory .
241,190
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 .
241,191
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
241,192
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
241,193
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
241,194
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
241,195
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
241,196
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
241,197
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 .
241,198
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
241,199
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 .