idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
232,500
protected function filterConfig ( string $ name , $ value = null ) { $ class = 'filterConfig' . ucfirst ( $ name ) ; if ( method_exists ( $ this , $ class ) === true ) { $ value = call_user_func ( [ $ this , $ class ] , $ value ) ; } return $ value ; }
Filter a configuration attribute value as it s being set .
232,501
public function loadConfig ( string $ file ) : self { if ( file_exists ( $ file ) === false ) { throw new \ RuntimeException ( 'No such config file.' ) ; } $ data = json_decode ( file_get_contents ( $ file ) , true ) ; if ( $ data === null ) { throw new \ RuntimeException ( 'Invalid config file.' ) ; } return $ this ->...
Set configuration from a JSON file .
232,502
public function table ( $ table , \ Closure $ callback ) { try { parent :: create ( $ table , $ callback ) ; } catch ( \ Exception $ e ) { try { parent :: table ( $ table , $ callback ) ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; } } }
Create table if not exist .
232,503
protected function isDynamic ( array $ attributeNames ) { foreach ( $ attributeNames as $ name ) { if ( isset ( $ this -> __attr [ $ name ] ) ) { return true ; } } return false ; }
Check if any of the given attribute names refers to a dynamic attribute .
232,504
protected function createIterator ( $ subject ) { if ( $ subject === NULL ) { return new \ ArrayIterator ( [ ] ) ; } if ( is_array ( $ subject ) ) { return new \ ArrayIterator ( $ subject ) ; } if ( $ subject instanceof \ Generator ) { return $ subject ; } if ( $ subject instanceof \ Iterator ) { $ subject -> rewind ( ...
Create an iterator from the given input will create an ArrayIterator backed by an empty array when the input is NULL .
232,505
public function status ( $ message , $ link = null ) { $ this -> response = $ this -> fb -> post ( '/me/feed' , [ 'message' => $ message , 'link' => $ link , ] ) ; return $ this ; }
Create a status .
232,506
public function photo ( $ source , $ caption = null ) { $ this -> response = $ this -> fb -> post ( '/me/photos' , [ 'source' => new FacebookFile ( $ source ) , 'caption' => $ caption , ] ) ; return $ this ; }
Create a photo .
232,507
public function photos ( array $ sources , $ caption = null ) { $ images = $ this -> unpublishedPhotos ( $ sources ) ; $ this -> response = $ this -> fb -> post ( '/me/feed' , array_merge ( [ 'message' => $ caption , ] , $ images ) ) ; return $ this ; }
Create multiple photos .
232,508
protected function unpublishedPhotos ( array $ sources ) { $ images = [ ] ; foreach ( $ sources as $ index => $ source ) { $ response = $ this -> fb -> post ( '/me/photos' , [ 'source' => new FacebookFile ( $ source ) , 'published' => false , ] ) -> getDecodedBody ( ) ; $ images [ "attached_media[{$index}]" ] = sprintf...
Create unpublished photos .
232,509
public function getId ( ) { if ( is_null ( $ this -> response ) ) { return false ; } return $ this -> explodeId ( $ this -> response -> getDecodedBody ( ) ) ; }
Get facebook response id .
232,510
protected function explodeId ( array $ body ) { if ( isset ( $ body [ 'post_id' ] ) ) { $ key = 'post_id' ; } elseif ( isset ( $ body [ 'id' ] ) ) { $ key = 'id' ; } else { return false ; } return array_combine ( [ 'id' , 'fbid' ] , explode ( '_' , $ body [ $ key ] ) ) ; }
Explode facebook response id field .
232,511
final public function file ( $ _ ) { $ args = func_get_args ( ) ; if ( count ( $ args ) > 3 ) { for ( $ i = 3 ; $ i < count ( $ args ) ; $ i ++ ) { unset ( $ args [ $ i ] ) ; } } switch ( count ( $ args ) ) { case 1 : $ this -> viewFile [ 2 ] = Util :: camelToHyphen ( $ args [ 0 ] ) ; break ; case 2 : $ this -> viewFil...
Determines which action s view to use instead of current s
232,512
final public function getViewFile ( $ addOthers = true ) { if ( $ addOthers ) { if ( ! isset ( $ this -> viewFile [ 0 ] ) ) $ this -> viewFile [ 0 ] = ucfirst ( Util :: hyphenToCamel ( engineGet ( 'module' ) ) ) ; if ( ! isset ( $ this -> viewFile [ 1 ] ) ) $ this -> viewFile [ 1 ] = Util :: camelToHyphen ( engineGet (...
Fetches the view file array
232,513
final public function url ( $ module , $ controller = null , $ action = null , array $ params = array ( ) , $ hash = null ) { $ module = ucfirst ( Util :: hyphenToCamel ( $ module ) ) ; $ moduleOptions = engineGet ( 'config' , 'modules' , $ module , false ) ; $ module = ( isset ( $ moduleOptions [ 'alias' ] ) ) ? $ mod...
Fetches the relative path to a resource
232,514
final public function getOutput ( $ module , $ controller , $ action , array $ params = array ( ) , $ partial = true ) { $ view = new View ( ) ; $ controllerClass = ucfirst ( \ Util :: hyphenToCamel ( $ module ) ) . '\Controllers\\' . ucfirst ( \ Util :: hyphenToCamel ( $ controller ) ) . 'Controller' ; $ controllerCla...
Fetches the output of an action
232,515
public static function getNameForOrdinal ( $ enumType , $ ordinal ) { $ constants = $ enumType :: values ( ) ; $ result = null ; foreach ( $ constants as $ constant ) { if ( $ constant -> getOrdinal ( ) === $ ordinal ) { $ result = $ constant -> getName ( ) ; break ; } } return $ result ; }
Returns the name of the enumeration constant of the specified enumeration type with the specified ordinal .
232,516
public static function getOrdinalForName ( $ enumType , $ name ) { $ constants = $ enumType :: values ( ) ; $ result = null ; foreach ( $ constants as $ constant ) { if ( $ constant -> getName ( ) === $ name ) { $ result = $ constant -> getOrdinal ( ) ; break ; } } return $ result ; }
Returns the ordinal of the enumeration constant of the specified enumeration type with the specified name .
232,517
public static function isDefinedName ( $ enumType , $ name ) { $ names = $ enumType :: names ( ) ; $ result = false ; foreach ( $ names as $ item ) { if ( $ item === $ name ) { $ result = true ; break ; } } return $ result ; }
Checks whether an enumeration constant with the specified name exists in the specified enumeration type .
232,518
public static function isDefinedOrdinal ( $ enumType , $ ordinal ) { $ constants = $ enumType :: values ( ) ; $ result = false ; foreach ( $ constants as $ constant ) { if ( $ constant -> getOrdinal ( ) === $ ordinal ) { $ result = true ; break ; } } return $ result ; }
Checks whether an enumeration constant with the specified ordinal exists in the specified enumeration type .
232,519
public function split ( array $ arguments = array ( ) ) { $ splittedArguments = new AppendIterator ( ) ; foreach ( $ this -> _options [ 'Period' ] as $ Date ) { $ _arguments = $ arguments ; $ _arguments [ '--range' ] = $ Date -> format ( Configure :: read ( 'Task.dateFormat' ) ) ; $ splittedArguments -> append ( $ this...
Split arguments by date range
232,520
public function csrf ( ) { if ( ! $ this -> csrf ) { $ this -> csrf = \ Dependency :: resolve ( 'security.csrf' , array ( $ this -> config , \ Application :: getInstance ( ) -> getSession ( ) ) ) ; } return $ this -> csrf ; }
Returns a Csrf instance
232,521
public function unregisterResource ( $ type ) { if ( isset ( $ this -> smarty -> registered_resources [ $ type ] ) ) { unset ( $ this -> smarty -> registered_resources [ $ type ] ) ; } }
Unregisters a resource
232,522
public function unregisterCacheResource ( $ type ) { if ( isset ( $ this -> smarty -> registered_cache_resources [ $ type ] ) ) { unset ( $ this -> smarty -> registered_cache_resources [ $ type ] ) ; } }
Unregisters a cache resource
232,523
public function expired ( string $ key ) : bool { try { return $ this -> storage -> expired ( $ key ) ; } catch ( BadPacketException $ e ) { return true ; } }
Determines whether an item is present in the cache and life time expired .
232,524
public function attach ( callable $ stage , callable $ fallback = null ) { $ this -> storage -> attach ( $ this -> marshalClosure ( $ stage ) , [ 'fallback' => is_callable ( $ fallback ) ? $ this -> marshalClosure ( $ fallback ) : null ] ) ; }
Attaches a stage and assigns a fallback to the attached stage .
232,525
private function hasRequest ( $ params , $ variables , $ i = null ) : array { foreach ( $ params as $ key => $ param ) { $ class = '\\' . $ param -> getType ( ) ; if ( class_exists ( $ class ) && new $ class ( ) instanceof Request ) { $ i = $ key ; } } if ( $ i !== null ) $ variables = $ this -> insert ( $ variables , ...
Check if the request class exists and insert it if it doesn t
232,526
protected function clean ( $ meta = null ) { if ( $ meta && ! ( $ meta instanceof StorageMeta ) ) { $ meta = $ this -> getMeta ( $ meta ) ; } if ( ! $ meta || empty ( $ meta -> token ) ) $ this -> cache = [ ] ; else foreach ( $ this -> cache as $ i => $ _ ) { if ( empty ( $ i ) || $ i == $ meta -> token [ 0 ] || strpos...
Clean the search cache based on the index
232,527
public static function fromNative ( ) { $ args = \ func_get_args ( ) ; if ( \ count ( $ args ) < 2 || \ count ( $ args ) > 3 ) { throw new \ BadMethodCallException ( 'You must provide 2 to 3 arguments: 1) latitude, 2) longitude, 3) valid ellipsoid type (optional)' ) ; } $ coordinate = new BaseCoordinate ( array ( $ arg...
Returns a new Coordinate object from native PHP arguments
232,528
public function sameValueAs ( ValueObjectInterface $ coordinate ) { if ( false === Util :: classEquals ( $ this , $ coordinate ) ) { return false ; } return $ this -> getLatitude ( ) -> sameValueAs ( $ coordinate -> getLatitude ( ) ) && $ this -> getLongitude ( ) -> sameValueAs ( $ coordinate -> getLongitude ( ) ) && $...
Tells whether tow Coordinate objects are equal
232,529
public function toDecimalMinutes ( ) { $ coordinate = self :: getBaseCoordinate ( $ this ) ; $ convert = new Convert ( $ coordinate ) ; $ dm = $ convert -> toDecimalMinutes ( ) ; return new StringLiteral ( $ dm ) ; }
Returns a decimal minutes representation of the coordinate
232,530
public function toUniversalTransverseMercator ( ) { $ coordinate = self :: getBaseCoordinate ( $ this ) ; $ convert = new Convert ( $ coordinate ) ; $ utm = $ convert -> toUniversalTransverseMercator ( ) ; return new StringLiteral ( $ utm ) ; }
Returns a Universal Transverse Mercator projection representation of the coordinate in meters
232,531
public function distanceFrom ( Coordinate $ coordinate , DistanceUnit $ unit = null , DistanceFormula $ formula = null ) { if ( null === $ unit ) { $ unit = DistanceUnit :: METER ( ) ; } if ( null === $ formula ) { $ formula = DistanceFormula :: FLAT ( ) ; } $ baseThis = self :: getBaseCoordinate ( $ this ) ; $ baseCoo...
Calculates the distance between two Coordinate objects
232,532
protected static function getBaseCoordinate ( self $ coordinate ) { $ latitude = $ coordinate -> getLatitude ( ) -> toNative ( ) ; $ longitude = $ coordinate -> getLongitude ( ) -> toNative ( ) ; $ ellipsoid = BaseEllipsoid :: createFromName ( $ coordinate -> getEllipsoid ( ) -> toNative ( ) ) ; $ coordinate = new Base...
Returns the underlying Coordinate object
232,533
public function getEventActions ( $ eventName ) { $ events = isset ( $ this -> events [ $ eventName ] ) ? $ this -> events [ $ eventName ] : [ ] ; return is_array ( $ events ) ? $ events : [ $ events ] ; }
Returns a list of methods associated with a event
232,534
public function handle ( $ eventName , $ data = null ) { $ results = [ ] ; if ( $ actions = $ this -> getEventActions ( $ eventName ) ) { $ actions = is_array ( $ actions ) ? $ actions : [ $ actions ] ; $ data = is_array ( $ data ) ? $ data : [ $ data ] ; foreach ( $ actions as $ action ) { if ( $ result = $ this -> ca...
Handles the event
232,535
protected function call ( $ eventName , $ method , $ data = null ) { if ( method_exists ( $ this , $ method ) ) { $ result = call_user_func_array ( [ $ this , $ method ] , $ data ) ; return $ result ; } return null ; }
Calls a event method
232,536
private function hasColumnDifference ( ) { return ! empty ( $ this -> createdColumns ) || ! empty ( $ this -> alteredColumns ) || ! empty ( $ this -> droppedColumns ) ; }
Checks if the table diff has column difference .
232,537
public function handleError ( $ errno , $ errstr , $ errfile , $ errline ) { if ( error_reporting ( ) === 0 ) { return false ; } $ exception = new ErrorException ( $ errstr , $ errno , $ errno , $ errfile , $ errline ) ; $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; array_shift ( $ trace ) ; foreach ( $ t...
An error handler function that throws exceptions .
232,538
public function register ( $ theDebug = false , $ theErrorTypes = null ) { if ( $ theErrorTypes === null ) { $ theErrorTypes = E_ALL | E_STRICT ; } $ this -> myDebug = $ theDebug ; ini_set ( 'display_errors' , false ) ; set_exception_handler ( [ $ this , 'handleException' ] ) ; set_error_handler ( [ $ this , 'handleErr...
Registers this error handler .
232,539
protected function validateString ( string $ string ) { if ( strlen ( $ string ) > self :: MAX_LENGTH || ! filter_var ( $ string , FILTER_VALIDATE_IP ) ) { throw InvalidArgumentException :: format ( 'Cannot construct class %s: argument must be a valid ip address, \'%s\' given' , get_class ( $ this ) , $ string ) ; } }
Validates the string is in the required format .
232,540
protected function parseArguments ( string $ string ) : ArgumentList { $ argParser = $ this -> argumentParserFactory -> create ( $ string ) ; return $ argParser -> tokenise ( ) ; }
Handlebars will give arguments in a string . This will transform them into a legitimate argument array .
232,541
protected function registerValidationRules ( $ validator ) { $ validator -> resolver ( function ( $ translator , $ data , $ rules , $ messages ) { return new BaseValidator ( $ translator , $ data , $ rules , $ messages ) ; } ) ; $ validator -> replacer ( 'elfinder_max' , function ( $ message , $ attribute , $ rule , $ ...
Registers validation rules
232,542
public function cmdGetPriceRule ( ) { $ result = $ this -> getListPriceRule ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePriceRule ( $ result ) ; $ this -> output ( ) ; }
Callback for pricerule - get command
232,543
public function cmdUpdatePriceRule ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ thi...
Callback for pricerule - update command
232,544
protected function addPriceRule ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> price_rule -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new price rule
232,545
protected function submitAddPriceRule ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'price_rule' ) ; $ this -> addPriceRule ( ) ; }
Add a new price rule at once
232,546
protected function wizardAddPriceRule ( ) { $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'price_rule' ) ; $ this -> validatePrompt ( 'trigger_id' , $ this -> text ( 'Trigger ID' ) , 'price_rule' ) ; $ types = array ( ) ; foreach ( $ this -> price_rule -> getTypes ( ) as $ id => $ type ) { $ types [ $...
Add a new price rule step by step
232,547
protected function setStatusPriceRule ( $ status ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && ! $ all ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = $ options = null ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric...
Sets status for one or several price rules
232,548
public static function turnDateIntervalToSeconds ( DateInterval $ dateInterval ) { return $ dateInterval -> y * 365 * 24 * 3600 + $ dateInterval -> m * 30 * 24 * 3600 + $ dateInterval -> d * 24 * 3600 + $ dateInterval -> h * 3600 + $ dateInterval -> i * 60 + $ dateInterval -> s ; }
1 Year is defined as 365 days and 1 Month is defined as 30 days
232,549
public function renderItem ( $ model , $ key , $ index ) { if ( $ this -> itemView === null ) { $ content = $ key ; } elseif ( is_string ( $ this -> itemView ) ) { $ content = $ this -> getView ( ) -> render ( $ this -> itemView , array_merge ( [ 'model' => $ model , 'key' => $ key , 'index' => $ index , 'widget' => $ ...
Renders a single data model .
232,550
public static function getClassProperties ( $ class ) { if ( is_string ( $ class ) ) { if ( isset ( self :: $ classPropertyes [ $ class ] ) ) { return self :: $ classPropertyes [ $ class ] ; } $ class = new \ ReflectionClass ( $ class ) ; } if ( ! $ class instanceof \ ReflectionClass ) { throw new \ InvalidArgumentExce...
Get array of class properties including parents private properties .
232,551
public function getUrl ( array $ data = [ ] ) { $ translation_guess = preg_replace ( [ '/\[([^\[]+)\]/is' , '/{(\w*?)}/is' , '/{(\w*?):(:?.*?)}/is' ] , '{$1}' , $ this -> _path ) ; $ keys = [ ] ; preg_match_all ( '/{(\w*?)}/is' , $ translation_guess , $ keys ) ; foreach ( $ keys [ 1 ] as $ key ) { $ translation_guess =...
Get route URL with parameters passed on .
232,552
protected function registerToHandler ( $ name , $ value , $ crypt = false ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { $ value = base64_encode ( serialize ( $ value ) ) ; } if ( true === $ crypt ) { $ value = $ this -> getCrypt ( ) -> encode ( $ crypt ) ; } $ this -> getHandler ( ) -> write ( $ name , $ v...
register a new session to handler
232,553
public function has ( $ name ) { $ value = $ this -> get ( $ name ) ; return isset ( $ value ) ? $ value : false ; }
check the value is exists
232,554
public function renderOptions ( array $ options , array $ selectedOptions = array ( ) ) { $ template = '<li %s><a href="#">%s</a></li>' ; $ optionStrings = array ( ) ; $ escapeHtml = $ this -> getEscapeHtmlHelper ( ) ; foreach ( $ options as $ key => $ optionSpec ) { $ value = '' ; $ label = '' ; $ selected = false ; $...
Render an array of options
232,555
public function renderOptgroup ( array $ optgroup , array $ selectedOptions = array ( ) ) { $ template = '<optgroup%s>%s</optgroup>' ; $ options = array ( ) ; if ( isset ( $ optgroup [ 'options' ] ) && is_array ( $ optgroup [ 'options' ] ) ) { $ options = $ optgroup [ 'options' ] ; unset ( $ optgroup [ 'options' ] ) ; ...
Render an optgroup
232,556
protected function validateMultiValue ( $ value , array $ attributes ) { if ( null === $ value ) { return array ( ) ; } if ( ! is_array ( $ value ) ) { return ( array ) $ value ; } if ( ! isset ( $ attributes [ 'multiple' ] ) || ! $ attributes [ 'multiple' ] ) { throw new Exception \ DomainException ( sprintf ( '%s doe...
Ensure that the value is set appropriately
232,557
protected function renderHidden ( \ Zend \ Form \ Element \ Select $ element , array $ attributes ) { $ attributes [ 'type' ] = 'select' ; $ attributes [ 'name' ] .= '[id]' ; if ( method_exists ( $ element , 'getId' ) ) { $ attributes [ 'value' ] = $ element -> getId ( ) ; } elseif ( array_key_exists ( 'value' , $ attr...
Render the hidden input with the captcha identifier
232,558
public function toString ( $ to = self :: TO_FRAGMENT , $ schemaRelative = false ) { if ( $ to == static :: TO_SCHEME ) { return $ this -> scheme ; } if ( $ schemaRelative || empty ( $ this -> scheme ) ) { $ uri = empty ( $ this -> host ) ? '' : '//' ; } else { $ uri = empty ( $ this -> host ) ? '' : ( $ this -> scheme...
Renders an encoded URI .
232,559
public static function encode ( $ string , $ encodeSlashes = false ) { if ( $ encodeSlashes ) { return rawurlencode ( $ string ) ; } return implode ( '/' , array_map ( 'rawurlencode' , explode ( '/' , ( string ) $ string ) ) ) ; }
URL - encode the given string .
232,560
private function setUserInfo ( $ user , $ pass ) { $ this -> userInfo = $ user . ( ! empty ( $ pass ) ? ':' . $ pass : '' ) ; return $ this ; }
Set user info
232,561
final public function setMinLevel ( $ minLevel ) { if ( isset ( $ this -> levels [ $ minLevel ] ) ) { $ this -> minLevel = $ this -> levels [ $ minLevel ] ; } return $ this ; }
If set then only messages with level equal or greater then minLevel will be logged .
232,562
function addString ( $ string_to_add ) { settype ( $ string_to_add , "string" ) ; if ( strlen ( $ string_to_add ) > 0 ) { $ this -> _Buffer [ ] = new StringBufferItem ( $ string_to_add ) ; } }
Adds another string to the buffer .
232,563
function addStringBuffer ( $ stringbuffer_to_add ) { if ( ! isset ( $ stringbuffer_to_add ) ) { return ; } for ( $ i = 0 ; $ i < sizeof ( $ stringbuffer_to_add -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ ] = $ stringbuffer_to_add -> _Buffer [ $ i ] ; } }
Adds content of another StringBuffer to the buffer .
232,564
function getLength ( ) { $ out = 0 ; for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ out = $ out + $ this -> _Buffer [ $ i ] -> getLength ( ) ; } return $ out ; }
Returns length of buffer content .
232,565
function printOut ( ) { for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ $ i ] -> flush ( ) ; } }
Echoes content of buffer .
232,566
function replace ( $ search , $ replace ) { settype ( $ search , "string" ) ; if ( is_object ( $ replace ) ) { $ replace = $ replace -> toString ( ) ; } for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ $ i ] -> replace ( $ search , $ replace ) ; } }
Replaces string in buffer with replacement string .
232,567
function replace ( $ search , $ replace ) { $ this -> _String = str_replace ( $ search , $ replace , $ this -> _String ) ; }
Replace part of string in buffer
232,568
function toString ( ) { if ( isset ( $ this -> _String ) ) { return parent :: toString ( ) ; } return Files :: GetFileContent ( $ this -> _Filename ) ; }
Outputs content of buffer as string .
232,569
function replace ( $ search , $ replace ) { $ this -> _String = $ this -> toString ( ) ; return parent :: replace ( $ search , $ replace ) ; }
Replaces part of a string with another string .
232,570
protected function toCollection ( $ data , $ collectionClass ) { if ( $ data instanceof $ collectionClass ) { return $ data ; } $ data = $ data ? : array ( ) ; if ( ! is_array ( $ data ) && ! $ data instanceof Collection ) { throw new \ InvalidArgumentException ( 'Can transform only Collections or arrays.' ) ; } return...
helper method to use for cast arrays to collections of entities .
232,571
public static function setAlias ( $ alias , $ realPath ) { if ( is_string ( $ alias ) && is_string ( $ realPath ) ) { self :: $ aliases [ strtolower ( $ alias ) ] = $ realPath ; } }
Setting or installing new alias
232,572
public static function getClassPath ( $ className , $ extension = '.php' ) { $ prefix = $ className = self :: camelCaseToLowerNamespace ( str_replace ( '_' , '\\' , $ className ) ) ; while ( false !== $ position = strrpos ( $ prefix , '\\' ) ) { $ prefix = substr ( $ prefix , 0 , $ position ) ; $ alias = self :: getAli...
Get class path
232,573
private static function camelCaseToLowerNamespace ( $ path ) { $ classNameArr = array_map ( function ( $ val ) { return lcfirst ( $ val ) ; } , explode ( '\\' , $ path ) ) ; $ classNameArr [ ] = ucfirst ( array_pop ( $ classNameArr ) ) ; return implode ( '\\' , $ classNameArr ) ; }
Convert first symbols of namespace to lowercase
232,574
public function getTableMetadata ( string $ tableName ) : TableMetadata { if ( ! array_key_exists ( $ tableName , $ this -> tableMetadataList ) ) { throw new \ RuntimeException ( 'Database "' . $ this -> databaseName . '" doesn\'t contain table "' . $ tableName . '"' ) ; } return $ this -> tableMetadataList [ $ tableNa...
Get the metadata for a single table .
232,575
public function error ( $ code = 404 , $ msg = "Resource not found" ) { $ request = HttpFactory :: i ( ) -> request ( ) ; if ( $ request -> ajax ( ) || $ request -> wantsJson ( ) ) return new JsonResponse ( [ 'error' => $ msg ] ) ; else return new Response ( Redirect :: back ( ) -> withInput ( $ request -> input ( ) ) ...
Produces a new error response based on if this is an api request or not .
232,576
protected function get ( $ path , $ body = [ ] , array $ headers = [ ] ) { $ client = $ this -> getClient ( ) ; $ request = AbstractHttpClient :: createRequest ( 'GET' , $ path , $ body , $ headers ) ; return $ this -> transformer -> transform ( $ client -> send ( $ request ) ) ; }
Execute a http get query
232,577
public function createColumn ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createColumnBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Column type guessing is not yet supported.' ) ; }
Creates a column builder .
232,578
public function createFilter ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createFilterBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Filter type guessing is not yet supported.' ) ; }
Creates a filter builder .
232,579
public function createAction ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createActionBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Action type guessing is not yet supported.' ) ; }
Creates a action builder .
232,580
private function resolveColumn ( $ name ) { $ info = $ this -> unresolvedColumns [ $ name ] ; $ child = $ this -> createColumn ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> columns [ $ name ] = $ child ; unset ( $ this -> unresolvedColumns [ $ name ] ) ; return $ child ; }
Converts an unresolved column into a column builder instance .
232,581
private function resolveFilter ( $ name ) { $ info = $ this -> unresolvedFilters [ $ name ] ; $ child = $ this -> createFilter ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> filters [ $ name ] = $ child ; unset ( $ this -> unresolvedFilters [ $ name ] ) ; return $ child ; }
Converts an unresolved filter into a filter builder instance .
232,582
private function resolveAction ( $ name ) { $ info = $ this -> unresolvedActions [ $ name ] ; $ child = $ this -> createAction ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> actions [ $ name ] = $ child ; unset ( $ this -> unresolvedActions [ $ name ] ) ; return $ child ; }
Converts an unresolved action into a action builder instance .
232,583
private function resolveElements ( ) { foreach ( $ this -> unresolvedColumns as $ name => $ info ) { $ this -> columns [ $ name ] = $ this -> createColumn ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; } $ this -> unresolvedColumns = [ ] ; foreach ( $ this -> unresolvedFilters as $ name => $ info ) { $ this ->...
Converts all unresolved elements into builder instances .
232,584
protected function isSyntacticallyValid ( ) : bool { if ( preg_match ( '!^([a-z][a-z0-9\+]*)://([^@]+@)?([^/?#]*)(/([^#?]*))?(.*)$!' , $ this -> parsedUri -> asString ( ) ) == 0 ) { return false ; } if ( $ this -> parsedUri -> hasUser ( ) ) { if ( preg_match ( '~([@:/])~' , $ this -> parsedUri -> user ( ) ) != 0 ) { re...
Checks whether URI is a syntactically correct URI .
232,585
public function asStringWithNonDefaultPort ( ) : string { if ( $ this -> parsedUri -> hasPort ( ) && ! $ this -> hasDefaultPort ( ) ) { return $ this -> asString ( ) ; } return $ this -> asStringWithoutPort ( ) ; }
Returns uri as string containing the port if it is not the default port .
232,586
public function password ( string $ defaultPassword = null ) { if ( ! $ this -> parsedUri -> hasUser ( ) ) { return null ; } if ( $ this -> parsedUri -> hasPassword ( ) ) { return $ this -> parsedUri -> password ( ) ; } return $ defaultPassword ; }
returns the password
232,587
public function addParams ( array $ params ) : self { foreach ( $ params as $ name => $ value ) { $ this -> addParam ( $ name , $ value ) ; } return $ this ; }
adds given map of params
232,588
public function addParam ( string $ name , $ value ) : self { $ this -> parsedUri -> queryString ( ) -> addParam ( $ name , $ value ) ; return $ this ; }
add a parameter to the uri
232,589
public function removeParam ( string $ name ) : self { $ this -> parsedUri -> queryString ( ) -> removeParam ( $ name ) ; return $ this ; }
remove a param from uri
232,590
public function prepare ( $ val , $ col = null , $ type = null ) { if ( is_array ( $ val ) ) { $ holder = [ ] ; foreach ( $ val as $ key => $ v ) { $ holder [ $ key ] = $ this -> prepare ( $ v , $ col , $ type ) ; } return $ holder ; } if ( $ val instanceof \ Closure ) return $ val ; $ holder = ( static :: $ useColumnI...
replaces value with place holder for prepared statement . the value is kept in prepared_value array .
232,591
public function setName ( $ name ) { if ( ! is_string ( $ name ) || ( strlen ( $ name ) <= 0 ) ) { $ explodedNamespace = explode ( '\\' , get_class ( $ this ) ) ; $ class = $ explodedNamespace [ count ( $ explodedNamespace ) - 1 ] ; $ asset = strtolower ( preg_replace ( '/(.)([A-Z])/' , '\\1 \\2' , $ class ) ) ; throw ...
Sets the asset name .
232,592
protected function generateIdentifier ( $ prefix , $ maxLength ) { $ hash = null ; $ dictionary = 'abcdefghijklmnopqrstuvwxyz0123456789' ; for ( $ i = 0 ; $ i < ( $ maxLength - strlen ( $ prefix ) ) ; $ i ++ ) { $ hash .= $ dictionary [ mt_rand ( 0 , strlen ( $ dictionary ) - 1 ) ] ; } return $ prefix . $ hash ; }
Generates a prefixed identifier .
232,593
public function isAllowed ( $ action , $ role = null ) { if ( $ this -> _acl_entity === null ) { return $ this -> getACL ( ) -> getDefaultPolicy ( ) ; } if ( $ role === null ) { $ role = $ this -> getACL ( ) -> getCurrentRole ( ) ; } return $ this -> _acl_entity -> isAllowed ( $ role , $ action , array ( get_class ( $ ...
Check if an action is allowed on this object . If the ACL subsystem is not loaded true will be returned .
232,594
public static function getACLClass ( ) { $ cl = static :: class ; $ parts = explode ( "\\" , $ cl ) ; if ( count ( $ parts ) === 1 ) return $ parts [ 0 ] ; $ first = reset ( $ parts ) ; $ last = end ( $ parts ) ; return $ first . "_" . $ last ; }
Generate a ACL Class name for the called DAO class . It will be composed of the first part of the namespace and the classname by default but subclasses may override this to alter this behaviour . It should return a unique name
232,595
public function generateID ( ) { $ id = $ this -> getID ( ) ; $ fmt_string = "%08s" ; if ( is_array ( $ id ) ) $ id = implode ( "-" , $ id ) ; if ( empty ( $ id ) ) throw new Exception ( "Cannot generate an ID for an empty object" ) ; $ id = substr ( sha1 ( $ id ) , 0 , 10 ) ; $ acl_class = $ this -> getACLClass ( ) ; ...
Generate a ID based on the provided Model object
232,596
function cacheApplication ( ) { $ this -> log ( "Downloading application..." ) ; $ app = Config :: instance ( ) -> application -> apiClient ( ) -> get ( "application" , array ( "definition" => "true" ) ) ; $ this -> cache ( Application :: cacheKey ( ) , json_encode ( $ app ) ) ; $ this -> log ( "Application has been ca...
Caches application data
232,597
function cacheLanguages ( ) { $ this -> log ( "Downloading languages..." ) ; $ count = 0 ; $ languages = Config :: instance ( ) -> application -> apiClient ( ) -> get ( "application/languages" , array ( "definition" => "true" ) ) ; foreach ( $ languages as $ lang ) { $ this -> cache ( Language :: cacheKey ( $ lang [ "l...
Caches application languages with full definition
232,598
public function only ( array $ array ) { $ data = [ ] ; foreach ( $ array as $ field ) { if ( $ this -> has ( $ field ) ) { $ data [ $ field ] = $ this -> data [ $ field ] ; } } return $ data ; }
Grab selected fields .
232,599
public function file ( $ name , $ disk = null ) { return File :: make ( $ this -> files [ $ name ] , $ disk ) ; }
Get request file