idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
10,100
public function logEvent ( array $ events = [ ] ) { foreach ( $ events as $ event ) { if ( ! in_array ( $ event , $ this -> loggerInstance -> logEvents , true ) ) { $ this -> loggerInstance -> logEvents [ ] = $ event ; } } return $ this ; }
log given events by given name
10,101
public function getConfiguration ( $ option = null ) { if ( ! is_null ( $ option ) ) { return $ this -> options [ $ option ] ; } return $ this -> options ; }
get complete object configuration or value of single option
10,102
protected function addError ( \ Exception $ exception ) { $ this -> errorList [ $ exception -> getCode ( ) ] = [ 'message' => $ exception -> getMessage ( ) , 'line' => $ exception -> getLine ( ) , 'file' => $ exception -> getFile ( ) , 'trace' => $ exception -> getTraceAsString ( ) , ] ; $ this -> hasErrors = true ; return $ this ; }
add new error to list
10,103
private function addPlugins ( $ path ) { foreach ( glob ( $ path . '/*.php' ) as $ filename ) { $ commandClass = __NAMESPACE__ . '\\' . basename ( $ filename , '.php' ) . 'Command' ; $ command = new $ commandClass ; $ this -> add ( $ command ) ; } }
Dynamically add all commands from a path
10,104
public function execute ( ) { $ results = ArrayList :: create ( ) ; foreach ( $ this -> classes as $ c ) { if ( $ this -> isOmitted ( $ c ) ) continue ; $ list = DataList :: create ( $ c ) -> filter ( 'ClassName' , $ c ) -> limit ( $ this -> getLimitFor ( $ c ) ) -> sort ( "RAND()" ) ; foreach ( $ list as $ record ) { $ results -> push ( $ record ) ; } } return $ results ; }
Executes the query gets the samples
10,105
protected function isOmitted ( $ c ) { foreach ( $ this -> omissions as $ o ) { if ( $ c == $ o || is_subclass_of ( $ c , $ o ) ) { return true ; } } return false ; }
Returns true if a class is omitted
10,106
protected function isAncestor ( $ tagname ) { $ candidate = $ this -> current ; while ( $ candidate -> nodeType === XML_ELEMENT_NODE ) { if ( $ candidate -> tagName == $ tagname ) { return true ; } $ candidate = $ candidate -> parentNode ; } return false ; }
Checks if the given tagname is an ancestor of the present candidate .
10,107
public function setPointColor ( $ r , $ g , $ b ) { $ this -> ink [ 'point' ] = imagecolorallocate ( $ this -> im , $ r , $ g , $ b ) ; }
Sets the point color in rgb format
10,108
public function setLineColor ( $ r , $ g , $ b ) { $ this -> ink [ 'line' ] = imagecolorallocate ( $ this -> im , $ r , $ g , $ b ) ; }
Sets the line color in rgb format
10,109
public function setTextColor ( $ r , $ g , $ b ) { $ this -> ink [ 'text' ] = imagecolorallocate ( $ this -> im , $ r , $ g , $ b ) ; }
Sets the text color in rgb format - labels
10,110
public function setAxisColor ( $ r , $ g , $ b ) { $ this -> ink [ 'axis' ] = imagecolorallocate ( $ this -> im , $ r , $ g , $ b ) ; }
Sets the axis color in rgb format - axis
10,111
private function createBackground ( ) { imagefilledrectangle ( $ this -> im , 0 , 0 , $ this -> width , $ this -> height , $ this -> ink [ 'black' ] ) ; }
Create the backgrround image
10,112
private function allocateColors ( ) { $ this -> ink [ 'red' ] = imagecolorallocate ( $ this -> im , 0xff , 0x00 , 0x00 ) ; $ this -> ink [ 'orange' ] = imagecolorallocate ( $ this -> im , 0xd2 , 0x8a , 0x00 ) ; $ this -> ink [ 'yellow' ] = imagecolorallocate ( $ this -> im , 0xff , 0xff , 0x00 ) ; $ this -> ink [ 'green' ] = imagecolorallocate ( $ this -> im , 0x00 , 0xff , 0x00 ) ; $ this -> ink [ 'blue' ] = imagecolorallocate ( $ this -> im , 0x00 , 0x00 , 0xff ) ; $ this -> ink [ 'purple' ] = imagecolorallocate ( $ this -> im , 0x70 , 0x70 , 0xf9 ) ; $ this -> ink [ 'white' ] = imagecolorallocate ( $ this -> im , 0xff , 0xff , 0xff ) ; $ this -> ink [ 'black' ] = imagecolorallocate ( $ this -> im , 0x00 , 0x00 , 0x00 ) ; $ this -> ink [ 'gray' ] = imagecolorallocate ( $ this -> im , 0xaf , 0xaf , 0xaf ) ; $ this -> ink [ 'axis' ] = imagecolorallocate ( $ this -> im , 95 , 95 , 95 ) ; $ this -> ink [ 'line' ] = imagecolorallocate ( $ this -> im , 0xff , 0xff , 0x00 ) ; $ this -> ink [ 'background' ] = imagecolorallocate ( $ this -> im , 0x00 , 0x00 , 0x00 ) ; $ this -> ink [ 'text' ] = imagecolorallocate ( $ this -> im , 0xff , 0xff , 0xff ) ; $ this -> ink [ 'point' ] = imagecolorallocate ( $ this -> im , 0xff , 0xff , 0xff ) ; }
Allocates the default color used
10,113
private function mapYvalue ( $ value ) { $ rangeMapper = new \ sb \ Math \ RangeMapper ( Array ( 30 , $ this -> graph_height ) , Array ( $ this -> min , $ this -> max ) ) ; return $ rangeMapper -> convert ( $ value ) ; }
Converts the range from point to pixel value
10,114
private function setValues ( $ values ) { $ numbers = Array ( ) ; foreach ( $ values as $ key => $ val ) { $ value = new \ stdClass ( ) ; $ value -> label = trim ( $ key ) ; if ( ! is_numeric ( $ val ) ) { $ val = null ; } $ value -> value = $ val ; $ this -> values [ ] = $ value ; $ numbers [ ] = $ val ; } $ min_max = Array ( ) ; foreach ( $ numbers as $ number ) { if ( ! is_null ( $ number ) ) { array_push ( $ min_max , $ number ) ; } } $ this -> min = min ( $ min_max ) ; $ this -> max = max ( $ min_max ) ; $ this -> total_values = count ( $ numbers ) ; $ separation_dist = ( ( $ this -> graph_width - 40 ) / $ this -> total_values ) ; $ i = 0 ; $ this -> points = Array ( ) ; foreach ( $ this -> values as $ value ) { $ point = new \ stdClass ( ) ; $ point -> x = ( $ i * $ separation_dist ) + $ this -> axis_offset + 40 ; $ point -> y = $ this -> plotValue ( $ value -> value ) ; $ point -> label = $ value -> label ; $ point -> value = $ value -> value ; $ this -> points [ ] = $ point ; $ i ++ ; } return $ this -> points ; }
Converts the values into usable data for the drawing of the graph
10,115
private function plotValue ( $ y ) { $ rangeMapper = new \ sb \ Math \ RangeMapper ( Array ( $ this -> axis_offset , $ this -> graph_height - $ this -> axis_offset ) , Array ( $ this -> max , $ this -> min ) ) ; return $ rangeMapper -> convert ( $ y ) ; }
Converts points on the graph to pixels
10,116
private function connectPoints ( ) { foreach ( $ this -> points as $ point ) { if ( is_null ( $ point -> value ) ) { $ last_x = $ point -> x ; $ last_y = $ point -> y ; $ last_val = $ point -> value ; continue ; } if ( isset ( $ last_x ) && ( isset ( $ last_val ) && ! is_null ( $ last_val ) ) ) { imageline ( $ this -> im , $ last_x , $ last_y , $ point -> x , $ point -> y , $ this -> ink [ 'line' ] ) ; } $ last_val = $ point -> value ; $ last_x = $ point -> x ; $ last_y = $ point -> y ; } }
Connect the points on a graph
10,117
public function draw ( ) { $ this -> drawYaxis ( ) ; if ( $ this -> connect_points == 1 ) { $ this -> connectPoints ( ) ; } foreach ( $ this -> points as $ point ) { if ( $ this -> y_axis_hints == 1 ) { imagedashedline ( $ this -> im , $ point -> x , $ this -> height , $ point -> x , 0 , $ this -> ink [ 'axis' ] ) ; } else { imageline ( $ this -> im , $ point -> x , $ this -> graph_height , $ point -> x , $ this -> graph_height + 10 , $ this -> ink [ 'axis' ] ) ; } imagestring ( $ this -> im , 1 , $ point -> x + 5 , $ this -> graph_height + 10 , $ point -> label , $ this -> ink [ 'text' ] ) ; if ( is_null ( $ point -> value ) ) { continue ; } imagefilledellipse ( $ this -> im , $ point -> x , $ point -> y , 7 , 7 , $ this -> ink [ 'point' ] ) ; if ( $ point -> y <= 5 ) { $ posy = $ point -> y + 5 ; } elseif ( $ point -> y >= $ this -> graph_height - 5 ) { $ posy = $ point -> y - 20 ; } else { $ posy = $ point -> y - 15 ; } imagestring ( $ this -> im , 3 , $ point -> x + 10 , $ posy , $ point -> value , $ this -> ink [ 'point' ] ) ; } }
Draw the basic graph and plot the points
10,118
public function addHorizontalLine ( $ y , $ color = 'red' , $ label = '' ) { if ( ! array_key_exists ( $ color , $ this -> ink ) ) { throw ( new \ Exception ( "Ink color must be in " . implode ( "," , \ array_keys ( $ this -> ink ) ) ) ) ; } $ y = $ this -> plotValue ( $ y ) ; imageline ( $ this -> im , 0 , $ y , $ this -> width , $ y , $ this -> ink [ $ color ] ) ; imagestring ( $ this -> im , 2 , $ this -> graph_width / 2 + $ this -> axis_offset , $ y , $ label , $ this -> ink [ $ color ] ) ; }
Add a horizontal line
10,119
protected function loadDependencies ( RecordSelector $ selector ) { if ( empty ( $ this -> dependencies ) ) { return $ selector ; } foreach ( $ this -> dependencies as $ dependency ) { $ selector = $ selector -> with ( $ dependency -> getRelation ( ) , $ dependency -> getOptions ( ) ) ; } return $ selector ; }
Apply dependencies for RecordSelector
10,120
public static function validateSignature ( $ signature , $ payload ) { $ parts = explode ( ',' , $ signature ) ; $ parameters = [ ] ; $ t = 0 ; foreach ( $ parts as $ part ) { parse_str ( $ part , $ parsed ) ; if ( key ( $ parsed ) === 't' ) { $ t = $ parsed [ 't' ] ; break ; } } if ( $ t === 0 ) { return false ; } $ wanted = hash_hmac ( 'sha256' , $ t . '.' . $ payload , self :: $ secret ) ; foreach ( $ parts as $ part ) { parse_str ( $ part , $ parsed ) ; if ( key ( $ parsed ) === 'v1' ) { if ( $ wanted === $ parsed [ 'v1' ] ) { return true ; } } } return false ; }
Validate the webhook signature
10,121
public function attachTag ( $ id ) { if ( ! $ this -> tags -> contains ( $ id ) ) { return $ this -> tags ( ) -> attach ( $ id ) ; } }
Links a tag to the node
10,122
private function executeParallel ( $ stmt , array $ values = null ) : PromiseInterface { if ( is_string ( $ stmt ) ) { $ stmt = $ this -> emulatePrepare ( ( string ) $ stmt , $ values ) ; } else { if ( ! $ stmt instanceof Statement ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected %s object, got %s' , Statement :: class , get_class ( $ stmt ) ) ) ; } if ( ! $ stmt instanceof EmulatedStatement ) { $ stmt = $ this -> emulatePrepare ( ( string ) $ stmt , $ values ?? $ stmt -> getValues ( ) ) ; } elseif ( null !== $ values ) { $ stmt = $ stmt -> withValues ( $ values ) ; } } try { $ credentials = $ this -> getCredentials ( ) ; $ cnx = self :: createLink ( $ credentials ) ; if ( $ this -> hasOption ( 'charset' ) ) { $ cnx -> set_charset ( $ this -> getOption ( 'charset' ) ) ; } } catch ( mysqli_sql_exception $ e ) { throw new AccessDeniedException ( $ e -> getMessage ( ) , ( int ) $ e -> getCode ( ) , $ e ) ; } $ stmt -> bind ( ) ; $ promise = MysqliAsync :: query ( $ stmt -> getRunnableQuery ( ) , $ cnx ) -> then ( function ( $ result ) use ( $ cnx , $ stmt ) { if ( ! $ result instanceof mysqli_result ) { $ result = null ; } return new Result ( $ cnx , $ result ) ; } ) ; return $ promise ; }
EXPERIMENTAL ! Executes a statement asynchronously . The promise will return a Result object .
10,123
public static function getType ( $ extension ) { foreach ( self :: $ map as $ mime => $ exts ) { if ( in_array ( strtolower ( $ extension ) , $ exts ) ) { return $ mime ; } } return null ; }
Retruns MIME type belonging to given file extension or null if not found .
10,124
public static function setByPath ( & $ subject , array $ path , $ value ) { $ ptr = & $ subject ; foreach ( $ path as $ key ) { if ( is_object ( $ ptr ) ) { if ( ! isset ( $ ptr -> $ key ) ) { $ ptr -> $ key = array ( ) ; } $ ptr = & $ ptr -> $ key ; } elseif ( is_array ( $ ptr ) ) { if ( ! isset ( $ ptr [ $ key ] ) ) { $ ptr [ $ key ] = array ( ) ; } $ ptr = & $ ptr [ $ key ] ; } } $ ptr = $ value ; return $ subject ; }
Set a property value by a path of property or key names .
10,125
public function get ( $ id ) { if ( ! isset ( $ this -> forms [ $ id ] ) ) { $ contentRepository = $ this -> container -> get ( 'doctrine' ) -> getRepository ( 'NetvliesFormBundle:Form' ) ; $ form = $ contentRepository -> findOneById ( $ id ) ; $ formBuilder = $ this -> container -> get ( 'form.factory' ) -> createBuilder ( ) ; $ formBuilder -> add ( 'form_id' , 'hidden' , array ( 'data' => $ id ) ) ; foreach ( $ form -> getFields ( ) as $ field ) { $ type = $ field -> getType ( ) ; $ options = array ( 'label' => $ field -> getLabel ( ) , 'constraints' => array ( ) , ) ; if ( $ field -> getRequired ( ) ) { $ options [ 'constraints' ] [ ] = new NotBlank ( ) ; } else { $ options [ 'required' ] = false ; } if ( $ field -> getDefault ( ) ) { $ options [ 'data' ] = $ field -> getDefault ( ) ; } switch ( $ field -> getType ( ) ) { case 'select' : $ type = 'choice' ; $ options [ 'expanded' ] = ( $ field -> getSelectType ( ) != 'dropdown' ) ; $ options [ 'multiple' ] = $ field -> getSelectMultiple ( ) ; $ options [ 'choices' ] = array ( ) ; foreach ( $ field -> getOptions ( ) as $ option ) { $ options [ 'choices' ] [ $ option -> getLabel ( ) ] = $ option -> getLabel ( ) ; } if ( $ field -> getDefault ( ) ) { $ options [ 'data' ] = $ field -> getDefault ( ) ; if ( $ options [ 'multiple' ] ) { $ options [ 'data' ] = explode ( ',' , $ options [ 'data' ] ) ; } } break ; case 'email' : $ options [ 'constraints' ] [ ] = new Email ( ) ; break ; case 'date' : $ options [ 'widget' ] = 'single_text' ; $ options [ 'attr' ] [ 'class' ] = 'datepicker' ; $ options [ 'attr' ] [ 'placeholder' ] = 'dd-mm-yyyy' ; $ options [ 'input' ] = 'string' ; $ options [ 'format' ] = 'd-M-y' ; break ; } $ formBuilder -> add ( 'field_' . $ field -> getId ( ) , $ type , $ options ) ; } if ( $ form -> getAddCaptcha ( ) ) { $ formBuilder -> add ( 'captcha' , 'captcha' ) ; } $ form -> setSf2Form ( $ formBuilder -> getForm ( ) ) ; $ this -> forms [ $ id ] = $ form ; } return $ this -> forms [ $ id ] ; }
Builds the form with the requested ID . When a form is requested for the second time the instance created earlier is returned to ensure only one form instance is used and form properties can be set and retrieved from all locations where the form is used .
10,126
public function load ( $ file ) { if ( is_resource ( $ file ) ) { return $ this -> loadHTML ( stream_get_contents ( $ file ) ) ; } $ input = new HTML5_Inputstream_File ( $ file ) ; return $ this -> parse ( $ input ) ; }
Load and parse an HTML file .
10,127
public function parse ( HTML5_Inputstream_Interface $ input ) { $ this -> errors = array ( ) ; $ events = new HTML5_Parser_DOMTreeBuilder ( false , $ this -> options ) ; $ scanner = new HTML5_Parser_Scanner ( $ input ) ; $ parser = new HTML5_Parser_Tokenizer ( $ scanner , $ events ) ; $ parser -> parse ( ) ; $ this -> errors = $ events -> getErrors ( ) ; return $ events -> document ( ) ; }
Parse an input stream .
10,128
public function parseFragment ( HTML5_Inputstream_Interface $ input ) { $ events = new HTML5_Parser_DOMTreeBuilder ( true , $ this -> options ) ; $ scanner = new HTML5_Parser_Scanner ( $ input ) ; $ parser = new HTML5_Parser_Tokenizer ( $ scanner , $ events ) ; $ parser -> parse ( ) ; $ this -> errors = $ events -> getErrors ( ) ; return $ events -> fragment ( ) ; }
Parse an input stream where the stream is a fragment .
10,129
public function save ( $ dom , $ file , $ options = array ( ) ) { $ close = true ; if ( is_resource ( $ file ) ) { $ stream = $ file ; $ close = false ; } else { $ stream = fopen ( $ file , 'w' ) ; } $ options = array_merge ( $ this -> getOptions ( ) , $ options ) ; $ rules = new HTML5_Serializer_OutputRules ( $ stream , $ options ) ; $ trav = new HTML5_Serializer_Traverser ( $ dom , $ stream , $ rules , $ options ) ; $ trav -> walk ( ) ; if ( $ close ) { fclose ( $ stream ) ; } }
Save a DOM into a given file as HTML5 .
10,130
public function saveHTML ( $ dom , $ options = array ( ) ) { $ stream = fopen ( 'php://temp' , 'w' ) ; $ this -> save ( $ dom , $ stream , array_merge ( $ this -> getOptions ( ) , $ options ) ) ; return stream_get_contents ( $ stream , - 1 , 0 ) ; }
Convert a DOM into an HTML5 string .
10,131
function interpolate ( $ message , array $ context = array ( ) ) { $ replace = array ( ) ; foreach ( $ context as $ key => $ val ) { if ( $ key == "exception" && $ val instanceof \ Exception ) { $ replace [ '{' . $ key . '}' ] = $ val -> getMessage ( ) ; } else { $ replace [ '{' . $ key . '}' ] = $ val ; } } return strtr ( $ message , $ replace ) ; }
Implementation of Placeholder Interpolation The message MAY contain placeholders which implementors MAY replace with values from the context array . Placeholder names MUST correspond to keys in the context array .
10,132
public function addLogFile ( $ key , $ logFileName ) { $ arrayKey = strtolower ( $ key ) ; return $ this -> _logFiles [ $ arrayKey ] = $ logFileName ; }
Add log file Valid if multiple log files exist
10,133
protected function getPackage ( RepositoryInterface $ repos , $ name ) { $ name = strtolower ( $ name ) ; $ pool = new Pool ( 'dev' ) ; $ pool -> addRepository ( $ repos ) ; $ matches = $ pool -> whatProvides ( $ name ) ; foreach ( $ matches as $ index => $ package ) { if ( $ package -> getName ( ) !== $ name ) { unset ( $ matches [ $ index ] ) ; continue ; } return $ package ; } }
finds a package by name
10,134
private function openBrowser ( $ url ) { $ url = ProcessExecutor :: escape ( $ url ) ; if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { return passthru ( 'start "web" explorer "' . $ url . '"' ) ; } passthru ( 'which xdg-open' , $ linux ) ; passthru ( 'which open' , $ osx ) ; if ( 0 === $ linux ) { passthru ( 'xdg-open ' . $ url ) ; } elseif ( 0 === $ osx ) { passthru ( 'open ' . $ url ) ; } else { $ this -> getIO ( ) -> writeError ( 'no suitable browser opening command found, open yourself: ' . $ url ) ; } }
opens a url in your system default browser
10,135
public function getFirstRow ( ) { $ rows = $ this -> data [ 'rows' ] ; if ( empty ( $ rows ) ) { return false ; } $ row = array_slice ( $ rows , 0 , 1 ) ; return current ( $ row ) ; }
Return the first row .
10,136
public function getLastRow ( ) { $ rows = $ this -> data [ 'rows' ] ; if ( empty ( $ rows ) ) { return false ; } $ row = array_slice ( $ rows , count ( $ rows ) - 1 ) ; return current ( $ row ) ; }
Return the last row .
10,137
public function off ( string $ event ) { if ( false === ( $ key = array_search ( $ event , $ this -> getSupportedEvents ( ) , true ) ) ) { return null ; } if ( ! isset ( $ this -> eventHandlers [ $ key ] ) || ! ( $ cb = $ this -> eventHandlers [ $ key ] ) ) { return null ; } $ this -> eventHandlers [ $ key ] = null ; return $ cb ; }
remove event handler
10,138
protected function calculateActionCount ( ) { $ counter = 0 ; foreach ( $ this -> actions as $ actions ) { $ counter += count ( $ actions ) ; } return $ counter ; }
Returns the total number of actions in all groups
10,139
protected function removeNotImportantRemainingActions ( ) { if ( ! empty ( $ this -> actions [ self :: GROUP_ADD ] ) ) { foreach ( $ this -> actions [ self :: GROUP_ADD ] as $ index => $ action ) { if ( $ action [ 0 ] === self :: MOVE ) { unset ( $ this -> actions [ self :: GROUP_ADD ] [ $ index ] ) ; } } } if ( ! empty ( $ this -> actions [ self :: GROUP_REMOVE ] ) && empty ( $ this -> actions [ self :: GROUP_ADD ] ) ) { unset ( $ this -> actions [ self :: GROUP_REMOVE ] ) ; } }
Checks if there are any not executed actions and remove actions which are not important
10,140
protected function isActionReadyToExecute ( $ key , $ args ) { switch ( $ key ) { case self :: ADD : $ parentId = $ args [ 1 ] ; $ siblingId = $ args [ 4 ] ; return ! $ parentId || ( $ this -> rawLayoutBuilder -> has ( $ parentId ) && ( ! $ siblingId || $ this -> rawLayoutBuilder -> isParentFor ( $ parentId , $ siblingId ) ) ) ; case self :: MOVE : list ( $ id , $ parentId , $ siblingId ) = $ args ; return ( ! $ id || $ this -> rawLayoutBuilder -> has ( $ id ) ) && ( ! $ parentId || $ this -> rawLayoutBuilder -> has ( $ parentId ) ) && ( ! $ siblingId || ( $ parentId && $ this -> rawLayoutBuilder -> isParentFor ( $ parentId , $ siblingId ) ) || ( ! $ parentId && $ this -> rawLayoutBuilder -> has ( $ siblingId ) ) ) ; case self :: REMOVE : case self :: SET_OPTION : case self :: APPEND_OPTION : case self :: SUBTRACT_OPTION : case self :: REPLACE_OPTION : case self :: REMOVE_OPTION : case self :: CHANGE_BLOCK_TYPE : $ id = $ args [ 0 ] ; return ! $ id || $ this -> rawLayoutBuilder -> has ( $ id ) ; case self :: SET_BLOCK_THEME : $ id = $ args [ 1 ] ; return ( ! $ id && ! $ this -> rawLayoutBuilder -> isEmpty ( ) ) || $ this -> rawLayoutBuilder -> has ( $ id ) ; case self :: ADD_ALIAS : $ id = $ args [ 1 ] ; return ! $ id || $ this -> rawLayoutBuilder -> has ( $ id ) ; case self :: REMOVE_ALIAS : $ alias = $ args [ 0 ] ; return ! $ alias || $ this -> rawLayoutBuilder -> hasAlias ( $ alias ) ; } return true ; }
Checks whether an action is ready to execute
10,141
protected function executeActions ( $ group ) { $ executedCount = 0 ; reset ( $ this -> actions [ $ group ] ) ; while ( list ( $ index , $ action ) = each ( $ this -> actions [ $ group ] ) ) { if ( $ this -> isActionReadyToExecute ( $ action [ 0 ] , $ action [ 2 ] ) ) { $ executedCount += $ this -> executeAction ( $ index , $ action ) ; unset ( $ this -> actions [ $ group ] [ $ index ] ) ; } } return $ executedCount ; }
Executes actions from the given group Use this method if the group does not contain depended each other actions
10,142
protected function executeDependedActions ( $ group ) { $ executedCount = 0 ; $ continue = true ; while ( $ continue ) { $ continue = false ; $ hasExecuted = false ; $ hasSkipped = false ; reset ( $ this -> actions [ $ group ] ) ; while ( list ( $ index , $ action ) = each ( $ this -> actions [ $ group ] ) ) { if ( $ this -> isActionReadyToExecute ( $ action [ 0 ] , $ action [ 2 ] ) ) { $ executedCount += $ this -> executeAction ( $ index , $ action ) ; unset ( $ this -> actions [ $ group ] [ $ index ] ) ; $ hasExecuted = true ; if ( $ hasSkipped ) { $ continue = true ; break ; } } else { $ hasSkipped = true ; if ( $ hasExecuted ) { $ continue = true ; break ; } } } } return $ executedCount ; }
Executes depended actions from the given group Use this method if the group can contain depended each other actions This method guarantee that all actions are executed in the order they are registered
10,143
public function setSelector ( PaginatorAwareInterface $ selector ) { $ this -> validateSelector ( $ selector ) ; $ this -> selector = $ selector ; return $ this ; }
Set active listing selector .
10,144
public function setLimits ( array $ limits = [ ] ) { if ( empty ( $ limits ) ) { throw new ListingException ( "You must provide at least one limit option" ) ; } $ this -> limits = array_values ( $ limits ) ; return $ this ; }
Set allowed pagination limits
10,145
protected function createPaginator ( ) { $ paginator = new Paginator ( $ this -> getLimit ( ) ) ; $ paginator = $ paginator -> withPage ( $ this -> getPage ( ) ) ; return $ paginator ; }
Get paginator associated with current listing
10,146
protected function getLimit ( ) { $ limit = $ this -> activeState ( ) -> getLimit ( ) ; if ( ! in_array ( $ limit , $ this -> limits ) ) { return $ this -> limits [ 0 ] ; } return $ limit ; }
Get active pagination limit
10,147
public function search ( $ pattern = null ) { if ( ! $ pattern ) { return ; } foreach ( $ this -> searchable as $ column ) { $ this -> resolveSearch ( $ column , $ pattern ) ; } }
Searches given columns .
10,148
protected function resolveSearch ( $ column , $ key ) { $ this -> resolve ( $ column , $ key , $ this -> getTableName ( ) , function ( $ query , $ pattern ) { $ this -> builder -> orWhere ( $ query , 'LIKE' , "%{$pattern}%" ) ; } ) ; }
Recursively build up the search query .
10,149
public function address ( array $ address ) { if ( ! isset ( $ this -> data -> addresses ) ) { $ this -> data -> addresses = [ ] ; } return $ this -> data -> addresses [ ] = ( object ) $ address ; }
Put a address on person data
10,150
public function contacts ( array $ contact ) { if ( ! isset ( $ this -> data -> contacts ) ) { $ this -> data -> contacts = [ ] ; } return $ this -> data -> contacts [ ] = ( object ) $ contact ; }
Put a contact on person data
10,151
public function references ( array $ reference = null ) { if ( ! isset ( $ this -> data -> references ) ) { $ this -> data -> references = [ ] ; } return $ this -> data -> contacts [ ] = ( object ) $ reference ; }
Put a commercial reference on person data
10,152
public function getAuthorizationCode ( array $ params ) { if ( isset ( $ params [ 'transaction_state' ] ) ) { $ params [ 'transaction_state' ] = json_encode ( $ params [ 'transaction_state' ] ) ; } return $ this -> post ( 'access/getAuthorizationCode' , $ params ) ; }
Get an authorization code that can be exchanged for an access_token and a refresh_token .
10,153
public function addResolvableOption ( $ name , $ shortcut = null , $ mode = null , $ help = null , $ default = null ) { $ this -> opts [ ] = $ name ; return parent :: addOption ( $ name , $ shortcut , $ mode , $ help , $ default ) ; }
will add the given option the opt stack so it will resolved for the z plugin .
10,154
protected function execute ( InputInterface $ input , Output \ OutputInterface $ output ) { foreach ( $ this -> getDefinition ( ) -> getArguments ( ) as $ arg ) { if ( $ arg -> getName ( ) === 'command' ) { continue ; } if ( $ input -> getArgument ( $ arg -> getName ( ) ) ) { $ this -> getContainer ( ) -> set ( explode ( '.' , $ this -> nameToVar ( $ arg -> getName ( ) ) ) , $ input -> getArgument ( $ arg -> getName ( ) ) ) ; } } foreach ( $ this -> opts as $ opt ) { if ( $ value = $ input -> getOption ( $ this -> varToName ( $ opt ) ) ) { $ this -> getContainer ( ) -> set ( explode ( '.' , $ opt ) , $ value ) ; } } foreach ( $ this -> flags as $ name => $ value ) { $ varName = explode ( '.' , $ name ) ; $ optName = $ this -> varToName ( $ name ) ; $ this -> getContainer ( ) -> set ( $ varName , $ value ) ; if ( $ input -> getOption ( 'no-' . $ optName ) && $ input -> getOption ( $ optName ) ) { throw new \ InvalidArgumentException ( "Conflicting options --no-{$optName} and --{$optName} supplied. That confuses me." ) ; } if ( $ input -> getOption ( 'no-' . $ optName ) ) { $ this -> getContainer ( ) -> set ( $ varName , false ) ; } elseif ( $ input -> getOption ( $ optName ) ) { $ this -> getContainer ( ) -> set ( $ varName , true ) ; } } $ callable = $ this -> getContainer ( ) -> get ( $ this -> getTaskReference ( ) ) ; call_user_func ( $ callable , $ this -> getContainer ( ) ) ; }
Executes the specified task
10,155
public function getEmoticonImages ( $ params = [ ] ) { $ defaults = [ 'emotesets' => null , ] ; return $ this -> wrapper -> request ( 'GET' , 'chat/emoticon_images' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
Returns a list of emoticons .
10,156
private function createDir ( $ path ) { if ( ! is_dir ( $ path ) ) { $ success = mkdir ( $ path , 0775 , true ) ; if ( ! $ success ) { throw new \ Exception ( "Cannot create folder {$path}. Check file system permissions." ) ; } } }
Create Directory If path doesn t exist create it
10,157
public function read ( $ filename , $ pathToFile = null ) { if ( ! $ this -> fileExists ( $ filename , $ pathToFile ) ) throw new \ Exception ( "File, '{$filename}', does not exist." ) ; if ( $ pathToFile == null ) { return file_get_contents ( $ this -> _filePath . "/" . $ filename ) ; } else { return file_get_contents ( $ pathToFile . "/" . $ filename ) ; } }
Read string to file
10,158
public function move ( $ filename , $ pathTo , $ pathFrom = null ) { if ( $ pathFrom == null ) { $ pathFrom = $ this -> _filePath ; } if ( file_exists ( $ pathFrom . "/" . $ filename ) ) { $ this -> createDir ( $ pathTo ) ; return rename ( $ pathFrom . "/" . $ filename , $ pathTo . "/" . $ filename ) ; } else { return null ; } }
Move a file
10,159
public static function getInstance ( $ name = 'default' ) { if ( isset ( static :: $ instances [ $ name ] ) ) { return static :: $ instances [ $ name ] ; } $ instance = new static ( ) ; static :: $ instances [ $ name ] = $ instance ; return $ instance ; }
Get the current instance .
10,160
public function geocode ( string $ latitude , string $ longitude , string $ radius ) : Search { $ this -> parameters [ 'geocode' ] = sprintf ( '%s %s %s' , $ latitude , $ longitude , $ radius ) ; return $ this ; }
use string instead of float
10,161
public static function toObject ( $ array , $ class = \ stdClass :: class ) { $ object = new $ class ; foreach ( $ array as $ name => $ value ) { $ name = trim ( $ name ) ; if ( ! $ name || is_numeric ( $ name ) ) { continue ; } $ object -> $ name = \ is_array ( $ value ) ? self :: toObject ( $ value ) : $ value ; } return $ object ; }
data to array
10,162
public static function safeOutput ( $ string , $ clearTag = false ) { if ( ! $ clearTag ) { $ string = strip_tags ( $ string ) ; } return @ self :: htmlentitiesUTF8 ( $ string ) ; }
Sanitize a string
10,163
public function get ( string $ name ) : array { if ( isset ( $ this -> compiled [ $ name ] ) ) { $ config = $ this -> compiled [ $ name ] ; } else { $ this -> compiled [ $ name ] = $ this -> createServiceConfig ( $ name ) ; $ config = $ this -> compiled [ $ name ] ; } if ( ! isset ( $ config [ 'use' ] ) ) { $ config [ 'use' ] = $ name ; } return $ config ; }
Get service configuration .
10,164
public function getEnv ( string $ param ) : string { if ( preg_match_all ( '#\{ENV\(([A-Za-z0-9_]+)(?:(,?)([^}]*))\)\}#' , $ param , $ matches ) ) { if ( 4 !== count ( $ matches ) ) { return $ param ; } for ( $ i = 0 ; $ i < count ( $ matches [ 0 ] ) ; ++ $ i ) { $ param = $ this -> parseEnv ( $ param , $ matches , $ i ) ; } return $ param ; } return $ param ; }
Parse env param .
10,165
protected function parseEnv ( string $ param , array $ variables , int $ key ) : string { $ env = getenv ( $ variables [ 1 ] [ $ key ] ) ; if ( false === $ env && ! empty ( $ variables [ 3 ] [ $ key ] ) ) { return str_replace ( $ variables [ 0 ] [ $ key ] , $ variables [ 3 ] [ $ key ] , $ param ) ; } if ( false === $ env ) { throw new Exception \ EnvVariableNotFound ( 'env variable ' . $ variables [ 1 ] [ $ key ] . ' required but it is neither set not a default value exists' ) ; } return str_replace ( $ variables [ 0 ] [ $ key ] , $ env , $ param ) ; }
Parse env .
10,166
protected function createServiceConfig ( string $ name ) : array { $ config = [ ] ; if ( $ this -> has ( $ name ) ) { $ config = $ this -> config [ $ name ] ; } $ class = $ name ; if ( isset ( $ config [ 'use' ] ) ) { if ( ! is_string ( $ config [ 'use' ] ) ) { throw new Exception \ InvalidConfiguration ( 'use must be a string for service ' . $ name ) ; } $ class = $ config [ 'use' ] = $ this -> getEnv ( $ config [ 'use' ] ) ; } if ( preg_match ( '#^\{([^{}]+)\}$#' , $ class ) ) { $ config = array_merge ( $ this -> getServiceDefaults ( ) , $ config ) ; return $ config ; } $ config = $ this -> mergeServiceConfig ( $ name , $ class , $ config ) ; if ( isset ( $ config [ 'use' ] ) ) { $ class = $ config [ 'use' ] = $ this -> getEnv ( $ config [ 'use' ] ) ; } if ( ! class_exists ( $ class ) ) { throw new Exception \ InvalidConfiguration ( 'class ' . $ class . ' is either not a class or can not be found' ) ; } return $ config ; }
Create service config .
10,167
protected function mergeServiceConfig ( string $ name , string $ class , array $ config ) : array { $ config = array_merge ( $ this -> getServiceDefaults ( ) , $ config ) ; if ( ! class_exists ( $ class ) && ! interface_exists ( $ class ) ) { return $ config ; } if ( false === $ config [ 'merge' ] ) { return $ config ; } $ tree = $ this -> getConfigTree ( ) ; $ parents = array_merge ( class_implements ( $ class ) , class_parents ( $ class ) ) ; foreach ( $ tree as $ parent_config ) { foreach ( $ parents as $ parent ) { if ( isset ( $ parent_config [ $ parent ] ) ) { $ config = array_replace_recursive ( $ config , $ parent_config [ $ parent ] ) ; } } if ( isset ( $ parent_config [ $ name ] ) ) { $ config = array_replace_recursive ( $ config , $ parent_config [ $ name ] ) ; } } return $ config ; }
Find parent classes or interfaces and merge service configurations .
10,168
protected function getConfigTree ( ) : array { $ tree = [ $ this -> getConfig ( ) ] ; $ parent = $ this -> container ; while ( $ parent = $ parent -> getParent ( ) ) { $ tree [ ] = $ parent -> getConfig ( ) -> getConfig ( ) ; } return $ tree ; }
Get config tree .
10,169
public function mergeParams ( $ method , Array $ params = [ ] ) { $ result = parent :: mergeParams ( $ method , $ params ) ; foreach ( $ this -> map as $ oldKey => $ newKey ) { if ( array_key_exists ( $ oldKey , $ result [ $ method ] ) ) { $ result [ $ method ] [ $ newKey ] = $ result [ $ method ] [ $ oldKey ] ; $ result [ $ method ] [ $ oldKey ] = null ; unset ( $ result [ $ method ] [ $ oldKey ] ) ; } } return $ result ; }
Merge and remap params
10,170
public static function encode ( $ data ) { $ data = ( array ) $ data ; $ resultString = self :: loopEncode ( $ data ) ; return trim ( $ resultString , PHP_EOL ) ; }
Encodes an array to ini strutcture
10,171
public static function loopEncode ( $ data , array $ parent = array ( ) ) { $ resultString = '' ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ sec = array_merge ( ( array ) $ parent , ( array ) $ key ) ; $ resultString .= PHP_EOL . '[' . join ( '.' , $ sec ) . ']' . PHP_EOL ; $ resultString .= self :: loopEncode ( $ value , $ sec ) ; } else { $ resultString .= "$key = $value" . PHP_EOL ; } } return $ resultString ; }
Method to look the data and encode it to ini format
10,172
public static function firstByTitleOrCreate ( $ title , $ locale = null ) { $ tag = Tag :: whereTranslation ( 'title' , $ title , $ locale ) -> first ( ) ; if ( is_null ( $ tag ) ) { $ attributes = compact ( 'title' ) ; if ( $ locale ) { $ attributes = [ $ locale => $ attributes ] ; } $ tag = Tag :: create ( $ attributes ) ; } return $ tag ; }
Finds a tag by title or creates it
10,173
protected function registerLocalizer ( ) { $ this -> app -> bind ( Localizer :: class , function ( $ app ) { $ locales = $ app [ 'config' ] -> get ( "{$this->name}.supported-locales" ) ; $ detectors = $ app [ 'config' ] -> get ( "{$this->name}.detectors" ) ; $ stores = $ app [ 'config' ] -> get ( "{$this->name}.stores" ) ; return new Localizer ( $ locales , $ detectors , $ stores ) ; } ) ; }
Register Localizer .
10,174
public function resolve ( string $ name , ? array $ parameters = null ) { if ( isset ( $ this -> service [ $ name ] ) ) { return $ this -> service [ $ name ] ; } if ( $ this -> config -> has ( $ name ) ) { return $ this -> wrapService ( $ name , $ parameters ) ; } if ( null !== $ this -> parent_service ) { $ parents = array_merge ( [ $ name ] , class_implements ( $ this -> parent_service ) , class_parents ( $ this -> parent_service ) ) ; if ( in_array ( $ name , $ parents , true ) && $ this -> parent_service instanceof $ name ) { return $ this -> parent_service ; } } if ( null !== $ this -> parent ) { return $ this -> parent -> resolve ( $ name , $ parameters ) ; } throw new Exception \ ServiceNotFound ( "service $name was not found in service tree" ) ; }
Resolve service .
10,175
protected function storeService ( string $ name , array $ config , $ service ) { if ( false === $ config [ 'singleton' ] ) { return $ service ; } $ this -> service [ $ name ] = $ service ; if ( isset ( $ this -> children [ $ name ] ) ) { $ this -> children [ $ name ] -> setParentService ( $ service ) ; } return $ service ; }
Store service .
10,176
protected function wrapService ( string $ name , ? array $ parameters = null ) { $ config = $ this -> config -> get ( $ name ) ; if ( true === $ config [ 'wrap' ] ) { $ that = $ this ; return function ( ) use ( $ that , $ name , $ parameters ) { return $ that -> autoWireClass ( $ name , $ parameters ) ; } ; } return $ this -> autoWireClass ( $ name , $ parameters ) ; }
Wrap resolved service in callable if enabled .
10,177
protected function autoWireClass ( string $ name , ? array $ parameters = null ) { $ config = $ this -> config -> get ( $ name ) ; $ class = $ config [ 'use' ] ; if ( null !== $ parameters ) { $ config [ 'singleton' ] = false ; } if ( preg_match ( '#^\{([^{}]+)\}$#' , $ class , $ match ) ) { return $ this -> wireReference ( $ name , $ match [ 1 ] , $ config ) ; } $ reflection = new ReflectionClass ( $ class ) ; if ( isset ( $ config [ 'factory' ] ) ) { $ factory = $ reflection -> getMethod ( $ config [ 'factory' ] ) ; $ args = $ this -> autoWireMethod ( $ name , $ factory , $ config , $ parameters ) ; $ instance = call_user_func_array ( [ $ class , $ config [ 'factory' ] ] , $ args ) ; return $ this -> prepareService ( $ name , $ instance , $ reflection , $ config ) ; } $ constructor = $ reflection -> getConstructor ( ) ; if ( null === $ constructor ) { return $ this -> storeService ( $ name , $ config , new $ class ( ) ) ; } $ args = $ this -> autoWireMethod ( $ name , $ constructor , $ config , $ parameters ) ; return $ this -> createInstance ( $ name , $ reflection , $ args , $ config ) ; }
Auto wire .
10,178
protected function wireReference ( string $ name , string $ reference , array $ config ) { $ service = $ this -> get ( $ reference ) ; $ reflection = new ReflectionClass ( get_class ( $ service ) ) ; $ config = $ this -> config -> get ( $ name ) ; $ service = $ this -> prepareService ( $ name , $ service , $ reflection , $ config ) ; return $ service ; }
Wire named referenced service .
10,179
protected function getProxyInstance ( string $ name , ReflectionClass $ class , array $ arguments , array $ config ) { $ factory = new LazyLoadingValueHolderFactory ( ) ; $ that = $ this ; return $ factory -> createProxy ( $ class -> getName ( ) , function ( & $ wrappedObject , $ proxy , $ method , $ parameters , & $ initializer ) use ( $ that , $ name , $ class , $ arguments , $ config ) { $ wrappedObject = $ that -> getRealInstance ( $ name , $ class , $ arguments , $ config ) ; $ initializer = null ; } ) ; }
Create proxy instance .
10,180
protected function getRealInstance ( string $ name , ReflectionClass $ class , array $ arguments , array $ config ) { $ instance = $ class -> newInstanceArgs ( $ arguments ) ; $ instance = $ this -> prepareService ( $ name , $ instance , $ class , $ config ) ; return $ instance ; }
Create real instance .
10,181
protected function autoWireMethod ( string $ name , ReflectionMethod $ method , array $ config , ? array $ parameters = null ) : array { $ params = $ method -> getParameters ( ) ; $ args = [ ] ; foreach ( $ params as $ param ) { $ type = $ param -> getClass ( ) ; $ param_name = $ param -> getName ( ) ; if ( isset ( $ parameters [ $ param_name ] ) ) { $ args [ $ param_name ] = $ parameters [ $ param_name ] ; } elseif ( isset ( $ config [ 'arguments' ] [ $ param_name ] ) ) { $ args [ $ param_name ] = $ this -> parseParam ( $ config [ 'arguments' ] [ $ param_name ] , $ name ) ; } elseif ( null !== $ type ) { $ args [ $ param_name ] = $ this -> resolveServiceArgument ( $ name , $ type , $ param ) ; } elseif ( $ param -> isDefaultValueAvailable ( ) ) { $ args [ $ param_name ] = $ param -> getDefaultValue ( ) ; } elseif ( $ param -> allowsNull ( ) ) { $ args [ $ param_name ] = null ; } else { throw new Exception \ InvalidConfiguration ( 'no value found for argument ' . $ param_name . ' in method ' . $ method -> getName ( ) . ' for service ' . $ name ) ; } if ( ! $ param -> canBePassedByValue ( ) ) { $ value = & $ args [ $ param_name ] ; $ args [ $ param_name ] = & $ value ; } } return $ args ; }
Autowire method .
10,182
protected function resolveServiceArgument ( string $ name , ReflectionClass $ type , ReflectionParameter $ param ) { $ type_class = $ type -> getName ( ) ; if ( $ type_class === $ name ) { throw new RuntimeException ( 'class ' . $ type_class . ' can not depend on itself' ) ; } try { return $ this -> traverseTree ( $ name , $ type_class ) ; } catch ( \ Exception $ e ) { if ( $ param -> isDefaultValueAvailable ( ) && null === $ param -> getDefaultValue ( ) ) { return null ; } throw $ e ; } }
Resolve service argument .
10,183
protected function parseParam ( $ param , string $ name ) { if ( is_iterable ( $ param ) ) { foreach ( $ param as $ key => $ value ) { $ param [ $ key ] = $ this -> parseParam ( $ value , $ name ) ; } return $ param ; } if ( is_string ( $ param ) ) { $ param = $ this -> config -> getEnv ( $ param ) ; if ( preg_match ( '#^\{\{([^{}]+)\}\}$#' , $ param , $ matches ) ) { return '{' . $ matches [ 1 ] . '}' ; } if ( preg_match ( '#^\{([^{}]+)\}$#' , $ param , $ matches ) ) { return $ this -> traverseTree ( $ name , $ matches [ 1 ] ) ; } return $ param ; } return $ param ; }
Parse param value .
10,184
protected function traverseTree ( string $ current_service , string $ service ) { if ( isset ( $ this -> children [ $ current_service ] ) ) { return $ this -> children [ $ current_service ] -> get ( $ service ) ; } $ config = $ this -> config -> get ( $ current_service ) ; if ( isset ( $ config [ 'services' ] ) ) { $ this -> children [ $ current_service ] = new self ( $ config [ 'services' ] , $ this , $ this -> service [ ContainerInterface :: class ] ) ; return $ this -> children [ $ current_service ] -> get ( $ service ) ; } return $ this -> get ( $ service ) ; }
Locate service .
10,185
private function _getClient ( ) : ClientInterface { if ( ! $ this -> client instanceof ClientInterface ) $ this -> client = new Client ( $ this -> clientConfig ) ; return $ this -> client ; }
get a client implements \ GuzzleHttp \ ClientInterface
10,186
public function addClientHeader ( string $ headerName , $ headerValue ) : self { $ this -> clientConfig [ 'headers' ] [ $ headerName ] = $ headerValue ; return $ this ; }
add a client request header
10,187
private function _responseSuccessHandle ( $ response , $ index ) { try { if ( ! $ response instanceof ResponseInterface ) throw new UnknowResponseExpection ( $ response ) ; $ result = $ response -> getBody ( ) -> getContents ( ) ; $ cbk = $ this -> requestList [ $ index ] -> getSuccessCallbackList ( ) ; if ( ! empty ( $ cbk ) ) { $ result = array_reduce ( $ cbk , function ( $ prev , $ cb ) { return $ cb ( $ prev ) ; } , $ result ) ; } $ response = new SimpleResponse ( ) ; $ response -> setResult ( $ result ) ; $ this -> requestList [ $ index ] -> setResponse ( $ response ) ; } catch ( \ Exception $ e ) { $ this -> _responseFailHandle ( $ e , $ index ) ; } }
when request successed this method will be called
10,188
private function _responseFailHandle ( $ error , $ index ) { $ cbk = $ this -> requestList [ $ index ] -> getFailCallbackList ( ) ; if ( ! empty ( $ cbk ) ) { $ error = array_reduce ( $ cbk , function ( $ prev , $ cb ) { return $ cb ( $ prev ) ; } , $ error ) ; } $ response = new SimpleResponse ( ) ; $ response -> setFail ( $ error ) ; $ this -> requestList [ $ index ] -> setResponse ( $ response ) ; }
when request failed this method will be called
10,189
private function _getRequestPool ( ) : Pool { return new Pool ( $ this -> _getClient ( ) , $ this -> _getRequestPromise ( ) , [ 'concurrency' => max ( 1 , $ this -> configOfConcurrency ) , 'fulfilled' => function ( ) { call_user_func_array ( [ $ this , '_responseSuccessHandle' ] , func_get_args ( ) ) ; } , 'rejected' => function ( ) { call_user_func_array ( [ $ this , '_responseFailHandle' ] , func_get_args ( ) ) ; } ] ) ; }
build a request pool implements \ GuzzleHttp \ Pool
10,190
public function customSetting ( string $ settingKey , $ settingValue ) : self { $ this -> clientConfig [ $ settingKey ] = $ settingValue ; return $ this ; }
add or modify client config by custom
10,191
public function authenticate ( CakeRequest $ request , CakeResponse $ response ) { App :: uses ( 'MtSites' , 'MtSites./Utility/MtSites' ) ; if ( ! MtSites :: isTenant ( ) ) { return false ; } $ userModel = $ this -> settings [ 'userModel' ] ; list ( , $ model ) = pluginSplit ( $ userModel ) ; $ fields = $ this -> settings [ 'fields' ] ; if ( ! $ this -> _checkFields ( $ request , $ model , $ fields ) ) { return false ; } return $ this -> _findUser ( $ request -> data [ $ model ] [ $ fields [ 'pin' ] ] ) ; }
Authenticates the identity contained in a request . Will use the settings . userModel and settings . fields to find POST data that is used to find a matching record in the settings . userModel . Will return false if there is no post data either username or pin is missing or if the scope conditions have not been met .
10,192
public function addTerm ( $ term , $ filename , $ line_number ) { if ( ! isset ( $ this [ $ term ] ) ) { $ this [ $ term ] = array ( ) ; } if ( ! isset ( $ this [ $ term ] [ $ filename ] ) ) { $ this [ $ term ] [ $ filename ] = array ( ) ; } $ this [ $ term ] [ $ filename ] [ ] = $ line_number ; }
Adds a glossary term to the collection .
10,193
public static function fromColumn ( Db \ Column $ column ) { $ data = $ column -> toArray ( ) ; if ( isset ( $ data [ 'type' ] ) && is_integer ( $ data [ 'type' ] ) ) { $ data [ 'type' ] = self :: getTypeName ( $ data [ 'type' ] ) ; } if ( isset ( $ data [ 'bindType' ] ) && is_integer ( $ data [ 'bindType' ] ) ) { $ data [ 'bindType' ] = self :: getBindName ( $ data [ 'bindType' ] ) ; } return new self ( $ data ) ; }
create column object
10,194
public function useEncryption ( $ key ) { $ this -> encryptor = new \ sb \ Encryption \ ForTransmission ( $ key ) ; $ this -> encryption_key = $ key ; }
Sets the key that data is encrypted with and turns on encryption the server must use the same key
10,195
public function addCookie ( $ cookie = Array ( ) ) { foreach ( $ cookie as $ key => $ val ) { if ( isset ( $ this -> encryption_key ) ) { $ val = $ this -> encryptor -> encrypt ( $ val ) ; } $ this -> cookies [ $ key ] = $ val ; } }
Adds a cookie to send to the server
10,196
protected function processResponse ( $ str ) { if ( ! empty ( $ this -> encryption_key ) ) { $ str = $ this -> encryptor -> decrypt ( $ str ) ; } $ this -> logResponse ( $ str ) ; if ( $ this -> php_serialize_response && ! empty ( $ str ) ) { try { $ serialized = \ unserialize ( $ str ) ; if ( $ serialized !== false ) { $ response = $ serialized ; } } catch ( \ Exception $ e ) { if ( $ this -> debug ) { echo $ body ; } } } $ str = \ utf8_encode ( $ str ) ; if ( ! isset ( $ response ) ) { $ response = new \ sb \ JSON \ RPC2 \ Response ( $ str ) ; } return $ response ; }
Break down the received data into headers and response and then handle gz encoding encryption utf etc
10,197
public static function files ( array $ listOfFiles ) { $ listOfContents = array ( ) ; foreach ( $ listOfFiles as $ key => $ filepath ) { $ listOfContents [ $ key ] = self :: file ( $ filepath ) ; } return $ listOfContents ; }
Creates an array of objects from multiple files
10,198
function fetchObjectAttributeHTTPInput ( $ http , $ base , $ contentObjectAttribute ) { $ enabledName = $ base . '_ezcomcomments_enabled_' . $ contentObjectAttribute -> attribute ( 'id' ) ; $ shownName = $ base . '_ezcomcomments_shown_' . $ contentObjectAttribute -> attribute ( 'id' ) ; $ enabledValue = - 1 ; $ shownValue = - 1 ; if ( $ http -> hasPostVariable ( $ enabledName ) ) { $ enabledValue = 1 ; } if ( $ http -> hasPostVariable ( $ shownName ) ) { $ shownValue = 1 ; } $ contentObjectAttribute -> setAttribute ( 'data_float' , $ shownValue ) ; $ contentObjectAttribute -> setAttribute ( 'data_int' , $ enabledValue ) ; return true ; }
put the option enabled of ezcomcomment into data_int of contentobjectattribute
10,199
function deleteStoredObjectAttribute ( $ contentObjectAttribute , $ version = null ) { $ version = $ contentObjectAttribute -> objectVersion ( ) ; if ( ! is_null ( $ version ) && $ version -> attribute ( 'status' ) == eZContentObjectVersion :: STATUS_PUBLISHED ) { $ contentObjectID = $ contentObjectAttribute -> attribute ( 'contentobject_id' ) ; $ languageID = $ contentObjectAttribute -> attribute ( 'language_id' ) ; eZPersistentObject :: removeObject ( ezcomComment :: definition ( ) , array ( 'contentobject_id' => $ contentObjectID , 'language_id' => $ languageID ) ) ; } }
When deleting the content object deleting all the comments .