idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
12,300
public function buildImporterQueue ( ) { $ queue = [ ] ; foreach ( Yii :: $ app -> getApplicationModules ( ) as $ id => $ module ) { $ response = $ module -> import ( $ this ) ; if ( is_array ( $ response ) ) { foreach ( $ response as $ class ) { $ object = Yii :: createObject ( $ class , [ $ this , $ module ] ) ; $ po...
Get all importer objects with the assigned queue position .
12,301
public function actionIndex ( ) { $ queue = $ this -> buildImporterQueue ( ) ; foreach ( $ queue as $ pos => $ object ) { $ this -> verbosePrint ( "Run importer object '{$object->className()}' on position '{$pos}'." , __METHOD__ ) ; $ this -> verbosePrint ( 'Module context id: ' . $ object -> module -> id ) ; $ object ...
Run the import process .
12,302
private function logValueToTable ( array $ logs ) { $ table = new Table ( ) ; $ table -> setHeaders ( [ 'Key' , 'Value' ] ) ; $ rows = [ ] ; foreach ( $ logs as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ kk => $ kv ) { $ rows [ ] = [ $ kk , $ kv ] ; } } else { $ rows [ ] = [ $ key , $ val...
Print the log values as a table .
12,303
protected function output ( $ message , $ color = null ) { $ format = [ ] ; if ( ! $ this -> isMuted ( ) ) { if ( $ color !== null ) { $ format [ ] = $ color ; } echo Console :: ansiFormat ( "\r" . $ message . "\n" , $ format ) ; } }
Helper method for writting console application output include before and after wrappers .
12,304
public static function getInstantiatedTagObjects ( ) { $ context = self :: getInstance ( ) ; foreach ( $ context -> tags as $ key => $ config ) { $ context -> instantiatTag ( $ key ) ; } return $ context -> tags ; }
Generate the instance for all registered tags .
12,305
private function parseTag ( $ tag , $ context ) { $ this -> instantiatTag ( $ tag ) ; $ value = isset ( $ context [ 'value' ] ) ? $ context [ 'value' ] : false ; $ sub = isset ( $ context [ 'sub' ] ) ? $ context [ 'sub' ] : false ; if ( $ sub ) { $ sub = str_replace ( [ '\)' , '\(' ] , [ ')' , '(' ] , $ sub ) ; } retur...
Parse the given tag with context informations .
12,306
private function processText ( $ text ) { if ( ! is_string ( $ text ) || empty ( $ text ) ) { return $ text ; } preg_match_all ( static :: REGEX , $ text , $ results , PREG_SET_ORDER ) ; foreach ( $ results as $ row ) { if ( empty ( $ row [ 'value' ] ) ) { continue ; } $ tag = $ row [ 'function' ] ; if ( $ this -> hasT...
Process a given text .
12,307
public function isCachable ( ) { if ( $ this -> _cachable === null ) { $ this -> _cachable = Yii :: $ app -> has ( 'cache' ) ? true : false ; } return $ this -> _cachable ; }
Check if the current configuration of the application and the property allows a caching of the language container data .
12,308
public function setHasCache ( $ key , $ value , $ dependency = null , $ cacheExpiration = null ) { if ( $ this -> isCachable ( ) ) { if ( is_array ( $ dependency ) ) { $ dependency = Yii :: createObject ( $ dependency ) ; } return Yii :: $ app -> cache -> set ( $ key , $ value , is_null ( $ cacheExpiration ) ? $ this -...
Store cache data for a specific key if caching is enabled in this application .
12,309
public function deleteHasCache ( $ key ) { if ( $ this -> isCachable ( ) ) { return Yii :: $ app -> cache -> delete ( $ key ) ; } return false ; }
Remove a value from the cache if caching is enabled .
12,310
public function getHasCache ( $ key ) { if ( $ this -> isCachable ( ) ) { $ data = Yii :: $ app -> cache -> get ( $ key ) ; $ enumKey = ( is_array ( $ key ) ) ? implode ( "," , $ key ) : $ key ; if ( $ data ) { Yii :: debug ( "Cacheable trait key '$enumKey' successfully loaded from cache." , __METHOD__ ) ; return $ dat...
Get the caching data if caching is allowed and there is any data stored for this key .
12,311
public function getMailer ( ) { if ( $ this -> _mailer === null ) { $ this -> _mailer = new PHPMailer ( ) ; $ this -> _mailer -> CharSet = 'UTF-8' ; $ this -> _mailer -> From = $ this -> from ; $ this -> _mailer -> FromName = $ this -> fromName ; $ this -> _mailer -> isHTML ( true ) ; $ this -> _mailer -> XMailer = ' '...
Getter for the mailer object
12,312
public function compose ( $ subject = null , $ body = null ) { $ this -> cleanup ( ) ; if ( $ subject !== null ) { $ this -> subject ( $ subject ) ; } if ( $ body !== null ) { $ this -> body ( $ body ) ; } return $ this ; }
Compose a new mail message .
12,313
public function body ( $ body ) { $ message = $ this -> wrapLayout ( $ body ) ; $ this -> getMailer ( ) -> Body = $ message ; $ alt = empty ( $ this -> altBody ) ? $ this -> convertMessageToAltBody ( $ message ) : $ this -> altBody ; $ this -> getMailer ( ) -> AltBody = $ alt ; return $ this ; }
Set the HTML body for the mailer message if a layout is defined the layout will automatically wrapped about the html body .
12,314
public function convertMessageToAltBody ( $ message ) { $ message = preg_replace ( '/<head>(.*?)<\/head>/s' , '' , $ message ) ; $ tags = [ '</p>' , '<br />' , '<br>' , '<hr />' , '<hr>' , '</h1>' , '</h2>' , '</h3>' , '</h4>' , '</h5>' , '</h6>' ] ; return trim ( strip_tags ( str_replace ( $ tags , PHP_EOL , $ message...
Try to convert the message into an alt body tag .
12,315
public function render ( $ viewFile , array $ params = [ ] ) { $ this -> body ( Yii :: $ app -> view -> render ( $ viewFile , $ params ) ) ; return $ this ; }
Render a view file for the given Controller context .
12,316
public function addresses ( array $ emails ) { foreach ( $ emails as $ name => $ mail ) { if ( is_int ( $ name ) ) { $ this -> address ( $ mail ) ; } else { $ this -> address ( $ mail , $ name ) ; } } return $ this ; }
Add multiple addresses into the mailer object .
12,317
public function address ( $ email , $ name = null ) { $ this -> getMailer ( ) -> addAddress ( $ email , ( empty ( $ name ) ) ? $ email : $ name ) ; return $ this ; }
Add a single address with optional name
12,318
public function ccAddresses ( array $ emails ) { foreach ( $ emails as $ name => $ mail ) { if ( is_int ( $ name ) ) { $ this -> ccAddress ( $ mail ) ; } else { $ this -> ccAddress ( $ mail , $ name ) ; } } return $ this ; }
Add multiple CC addresses into the mailer object .
12,319
public function ccAddress ( $ email , $ name = null ) { $ this -> getMailer ( ) -> addCC ( $ email , ( empty ( $ name ) ) ? $ email : $ name ) ; return $ this ; }
Add a single CC address with optional name
12,320
public function bccAddresses ( array $ emails ) { foreach ( $ emails as $ name => $ mail ) { if ( is_int ( $ name ) ) { $ this -> bccAddress ( $ mail ) ; } else { $ this -> bccAddress ( $ mail , $ name ) ; } } return $ this ; }
Add multiple BCC addresses into the mailer object .
12,321
public function bccAddress ( $ email , $ name = null ) { $ this -> getMailer ( ) -> addBCC ( $ email , ( empty ( $ name ) ) ? $ email : $ name ) ; return $ this ; }
Add a single BCC address with optional name
12,322
public function addAttachment ( $ filePath , $ name = null ) { $ this -> getMailer ( ) -> addAttachment ( $ filePath , empty ( $ name ) ? pathinfo ( $ filePath , PATHINFO_BASENAME ) : $ name ) ; return $ this ; }
Add attachment .
12,323
public function addReplyTo ( $ email , $ name = null ) { $ this -> getMailer ( ) -> addReplyTo ( $ email , empty ( $ name ) ? $ email : $ name ) ; return $ this ; }
Add ReplyTo Address .
12,324
public function send ( ) { if ( empty ( $ this -> mailer -> Subject ) || empty ( $ this -> mailer -> Body ) ) { throw new Exception ( "Mail subject() and body() can not be empty in order to send mail." ) ; } if ( ! $ this -> getMailer ( ) -> send ( ) ) { Yii :: error ( $ this -> getError ( ) , __METHOD__ ) ; return fal...
Trigger the send event of the mailer
12,325
private function getUserAuthClass ( ) { if ( $ this instanceof UserBehaviorInterface ) { $ class = $ this -> userAuthClass ( ) ; if ( ! $ class ) { return false ; } if ( ! is_object ( $ class ) ) { return Yii :: createObject ( $ class ) ; } return $ class ; } return false ; }
Whether the rest controller is protected or not .
12,326
public function sendModelError ( Model $ model ) { if ( ! $ model -> hasErrors ( ) ) { throw new InvalidParamException ( 'The model as thrown an uknown Error.' ) ; } Yii :: $ app -> response -> setStatusCode ( 422 , 'Data Validation Failed.' ) ; $ result = [ ] ; foreach ( $ model -> getFirstErrors ( ) as $ name => $ me...
Send Model errors with correct headers .
12,327
public function sendArrayError ( array $ errors ) { Yii :: $ app -> response -> setStatusCode ( 422 , 'Data Validation Failed.' ) ; $ result = [ ] ; foreach ( $ errors as $ key => $ value ) { $ messages = ( array ) $ value ; foreach ( $ messages as $ msg ) { $ result [ ] = [ 'field' => $ key , 'message' => $ msg ] ; } ...
Send Array validation error .
12,328
public function parse ( $ value , $ sub ) { $ label = $ sub ? : $ value ; if ( $ this -> obfuscate ) { if ( ! $ sub ) { $ label = $ this -> obfuscate ( $ label ) ; } return '<a href="' . $ this -> obfuscate ( "mailto:{$value}" ) . '" rel="nofollow">' . $ label . '</a>' ; } return Html :: mailto ( $ label , $ value , [ ...
Generate the Mail Tag .
12,329
public function obfuscate ( $ email ) { $ output = null ; for ( $ i = 0 ; $ i < strlen ( $ email ) ; $ i ++ ) { $ output .= '&#' . ord ( $ email [ $ i ] ) . ';' ; } return $ output ; }
Obfucscate email adresse
12,330
public function autoFormat ( $ value ) { if ( ( new EmailValidator ( ) ) -> validate ( $ value ) ) { return $ this -> asEmail ( $ value ) ; } if ( ( new UrlValidator ( ) ) -> validate ( $ value ) ) { return $ this -> asUrl ( $ value ) ; } if ( is_bool ( $ value ) ) { return $ this -> asBoolean ( $ value ) ; } return $ ...
Auto format the value to a given format like url email .
12,331
public static function csv ( $ input , array $ keys = [ ] , $ header = true ) { $ delimiter = "," ; $ input = self :: transformInput ( $ input ) ; $ array = self :: generateContentArray ( $ input , $ keys , $ header ) ; return self :: generateOutputString ( $ array , $ delimiter ) ; }
Export an Array or ActiveQuery instance into a CSV formated string .
12,332
public static function xlsx ( $ input , array $ keys = [ ] , $ header = true ) { $ input = self :: transformInput ( $ input ) ; $ array = self :: generateContentArray ( $ input , $ keys , $ header ) ; $ writer = new XLSXWriter ( ) ; $ writer -> writeSheet ( $ array ) ; return $ writer -> writeToString ( ) ; }
Export an Array or ActiveQuery instance into a Excel formatted string .
12,333
protected static function generateContentArray ( $ contentRows , $ keys , $ generateHeader = true ) { if ( is_scalar ( $ contentRows ) ) { throw new Exception ( "Content must be either an array, object or traversable" ) ; } $ attributeKeys = $ keys ; $ header = [ ] ; $ rows = [ ] ; $ i = 0 ; foreach ( $ contentRows as ...
Generate content by rows .
12,334
protected static function generateRow ( array $ row , $ delimiter , $ enclose ) { array_walk ( $ row , function ( & $ item ) use ( $ enclose ) { if ( is_bool ( $ item ) ) { $ item = ( int ) $ item ; } elseif ( is_null ( $ item ) ) { $ item = '' ; } elseif ( ! is_scalar ( $ item ) ) { $ item = "[array]" ; } $ item = $ e...
Generate a row by its items .
12,335
public function setTelephone ( $ telephone ) { $ telephone = ltrim ( $ telephone , '\\' ) ; $ validator = new RegularExpressionValidator ( [ 'pattern' => '#^(?:0|\+[0-9]{2})[\d\- ()]+$#' ] ) ; if ( $ validator -> validate ( $ telephone , $ error ) ) { $ this -> _telephone = $ telephone ; } else { $ this -> _telephone =...
Setter method for telephone number .
12,336
public function transferMessage ( $ message , $ file = __FILE__ , $ line = __LINE__ ) { return $ this -> apiServerSendData ( $ this -> getExceptionArray ( [ 'message' => $ message , 'file' => $ file , 'line' => $ line , ] ) ) ; }
Send a custom message to the api server event its not related to an exception .
12,337
private function apiServerSendData ( array $ data ) { if ( $ this -> transferException ) { $ curl = new Curl ( ) ; $ curl -> setOpt ( CURLOPT_CONNECTTIMEOUT , 2 ) ; $ curl -> setOpt ( CURLOPT_TIMEOUT , 2 ) ; $ curl -> post ( Url :: ensureHttp ( rtrim ( $ this -> api , '/' ) ) . '/create' , [ 'error_json' => Json :: enc...
Send the array data to the api server .
12,338
public function getExceptionArray ( $ exception ) { $ _message = 'Uknonwn exception object, not instance of \Exception.' ; $ _file = 'unknown' ; $ _line = 0 ; $ _trace = [ ] ; $ _previousException = [ ] ; if ( is_object ( $ exception ) ) { $ prev = $ exception -> getPrevious ( ) ; if ( ! empty ( $ prev ) ) { $ _previou...
Get an readable array to transfer from an exception
12,339
private function buildTrace ( $ exception ) { $ _trace = [ ] ; foreach ( $ exception -> getTrace ( ) as $ key => $ item ) { $ _trace [ $ key ] = [ 'file' => isset ( $ item [ 'file' ] ) ? $ item [ 'file' ] : null , 'line' => isset ( $ item [ 'line' ] ) ? $ item [ 'line' ] : null , 'function' => isset ( $ item [ 'functio...
Build trace array from exception .
12,340
public function getIsAdmin ( ) { if ( $ this -> _isAdmin === null ) { if ( $ this -> getIsConsoleRequest ( ) && ! $ this -> forceWebRequest && ! Yii :: $ app -> hasModule ( 'admin' ) ) { $ this -> _isAdmin = false ; } else { if ( Yii :: $ app -> defaultRoute == 'admin' && empty ( $ this -> pathInfo ) ) { $ this -> _isA...
Getter method resolves the current url request and check if admin context .
12,341
public function verbosePrint ( $ message , $ section = null ) { if ( $ this -> verbose ) { $ this -> output ( ( ! empty ( $ section ) ) ? $ section . ': ' . $ message : $ message ) ; } }
Method to print informations directly when verbose is enabled .
12,342
public function selectModule ( array $ options = [ ] ) { $ modules = [ ] ; foreach ( Yii :: $ app -> getModules ( ) as $ id => $ object ) { if ( ! $ object instanceof \ luya \ base \ Module ) { continue ; } if ( isset ( $ options [ 'onlyAdmin' ] ) && $ options [ 'onlyAdmin' ] ) { if ( ! $ object instanceof AdminModuleI...
Get selection list for console commands with defined options .
12,343
public function createClassName ( $ string , $ suffix = false ) { $ name = Inflector :: camelize ( $ string ) ; if ( $ suffix !== false && StringHelper :: endsWith ( $ name , $ suffix , false ) ) { $ name = substr ( $ name , 0 , - ( strlen ( $ suffix ) ) ) ; } return $ name . $ suffix ; }
Generates a class name with camelcase style and specific suffix if not already provided
12,344
public function getSqlTablesArray ( ) { $ names = Yii :: $ app -> db -> schema -> tableNames ; return array_combine ( $ names , $ names ) ; }
Get the sql tables from the current database connection
12,345
protected function isColumnAutoIncremental ( $ table , $ columns ) { foreach ( $ columns as $ column ) { if ( isset ( $ table -> columns [ $ column ] ) && $ table -> columns [ $ column ] -> autoIncrement ) { return true ; } } return false ; }
Checks if any of the specified columns is auto incremental .
12,346
public function autoEncodeAttributes ( ) { foreach ( $ this -> attributes as $ name ) { if ( ! isset ( $ this -> owner -> getDirtyAttributes ( ) [ $ name ] ) ) { continue ; } $ value = $ this -> owner -> { $ name } ; if ( is_array ( $ value ) ) { $ this -> owner -> { $ name } = $ this -> jsonEncode ( $ name ) ; } } }
Encode attributes .
12,347
public static function coverSensitiveValues ( array $ data , array $ keys = [ ] ) { if ( empty ( $ keys ) ) { $ keys = self :: $ sensitiveDefaultKeys ; } $ clean = [ ] ; foreach ( $ keys as $ key ) { $ kw = strtolower ( $ key ) ; foreach ( $ data as $ k => $ v ) { if ( is_array ( $ v ) ) { $ clean [ $ k ] = static :: c...
Cover senstive values from a given list of keys .
12,348
public static function arrayUnshiftAssoc ( & $ arr , $ key , $ val ) { $ arr = array_reverse ( $ arr , true ) ; $ arr [ $ key ] = $ val ; return array_reverse ( $ arr , true ) ; }
Prepend an assoc array item as first entry for a given array .
12,349
public static function typeCast ( array $ array ) { $ return = [ ] ; foreach ( $ array as $ k => $ v ) { if ( is_numeric ( $ v ) ) { $ return [ $ k ] = StringHelper :: typeCastNumeric ( $ v ) ; } elseif ( is_array ( $ v ) ) { $ return [ $ k ] = self :: typeCast ( $ v ) ; } else { $ return [ $ k ] = $ v ; } } return $ r...
TypeCast values from a mixed array source . numeric values will be casted as integer .
12,350
public static function search ( array $ array , $ searchText , $ sensitive = false ) { $ function = ( $ sensitive ) ? 'strpos' : 'stripos' ; return array_filter ( $ array , function ( $ item ) use ( $ searchText , $ function ) { $ response = false ; foreach ( $ item as $ key => $ value ) { if ( $ response ) { continue ...
Search trough all keys inside of an array any occurence will return the rest of the array .
12,351
public static function searchColumn ( array $ array , $ column , $ search ) { $ array = array_values ( $ array ) ; $ columns = array_column ( $ array , $ column ) ; $ key = array_search ( $ search , $ columns ) ; return ( $ key !== false ) ? $ array [ $ key ] : false ; }
Search for a Column Value inside a Multidimension array and return the array with the found key .
12,352
public static function searchColumns ( array $ array , $ column , $ search ) { $ keys = array_filter ( $ array , function ( $ var ) use ( $ column , $ search ) { return strcasecmp ( $ search , $ var [ $ column ] ) == 0 ? true : false ; } ) ; return $ keys ; }
Search for columns with the given search value returns the full array with all valid items .
12,353
public static function generateRange ( $ from , $ to , $ text = null ) { $ range = range ( $ from , $ to ) ; $ array = array_combine ( $ range , $ range ) ; if ( $ text ) { array_walk ( $ array , function ( & $ item , $ key ) use ( $ text ) { if ( is_array ( $ text ) ) { list ( $ singular , $ plural ) = $ text ; if ( $...
Generate an Array from a Rang with an appending optional Text .
12,354
public static function classInfo ( $ file ) { if ( is_file ( $ file ) ) { $ phpCode = file_get_contents ( $ file ) ; } else { $ phpCode = $ file ; } $ namespace = false ; if ( preg_match ( '/^namespace\s+(.+?);(\s+|\r\n)?$/sm' , $ phpCode , $ results ) ) { $ namespace = $ results [ 1 ] ; } $ classes = self :: className...
Provide class informations from a file path or file content .
12,355
private static function classNameByTokens ( $ phpCode ) { $ classes = [ ] ; $ tokens = token_get_all ( $ phpCode ) ; $ count = count ( $ tokens ) ; for ( $ i = 2 ; $ i < $ count ; $ i ++ ) { if ( $ tokens [ $ i - 2 ] [ 0 ] == T_CLASS && $ tokens [ $ i - 1 ] [ 0 ] == T_WHITESPACE && $ tokens [ $ i ] [ 0 ] == T_STRING ) ...
Tokenize the php code from a given class in in order to determine the class name .
12,356
public static function unlink ( $ file ) { try { if ( parent :: unlink ( $ file ) ) { return true ; } } catch ( \ Exception $ e ) { } if ( is_link ( $ file ) ) { $ sym = @ readlink ( $ file ) ; if ( $ sym ) { if ( @ unlink ( $ file ) ) { return true ; } } } if ( realpath ( $ file ) && realpath ( $ file ) !== $ file ) {...
Unlink a file which handles symlinks .
12,357
public function routeHasLanguageCompositionPrefix ( $ route , $ language ) { $ parts = explode ( "/" , $ route ) ; if ( isset ( $ parts [ 0 ] ) && $ parts [ 0 ] == $ language ) { return true ; } return false ; }
Ensure whether a route starts with a language short key or not .
12,358
public function getMenu ( ) { if ( $ this -> _menu === null ) { $ menu = Yii :: $ app -> get ( 'menu' , false ) ; if ( $ menu ) { $ this -> _menu = $ menu ; } else { $ this -> _menu = false ; } } return $ this -> _menu ; }
Get the menu component if its registered in the current applications .
12,359
public function getComposition ( ) { if ( $ this -> _composition === null ) { $ this -> _composition = Yii :: $ app -> get ( 'composition' ) ; } return $ this -> _composition ; }
Get the composition component
12,360
public function createUrl ( $ params ) { $ response = $ this -> internalCreateUrl ( $ params ) ; if ( $ this -> contextNavItemId ) { return $ this -> urlReplaceModule ( $ response , $ this -> contextNavItemId , $ this -> getComposition ( ) ) ; } return $ response ; }
Extend createUrl method by verify its context implementation to add cms urls prepand to the requested createurl params .
12,361
public function createMenuItemUrl ( $ params , $ navItemId , $ composition = null ) { $ composition = empty ( $ composition ) ? $ this -> getComposition ( ) : $ composition ; $ url = $ this -> internalCreateUrl ( $ params , $ composition ) ; if ( ! $ this -> menu ) { return $ url ; } return $ this -> urlReplaceModule (...
Create an url for a menu item .
12,362
public function internalCreateUrl ( $ params , $ composition = null ) { $ params = ( array ) $ params ; $ composition = empty ( $ composition ) ? $ this -> getComposition ( ) : $ composition ; $ originalParams = $ params ; $ params [ 0 ] = $ composition -> prependTo ( $ params [ 0 ] , $ composition -> createRoute ( ) )...
Yii2 createUrl base implementation extends the prepand of the comosition
12,363
public function internalCreateAbsoluteUrl ( $ params , $ scheme = null ) { $ params = ( array ) $ params ; $ url = $ this -> internalCreateUrl ( $ params ) ; if ( strpos ( $ url , '://' ) === false ) { $ url = $ this -> getHostInfo ( ) . $ url ; } if ( is_string ( $ scheme ) && ( $ pos = strpos ( $ url , '://' ) ) !== ...
Create absolute url from the given route params .
12,364
private function findModuleInRoute ( $ route ) { $ route = parse_url ( $ route , PHP_URL_PATH ) ; $ parts = array_values ( array_filter ( explode ( '/' , $ route ) ) ) ; if ( isset ( $ parts [ 0 ] ) && array_key_exists ( $ parts [ 0 ] , Yii :: $ app -> getApplicationModules ( ) ) ) { return $ parts [ 0 ] ; } return fal...
See if the module of a provided route exists in the luya application list .
12,365
private function urlReplaceModule ( $ url , $ navItemId , Composition $ composition ) { $ route = $ composition -> removeFrom ( $ this -> removeBaseUrl ( $ url ) ) ; $ moduleName = $ this -> findModuleInRoute ( $ route ) ; if ( $ moduleName === false || $ this -> menu === false ) { return $ url ; } $ item = $ this -> m...
Replace the url with the current module context .
12,366
public function setAreaServed ( $ areaServed ) { ObjectHelper :: isInstanceOf ( $ areaServed , [ Place :: class , TextValue :: class ] ) ; $ this -> _areaServed = $ areaServed ; return $ this ; }
Set Area Served .
12,367
public function inGroup ( $ alias ) { if ( $ this -> isGuest ) { return false ; } $ identity = $ this -> identity ; if ( ! $ identity instanceof GroupUserIdentityInterface ) { throw new InvalidConfigException ( 'The $identityClass must be instance of luya\web\GroupUserIdentityInterface.' ) ; } $ groups = ( array ) $ al...
Checks whether a user exists for the provided group based on the GroupUserIdentityInterface implementation
12,368
public static function isTraitInstanceOf ( $ object , $ haystack ) { $ traits = static :: traitsList ( $ object ) ; if ( is_object ( $ haystack ) ) { $ haystack = static :: traitsList ( $ haystack ) ; } foreach ( ( array ) $ haystack as $ stack ) { if ( in_array ( $ stack , $ traits ) ) { return true ; } } return false...
Check whether a given object contains a trait .
12,369
public static function traitsList ( $ object , $ autoload = true ) { $ traits = [ ] ; do { $ traits = array_merge ( class_uses ( $ object , $ autoload ) , $ traits ) ; } while ( $ object = get_parent_class ( $ object ) ) ; $ traitsToSearch = $ traits ; while ( ! empty ( $ traitsToSearch ) ) { $ newTraits = class_uses (...
Get an array with all traits for a given object
12,370
public static function callMethodSanitizeArguments ( $ object , $ method , array $ argumentsList = [ ] ) { $ reflection = new ReflectionMethod ( $ object , $ method ) ; $ methodArgs = [ ] ; foreach ( $ reflection -> getParameters ( ) as $ param ) { if ( array_key_exists ( $ param -> name , $ argumentsList ) ) { $ metho...
Call a method and ensure arguments .
12,371
public function resolveRoute ( $ route ) { $ routeParts = explode ( '/' , $ route ) ; foreach ( $ routeParts as $ k => $ v ) { if ( ( $ k == 0 && $ v == $ this -> id ) || ( empty ( $ v ) ) ) { unset ( $ routeParts [ $ k ] ) ; } } if ( count ( $ routeParts ) == 0 ) { return $ this -> defaultRoute ; } return implode ( '/...
Extract the current module from the route and return the new resolved route .
12,372
public static function registerTranslation ( $ prefix , $ basePath , array $ fileMap ) { if ( ! isset ( Yii :: $ app -> i18n -> translations [ $ prefix ] ) ) { Yii :: $ app -> i18n -> translations [ $ prefix ] = [ 'class' => 'yii\i18n\PhpMessageSource' , 'basePath' => $ basePath , 'fileMap' => $ fileMap , ] ; } }
Register a Translation to the i18n component .
12,373
public static function baseT ( $ category , $ message , array $ params = [ ] , $ language = null ) { static :: onLoad ( ) ; return Yii :: t ( $ category , $ message , $ params , $ language ) ; }
Base translation method which invokes the onLoad function .
12,374
public function setSuffix ( $ suffix ) { $ this -> _suffix = $ suffix ; $ this -> request -> setPathInfo ( implode ( '/' , [ $ this -> module -> id , $ suffix ] ) ) ; }
Setter for the suffix property .
12,375
public function getRequestRoute ( ) { if ( $ this -> _requestRoute !== null ) { return $ this -> _requestRoute ; } if ( $ this -> _defaultRoute !== null && empty ( $ this -> getSuffix ( ) ) ) { $ array = $ this -> _defaultRoute ; } else { $ route = $ this -> urlManager -> parseRequest ( $ this -> request ) ; $ array = ...
Determine the default route based on current defaultRoutes or parsedRequested by the UrlManager .
12,376
public function defaultRoute ( $ controller , $ action = null , array $ args = [ ] ) { $ this -> _defaultRoute = [ 'route' => implode ( '/' , [ $ this -> module -> id , $ controller , ( empty ( $ action ) ) ? 'index' : $ action ] ) , 'args' => $ args , 'originalArgs' => $ args , ] ; }
Inject a defaultRoute .
12,377
public function getUrlRule ( ) { $ request = $ this -> getRequestRoute ( ) ; return [ 'module' => $ this -> module -> id , 'route' => $ this -> module -> id . '/' . $ request [ 'route' ] , 'params' => $ request [ 'originalArgs' ] , ] ; }
Returns the url rule parameters which are taken from the requested route .
12,378
public function run ( ) { $ requestRoute = $ this -> getRequestRoute ( ) ; $ controller = $ this -> module -> createController ( $ requestRoute [ 'route' ] ) ; if ( ! isset ( $ controller [ 0 ] ) && ! is_object ( $ controller [ 0 ] ) ) { throw new NotFoundHttpException ( sprintf ( "Unable to create controller '%s' for ...
Run the route based on the values .
12,379
public function getResolvedKeyValue ( $ key ) { $ keys = $ this -> resolvedValues ; return isset ( $ keys [ $ key ] ) ? $ keys [ $ key ] : false ; }
Get a value for a given resolved pattern key .
12,380
protected function getInternalResolverArray ( ) { if ( $ this -> _resolved === null ) { $ requestPathInfo = $ this -> trailingPathInfo ( ) ; $ newRegex = $ this -> buildRegexPattern ( ) ; preg_match_all ( static :: VAR_MATCH_REGEX , $ this -> composition -> pattern , $ patternDefinitions , PREG_SET_ORDER ) ; foreach ( ...
Resolve the current data .
12,381
public function setAuthor ( $ author ) { ObjectHelper :: isInstanceOf ( $ author , [ Organization :: class , PersonInterface :: class ] ) ; $ this -> _author = $ author ; return $ this ; }
The author of this content or rating . Please note that author is special in that HTML 5 provides a special mechanism for indicating authorship via the rel tag . That is equivalent to this and may be used interchangeably .
12,382
public function setCopyrightHolder ( $ copyrightHolder ) { ObjectHelper :: isInstanceOf ( $ copyrightHolder , [ Organization :: class , PersonInterface :: class ] ) ; $ this -> _copyrightHolder = $ copyrightHolder ; return $ this ; }
The party holding the legal copyright to the CreativeWork .
12,383
public function setPublisher ( $ publisher ) { ObjectHelper :: isInstanceOf ( $ publisher , [ Organization :: class , Person :: class ] ) ; $ this -> _publisher = $ publisher ; return $ this ; }
The publisher of the creative work .
12,384
public function setAutoGenerateProxyClasses ( int $ mode ) : void { $ this -> autoGenerateProxyClasses = $ mode ; $ proxyManagerConfig = $ this -> getProxyManagerConfiguration ( ) ; switch ( $ mode ) { case self :: AUTOGENERATE_FILE_NOT_EXISTS : $ proxyManagerConfig -> setGeneratorStrategy ( new FileWriterGeneratorStra...
Sets an int flag that indicates whether proxy classes should always be regenerated during each script execution .
12,385
public function addFilter ( string $ name , string $ className , array $ parameters = [ ] ) : void { $ this -> attributes [ 'filters' ] [ $ name ] = [ 'class' => $ className , 'parameters' => $ parameters , ] ; }
Add a filter to the list of possible filters .
12,386
public function geoNear ( $ x , $ y = null ) : Stage \ GeoNear { return $ this -> builder -> geoNear ( $ x , $ y ) ; }
Outputs documents in order of nearest to farthest from a specified point . You can only use this as the first stage of a pipeline .
12,387
public function generateHydratorClasses ( array $ classes , ? string $ toDir = null ) : void { $ hydratorDir = $ toDir ? : $ this -> hydratorDir ; $ hydratorDir = rtrim ( $ hydratorDir , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; foreach ( $ classes as $ class ) { $ hydratorClassName = str_replace ( '\\' , '' , $ cl...
Generates hydrator classes for all given classes .
12,388
public static function isAtomic ( string $ strategy ) : bool { return $ strategy === ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET || $ strategy === ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET_ARRAY ; }
Returns whether update query must be included in query updating owning document .
12,389
public static function isHash ( string $ strategy ) : bool { return $ strategy === ClassMetadata :: STORAGE_STRATEGY_SET || $ strategy === ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET ; }
Returns whether Collection hold associative array .
12,390
public static function isList ( ? string $ strategy ) : bool { return $ strategy !== ClassMetadata :: STORAGE_STRATEGY_SET && $ strategy !== ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET ; }
Returns whether Collection hold array indexed by consecutive numbers .
12,391
public function showLatencyStats ( bool $ histograms = false ) : self { $ this -> latencyStats = $ histograms ? self :: LATENCY_STATS_HISTOGRAMS : self :: LATENCY_STATS_SIMPLE ; return $ this ; }
Adds latency statistics to the return document .
12,392
private function wrapCursor ( Cursor $ baseCursor ) : Iterator { return new CachingIterator ( new HydratingIterator ( $ baseCursor , $ this -> dm -> getUnitOfWork ( ) , $ this -> class ) ) ; }
Wraps the supplied base cursor in the corresponding ODM class .
12,393
private function createDocument ( array $ result , ? object $ document = null , array $ hints = [ ] ) : ? object { if ( $ document !== null ) { $ hints [ Query :: HINT_REFRESH ] = true ; $ id = $ this -> class -> getPHPIdentifierValue ( $ result [ '_id' ] ) ; $ this -> uow -> registerManaged ( $ document , $ id , $ res...
Creates or fills a single document object from an query result .
12,394
public function prepareProjection ( array $ fields ) : array { $ preparedFields = [ ] ; foreach ( $ fields as $ key => $ value ) { $ preparedFields [ $ this -> prepareFieldName ( $ key ) ] = $ value ; } return $ preparedFields ; }
Prepare a projection array by converting keys which are PHP property names to MongoDB field names .
12,395
public function prepareSort ( array $ fields ) : array { $ sortFields = [ ] ; foreach ( $ fields as $ key => $ value ) { if ( is_array ( $ value ) ) { $ sortFields [ $ this -> prepareFieldName ( $ key ) ] = $ value ; } else { $ sortFields [ $ this -> prepareFieldName ( $ key ) ] = $ this -> getSortDirection ( $ value )...
Prepare a sort specification array by converting keys to MongoDB field names and changing direction strings to int .
12,396
private function hasDBRefFields ( $ value ) : bool { if ( ! is_array ( $ value ) && ! is_object ( $ value ) ) { return false ; } if ( is_object ( $ value ) ) { $ value = get_object_vars ( $ value ) ; } foreach ( $ value as $ key => $ _ ) { if ( $ key === '$ref' || $ key === '$id' || $ key === '$db' ) { return true ; } ...
Checks whether the value has DBRef fields .
12,397
private function hasQueryOperators ( $ value ) : bool { if ( ! is_array ( $ value ) && ! is_object ( $ value ) ) { return false ; } if ( is_object ( $ value ) ) { $ value = get_object_vars ( $ value ) ; } foreach ( $ value as $ key => $ _ ) { if ( isset ( $ key [ 0 ] ) && $ key [ 0 ] === '$' ) { return true ; } } retur...
Checks whether the value has query operators .
12,398
private function getClassDiscriminatorValues ( ClassMetadata $ metadata ) : array { $ discriminatorValues = [ ] ; if ( $ metadata -> discriminatorValue !== null ) { $ discriminatorValues [ ] = $ metadata -> discriminatorValue ; } foreach ( $ metadata -> subClasses as $ className ) { $ key = array_search ( $ className ,...
Returns the list of discriminator values for the given ClassMetadata
12,399
private function getQueryForDocument ( object $ document ) : array { $ id = $ this -> uow -> getDocumentIdentifier ( $ document ) ; $ id = $ this -> class -> getDatabaseIdentifierValue ( $ id ) ; $ shardKeyQueryPart = $ this -> getShardKeyQuery ( $ document ) ; return array_merge ( [ '_id' => $ id ] , $ shardKeyQueryPa...
Get shard key aware query for single document .