idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
10,400
public static function create ( $ function ) : \ ReflectionFunctionAbstract { if ( \ is_string ( $ function ) ) { return \ strpos ( $ function , '::' ) ? new \ ReflectionMethod ( $ function ) : new \ ReflectionFunction ( $ function ) ; } if ( \ is_array ( $ function ) ) { return ( new \ ReflectionClass ( \ ReflectionMe...
Creates a reflection for a given function .
10,401
public function sendNotification ( $ user ) { $ token = Hash :: random ( 35 ) ; VerifiedUser :: create ( [ 'email' => $ user -> email , 'token' => $ token ] ) ; return $ this -> sendVerifyEmailNotification ( $ user , $ token ) ; }
Send email verification email
10,402
public function getUserAgent ( ) { if ( empty ( $ this -> userAgent ) ) { $ this -> userAgent = self :: DEFAULT_USERAGENT ; } return $ this -> userAgent ; }
Get user agent
10,403
public function getAuthenticate ( ) { if ( $ this -> authenticate === null ) { $ this -> authenticate = new Authenticate ( $ this -> getSecretKey ( ) , $ this -> getAccessKey ( ) ) ; } return $ this -> authenticate ; }
Get authenticate object
10,404
public function innerJoin ( $ table , $ where , $ using = true ) { return $ this -> join ( 'INNER' , $ table , $ where , $ using ) ; }
Inner join clause
10,405
public function leftJoin ( $ table , $ where , $ using = true ) { return $ this -> join ( 'LEFT' , $ table , $ where , $ using ) ; }
Left join clause
10,406
public function rightJoin ( $ table , $ where , $ using = true ) { return $ this -> join ( 'RIGHT' , $ table , $ where , $ using ) ; }
Right join clause
10,407
protected function generateLoginUrl ( $ query ) { if ( ! is_null ( $ this -> scope ) ) { if ( is_array ( $ this -> scope ) ) { $ this -> scope = implode ( ' ' , $ this -> scope ) ; } $ query [ 'scope' ] = $ this -> scope ; } if ( ! is_null ( $ this -> state ) ) { $ query [ 'state' ] = $ this -> state ; } if ( ! is_null...
Generates a login url to redirect to
10,408
protected function generateAccess ( $ query , $ code = null , $ refreshToken = false ) { if ( ! is_null ( $ code ) ) { if ( $ refreshToken ) { $ query [ 'refresh_token' ] = $ code ; } else { $ query [ self :: CODE ] = $ code ; } } $ curl = Curl :: i ( ) -> setUrl ( $ this -> accessUrl ) -> verifyHost ( false ) -> verif...
Returns an access token from server
10,409
public function askConfirmation ( $ question , $ default = true ) { $ helper = $ this -> _helperSet -> get ( 'question' ) ; $ confirmation_question = new ConfirmationQuestion ( '<question>' . $ question . ' [' . ( $ default ? 'y' : 'n' ) . ']?</question> ' , $ default ) ; return $ helper -> ask ( $ this -> _input , $ t...
Asks a confirmation to the user . The question will be asked until the user answers by nothing yes or no .
10,410
public function choose ( $ question , array $ options , $ default , $ error_message ) { $ helper = $ this -> _helperSet -> get ( 'question' ) ; $ choice_question = new ChoiceQuestion ( '<question>' . $ question . '</question> ' , $ options , $ default ) ; $ choice_question -> setErrorMessage ( $ error_message ) ; retur...
Asks user to choose .
10,411
public function onKernelException ( GetResponseForExceptionEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ exception = $ event -> getException ( ) ; if ( $ request -> isXmlHttpRequest ( ) ) { if ( $ exception instanceof AccessDeniedException ) { $ token = $ this -> context -> getToken ( ) ; if ( ! $ this ->...
Returns a response when is an ajax request and an AccessDeniedException has been thrown
10,412
public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( $ this -> getAlias ( ) ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new Loader \ YamlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config'...
Load extension .
10,413
private function disableDoctrineListener ( ContainerBuilder $ container ) { if ( ! $ container -> hasParameter ( 'kernel.bundles' ) ) { return ; } $ bundles = $ container -> getParameter ( 'kernel.bundles' ) ; if ( ! isset ( $ bundles [ 'DoctrineBundle' ] ) ) { $ container -> prependExtensionConfig ( $ this -> getAlias...
Disable clear entity managers listener if no doctrine bundle is installed .
10,414
public function filter ( $ node , $ tagname ) { $ ret = array ( ) ; while ( $ node = Dom :: getNextSiblingElement ( $ node ) ) { array_push ( $ ret , $ node ) ; } return $ ret ; }
Gets the general sibling nodes .
10,415
public static function csrfInput ( ) { return Html :: hiddenInput ( \ Yii :: $ app -> request -> csrfParam , \ Yii :: $ app -> request -> csrfToken ) ; }
Csrf input for submitting form data
10,416
public static function displayError ( $ code , $ message , $ file , $ line ) { if ( YII_DEBUG ) { echo "<h1>PHP Error [$code]</h1>\n" ; echo "<p>$message ($file:$line)</p>\n" ; echo '<pre>' ; $ trace = debug_backtrace ( ) ; if ( count ( $ trace ) > 3 ) $ trace = array_slice ( $ trace , 3 ) ; foreach ( $ trace as $ i =>...
Yii1 function Displays the captured PHP error . This method displays the error in HTML when there is no active error handler .
10,417
public static function buttonGroup ( $ button , $ links ) { foreach ( $ links as $ key => $ link ) { $ links [ $ key ] = Html :: beginTag ( 'li' ) . Html :: a ( $ link [ 0 ] , $ link [ 1 ] , $ link [ 2 ] ) . Html :: endTag ( 'li' ) ; } return Html :: beginTag ( 'div' , [ 'class' => 'btn-group' ] ) . Html :: button ( $ ...
Renders bootstrap3 button group
10,418
public static function arrayPrettyPrint ( $ array , $ raw = false ) { if ( ! $ array ) { return '' ; } $ parentOptions = [ 'tag' => 'dl' , 'class' => 'dl-horizontal' ] ; $ labelOptions = [ 'tag' => 'dt' ] ; $ valueOptions = [ 'tag' => 'dd' ] ; $ content = [ ] ; foreach ( $ array as $ key => $ value ) { $ value = is_arr...
Returns array as key = > value ul - > li lists
10,419
public static function urlToPath ( $ url ) { $ baseUrl = Yii :: $ app -> request -> hostInfo ; $ parsedUrl = parse_url ( $ url ) ; if ( isset ( $ parsedUrl [ 'host' ] ) && ! strpos ( $ baseUrl , $ parsedUrl [ 'host' ] ) ) { return false ; } if ( ! isset ( $ parsedUrl [ 'path' ] ) ) { return false ; } $ path = str_repla...
Gets router rule for url .
10,420
public static function getObjectTransValue ( $ parameters , $ objectTrans ) { if ( Lang :: has ( $ parameters [ 'package' ] . '::pulsar.' . $ objectTrans ) ) { return $ parameters [ 'package' ] . '::pulsar.' . $ objectTrans ; } elseif ( Lang :: has ( 'pulsar::pulsar.' . $ objectTrans ) ) { return 'pulsar::pulsar.' . $ ...
Funtion to set ObjectTrans variable
10,421
public static function setDataAttributes ( $ data ) { if ( is_array ( $ data ) && count ( $ data ) > 0 ) { $ keys = array_keys ( $ data ) ; $ response = '' ; foreach ( $ keys as $ key ) { $ response .= ' data-' . $ key . '="' . $ data [ $ key ] . '"' ; } return $ response ; } return null ; }
Funtion to set data atrributes to html tags
10,422
public static function setDataOptionAttributes ( $ data , $ object ) { if ( is_array ( $ data ) && count ( $ data ) > 0 ) { $ keys = array_keys ( $ data ) ; $ response = '' ; foreach ( $ keys as $ key ) { $ response .= ' data-' . $ key . '="' . $ object -> { $ data [ $ key ] } . '"' ; } return $ response ; } return nul...
Funtion to set data atrributes to option html tag
10,423
public static function isSelected ( $ value , $ valueObject ) { if ( is_array ( $ value ) && count ( $ value ) > 0 ) { return in_array ( $ valueObject , $ value ) ; } if ( $ value instanceof Collection ) { foreach ( $ value as $ v ) { if ( $ v -> getKey ( ) === $ valueObject ) { return true ; } } return false ; } elsei...
Funtion to check if option from select is seleted
10,424
public static function base64ImageUpload ( $ inputName , $ path , $ encryption = false , $ newFilename = false ) { $ json = json_decode ( Request :: input ( $ inputName ) ) ; $ imageData = base64_decode ( explode ( ',' , $ json -> data ) [ 1 ] ) ; $ nameArray = explode ( '.' , $ json -> name ) ; $ extension = strtolowe...
Function to upload base64 image
10,425
public static function getMimesAccept ( $ resource ) { $ attachmentMimes = AttachmentMime :: builder ( ) -> where ( 'resource_id_019' , $ resource ) -> get ( ) ; $ index = 1 ; $ mimes = null ; foreach ( $ attachmentMimes as $ attachmentMime ) { $ mimes .= "'" . $ attachmentMime -> mime_019 . "'" ; if ( $ index < count ...
get string with mimes to getfile plugin
10,426
public static function phoneNumberFormat ( $ numero ) { $ numero = str_replace ( array ( " " , "-" ) , array ( "" ) , $ numero ) ; $ comienzo = strlen ( $ numero ) ; $ resultado = '' ; while ( $ comienzo >= 0 ) { $ resultado = substr ( $ numero , $ comienzo , 3 ) . " " . $ resultado ; $ comienzo -= 3 ; } return $ resul...
Function to format phone
10,427
public static function extractEmail ( $ text ) { $ matches = array ( ) ; $ pattern = "/(?:[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(...
Function to etract email from text
10,428
public static function inArray ( $ needle , $ haystack , $ index ) { foreach ( $ haystack as $ element ) { if ( $ element [ $ index ] == $ needle ) return true ; } return false ; }
Function to search in array
10,429
public static function arrayToObject ( $ array ) { $ obj = new \ stdClass ( ) ; foreach ( $ array as $ k => $ v ) { if ( strlen ( $ k ) ) { if ( is_array ( $ v ) && count ( $ v ) > 0 ) { $ instance = new static ; $ obj -> { $ k } = $ instance -> arrayToObject ( $ v ) ; } else { $ obj -> { $ k } = $ v ; } } } return $ o...
convert a array to object
10,430
public static function dataTablePaginate ( $ request , $ parameters = [ ] ) { $ parameters [ 'start' ] = null ; $ parameters [ 'length' ] = null ; if ( $ request -> input ( 'start' ) != null && $ request -> input ( 'length' ) != '-1' ) { $ parameters [ 'start' ] = $ request -> input ( 'start' ) ; $ parameters [ 'length...
Function to set config arguments datatable
10,431
public static function dataTableSorting ( $ request , $ parameters , $ indexColumns ) { $ order = $ request -> input ( 'order' ) ; $ columns = $ request -> input ( 'columns' ) ; if ( is_array ( $ order [ 0 ] ) && isset ( $ order [ 0 ] [ 'column' ] ) && isset ( $ order [ 0 ] [ 'dir' ] ) && $ columns [ ( int ) $ order [ ...
Function to set config arguments to sorting datatable
10,432
public static function dataTableFiltering ( $ request , $ parameters ) { $ args [ 'where' ] = null ; if ( $ request -> input ( 'search' ) [ 'value' ] !== "" ) { $ parameters [ 'where' ] = $ request -> input ( 'search' ) [ 'value' ] ; } return $ parameters ; }
Function to set arguments to search on datatable
10,433
public static function getQueryWhere ( $ request , $ query , $ parameters ) { $ indexColumns = isset ( $ parameters [ 'indexColumns' ] ) ? $ parameters [ 'indexColumns' ] : null ; $ where = isset ( $ parameters [ 'where' ] ) ? $ parameters [ 'where' ] : null ; $ whereColumns = isset ( $ parameters [ 'whereColumns' ] ) ...
Function to set arguments to SQL query
10,434
public static function getQuarter ( $ quarter = 'current' ) { $ response [ 'startDate' ] = null ; $ response [ 'endDate' ] = null ; switch ( $ quarter ) { case 'current' : $ currentMonth = date ( 'm' ) ; $ currentYear = date ( 'Y' ) ; if ( $ currentMonth >= 1 && $ currentMonth <= 3 ) { $ response [ 'startDate' ] = strt...
get start and end date of select quarter
10,435
public static function compact ( array $ wraps ) { $ consolidated = [ ] ; if ( $ wraps === [ ] ) { return $ consolidated ; } $ first = true ; $ prev = null ; foreach ( $ wraps as $ wrap ) { if ( $ first ) { $ first = false ; $ prev = $ wrap ; continue ; } if ( $ prev instanceof WrappedString && $ wrap instanceof Wrappe...
Merge consecutive WrappedString objects with the same prefix and suffix .
10,436
protected function createSortedQuery ( AbstractQuery $ query , SearchEventsRequest $ request ) : Query { switch ( $ request -> get ( 'sort' ) -> getValue ( ) ) { case SearchEventsSort :: DATE_DESC : $ query = Query :: create ( $ query ) ; $ query -> setSort ( [ 'occurred_at' => 'desc' ] ) ; break ; case SearchEventsSor...
Applies sorting and scoring to the query and returns the final query object which will be sent to elastic search .
10,437
public function onBeforeAddLanguageCommit ( BeforeAddLanguageCommitEvent $ event ) { if ( $ event -> isAborted ( ) ) { return ; } $ this -> languageManager = $ event -> getContentManager ( ) ; $ languageRepository = $ this -> languageManager -> getLanguageRepository ( ) ; $ this -> mainLanguage = $ languageRepository -...
Listen the onBeforeAddLanguageCommit event to copy the source object to the new language
10,438
protected function getBaseLanguage ( ) { $ languageRepository = $ this -> languageManager -> getLanguageRepository ( ) ; if ( null !== $ this -> request ) { $ languages = $ this -> request -> getLanguages ( ) ; $ alLanguage = $ languageRepository -> fromLanguageName ( $ languages [ 1 ] ) ; if ( null !== $ alLanguage ) ...
Fetches the base language used to copy the entities
10,439
public static function OutOfQueriesException ( ) { if ( false === get_transient ( 'geot_OutOfQueriesException' ) ) { set_transient ( 'geot_OutOfQueriesException' , true , 2 * 3600 ) ; $ message = sprintf ( __ ( 'Your <a href="%s">GeotargetingWP account</a> have run out of queries. Please <a href="%s">add some</a> more ...
Send email every two hours when user run out of queries in maxmind
10,440
public function validate ( $ entity , $ constraints = null , $ groups = null ) { if ( ! is_object ( $ entity ) ) { throw new InvalidArgumentException ( 'validator has no valid entity' ) ; } $ result = array ( ) ; $ violations = $ this -> getHandler ( ) -> validate ( $ entity , $ constraints , $ groups ) ; foreach ( $ v...
validate a given entity
10,441
protected function buildFormOptions ( array $ payload = null ) { $ formOptions = null ; switch ( $ this -> configuration -> get ( 'collection_type' ) ) { case self :: COLLECTION_TYPE_ONE : case self :: COLLECTION_TYPE_MANY : $ formOptions = array ( ) ; if ( ! is_null ( $ payload ) && isset ( $ payload [ $ this -> getNa...
return form options
10,442
public function make ( ) { $ table = [ ] ; $ field_lengths = $ this -> maxMultidimensionalArrayStringSize ( $ this -> data ) ; $ row_length = $ this -> calculateRowLength ( $ field_lengths , $ this -> seperator_padding , $ this -> seperator ) ; $ book_end = $ this -> su -> fill ( $ row_length , $ this -> header_charact...
Make a table based on the values assigned to the class via methods .
10,443
protected function calculateRowLength ( array $ field_lengths , int $ seperator_padding , string $ seperator ) { $ sample_row = $ seperator . $ this -> su -> fill ( $ seperator_padding ) ; for ( $ i = 0 ; $ i < count ( $ field_lengths ) ; $ i ++ ) { $ sample_row .= $ this -> su -> fill ( $ field_lengths [ $ i ] ) . $ t...
Calculate the length of a row by taking it s field lengths seperator padding and seperator and mocking update a row to get the strlen of
10,444
protected function deleteBlocks ( ) { $ blocks = $ this -> blockRepository -> retrieveContentsBySlotName ( $ this -> slot -> getSlotName ( ) ) ; if ( count ( $ blocks ) <= 0 ) { return null ; } try { $ result = null ; $ this -> blockRepository -> startTransaction ( ) ; foreach ( $ blocks as $ block ) { $ result = $ thi...
Removes the blocks placed on the current slot from the database
10,445
protected function updateBlock ( array $ block , $ idLanguage , $ idPage ) { $ block [ "LanguageId" ] = $ idLanguage ; $ block [ "PageId" ] = $ idPage ; $ className = $ this -> blockRepository -> getRepositoryObjectClassName ( ) ; $ modelObject = new $ className ( ) ; $ result = $ this -> blockRepository -> setReposito...
Updates the block according the page and language with the new repeated status
10,446
private function blocksToArray ( array $ slotBlocks ) { foreach ( $ slotBlocks as $ block ) { $ aBlock = $ block -> toArray ( ) ; unset ( $ aBlock [ "Id" ] ) ; $ this -> arrayBlocks [ ] = $ aBlock ; } }
Converts to array the blocks placed on the current slot
10,447
public function registerProcessorIdForCommand ( $ commandClassName , $ serviceId ) { if ( $ this -> hasProcessor ( $ commandClassName ) ) { throw new MultipleProcessorsException ( $ commandClassName ) ; } $ this -> serviceIds [ $ commandClassName ] = $ serviceId ; }
Register processor service for command class .
10,448
public function getProcessor ( CommandInterface $ command ) { $ className = get_class ( $ command ) ; try { return parent :: getProcessor ( $ command ) ; } catch ( ProcessorNotFoundException $ ex ) { if ( ! array_key_exists ( $ className , $ this -> serviceIds ) ) { throw new InvalidArgumentException ( 'No processor re...
Get processor for class name if any is registered .
10,449
public function formatTime ( $ column , $ format = self :: DATETIME ) { if ( ! isset ( $ this -> data [ $ column ] ) ) { return $ this ; } if ( is_numeric ( $ this -> data [ $ column ] ) ) { $ this -> data [ $ column ] = ( int ) $ this -> data [ $ column ] ; } if ( is_string ( $ this -> data [ $ column ] ) ) { $ this -...
Useful method for formating a time column .
10,450
public function remove ( $ table = null , SqlInterface $ database = null , $ primary = null ) { if ( is_null ( $ table ) ) { if ( ! $ this -> table ) { throw SqlException :: forTableNotSet ( ) ; } $ table = $ this -> table ; } if ( is_null ( $ database ) ) { if ( ! $ this -> database ) { throw SqlException :: forDataba...
Removes model from database
10,451
final private function checkScalarValue ( string $ scalar ) : bool { if ( $ this -> strlikeInArray ( $ scalar , $ this -> scalar ) !== false ) { return ( true ) ; } else { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Unknow type $scalar in Mercure" , "solution" => "Type must be : " . json_encode ( $ ...
Check if the scalar type exist in Mercure
10,452
private function isJsonMercureFormat ( string $ string ) : int { $ len = strlen ( $ string ) ; if ( $ len > 3 && ( $ string [ 0 ] == "{" && $ string [ $ len - 1 ] == "}" ) ) { $ string = str_replace ( "{" , "" , $ string ) ; $ string = str_replace ( "}" , "" , $ string ) ; $ r = explode ( ',' , $ string ) ; return ( ! ...
Check if string is a JSON Mercure
10,453
private function trsJsonMercureToArray ( string $ string ) : array { $ len = strlen ( $ string ) ; if ( $ len > 3 && ( $ string [ 0 ] == "{" && $ string [ $ len - 1 ] == "}" ) ) { $ string = str_replace ( "{" , "" , $ string ) ; $ string = str_replace ( "}" , "" , $ string ) ; $ r = explode ( ',' , $ string ) ; return ...
Transform JSON Mercure to array
10,454
private function checkIfKeyExist ( array $ resource , string $ filename , string $ appname ) : int { if ( ! isset ( $ resource [ "activity" ] ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Missing Tag 'activity' in " . strtoupper ( $ filename ) . " routing file : " . $ appname , "solution" => "Pl...
Check if key exist
10,455
public function listingRouters ( bool $ isbase = false ) : int { if ( $ this -> appWording ( ) == 1 ) { $ this -> routers = scandir ( ( ( $ isbase == false ) ? FEnv :: get ( "framework.apps" ) : FEnv :: get ( "framework.baseapps" ) ) . $ this -> appName . "/Routing" ) ; return ( 1 ) ; } return ( 0 ) ; }
Return router list
10,456
protected function analyseMercure ( $ file , string $ filename , string $ appname ) : int { $ start = 0 ; $ end = 0 ; while ( $ listen = trim ( fgets ( $ file , 1024 ) ) ) { if ( $ listen == "route:" || $ listen == "route :" ) { $ start ++ ; } if ( $ listen == "endroute" ) { $ end ++ ; } } if ( $ start != $ end ) { if ...
Analyse Mercure file to detect some errors
10,457
private function detectParameters ( string $ path ) : array { $ params = array ( ) ; for ( $ i = 0 ; $ i < strlen ( $ path ) ; $ i ++ ) { if ( $ path [ $ i ] == "{" ) { $ param = "" ; for ( ( $ p = $ i + 1 ) ; $ p < strlen ( $ path ) ; $ p ++ ) { if ( $ path [ $ p ] == "}" ) { $ p = strlen ( $ path ) ; array_push ( $ p...
Detect any parameters in path
10,458
protected function prepareProducSuperAttributeAttributes ( ) { $ parentId = $ this -> getParentId ( ) ; $ attributeId = $ this -> eavAttribute [ MemberNames :: ATTRIBUTE_ID ] ; return $ this -> initializeEntity ( array ( MemberNames :: PRODUCT_ID => $ parentId , MemberNames :: ATTRIBUTE_ID => $ attributeId , MemberName...
Prepare the product super attribute attributes that has to be persisted .
10,459
protected function prepareProductSuperAttributeLabelAttributes ( ) { $ variationLabel = $ this -> getValue ( ColumnKeys :: VARIANT_VARIATION_LABEL ) ; if ( empty ( $ variationLabel ) ) { $ variationLabel = $ this -> eavAttribute [ MemberNames :: FRONTENT_LABEL ] ; } return $ this -> initializeEntity ( array ( MemberNam...
Prepare the product super attribute label attributes that has to be persisted .
10,460
private function getIntegrityHtml ( Asset $ asset ) : string { return $ this -> isDebug ? "" : sprintf ( ' integrity="sha256-%s"' , $ this -> registry -> get ( $ asset ) -> getHash ( ) ) ; }
Returns the integrity HTML snippet
10,461
public function getPropertyValue ( $ name , $ object = null ) { return $ this -> getProperty ( $ name ) -> getValue ( $ this -> getObject ( $ object ) ) ; }
Gets value from property .
10,462
public function getAnyPropertyValue ( $ name , $ object = null ) { $ property = $ this -> getProperty ( $ name ) ; $ property -> setAccessible ( true ) ; $ value = $ property -> getValue ( $ this -> getObject ( $ object ) ) ; return $ value ; }
Get property value in any case if the property is not accessible it will change the accessibility and restore it before return .
10,463
public function setAnyPropertyValue ( $ name , $ value , $ object = null ) { $ property = $ this -> getProperty ( $ name ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ this -> getObject ( $ object ) , $ value ) ; return $ this ; }
Set property value in any case if the property is not accessible it will change the accessibility and restore it before return .
10,464
public function invokeAnyMethod ( $ name , array $ args = array ( ) , $ object = null ) { $ method = $ this -> getMethod ( $ name ) ; $ method -> setAccessible ( true ) ; $ value = $ method -> invokeArgs ( $ this -> getObject ( $ object ) , $ args ) ; return $ value ; }
Invoke method in any case if the method is not accessible it will change the accessibility and restore it before return .
10,465
protected function validateByBaseValidator ( ValidationContract $ validation , array $ input , array $ baseRules , AppliesToResource $ resource = null , $ locale = null ) { if ( ! $ this -> baseValidator ) { throw new UnConfiguredException ( "Assign a callable to do the validation" ) ; } call_user_func ( $ this -> base...
Perform validation by the the base validator . Reimplement this method to use it with your favorite base validator .
10,466
public function numberToString ( $ var ) : string { static $ precision ; if ( ! $ precision ) { $ precision = pow ( 10 , ( int ) ini_get ( 'precision' ) ) ; } $ v = '' . $ var ; if ( ! is_numeric ( $ v ) ) { throw new \ InvalidArgumentException ( 'Arg var is not integer/float nor number-like when stringified.' ) ; } re...
Convert number to string avoiding E - notation for numbers outside system precision range .
10,467
public function toCamelCase ( $ var , $ upperFirst = false ) { $ v = '' . $ var ; $ le = strlen ( $ v ) ; if ( ! $ le ) { return '' ; } $ arr = preg_split ( '/[_\- ]/' , $ v ) ; for ( $ i = 0 ; $ i < $ le ; ++ $ i ) { if ( $ i || $ upperFirst ) { $ arr [ $ i ] = ucfirst ( $ arr [ $ i ] { 0 } ) . substr ( $ arr [ $ i ] ...
Unicode not supported .
10,468
static function getContentFilePath ( string $ contentPath ) { $ pathComponents = Request :: getPathSegments ( ) ; $ requestFilePath = $ contentPath ; foreach ( $ pathComponents as $ index => $ pathComponent ) { if ( trim ( $ pathComponent ) != "" && ( $ index != 0 || $ pathComponent !== INDEX_FILE ) ) { $ requestFilePa...
Get the absolute path to the file in the specified content directory for the current request .
10,469
static function getFirstCallingClazzNotBeing ( string $ notBeing ) { $ backtrace = debug_backtrace ( false ) ; foreach ( $ backtrace as $ caller ) { $ clazz = $ caller [ 'class' ] ; if ( $ clazz != __CLASS__ && $ clazz != $ notBeing ) { return $ clazz ; } } return null ; }
Return the first class at the top of the call stack not being the class given in the argument .
10,470
public static function getEnvironmentVariableName ( $ name ) { if ( empty ( $ name ) || ! is_string ( $ name ) ) { return null ; } $ envName = str_replace ( '.' , '_' , $ name ) ; $ envName = Xentriq :: ENVIRONMENT_VARIABLE_PREFIX . StringUtils :: toSnakeCase ( $ envName ) ; return strtoupper ( $ envName ) ; }
Get environment variable name which would apply in Xentriq s environment specific configuration .
10,471
public static function hasEnvironmentVariable ( $ name , bool $ ignoreCase = false ) : bool { if ( empty ( $ name ) || ! is_string ( $ name ) ) { return false ; } return ( getenv ( $ name ) || ArrayUtils :: doesArrayHaveValueForKey ( $ _ENV , $ name , $ ignoreCase ) ) ; }
Check if environment variable with specified name exists .
10,472
public static function getEnvironmentVariable ( $ name , $ default = null , bool $ ignoreCase = false ) { if ( empty ( $ name ) || ! is_string ( $ name ) ) { return null ; } if ( ( $ value = getenv ( $ name ) ) ) { return $ value ; } return ArrayUtils :: getArrayValueForKeyOrDefault ( $ _ENV , $ name , $ default , $ ig...
Retrieve value of environment variable .
10,473
public function check ( ? int $ iterationNumber = null ) : self { if ( $ this -> isStopped ( ) ) { throw new \ RuntimeException ( 'Timer[' . $ this -> name . '] is already stopped.' ) ; } if ( $ this -> isNotStarted ( ) ) { $ this -> start ( ) ; } else { $ this -> mark ( $ iterationNumber ) ; } return $ this ; }
Marks the time . If timer was not started starts the timer .
10,474
public function getProviderInfo ( ) : array { if ( $ this -> info === null ) { $ event = new RegisterProviderInfo ( ) ; $ this -> trigger ( $ event :: REGISTER_INFO , $ event ) ; $ this -> info = $ event -> info ; $ this -> formatInfoArray ( $ this -> info ) ; } return $ this -> info ; }
This should give is some additional information about the provider .
10,475
public function rawPost ( $ id ) { $ item = $ this -> dataService -> byId ( 'MicroPost' , $ id ) ; if ( $ item -> checkPerm ( 'Write' ) ) { return $ item ; } }
Gets the raw post if allowed
10,476
public function savePost ( DataObject $ post , $ data ) { if ( $ post -> checkPerm ( 'Write' ) && isset ( $ data [ 'Content' ] ) ) { $ post -> Content = $ data [ 'Content' ] ; if ( $ this -> securityContext -> getMember ( ) -> Balance >= MicroBlogMember :: BALANCE_THRESHOLD ) { $ post -> analyseContent ( ) ; $ post -> ...
Save the post
10,477
public function rewardMember ( $ member , $ votes ) { $ member -> VotesToGive += $ votes ; $ this -> transactionManager -> run ( function ( ) use ( $ member ) { $ member -> write ( ) ; } , $ member ) ; }
Reward a member with a number of votes to be given
10,478
public function globalFeed ( $ filter = array ( ) , $ orderBy = 'ID DESC' , $ since = null , $ number = 10 , $ markViewed = true ) { $ number = ( int ) $ number ; if ( ! count ( $ filter ) ) { $ filter = array ( 'ParentID' => 0 ) ; } $ filter [ 'Deleted' ] = 0 ; $ items = MicroPost :: get ( ) -> filter ( $ filter ) -> ...
Get all posts that the current user has access to
10,479
public function getStatusUpdates ( $ filter = array ( ) , $ sortBy = 'ID' , $ since = 0 , $ before = false , $ topLevelOnly = true , $ tags = array ( ) , $ offset = 0 , $ number = 10 ) { if ( $ filter instanceof Member ) { $ userIds [ ] = $ filter -> ProfileID ; $ filter = array ( 'ThreadOwnerID' => $ userIds , ) ; } i...
Gets all the status updates for a particular user before a given time
10,480
public function getTimeline ( DataObject $ member , $ sortBy = 'ID' , $ since = 0 , $ before = false , $ topLevelOnly = true , $ tags = array ( ) , $ offset = 0 , $ number = 10 ) { $ following = $ this -> friendsList ( $ member ) ; $ number = ( int ) $ number ; $ userIds = array ( ) ; if ( $ following ) { $ userIds = $...
Gets all the updates for a given user s list of followers for a given time period
10,481
public function getRepliesTo ( DataObject $ to , $ sortBy = 'ID' , $ since = 0 , $ before = false , $ topLevelOnly = false , $ tags = array ( ) , $ offset = 0 , $ number = 100 ) { $ filter = array ( 'ParentID' => $ to -> ID , ) ; return $ this -> microPostList ( $ filter , $ sortBy , $ since , $ before , $ topLevelOnly...
Get the list of replies to a particular post
10,482
public function microPostList ( $ filter , $ sortBy = 'ID' , $ since = 0 , $ before = false , $ topLevelOnly = true , $ tags = array ( ) , $ offset = 0 , $ number = 10 ) { if ( $ topLevelOnly ) { $ filter [ 'ParentID' ] = '0' ; } $ filter [ 'Deleted' ] = 0 ; if ( $ since ) { $ since = Convert :: raw2sql ( $ since ) ; $...
Create a list of posts depending on a filter and time range
10,483
public function findMember ( $ searchTerm ) { $ term = Convert :: raw2sql ( $ searchTerm ) ; $ current = ( int ) $ this -> securityContext -> getMember ( ) -> ID ; $ filter = '("Username" LIKE \'' . $ term . '%\' OR "FirstName" LIKE \'' . $ term . '%\' OR "Surname" LIKE \'' . $ term . '%\') AND "ID" <> ' . $ current ; ...
Search for a member or two
10,484
public function addFriendship ( DataObject $ member , DataObject $ followed ) { if ( ! $ member || ! $ followed ) { throw new PermissionDeniedException ( 'Read' , 'Cannot read those users' ) ; } if ( $ member -> ID != $ this -> securityContext -> getMember ( ) -> ID ) { throw new PermissionDeniedException ( 'Write' , '...
Create a friendship relationship object
10,485
public function removeFriendship ( DataObject $ relationship ) { if ( $ relationship && $ relationship -> canDelete ( ) ) { if ( $ relationship -> Status == 'Approved' ) { $ reciprocal = $ relationship -> reciprocal ( ) ; if ( $ reciprocal ) { $ reciprocal -> Status = 'Pending' ; $ reciprocal -> write ( ) ; } $ friends...
Remove a friendship object
10,486
public function friendsList ( DataObject $ member ) { if ( ! $ member ) { return ; } $ list = DataList :: create ( 'Friendship' ) -> filter ( array ( 'InitiatorID' => $ member -> ID ) ) ; return $ list ; }
Get a list of friends for a particular member
10,487
public function vote ( DataObject $ post , $ dir = 1 ) { $ member = $ this -> securityContext -> getMember ( ) ; if ( $ this -> requireVoteBalance && $ member -> VotesToGive <= 0 ) { $ post -> RemainingVotes = 0 ; return $ post ; } $ currentVote = null ; if ( $ this -> singleVotes ) { $ votes = $ post -> currentVotesBy...
Vote for a particular post
10,488
public function fileLookup ( $ fileId ) { $ member = $ this -> securityContext -> getMember ( ) ; if ( ! $ member ) { return ; } $ file = File :: get ( ) -> filter ( array ( 'ID' => $ fileId , 'OwnerID' => $ member -> ID ) ) -> first ( ) ; if ( $ file && $ file -> ID ) { return array ( 'Title' => $ file -> Title , 'Lin...
Lookup files that you have uploaded
10,489
public function findAssets ( ) : array { $ assets = [ ] ; foreach ( $ this -> namespaces as $ namespace => $ dir ) { if ( ! \ is_dir ( $ dir ) ) { continue ; } $ finder = new Finder ( ) ; $ finder -> files ( ) -> followLinks ( ) -> in ( $ dir ) ; foreach ( $ finder as $ foundFile ) { $ assets [ ] = new Asset ( $ namesp...
Finds all assets in the namespaces
10,490
public function write ( ) { foreach ( config ( 'squanto.locales' , [ ] ) as $ locale ) { $ this -> writeLocale ( $ locale , Line :: getValuesByLocale ( $ locale ) ) ; } return $ this ; }
Write all translations to cache
10,491
protected function writeLocale ( $ locale , array $ lines = [ ] ) { $ translations = ConvertToTree :: fromFlattened ( $ lines ) ; foreach ( $ translations as $ section => $ trans ) { $ this -> filesystem -> put ( $ locale . '/' . $ section . '.php' , "<?php\n\n return " . var_export ( $ trans , true ) . ";\n" ) ; } }
Create new cached translation files based on database entries
10,492
public function getStatisticsRouting ( ) : array { $ f = $ this -> getallRouting ( ) ; $ fc = 0 ; $ fdisabled = 0 ; $ fpublic = 0 ; foreach ( $ f as $ one ) { $ fc += $ one [ 'count_route' ] ; $ z = $ this -> getMercureContent ( str_replace ( ".merc" , "" , $ one [ 'name' ] ) , $ one [ 'app' ] ) ; foreach ( $ z as $ tw...
Get routing statistics
10,493
private function methodAllowedTransform ( string $ methods ) : array { if ( is_string ( $ methods ) || $ this -> isJsonMercureFormat ( $ methods ) ) { switch ( $ methods ) { case $ this -> isJsonMercureFormat ( $ methods ) == 1 : $ r = $ this -> trsJsonMercureToArray ( $ methods ) ; foreach ( $ r as $ one ) { if ( $ th...
Transform method allowed argument to array
10,494
private function checkMethodExist ( string $ method ) : int { if ( in_array ( $ method , $ this -> methodsReq ) ) { return ( 1 ) ; } else { new Server500 ( new \ ArrayObject ( array ( "explain" => "Unknown method $method for Allowed method request" , "solution" => "Allowed methods request must be " . json_encode ( $ th...
Check if request method exist
10,495
public function removeActivity ( string $ filename , string $ appname ) { Server :: delete ( FEnv :: get ( "framework.root" ) . "apps/$appname/Routing/$filename.merc" , "file" ) ; return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "msg" => "OK" ) ) ) ; }
Remove a routing file
10,496
public function getOneActivity ( string $ filename , string $ appname ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "msg" => "OK" , "results" => $ this -> getMercureContent ( $ filename , $ appname ) ) ) ) ; }
Get a routing file
10,497
private function detectParametersType ( string $ parameters , string $ keyword_ft ) : array { if ( $ keyword_ft != "parameters" ) { return ( array ( ) ) ; } $ parameters = str_replace ( "parameters:" , "" , $ parameters ) ; if ( ! ( isset ( $ parameters [ 0 ] ) && $ parameters [ 0 ] == "{" ) ) { throw new Server500 ( n...
Detect parameters type for a specific route
10,498
public function add ( Asset $ asset ) : void { $ this -> assets [ $ asset -> getAssetPath ( ) ] = $ asset ; $ this -> setAssets ( $ this -> assets ) ; }
Adds an asset to the cache
10,499
private function setAssets ( array $ newAssets ) : void { $ this -> assets = $ newAssets ; $ this -> cacheItem -> set ( $ this -> assets ) ; $ this -> cachePool -> save ( $ this -> cacheItem ) ; }
Sets and stores the new assets array