idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
52,900
public function paginate ( $ limit ) { $ capsule = $ this -> _database -> getCapsule ( ) ; $ this -> _model = $ capsule -> table ( $ this -> table ) ; $ paginator = new Pagination ( ) ; $ paginator -> setLimit ( $ limit ) -> setModel ( $ this , $ this -> _model ) ; return $ paginator -> paginate ( ) ; }
Does like all but creates pagination for results .
52,901
public function save ( $ options ) { $ gcc = get_called_class ( ) ; $ class = $ gcc :: init ( ) ; $ cap = $ this -> _database -> getCapsule ( ) ; $ params = ( array ) $ options ; $ this -> filter ( $ params ) ; return $ cap -> table ( $ this -> table ) -> update ( $ params ) ; }
Saves changes to a model .
52,902
private function filter ( & $ options ) { foreach ( $ options as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> fillable ) ) { unset ( $ options [ $ key ] ) ; } } }
Filters out options that are not included in a model s fillable array .
52,903
protected function parseResourceSignature ( ) { list ( $ topic , $ actionAndFormat ) = explode ( '/' , $ this -> signature ) ; list ( $ action , $ format ) = explode ( '.' , $ actionAndFormat ) ; $ this -> topic = ucfirst ( $ topic ) ; $ this -> action = ucfirst ( $ action ) ; $ this -> format = $ format ; }
parses a resource signature
52,904
protected function initializeConcreteResource ( ) { $ this -> concreteResource = $ this -> resourceResolver -> resolve ( $ this -> topic , $ this -> action ) ; }
initializes a concrete resource implementation
52,905
public function restore ( ) { $ this -> offsetRef = $ this -> offset ; $ this -> lineRef = $ this -> line ; $ this -> rowRef = $ this -> row ; }
Restores the source to which this state belongs to this state .
52,906
public static function replace ( array $ words , $ replacement , $ text ) { $ self = new self ; $ length = $ self -> wordsLength ( $ words ) ; $ blocks = array_unique ( $ length ) ; $ min = end ( $ blocks ) ; $ chars = $ self -> splitText ( $ text ) ; $ index = $ self -> index ( $ chars ) ; $ pinyins = $ self -> pinyin...
Replace words with replacements in a text .
52,907
protected function wordsLength ( array $ words ) { $ length = [ ] ; foreach ( $ words as $ word ) { $ pinyin = $ this -> pinyin -> sentence ( $ word ) ; $ length [ md5 ( $ pinyin ) ] = ( $ pinyin === $ word ) ? 1 : mb_strlen ( $ word ) ; } arsort ( $ length ) ; return $ length ; }
Get echo word length and use md5 as key .
52,908
protected function splitText ( $ text ) { $ punctuations = preg_quote ( implode ( '' , $ this -> punctuations ) , '/' ) ; $ text = preg_replace ( '/([^\p{Han}\s' . $ punctuations . ']+)/u' , "\t\t\t$1\t\t" , $ text ) ; $ array = [ ] ; foreach ( preg_split ( '/\t\t/u' , $ text , - 1 , PREG_SPLIT_NO_EMPTY ) as $ item ) {...
Spilt text to array .
52,909
protected function index ( array $ chars ) { $ index = [ ] ; foreach ( $ chars as $ key => $ char ) { if ( preg_match ( '/[\p{Han}\w]+/u' , $ char ) ) { $ index [ ] = $ key ; } } return $ index ; }
Build words index .
52,910
public function setData ( array $ data = [ ] ) { $ this -> default = empty ( $ data ) ; $ this -> data = array_replace ( [ static :: VISIBLE_COLUMNS => [ ] , static :: MAX_PER_PAGE => null , static :: CONFIG => null , static :: PAGE_NUM => null , static :: SORT => null , static :: ADD_FILTER => null , static :: REMOVE_...
Sets the data .
52,911
public function getSortHref ( ColumnInterface $ column ) { $ parameter = $ this -> getSortName ( ) ; $ dir = ( $ column -> getSortDirection ( ) === ColumnSort :: ASC ? ColumnSort :: DESC : ColumnSort :: ASC ) ; return '?' . $ parameter . '[by]=' . $ column -> getName ( ) . '&' . $ parameter . '[dir]=' . $ dir ; }
Returns the sort column href .
52,912
public function getIdentifiersName ( ) { $ name = $ this -> tableName . '[' . static :: IDENTIFIERS . ']' ; if ( $ this -> selectionMode == Config :: SELECTION_MULTIPLE ) { $ name .= '[]' ; } return $ name ; }
Returns the identifiers parameter name .
52,913
private function getProfileValue ( $ name ) { if ( isset ( $ this -> data [ static :: PROFILE ] [ $ name ] ) ) { return $ this -> data [ static :: PROFILE ] [ $ name ] ; } return null ; }
Returns the profile parameter value .
52,914
public function offsetExists ( $ key ) { if ( is_numeric ( $ key ) ) { throw new InvalidArgumentException ( 'Entity array access only supports non-numeric keys' ) ; } if ( $ this -> separator && strstr ( $ key , $ this -> separator ) ) { return $ this -> hasWithSeparator ( $ key ) ; } $ key = $ this -> camelize ( $ key...
Determines if this store contains the specified key and if its value is not NULL .
52,915
public function offsetReplace ( $ key , $ value ) { if ( is_numeric ( $ key ) ) { throw new InvalidArgumentException ( 'Entity array access only supports non-numeric keys' ) ; } $ key = $ this -> camelize ( $ key ) ; if ( $ key === '' ) { return ; } if ( is_array ( $ value ) && isset ( $ this [ $ key ] ) ) { $ data = $...
Replaces the value from the specified key .
52,916
public function addFile ( $ path ) { $ config = $ this -> loadFile ( $ path ) ; if ( is_array ( $ config ) ) { $ this -> merge ( $ config ) ; } return $ this ; }
Adds a configuration file to the configset .
52,917
public static function ltrim ( $ docComment ) { $ regexp = array ( '|^[\s\t]*(/\*\*)|um' => '\\1' , '|^[\s\t]*([ ]\*/)|um' => '\\1' , '|^[\s\t]*([ ]\*[ ]*)|um' => '\\1' , ) ; $ patterns = array_keys ( $ regexp ) ; $ replacements = array_values ( $ regexp ) ; $ docComment = preg_replace ( $ patterns , $ replacements , $...
Trim spaces and tabs on the left
52,918
public function renderColumnBody ( ColumnView $ view , array $ variables = array ( ) ) { return $ this -> render ( $ view , 'column_' . $ view -> get ( 'type' ) , $ variables ) ; }
Renders column body .
52,919
protected function getBlocks ( DataGridView $ view ) { if ( ! $ this -> blocks -> contains ( $ view ) ) { $ templates = $ this -> resources ; if ( isset ( $ this -> themes [ $ view ] ) ) { $ templates = array_merge ( $ templates , $ this -> themes [ $ view ] ) ; } $ blocks = array ( ) ; foreach ( $ templates as $ templ...
Returns the blocks used to render the view .
52,920
public function getShippingContactDifferences ( $ mode = self :: MODE_FILTER_EMPTY_WHEN_STRING_VALUES ) { $ difference = [ ] ; foreach ( $ this -> getContactParameterNames ( ) as $ parameterName ) { $ billingGetter = 'getBilling' . ucfirst ( $ parameterName ) ; $ shippingGetter = 'getShipping' . ucfirst ( $ parameterNa...
Returns those shipping contact parameters which are different for shipping and billing Keys are camel cased parameter names without shipping prefix values are shipping contact parameter values
52,921
public function chain ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ __ = ( isset ( $ this ) && isset ( $ this -> _chained ) && $ this -> _chained ) ? $ this : __ ( $ item ) ; $ __ -> _chained = true ; return $ __ ; }
Are we in a chain?
52,922
public function each ( $ collection = null , $ iterator = null ) { list ( $ collection , $ iterator ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; if ( is_null ( $ collection ) ) return self :: _wrap ( null ) ; $ collection = ( array ) self :: _collection ( $ collection ) ; if ( count ( $ collection ) === 0 ) return...
Invoke the iterator on each item in the collection
52,923
public function invoke ( $ collection = null , $ function_name = null , $ arguments = null ) { $ args = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ __ = new self ; list ( $ collection , $ function_name ) = $ __ -> first ( $ args , 2 ) ; $ arguments = $ __ -> rest ( func_get_args ( ) , 2 ) ; $ is_obj = is_object ( $...
Invoke the named function over each item in the collection optionally passing arguments to the function
52,924
public function size ( $ collection = null ) { list ( $ collection ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ collection = self :: _collection ( $ collection ) ; return self :: _wrap ( count ( ( array ) $ collection ) ) ; }
How many items are in this collection?
52,925
public function initial ( $ collection = null , $ n = null ) { list ( $ collection , $ n ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ collection = ( array ) self :: _collection ( $ collection ) ; if ( is_null ( $ n ) ) $ n = 1 ; $ first_index = count ( $ collection ) - $ n ; $ __ = new self ; return self :: _wra...
Return everything but the last array element . Passing n excludes the last n elements .
52,926
public function compact ( $ collection = null ) { list ( $ collection ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ collection = self :: _collection ( $ collection ) ; $ __ = new self ; return self :: _wrap ( $ __ -> select ( $ collection , function ( $ val ) { return ( bool ) $ val ; } ) ) ; }
Return a copy of the array with falsy values removed
52,927
public function flatten ( $ collection = null , $ shallow = null ) { list ( $ collection , $ shallow ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ collection = self :: _collection ( $ collection ) ; $ return = array ( ) ; if ( count ( $ collection ) > 0 ) { foreach ( $ collection as $ item ) { if ( is_array ( $ i...
Flattens a multidimensional array
52,928
public function without ( $ collection = null , $ val = null ) { $ args = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ collection = $ args [ 0 ] ; $ collection = self :: _collection ( $ collection ) ; $ num_args = count ( $ args ) ; if ( $ num_args === 1 ) return self :: _wrap ( $ collection ) ; if ( count ( $ colle...
Returns a copy of the array with all instances of val removed
52,929
public function intersection ( $ array = null ) { $ arrays = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; if ( count ( $ arrays ) === 1 ) return self :: _wrap ( $ array ) ; $ __ = new self ; $ return = $ __ -> first ( $ arrays ) ; foreach ( $ __ -> rest ( $ arrays ) as $ next ) { if ( ! $ __ -> isArray ( $ next ) ) $ ...
Returns an array containing the intersection of all the arrays
52,930
public function union ( $ array = null ) { $ arrays = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; if ( count ( $ arrays ) === 1 ) return self :: _wrap ( $ array ) ; $ __ = new self ; return self :: _wrap ( $ __ -> flatten ( array_values ( array_unique ( call_user_func_array ( 'array_merge' , $ arrays ) ) ) ) ) ; }
Merge together multiple arrays
52,931
public function difference ( $ array_one = null , $ array_two = null ) { $ arrays = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( array_values ( call_user_func_array ( 'array_diff' , $ arrays ) ) ) ; }
Get the difference between two arrays
52,932
public function indexOf ( $ collection = null , $ item = null ) { list ( $ collection , $ item ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ collection = self :: _collection ( $ collection ) ; $ key = array_search ( $ item , $ collection , true ) ; return self :: _wrap ( ( is_bool ( $ key ) ) ? - 1 : $ key ) ; }
Get the index of the first match
52,933
public function lastIndexOf ( $ collection = null , $ item = null ) { list ( $ collection , $ item ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ collection = self :: _collection ( $ collection ) ; krsort ( $ collection ) ; $ __ = new self ; return self :: _wrap ( $ __ -> indexOf ( $ collection , $ item ) ) ; }
Get the index of the last match
52,934
public function max ( $ collection = null , $ iterator = null ) { list ( $ collection , $ iterator ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; if ( is_null ( $ iterator ) ) return self :: _wrap ( max ( $ collection ) ) ; $ results = array ( ) ; foreach ( $ collection as $ k => $ item ) { $ results [ $ k ] = $ ite...
Get the max value in the collection
52,935
public function sortedIndex ( $ collection = null , $ value = null , $ iterator = null ) { list ( $ collection , $ value , $ iterator ) = self :: _wrapArgs ( func_get_args ( ) , 3 ) ; $ collection = ( array ) self :: _collection ( $ collection ) ; $ __ = new self ; $ calculated_value = ( ! is_null ( $ iterator ) ) ? $ ...
Returns the index at which the value should be inserted into the sorted collection
52,936
public function shuffle ( $ collection = null ) { list ( $ collection ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ collection = ( array ) self :: _collection ( $ collection ) ; shuffle ( $ collection ) ; return self :: _wrap ( $ collection ) ; }
Shuffle the array
52,937
public function keys ( $ collection = null ) { list ( $ collection ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; if ( ! is_object ( $ collection ) && ! is_array ( $ collection ) ) throw new Exception ( 'Invalid object' ) ; return self :: _wrap ( array_keys ( ( array ) $ collection ) ) ; }
Get the collection s keys
52,938
public function values ( $ collection = null ) { list ( $ collection ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( array_values ( ( array ) $ collection ) ) ; }
Get the collection s values
52,939
public function extend ( $ object = null ) { $ args = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ num_args = func_num_args ( ) ; if ( $ num_args === 1 ) return $ object ; $ is_object = is_object ( $ object ) ; $ array = ( array ) $ object ; $ __ = new self ; $ extensions = $ __ -> rest ( func_get_args ( ) ) ; forea...
Copy all properties from the source objects into the destination object
52,940
public function defaults ( $ object = null ) { $ args = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; list ( $ object ) = $ args ; $ num_args = count ( $ args ) ; if ( $ num_args === 1 ) return $ object ; $ is_object = is_object ( $ object ) ; $ array = ( array ) $ object ; $ __ = new self ; $ extensions = $ __ -> rest...
Returns the object with any missing values filled in using the defaults .
52,941
public function clon ( & $ object = null ) { list ( $ object ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; $ clone = null ; if ( is_array ( $ object ) ) $ clone = ( array ) clone ( object ) $ object ; elseif ( ! is_object ( $ object ) ) $ clone = $ object ; elseif ( ! $ clone ) $ clone = clone $ object ; if ( is_ob...
Returns a shallow copy of the object
52,942
public function tap ( $ object = null , $ interceptor = null ) { list ( $ object , $ interceptor ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ interceptor ( $ object ) ; return self :: _wrap ( $ object ) ; }
Invokes the interceptor on the object then returns the object
52,943
public function has ( $ collection = null , $ key = null ) { list ( $ collection , $ key ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ collection = ( array ) self :: _collection ( $ collection ) ; return self :: _wrap ( array_key_exists ( $ key , $ collection ) ) ; }
Does the given key exist?
52,944
public function isEqual ( $ a = null , $ b = null ) { list ( $ a , $ b ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; if ( isset ( $ this ) && isset ( $ this -> _chained ) && $ this -> _chained ) $ a = & $ this ; if ( $ a === $ b ) return self :: _wrap ( true ) ; if ( gettype ( $ a ) !== gettype ( $ b ) ) return sel...
Are these items equal?
52,945
public function isEmpty ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_array ( $ item ) || is_object ( $ item ) ) ? ! ( ( bool ) count ( ( array ) $ item ) ) : ( ! ( bool ) $ item ) ; }
Is this item empty?
52,946
public function isObject ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_object ( $ item ) ) ; }
Is this item an object?
52,947
public function isArray ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_array ( $ item ) ) ; }
Is this item an array?
52,948
public function isString ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_string ( $ item ) ) ; }
Is this item a string?
52,949
public function isNumber ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( ( is_int ( $ item ) || is_float ( $ item ) ) && ! is_nan ( $ item ) && ! is_infinite ( $ item ) ) ; }
Is this item a number?
52,950
public function isBoolean ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_bool ( $ item ) ) ; }
Is this item a bool?
52,951
public function isDate ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_object ( $ item ) && get_class ( $ item ) === 'DateTime' ) ; }
Is this item an instance of DateTime?
52,952
public function isNaN ( $ item = null ) { list ( $ item ) = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( is_nan ( $ item ) ) ; }
Is this item a NaN value?
52,953
public function identity ( ) { $ args = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; if ( is_array ( $ args ) ) return self :: _wrap ( $ args [ 0 ] ) ; return self :: _wrap ( function ( $ x ) { return $ x ; } ) ; }
Returns the same value passed as the argument
52,954
public function times ( $ n = null , $ iterator = null ) { list ( $ n , $ iterator ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; if ( is_null ( $ n ) ) $ n = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ iterator ( $ i ) ; return self :: _wrap ( null ) ; }
Invokes the iterator n times
52,955
public function templateSettings ( $ settings = null ) { $ _template_settings = & self :: getInstance ( ) -> _template_settings ; if ( is_null ( $ settings ) ) { $ _template_settings = array ( 'evaluate' => self :: TEMPLATE_DEFAULT_EVALUATE , 'interpolate' => self :: TEMPLATE_DEFAULT_INTERPOLATE , 'escape' => self :: T...
Set template settings
52,956
public function template ( $ code = null , $ context = null ) { list ( $ code , $ context ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; $ class_name = __CLASS__ ; $ return = self :: _wrap ( function ( $ context = null ) use ( $ code , $ class_name ) { $ ts = $ class_name :: getInstance ( ) -> _template_settings ; e...
Compile templates into functions that can be evaluated for rendering
52,957
public function wrap ( $ function = null , $ wrapper = null ) { list ( $ function , $ wrapper ) = self :: _wrapArgs ( func_get_args ( ) , 2 ) ; return self :: _wrap ( function ( ) use ( $ wrapper , $ function ) { $ args = array_merge ( array ( $ function ) , func_get_args ( ) ) ; return call_user_func_array ( $ wrapper...
Wraps the function inside the wrapper function passing it as the first argument
52,958
public function compose ( ) { $ functions = self :: _wrapArgs ( func_get_args ( ) , 1 ) ; return self :: _wrap ( function ( ) use ( $ functions ) { $ args = func_get_args ( ) ; foreach ( $ functions as $ function ) { $ args [ 0 ] = call_user_func_array ( $ function , $ args ) ; } return $ args [ 0 ] ; } ) ; }
Returns the composition of the functions
52,959
private function _wrap ( $ val ) { if ( isset ( $ this ) && isset ( $ this -> _chained ) && $ this -> _chained ) { $ this -> _wrapped = $ val ; return $ this ; } return $ val ; }
Value passed from one chained method to the next
52,960
private function _wrapArgs ( $ caller_args , $ num_args = null ) { $ num_args = ( is_null ( $ num_args ) ) ? count ( $ caller_args ) - 1 : $ num_args ; $ filled_args = array ( ) ; if ( isset ( $ this ) && isset ( $ this -> _wrapped ) ) { $ filled_args [ ] = & $ this -> _wrapped ; } if ( count ( $ caller_args ) > 0 ) { ...
because this function understands both OO - style and functional calls
52,961
private function _collection ( $ collection ) { return ( ! is_array ( $ collection ) && ! is_object ( $ collection ) ) ? str_split ( ( string ) $ collection ) : $ collection ; }
Get a collection in a way that supports strings
52,962
public function hasFlag ( $ flag ) { if ( ! is_string ( $ flag ) ) { throw new \ Console \ Exception \ InvalidArgument ( 'Parameter must be string.' ) ; } return in_array ( $ flag , $ this -> _flags ) ; }
Check if flag exists
52,963
public function hasOption ( $ option ) { if ( ! is_string ( $ option ) ) { throw new \ Console \ Exception \ InvalidArgument ( 'Parameter must be string.' ) ; } return isset ( $ this -> _options [ $ option ] ) ; }
Check if option exists
52,964
public function hasOptions ( array $ options ) { $ all = true ; foreach ( $ options as $ option ) { if ( ! isset ( $ this -> _options [ $ option ] ) ) { $ all = false ; } } return $ all ; }
Check if multiple options are given in the command - line arguments
52,965
public function getOption ( $ option ) { return isset ( $ this -> _options [ $ option ] ) ? $ this -> _options [ $ option ] : null ; }
Get option value
52,966
protected function getUserAccountName ( NotificationInterface $ notification , $ keyInData = 'uid' ) { $ names = [ ] ; $ count = 0 ; if ( isset ( $ notification [ $ keyInData ] ) ) { $ uidList = $ notification [ $ keyInData ] ; $ count = count ( $ uidList ) ; if ( ! is_array ( $ uidList ) ) { $ uidList = [ $ uidList ] ...
Return user account name for given uid
52,967
protected function getTitleString ( $ titles , $ count ) { $ limit = $ this -> getLimit ( ) ; $ okCount = count ( $ titles ) ; $ missing = $ count - $ okCount ; $ andCount = max ( [ 0 , $ okCount - $ limit ] ) + $ missing ; if ( ! $ okCount ) { list ( $ singular , $ plural ) = $ this -> getTypeLabelVariations ( $ count...
Get title string
52,968
public function addFieldError ( $ failureCode , $ fieldResolved , $ fieldType , $ fieldTitle , $ value , $ defaultErrorMessage ) { $ this -> errors [ ] = new FieldValidationError ( $ failureCode , $ fieldResolved , $ fieldType , $ fieldTitle , $ value , $ defaultErrorMessage ) ; return $ this ; }
Adds an error that is associated with a form field .
52,969
public function addErrors ( array $ errors ) { foreach ( $ errors as $ error ) { if ( ! $ error instanceof ValidationError ) throw new Exception ( 'Error was not instance of ValidationError: ' . $ error ) ; if ( ! in_array ( $ error , $ this -> errors ) ) $ this -> errors [ ] = $ error ; } return $ this ; }
Adds more than one error to the collection of errors
52,970
public function hasFieldError ( $ field ) { foreach ( ( array ) $ this -> errors as $ err ) { if ( $ err instanceof FieldValidationError ) { $ tfield = $ err -> getFieldResolved ( ) ; if ( $ tfield == $ field ) return true ; } } return false ; }
Determines if an error has occurred for the supplied field already
52,971
public function getErrorsAsArray ( ) { $ errors = array ( ) ; $ errors [ 'HasErrors' ] = $ this -> hasErrors ( ) ; $ errors [ 'ErrorCount' ] = $ this -> getErrorCount ( ) ; $ errors [ 'Errors' ] = ( array ) $ this -> errors ; foreach ( ( array ) $ this -> errors as $ err ) { if ( $ err instanceof FieldValidationError )...
Extracts the errors from the collection as ValidationErrors into simple arrays
52,972
public function toString ( ) { $ errorString = '' ; foreach ( ( array ) $ this -> errors as $ err ) { $ errorString .= $ err -> getDefaultErrorMessage ( ) . ", " ; } return substr ( $ errorString , 0 , - 2 ) ; }
Returns a string that s a combination of all errors
52,973
public function rejectField ( $ errorCode , $ fieldResolved , $ fieldTitle , $ value , $ message = '' ) { $ this -> addFieldError ( $ errorCode , $ fieldResolved , 'field' , $ fieldTitle , $ value , $ message == '' ? "$fieldTitle is required." : $ message ) ; return $ this ; }
Adds a field error to the specified field
52,974
public function validateModelObject ( ModelObject $ model ) { $ fields = $ model -> getPersistentFields ( ) ; foreach ( $ fields as $ fieldName ) { $ value = $ model -> $ fieldName ; $ fieldResolved = get_class ( $ model ) . '.' . $ fieldName ; $ this -> rejectIfInvalid ( $ fieldResolved , 'field' , $ model -> getField...
Validates the model object rejecting the fields that fail validation
52,975
public static function wordsTokenized ( $ string ) { for ( $ tokens = array ( ) , $ nextToken = strtok ( $ string , ' ' ) ; $ nextToken !== false ; $ nextToken = strtok ( ' ' ) ) { if ( $ nextToken { 0 } == '"' ) $ nextToken = $ nextToken { strlen ( $ nextToken ) - 1 } == '"' ? '"' . substr ( $ nextToken , 1 , - 1 ) . ...
Splits a string into an array exploded by spaces . However it takes quoted strings into account will count them as a single item .
52,976
public static function smartSplit ( $ data , $ delimiter = ';' , $ quote = "'" , $ escape = "\\'" , $ limit = null ) { $ results = array ( ) ; $ lines = explode ( $ delimiter , $ data ) ; if ( empty ( $ lines ) ) return array ( ) ; $ broke = false ; for ( $ i = 0 ; $ i < count ( $ lines ) ; $ i ++ ) { $ line = $ lines ...
Split a string around a delimiter taking into account quoted substrings
52,977
public static function lineIsOpenQuoted ( $ line , $ quote , $ escape ) { $ pos = 0 ; $ quote_open = false ; $ esc_len = strlen ( $ escape ) ; for ( ; $ pos < strlen ( $ line ) ; ++ $ pos ) { $ char = $ line [ $ pos ] ; if ( substr ( $ line , $ pos , $ esc_len ) == $ escape ) { $ pos += $ esc_len - 1 ; continue ; } if ...
Determines if a line is open - quoted and continues to the next line .
52,978
public static function smartExplode ( $ string ) { if ( empty ( $ string ) ) return array ( ) ; if ( is_array ( $ string ) ) return $ string ; if ( ! is_array ( $ string ) ) { if ( strpos ( $ string , ';' ) !== false ) return explode ( ';' , trim ( $ string , ';' ) ) ; if ( strpos ( $ string , ',' ) !== false ) return ...
Explodes a string into an array split upon ; or characters
52,979
public static function pluralize ( $ word ) { $ plural = array ( '/(quiz)$/i' => '\1zes' , '/^(ox)$/i' => '\1en' , '/([m|l])ouse$/i' => '\1ice' , '/(matr|vert|ind)ix|ex$/i' => '\1ices' , '/(x|ch|ss|sh)$/i' => '\1es' , '/([^aeiouy]|qu)ies$/i' => '\1y' , '/([^aeiouy]|qu)y$/i' => '\1ies' , '/(hive)$/i' => '\1s' , '/(?:([^...
Takes a word and makes it plural .
52,980
public static function strToBool ( $ string ) { if ( is_bool ( $ string ) ) return $ string ; if ( in_array ( strtolower ( ( string ) $ string ) , array ( '1' , 'true' , 'on' , '+' , 'yes' , 'y' ) ) ) return true ; elseif ( in_array ( strtolower ( ( string ) $ string ) , array ( '' , '0' , 'false' , 'off' , '-' , 'no' ...
Translates the given string into a boolean value if it s in the proper format
52,981
public static function stripslashesDeep ( $ value ) { $ value = is_array ( $ value ) ? array_map ( array ( 'StringUtils' , 'stripslashesDeep' ) , $ value ) : stripslashes ( $ value ) ; return $ value ; }
Recursively strips slashes from all values in the array
52,982
public static function stripHtml ( $ value , $ tags = null , $ keepContent = false ) { $ content = '' ; if ( ! is_array ( $ tags ) ) { $ tags = ( strpos ( $ value , '>' ) !== false ? explode ( '>' , str_replace ( '<' , '' , $ tags ) ) : array ( $ tags ) ) ; if ( end ( $ tags ) == '' ) array_pop ( $ tags ) ; } foreach (...
Strips a string of HTML tags specified can strip content or just remove tags
52,983
public static function convertMetric ( $ value , $ from , $ to , $ precision = null ) { switch ( $ from . $ to ) { case 'incm' : $ value *= 2.54 ; break ; case 'inmm' : $ value *= 25.4 ; break ; case 'inpt' : $ value *= 72 ; break ; case 'cmin' : $ value /= 2.54 ; break ; case 'cmmm' : $ value *= 10 ; break ; case 'cmp...
convert value from one metric to another .
52,984
public function setValues ( $ values ) { if ( false === is_array ( $ values ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ values ) ) , E_USER_ERROR ) ; } $ this -> values = $ values ; return $ this ; }
Add one or multiple fields to combine them as one
52,985
public function setFieldnames ( $ fieldnames ) { if ( false === is_array ( $ fieldnames ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ fieldnames ) ) , E_USER_ERROR ) ; } $ this -> fieldnames = $ fieldnames ; }
Sets the fieldnames
52,986
public function glue ( $ glue ) { if ( false === is_string ( $ glue ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ glue ) ) , E_USER_ERROR ) ; } $ this -> glue = $ glue ; return $ this ; }
Joins the fieldnames with the glue string between each fieldname
52,987
public function format ( $ format ) { if ( false === is_string ( $ format ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ format ) ) , E_USER_ERROR ) ; } $ this -> format = $ format ; return $ this ; }
Converts the fieldname values to the specific given format
52,988
public function name ( $ name ) { if ( false === is_string ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } $ this -> name = $ name ; return $ this ; }
Gives the combined fieldnames a new single name
52,989
public function combine ( ) { if ( count ( $ this -> values ) > 0 ) { if ( null !== $ this -> glue ) { return implode ( $ this -> glue , $ this -> values ) ; } return vsprintf ( $ this -> format , $ this -> values ) ; } }
Combine the values with the glue or format
52,990
protected function getRecursiveAncestry ( Collection $ all_results , $ ids ) { $ all_results -> merge ( $ results = DB :: table ( $ this -> hierarchyTable ) -> whereIn ( 'term_id' , $ ids ) -> get ( ) ) ; if ( count ( $ results ) ) { $ this -> getRecursiveAncestry ( $ all_results , Arr :: pluck ( $ results , 'parent_id...
Get the ancestry recursively
52,991
public function createManyToOne ( $ request , $ match ) { $ parent = Pluf_Shortcuts_GetObjectOr404 ( 'Tenant_Ticket' , $ match [ 'parentId' ] ) ; $ object = new Tenant_Comment ( ) ; $ form = Pluf_Shortcuts_GetFormForModel ( $ object , $ request -> REQUEST ) ; $ object = $ form -> save ( false ) ; $ object -> ticket_id ...
Create new comment
52,992
public function generateVersioned ( $ pathBase , $ pathAppend ) { $ pathAbsolute = $ pathBase . $ pathAppend ; if ( ! file_exists ( $ pathAbsolute ) ) { throw new \ Exception ( "cannot get cache busting path for file '$pathAbsolute'" ) ; } $ timeModified = filemtime ( $ pathAbsolute ) ; return $ this -> generate ( ) . ...
gets absolute path of a single file with cache busting powers!
52,993
public function actionError ( ) { $ error = array ( ) ; if ( ! empty ( Yii :: app ( ) -> errorHandler -> error ) ) $ error = Yii :: app ( ) -> errorHandler -> error ; $ this -> render ( 'error' , array ( 'error' => $ error ) ) ; }
Error Action The installer shouldn t error if this happens flat out die and blame the developer
52,994
public function actionIndex ( ) { $ model = new DatabaseForm ; if ( Cii :: get ( Yii :: app ( ) -> session [ 'dsn' ] ) != "" ) $ model -> attributes = Yii :: app ( ) -> session [ 'dsn' ] ; if ( Cii :: get ( $ _POST , 'DatabaseForm' ) ) { $ model -> attributes = $ _POST [ 'DatabaseForm' ] ; if ( $ model -> validateConne...
Initial action the user arrives to . Handles setting up the database connection
52,995
public function actionCreateAdmin ( ) { $ model = new UserForm ; if ( Cii :: get ( $ _POST , 'UserForm' ) != NULL ) { $ model -> attributes = Cii :: get ( $ _POST , 'UserForm' , array ( ) ) ; if ( $ model -> validate ( ) ) { $ response = $ this -> runInstaller ( $ model ) ; if ( file_exists ( Yii :: getPathOfAlias ( 'a...
This action enables us to create an admin user for CiiMS
52,996
public function actionRunMigrations ( ) { header ( 'Content-Type: application/json' ) ; $ response = $ this -> runMigrationTool ( ) ; $ data = array ( 'migrated' => false , 'details' => $ response ) ; if ( strpos ( $ response , 'Migrated up successfully.' ) || strpos ( $ response , 'Your system is up-to-date.' ) ) $ da...
Ajax comment to run CDbMigrations
52,997
private function runInstaller ( $ userModel ) { return $ this -> runCommand ( Yii :: app ( ) -> session [ 'dsn' ] , 'application.modules.install.InstallerCommand' , array ( 'yiic' , 'installer' , 'index' , '--dbHost=' . Yii :: app ( ) -> session [ 'dsn' ] [ 'host' ] , '--dbName=' . Yii :: app ( ) -> session [ 'dsn' ] [...
Runs the CLI installer which writes the config files and create the initial admin user
52,998
private function runCommand ( $ dsn , $ command , $ data ) { $ runner = new CConsoleCommandRunner ( ) ; $ runner -> commands = array ( 'migrate' => array ( 'class' => $ command , 'dsn' => $ dsn , 'interactive' => 0 , ) , 'db' => array ( 'class' => 'CDbConnection' , 'connectionString' => "mysql:host={$dsn['host']};dbnam...
Runs a given command
52,999
public function setDriver ( $ dsn , array $ config = [ ] , array $ options = [ ] ) { $ class = '\Micro\Db\Drivers\\' . ucfirst ( substr ( $ dsn , 0 , strpos ( $ dsn , ':' ) ) ) . 'Driver' ; if ( ! class_exists ( $ class ) ) { throw new Exception ( 'DB driver `' . $ class . '` not supported' ) ; } unset ( $ this -> driv...
Set active connection driver