idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
234,100
public function isValid ( $ value ) { $ acceptedValues = GeneralUtility :: trimExplode ( '|' , $ this -> options [ 'values' ] ) ; if ( false === in_array ( $ value , $ acceptedValues ) ) { $ errorMessage = $ this -> translateErrorMessage ( 'validator.has_values.not_valid' , 'configuration_object' , [ implode ( ', ' , $...
Checks if the given values is one of the accepted values .
234,101
public function getMethodAnnotations ( \ ReflectionMethod $ method ) { return array_merge ( $ this -> reader -> getMethodAnnotations ( $ method ) , $ this -> converter -> getMethodAnnotations ( $ method ) ) ; }
Collect method annotations .
234,102
public function getPropertyAnnotations ( \ ReflectionProperty $ prop ) { return array_merge ( $ this -> reader -> getPropertyAnnotations ( $ prop ) , $ this -> converter -> getPropertyAnnotations ( $ prop ) ) ; }
Collect property annotations .
234,103
public function processEvent ( Interfaces \ EventInterface $ event , callable $ callback = null ) { $ eventName = $ event -> getName ( ) ; $ queue = $ this -> matchEventQueue ( $ eventName , $ this ) ; $ managers = $ this -> getOtherManagers ( ) ; foreach ( $ managers as $ mgr ) { $ q = $ this -> matchEventQueue ( $ ev...
Process events by all managers in the pool
234,104
public function updateContinent ( Continent $ continent , $ andFlush = true ) { $ this -> objectManager -> persist ( $ continent ) ; if ( $ andFlush ) { $ this -> objectManager -> flush ( ) ; } }
Updates a Continent .
234,105
public function refreshContinent ( Continent $ continent ) { $ refreshedContinent = $ this -> findContinentBy ( array ( 'id' => $ continent -> getId ( ) ) ) ; if ( null === $ refreshedContinent ) { throw new UsernameNotFoundException ( sprintf ( 'User with ID "%d" could not be reloaded.' , $ continent -> getId ( ) ) ) ...
Refreshed a Continent by Continent Instance
234,106
protected static function getModeConstant ( $ value ) { if ( is_int ( $ value ) ) { if ( $ value <= 16 ) { return self :: VT100 ; } else if ( $ value <= 256 ) { return self :: XTERM ; } else { return self :: RGB ; } } else if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; $ value = strtoupper ( $ value ) ; if...
Helper function to take a value and turn it into a valid constant integer value
234,107
public function onKernelEarlyRequest ( GetResponseEvent $ e ) { $ request = $ e -> getRequest ( ) ; foreach ( $ this -> pathConfig as $ regex => $ config ) { if ( preg_match ( $ regex , $ request -> getPathInfo ( ) ) ) { $ this -> enabled = true ; if ( ! $ this -> subscribed ) { $ e -> getDispatcher ( ) -> addSubscribe...
Listens early in the kernel . request cycle for incoming requests and checks for a matching path . If a match is found the rest of the kernel listeners are registered and the relevant path config is stored for use in those listeners .
234,108
public function onKernelLateRequest ( GetResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ req = $ e -> getRequest ( ) ; if ( ! $ config = $ req -> attributes -> get ( '_ac_web_service' , false ) ) { return ; } $ config = $ this -> negotiateResponseFormat ( $ req , $ config ) ; $ req -> attributes -> set ( '_...
Fires at the end of the kernel . request cycle - so listeners should receive a request that has already been resolved to a controller .
234,109
public function onKernelResponse ( FilterResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ response = $ e -> getResponse ( ) ; $ config = $ e -> getRequest ( ) -> attributes -> get ( '_ac_web_service' ) ; if ( ! $ config [ 'negotiated' ] ) { $ config = $ this -> negotiateResponseFormat ( $ e -> getRequest ( )...
Called when a response object has been resolved .
234,110
public function onKernelTerminate ( PostResponseEvent $ e ) { if ( ! $ this -> enabled ) return ; $ e -> getDispatcher ( ) -> dispatch ( self :: API_TERMINATE , $ e ) ; }
Called after a response has already been sent .
234,111
protected function includes ( ) { $ moduleInclude = ( array ) $ this -> def ( 'include' ) ; $ globalInclude = $ this -> app [ 'config' ] -> get ( 'module::include' ) ; $ specificInclude = array ( $ this -> name . '.php' ) ; $ include = array_merge ( $ moduleInclude , $ specificInclude , $ globalInclude ) ; foreach ( $ ...
Include some files determined in config . php of CheeModule and module . json of modules
234,112
protected function registerProviders ( ) { $ providers = $ this -> def ( 'provider' ) ; if ( $ providers ) { if ( is_array ( $ providers ) ) { foreach ( $ providers as $ provider ) { $ this -> app -> register ( $ instance = new $ provider ( $ this -> app ) ) ; } } else { $ this -> app -> register ( $ instence = new $ p...
Register service providers of module
234,113
protected function validatePagination ( $ pagination ) : void { if ( ! is_array ( $ pagination ) ) { throw new InvalidQueryException ( 'Attribute "page" of query must be an array.' ) ; } $ unexpected = array_diff ( array_keys ( $ pagination ) , [ 'offset' , 'limit' ] ) ; if ( empty ( $ unexpected ) ) { return ; } throw...
Validate pagination definition
234,114
public function substring ( $ start , $ length = null ) { if ( $ length == null ) { $ substring = substr ( $ this -> value , $ start ) ; } else { $ substring = substr ( $ this -> value , $ start , $ length ) ; } $ this -> value = $ substring ; return $ this ; }
Unterschied zu getSubstring !!!
234,115
public function save ( $ id , $ data , $ ttl = 60 , $ raw = FALSE ) { $ contents = array ( 'time' => time ( ) , 'ttl' => $ ttl , 'data' => $ data ) ; if ( write_file ( $ this -> _cache_path . $ id , serialize ( $ contents ) ) ) { chmod ( $ this -> _cache_path . $ id , 0640 ) ; return TRUE ; } return FALSE ; }
Save into cache
234,116
public function delete ( $ id ) { return file_exists ( $ this -> _cache_path . $ id ) ? unlink ( $ this -> _cache_path . $ id ) : FALSE ; }
Delete from Cache
234,117
protected function load ( $ path ) { $ file = require ( $ path ) ; if ( ! is_array ( $ file ) ) { $ message = "{$path} configuration file is not readable." ; throw new ConfigException ( $ message ) ; } return $ file ; }
Load configuration file .
234,118
public function random_string ( $ length = 32 ) { return substr ( str_shuffle ( str_repeat ( $ x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , ceil ( $ length / strlen ( $ x ) ) ) ) , 1 , $ length ) ; }
Generates a random string based on given length .
234,119
public function tokenize ( $ iv , $ string = '' ) { if ( empty ( $ string ) ) { $ string = $ this -> random_string ( ) ; } return openssl_encrypt ( $ string , 'AES-256-CBC' , $ this -> _config -> get ( 'token' ) , 0 , $ iv ) ; }
Generate a token using OpenSSL extensions .
234,120
public static function isInteger ( $ input ) : bool { return self :: is ( $ input ) && ( string ) ( int ) $ input === ( string ) $ input ; }
Check if the input is true integer number or can be converted from string into integer
234,121
public static function write ( $ input , ? int $ precision = null , $ default = null ) { if ( ! self :: is ( $ input ) ) return $ default ; else { $ input = self :: cast ( $ input ) ; if ( is_int ( $ precision ) ) return number_format ( $ input , $ precision , '.' , '' ) ; else if ( is_int ( $ input ) ) return ( string...
Convert numbers to string
234,122
public static function equal ( $ a , $ b , int $ precision = 0 ) : bool { return self :: write ( $ a , $ precision ) === self :: write ( $ b , $ precision ) ; }
Check if two number is equals . Can handle floats with precision
234,123
protected function BeforeInit ( ) { $ this -> user = User :: Schema ( ) -> ByID ( Request :: GetData ( 'user' ) ) ; if ( ! $ this -> user || ! self :: Guard ( ) -> Allow ( BackendAction :: AssignGroups ( ) , $ this -> user ) ) { Response :: Redirect ( BackendRouter :: ModuleUrl ( new UserList ( ) ) ) ; } return parent ...
Gets and checks the requested user
234,124
public function getComment ( ) { if ( ! $ this -> _commentFetched ) { $ this -> _comment = $ this -> _fetchComment ( ) ; $ this -> _commentFetched = true ; } return $ this -> _comment ; }
Return table comment
234,125
public function setComment ( $ comment ) { if ( $ comment != $ this -> getComment ( ) and $ this -> _setComment ( $ comment ) ) { $ this -> _comment = $ comment ; } }
Set table comment
234,126
protected function _fetchColumns ( ) { $ columns = $ this -> _database -> query ( 'SELECT ' . implode ( ',' , $ this -> _informationSchemaColumns ) . ' FROM information_schema.columns WHERE table_schema=? AND LOWER(table_name)=? ORDER BY ordinal_position' , array ( $ this -> _database -> getTableSchema ( ) , $ this -> ...
Fetch column information from the database
234,127
protected function _fetchConstraints ( ) { $ constraints = $ this -> _database -> query ( <<<EOT SELECT kcu.column_name FROM information_schema.key_column_usage kcu JOIN information_schema.table_constraints tc USING (table_schema, table_name, constraint_schema, co...
Fetch constraint information from the database
234,128
public function requireColumn ( $ name ) { if ( $ name != strtolower ( $ name ) ) { throw new \ DomainException ( 'Column name must be lowercase: ' . $ name ) ; } if ( ! isset ( $ this -> _columns [ $ name ] ) ) { throw new \ RuntimeException ( 'Undefined column: ' . $ this -> _name . '.' . $ name ) ; } }
Force presence of column
234,129
public function alter ( $ operation ) { return $ this -> _database -> exec ( 'ALTER TABLE ' . $ this -> _database -> prepareIdentifier ( $ this -> _name ) . ' ' . $ operation ) ; }
Compose and execute an ALTER TABLE statement
234,130
public final function addColumn ( $ name , $ type , $ length = null , $ notnull = false , $ default = null , $ autoIncrement = false , $ comment = null ) { return $ this -> addColumnObject ( $ this -> _database -> createColumn ( $ name , $ type , $ length , $ notnull , $ default , $ autoIncrement , $ comment ) ) ; }
Add a column using parameters
234,131
public function addColumnObject ( $ column ) { $ name = $ column -> getName ( ) ; $ this -> forbidColumn ( $ name ) ; $ sql = 'ADD COLUMN ' ; $ sql .= $ this -> _database -> prepareIdentifier ( $ name ) ; $ sql .= ' ' ; $ sql .= $ column -> getDefinition ( ) ; $ this -> alter ( $ sql ) ; $ this -> _columns [ $ name ] =...
Add a column using a column object
234,132
public function dropColumn ( $ name ) { $ this -> requireColumn ( $ name ) ; $ this -> alter ( 'DROP COLUMN ' . $ this -> _database -> prepareIdentifier ( $ name ) ) ; unset ( $ this -> _columns [ $ name ] ) ; $ this -> _updateConstraints ( $ name , null ) ; }
Drop a column
234,133
protected function _updateConstraints ( $ oldColumnName , $ newColumnName ) { $ columnIndex = null ; foreach ( $ this -> _primaryKey as $ index => $ column ) { if ( $ oldColumnName == $ column -> getName ( ) ) { $ columnIndex = $ index ; break ; } } if ( $ columnIndex !== null ) { if ( $ newColumnName ) { $ this -> _pr...
Update constraints after renaming or dropping a column
234,134
public function hasIndex ( $ columns , $ unique = false ) { if ( ! is_array ( $ columns ) ) { $ columns = array ( $ columns ) ; } foreach ( $ this -> getIndexes ( ) as $ index ) { if ( $ index -> isUnique ( ) == $ unique and $ index -> getColumns ( ) == $ columns ) { return true ; } } return false ; }
Check for presence of index with given properties ignoring index name
234,135
public function toArray ( $ assoc = false ) { $ data = array ( 'name' => $ this -> _name , 'comment' => $ this -> getComment ( ) , ) ; foreach ( $ this -> _columns as $ name => $ column ) { if ( $ assoc ) { $ data [ 'columns' ] [ $ name ] = $ column -> toArray ( ) ; } else { $ data [ 'columns' ] [ ] = $ column -> toArr...
Export table data to an associative array
234,136
public function to ( $ url ) { if ( $ url == '/' && $ this -> getRoot ( ) == $ url ) { return $ url ; } return $ this -> isValidUrl ( $ url ) ? $ url : $ this -> generateUrl ( $ url ) ; }
Generates a URL useful for anchor tags .
234,137
public function redirect ( $ url ) { if ( ! $ this -> isValidUrl ( $ url ) ) { $ url = $ this -> generateUrl ( $ url ) ; } header ( 'Location: ' . $ url ) ; }
Redirect to given URL .
234,138
public function generateUrl ( $ url ) { $ extern = false ; if ( ( 0 === strrpos ( $ url , 'http://' ) ) || ( 0 === strrpos ( $ url , 'https://' ) ) ) { $ extern = true ; } $ http = ( isset ( $ _SERVER [ 'HTTPS' ] ) ) ? 'https://' : 'http://' ; if ( ! $ extern ) { return ( $ this -> getRoot ( ) == '/' ) ? ( ( $ this -> ...
Used to generate a URL based on relative or absolute .
234,139
public static function get ( string $ type ) : ImagineInterface { switch ( $ type ) { case self :: GD : return new GdImagine ( ) ; case self :: IMAGICK : return new ImagickImagine ( ) ; case self :: GMAGICK : return new GmagickImagine ( ) ; default : throw new InvalidConfigException ( sprintf ( 'Image driver %s not fou...
Create imagine object for given driver
234,140
public static function get_image_fields ( $ field , $ attachment_id , $ sub_field = false ) { $ size = apply_filters ( Filter :: IMAGE , false , $ field , $ sub_field ) ; if ( ! $ size ) { return $ attachment_id ; } $ src = wp_get_attachment_image_src ( $ attachment_id , $ size ) ; if ( ! $ src ) { return $ attachment_...
Get image fields .
234,141
public function setFlashVar ( $ key , $ value ) { $ this -> flashVar [ $ key ] = $ value ; $ this -> set ( $ key , $ value ) ; }
Set session var that is only valid for only one request .
234,142
public function removeFlashVar ( ) { foreach ( $ this -> flashVar as $ key => $ value ) { unset ( $ this -> storage [ $ key ] ) ; } $ this -> flashVar = array ( ) ; }
Remove the FlashVars and the respective vars in the storage var .
234,143
public function moveToPermanent ( ) { $ destination_path = str_replace ( $ this -> getFileName ( ) , '' , $ this -> getPathName ( ) ) ; if ( null !== $ this -> getPathName ( ) && $ this -> getPathName ( ) != $ this -> prePersistName ) { $ this -> move ( $ destination_path ) ; } }
When the file persists if it is in the tmp subdir it will be move before save .
234,144
public function getRedirect ( ) { if ( ! $ this -> isRedirect ( ) ) return null ; if ( $ this -> isPermanentRedirect ( ) ) return substr ( $ this -> name , 19 ) ; return substr ( $ this -> name , 9 ) ; }
Returns the redirect value for this view providing it s a redirect
234,145
public function convert ( $ xmlString ) { $ dom = new \ DOMDocument ( ) ; $ dom -> loadXML ( $ xmlString ) ; $ documentElement = $ dom -> documentElement ; return $ documentElement ? $ this -> convertDOM ( $ dom -> documentElement ) : $ xmlString ; }
Main conversion API method to convert an XML string into an object tree .
234,146
public function stream ( ) { $ stream = fopen ( $ this -> file , 'r' ) ; $ stream = $ stream === false ? null : $ stream ; return new Stream ( $ stream ) ; }
Returns a stream representing the uploaded file .
234,147
protected function getConfig ( ) { $ config = array ( ) ; $ config [ 'headers' ] = $ this -> headers ; $ config [ 'config' ] = array ( 'curl' => $ this -> curlConfig ) ; $ config [ 'query' ] = $ this -> parameters ; $ config [ 'cookies' ] = true ; return $ config ; }
Get http request config for guzzle
234,148
public function formatException ( \ Exception $ exception , array $ record = array ( ) ) { $ record [ 'msg' ] = $ this -> normalizeException ( $ exception ) ; return $ this -> format ( $ record ) ; }
Format exception with normalizer And replace msg record with formatted exception
234,149
public static function fromNative ( ) { $ args = func_get_args ( ) ; if ( count ( $ args ) != 2 ) { throw new \ BadMethodCallException ( 'This methods expects two arguments. One for the key and one for the value.' ) ; } $ keyString = \ strval ( $ args [ 0 ] ) ; $ valueString = \ strval ( $ args [ 1 ] ) ; $ key = new St...
Returns a KeyValuePair from native PHP arguments evaluated as strings
234,150
public function sameValueAs ( ValueObjectInterface $ keyValuePair ) { if ( false === Util :: classEquals ( $ this , $ keyValuePair ) ) { return false ; } return $ this -> getKey ( ) -> sameValueAs ( $ keyValuePair -> getKey ( ) ) && $ this -> getValue ( ) -> sameValueAs ( $ keyValuePair -> getValue ( ) ) ; }
Tells whether two KeyValuePair are equal
234,151
private function fromArray ( array $ metadata ) { $ defaults = array ( 'type' => 'mixed' , 'mappedClass' => null ) ; $ data = array_merge ( $ defaults , $ metadata ) ; $ type = $ data [ 'type' ] ; $ mappedClass = $ data [ 'mappedClass' ] ; $ isSupported = isset ( static :: $ supportedTypes [ $ type ] ) ; if ( $ isSuppo...
Import an array of metadata
234,152
protected function filtering ( RouteInterface $ route , RequestInterface $ request ) { foreach ( $ route -> getFilters ( ) as $ field => $ filter ) { list ( $ grpName , $ keyName ) = explode ( '.' , $ field , 2 ) ; switch ( $ grpName ) { case 'session' : $ against = isset ( $ _SESSION [ $ keyName ] ) ? $ _SESSION [ $ k...
Filtering in route
234,153
function responseCode ( $ code = null ) { if ( $ code === null ) { return $ this -> http_response_code ; } else { $ this -> http_response_code = $ code ; return $ this ; } }
Equivalent in functionality to http_response_code from PHP
234,154
private function getOtherValue ( $ val ) { $ otherValue = $ val -> getValue ( ) ; return $ otherValue instanceof XPath2Item ? $ otherValue -> getValue ( ) : $ otherValue ; }
Convert an XPath2Item value to a native float or return the original value
234,155
public function addGet ( $ pathPattern , $ handler = null , array $ defaultValues = [ ] ) { $ this -> getCollectors ( ) [ 0 ] -> addGet ( $ pathPattern , $ handler , $ defaultValues ) ; return $ this ; }
Add a GET HEAD route to the first collector
234,156
public function addPost ( $ pathPattern , $ handler = null , array $ defaultValues = [ ] ) { $ this -> getCollectors ( ) [ 0 ] -> addPost ( $ pathPattern , $ handler , $ defaultValues ) ; return $ this ; }
Add a POST route to the first collector
234,157
protected function matchRoute ( ) { foreach ( $ this -> getCollectors ( ) as $ coll ) { if ( $ coll -> matchRoute ( $ this -> result ) ) { return true ; } } return false ; }
Match routes in collectors
234,158
protected function executeHandler ( ) { $ handler = $ this -> result -> getHandler ( ) ; if ( is_null ( $ handler ) ) { return $ this -> defaultHandler ( ) ; } else { $ callable = $ this -> resolver -> resolve ( $ handler ) ; if ( ( $ route = $ this -> result -> getRoute ( ) ) && $ route -> hasExtension ( ) ) { if ( $ ...
Execute handler from result
234,159
protected function defaultHandler ( ) { if ( $ this -> runExtensions ( self :: BEFORE_DEFAULT , $ this -> result ) ) { $ status = $ this -> result -> getStatus ( ) ; $ handler = $ this -> getHandler ( $ status ) ; if ( $ handler ) { $ handler ( $ this -> result ) ; } else { echo Message :: get ( Message :: DEBUG_NEED_H...
Execute dispatcher s default handler
234,160
public function isMatched ( $ pathinfo , $ index ) { $ pathinfo = $ this -> _urlRewrite ( $ pathinfo ) ; if ( ! empty ( $ pathinfo ) ) { $ res = explode ( '/' , $ pathinfo ) ; $ this -> _controllerName = empty ( $ res [ 0 ] ) ? $ this -> _controllerName : ucfirst ( $ res [ 0 ] ) ; if ( count ( $ res ) >= 2 ) { $ this -...
Determine whether the routing rules is matched .
234,161
public static function getStackByType ( $ type ) { foreach ( self :: getStacks ( ) as $ stack ) { if ( $ stack -> isType ( $ type ) ) { return $ stack ; } } return new Stacks \ NullStack ( ) ; }
Returns a stack based on type .
234,162
public static function inspect ( $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new FileNotFoundException ( sprintf ( 'Directory "%s" does not exist.' , $ dir ) ) ; } foreach ( self :: getStacks ( ) as $ stack ) { if ( $ stack -> inspect ( $ dir ) === true ) { return $ stack ; } } return new Stacks \ NullStack ( ) ; }
Inspects directory with stacks .
234,163
public function process ( $ access = '' ) { if ( is_array ( $ access ) ) { if ( isset ( $ access [ 'name' ] ) ) { $ name = $ access [ 'name' ] ; if ( isset ( $ this -> access [ $ name ] ) ) { $ accessInstance = $ this -> access [ $ name ] ; $ accessInstance = new $ accessInstance ; if ( $ accessInstance instanceof Midd...
Process the array
234,164
protected function isSerialized ( $ message ) { $ this -> statHat -> ezCount ( 'MB_Toolbox: MB_Toolbox_BaseConsumer: isSerialized' , 1 ) ; return ( $ message == serialize ( false ) || @ unserialize ( $ message ) !== false ) ; }
Detect if the message is in seralized format .
234,165
protected function reportErrorPayload ( ) { $ errorPayload = $ this -> message ; unset ( $ errorPayload [ 'payload' ] ) ; unset ( $ errorPayload [ 'original' ] ) ; echo '-> message: ' . print_r ( $ errorPayload , true ) , PHP_EOL ; $ this -> statHat -> ezCount ( 'MB_Toolbox: MB_Toolbox_BaseConsumer: reportErrorPayload'...
Log payload with RabbitMQ objects removed for clarity .
234,166
protected function throttle ( $ maxMessageRate ) { $ this -> throttleMessageCount ++ ; if ( $ this -> throttleSecondStamp != date ( 's' ) ) { $ this -> throttleSecondStamp = date ( 's' ) ; $ this -> throttleMessageCount = 0 ; } if ( $ this -> throttleMessageCount > $ maxMessageRate ) { sleep ( MBC_BaseConsumer :: THROT...
Throddle the rate the consumer processes messages .
234,167
public static function extractImports ( $ content ) { $ imports = array ( ) ; static :: filterImports ( $ content , function ( $ matches ) use ( & $ imports ) { $ imports [ ] = $ matches [ 'url' ] ; } ) ; return array_unique ( $ imports ) ; }
Extracts all references from the supplied CSS content .
234,168
static function getTrace ( $ e , $ seen = null ) { $ starter = $ seen ? 'Caused by: ' : '' ; $ result = array ( ) ; if ( ! $ seen ) $ seen = array ( ) ; $ trace = $ e -> getTrace ( ) ; $ prev = $ e -> getPrevious ( ) ; $ result [ ] = sprintf ( '%s%s: %s' , $ starter , get_class ( $ e ) , $ e -> getMessage ( ) ) ; $ fil...
Returns a string describing in detail the stack context of an exception .
234,169
public function loadFromFile ( $ path ) { $ fileSystem = new Filesystem ( ) ; if ( ! $ fileSystem -> exists ( $ path ) ) { throw new FileNotFoundException ( ) ; } $ configurationFile = new SplFileInfo ( $ path ) ; if ( $ configurationFile -> getExtension ( ) !== 'yml' ) { throw new Exception ( 'Only yml are allowed for...
Load the configuration from a yaml file in the file system .
234,170
public function cmdGetState ( ) { $ result = $ this -> getListState ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableState ( $ result ) ; $ this -> output ( ) ; }
Callback for state - get command
234,171
public function cmdUpdateState ( ) { $ 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' ) ) ; } $ this ->...
Callback for state - update command
234,172
protected function getListState ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { $ list = $ this -> state -> getList ( ) ; $ this -> limitArray ( $ list ) ; return $ list ; } if ( $ this -> getParam ( 'country' ) ) { $ list = $ this -> state -> getList ( array ( 'country' => $ id ) ) ; $ this -> limitA...
Returns an array of country states
234,173
protected function submitAddState ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'state' ) ; $ this -> addState ( ) ; }
Add a new country state at once
234,174
protected function addState ( ) { if ( ! $ this -> isError ( ) ) { $ state_id = $ this -> state -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ state_id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ state_id ) ; } }
Add a new country state
234,175
protected function wizardAddState ( ) { $ this -> validatePrompt ( 'code' , $ this -> text ( 'Code' ) , 'state' ) ; $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'state' ) ; $ this -> validatePrompt ( 'country' , $ this -> text ( 'Country' ) , 'state' ) ; $ this -> validatePrompt ( 'zone_id' , $ this ...
Add a new country state step by step
234,176
public function matchRequest ( $ requestedRoute , $ httpMethod ) { foreach ( $ this -> routes as $ route => $ callback ) { $ routeRx = preg_replace ( '%/:([^ /?]+)(\?)?%' , '/\2(?P<\1>[^ /?]+)\2' , $ route ) ; $ routeMethod = strstr ( $ route , ':' , true ) ; if ( $ routeMethod && substr ( $ routeMethod , - 1 ) != '/' ...
Compares the requested route param with the registered routes and checks whether there is a match - true on a match false if not .
234,177
public function getClosure ( $ app ) { if ( ! isset ( $ this -> routes [ $ this -> matched ] ) ) return false ; $ callback = $ this -> routes [ $ this -> matched ] ; if ( is_string ( $ callback ) ) { $ className = 'Resources\\' . $ callback ; if ( class_exists ( $ className ) ) { $ callback = function ( ) use ( $ app ,...
Returns a Closure instance which contains the logic to generate the output for the requested route or false .
234,178
public function jsonEncode ( $ object , UriBuilder $ uriBuilder , $ metaDataProcessorGroup = NULL ) { return json_encode ( $ this -> process ( $ object , $ uriBuilder , $ metaDataProcessorGroup ) ) ; }
Returns JsonEncode of the given object . If UriPointers are found in the DTO hierarchy the UriBuilder is required to resolve them .
234,179
public function process ( $ object , UriBuilder $ uriBuilder , $ metaDataProcessorGroup = NULL ) { $ formerConfigurationStackAttributes = array ( 'cacheTagService' , 'metaDataProcessors' , 'metaDataProcessorStorage' , 'uriBuilder' , 'propertyPath' , ) ; array_unshift ( $ this -> formerConfigurationStack , [ ] ) ; forea...
Basically TearUp and TearDown of the processing environment . The processing mechanism is another method .
234,180
protected function processInternal ( $ object ) { if ( is_scalar ( $ object ) ) { return $ object ; } elseif ( is_array ( $ object ) ) { return $ this -> processCollectionType ( $ object , array_keys ( $ object ) ) ; } elseif ( $ object instanceof \ DateTime ) { return $ object -> format ( DateTimeConverter :: DEFAULT_...
Dispatcher which kind of processing has to be done .
234,181
protected function processCollectionType ( $ collection , $ collectionKeys ) { $ result = [ ] ; foreach ( $ collectionKeys as $ collectionKey ) { array_push ( $ this -> propertyPath , $ collectionKey ) ; $ value = ObjectAccess :: getProperty ( $ collection , $ collectionKey ) ; $ result [ $ collectionKey ] = $ this -> ...
This method handles collection types which are DTOs and arrays .
234,182
protected function processUriPointer ( UriPointer $ uriPointer ) { $ uri = $ this -> uriBuilder -> reset ( ) -> setCreateAbsoluteUri ( TRUE ) -> uriFor ( $ uriPointer -> getActionName ( ) , $ uriPointer -> getArguments ( ) , $ uriPointer -> getControllerName ( ) , $ uriPointer -> getPackageKey ( ) , $ uriPointer -> get...
UriPointers are a special type because they are meant to create a very specific and unique uri string .
234,183
protected function getMetaData ( $ propertyPath , $ processedValue , $ object ) { $ metaData = [ ] ; foreach ( $ this -> metaDataProcessors as $ metaDataProcessorKey => $ metaDataProcessorConfiguration ) { if ( ! isset ( $ this -> metaDataProcessorStorage [ $ metaDataProcessorKey ] ) ) { $ this -> metaDataProcessorStor...
Returns MetaData for the given property
234,184
private function extractClass ( $ regEx , $ classContent ) { preg_match ( $ regEx , $ classContent , $ matches ) ; if ( isset ( $ matches [ 1 ] ) && class_exists ( $ matches [ 1 ] ) ) { return $ matches [ 1 ] ; } return ; }
Extract class usage from origin class content using regular expresion .
234,185
public function redirect ( $ key , $ config = [ ] , $ statusCode = 302 ) { $ router = $ this -> getService ( 'Router' ) ; $ url = $ this -> getService ( 'Url' ) ; $ urlNew = $ url -> generate ( $ key , $ config ) ; $ router -> redirect ( $ urlNew , $ statusCode ) ; }
deprecated and must use redirectAbs
234,186
public function redirectAbs ( $ url , $ statusCode = 302 ) { $ router = $ this -> getService ( 'Router' ) ; $ router -> redirect ( $ url , $ statusCode ) ; exit ; }
must be renamed to redirect in next major version
234,187
private function toOutput ( \ Throwable $ t ) { $ renderer = new \ Nuki \ Handlers \ Http \ Output \ Renderers \ RawRenderer ( ) ; $ response = new \ Nuki \ Handlers \ Http \ Output \ Response ( $ renderer ) ; $ content = get_class ( $ t ) . ': ' ; $ content .= $ t -> getMessage ( ) ; $ content .= ' in ' ; $ content .=...
Write to output
234,188
private function toUserOutput ( string $ msg ) { $ renderer = new \ Nuki \ Handlers \ Http \ Output \ Renderers \ RawRenderer ( ) ; $ response = new \ Nuki \ Handlers \ Http \ Output \ Response ( $ renderer ) ; $ renderer -> setContent ( new \ Nuki \ Models \ IO \ Output \ Content ( $ msg ) ) ; $ response -> httpStatus...
Write message to user output
234,189
public static function imgUrl ( $ file , $ folder = false ) { $ src = '@web/images/' ; if ( $ folder !== false ) { $ src .= $ folder . '/' ; } $ src .= $ file ; return Url :: to ( $ src ) ; }
Get image url by filename
234,190
public static function img ( $ file , $ folder = false , array $ options = [ ] ) { return Html :: img ( self :: imgUrl ( $ file , $ folder ) , $ options ) ; }
Display img tag
234,191
public static function linkUrl ( $ pageId , $ pageUrl ) { if ( self :: $ pages === null ) { self :: initPages ( ) ; } if ( $ pageUrl ) { if ( strpos ( $ pageUrl , 'http' ) === 0 ) { return Url :: to ( $ pageUrl ) ; } return Url :: to ( [ $ pageUrl ] ) ; } if ( isset ( self :: $ pages [ $ pageId ] [ 'link' ] ) ) { if ( ...
Get page url by id
234,192
public static function link ( $ menu , $ text , array $ options = [ ] , array $ fields = [ ] ) { if ( $ menu instanceof ActiveRecord ) { if ( ! $ fields ) { $ fields = self :: $ fields ; } if ( $ menu -> { $ fields [ 'page_blank' ] } ) { $ options [ 'target' ] = '_blank' ; } return Html :: a ( $ text , self :: linkUrl ...
Display link by page
234,193
public static function isLinkActive ( $ menu , array $ fields = [ ] ) { if ( $ menu instanceof ActiveRecord ) { if ( self :: $ pages === null ) { self :: initPages ( ) ; } if ( ! $ fields ) { $ fields = self :: $ fields ; } $ pageUrl = $ menu -> { $ fields [ 'page_url' ] } ; if ( $ pageUrl ) { if ( strpos ( $ pageUrl ,...
Check if page is active
234,194
public static function youTubeId ( $ url ) { parse_str ( parse_url ( $ url , PHP_URL_QUERY ) , $ vars ) ; if ( isset ( $ vars [ 'v' ] ) ) { return $ vars [ 'v' ] ; } return false ; }
Return movie ID based on YouTube url
234,195
private static function initPages ( ) { $ modelPage = Yii :: createObject ( Page :: class ) ; $ pages = $ modelPage :: find ( ) -> getMap ( ) -> asArray ( ) -> all ( ) ; if ( $ pages ) { foreach ( $ pages as $ page ) { self :: $ pages [ $ page [ 'id' ] ] = $ page ; } } }
Init pages array
234,196
public function getDescendantsAndSelf ( $ columns = [ '*' ] ) { if ( is_array ( $ columns ) ) return $ this -> descendantsAndSelf ( ) -> get ( $ columns ) ; $ arguments = func_get_args ( ) ; $ limit = intval ( array_shift ( $ arguments ) ) ; $ columns = array_shift ( $ arguments ) ? : [ '*' ] ; return $ this -> descend...
Retrieve all nested children an self .
234,197
public function moveToNewParent ( ) { $ pid = static :: $ moveToNewParentId ; if ( is_null ( $ pid ) ) $ this -> makeRoot ( ) ; else if ( $ pid !== false ) $ this -> makeChildOf ( $ pid ) ; }
Move to the new parent if appropiate .
234,198
public function restoreDescendants ( ) { if ( is_null ( $ this -> getRight ( ) ) || is_null ( $ this -> getLeft ( ) ) ) return ; $ self = $ this ; $ this -> getConnection ( ) -> transaction ( function ( ) use ( $ self ) { $ self -> newNestedSetQuery ( ) -> withTrashed ( ) -> where ( $ self -> getLeftColumnName ( ) , '>...
Restores all of the current node s descendants .
234,199
protected function determineDepth ( $ node , $ nesting = 0 ) { while ( $ parent = $ node -> parent ( ) -> first ( ) ) { $ nesting = $ nesting + 1 ; $ node = $ parent ; } return [ $ node , $ nesting ] ; }
Return an array with the last node we could reach and its nesting level