idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
11,900
public function postPermissionSource ( ) { if ( $ this -> owner -> MyPermSourceID ) { return $ this -> owner -> MyPermSource ( ) ; } $ source = new PermissionParent ( ) ; $ source -> Title = 'Posts for ' . $ this -> owner -> getTitle ( ) ; $ owner = $ this -> owner ; $ this -> transactionManager -> run ( function ( ) u...
Retrieve the container permission source for all this user s posts
11,901
public function updatePostPermissions ( ) { $ set = $ this -> owner -> PostPermission ; $ source = $ this -> postPermissionSource ( ) ; switch ( $ set ) { case 'Hidden' : { $ this -> permissionService -> removePermissions ( $ source , 'View' , $ this -> getGroupFor ( self :: FOLLOWERS ) ) ; $ this -> permissionService ...
set permissions for this user s posts
11,902
public function getGroupFor ( $ type ) { $ groupType = $ type . 'Group' ; $ groupTypeID = $ type . 'GroupID' ; if ( $ this -> owner -> $ groupTypeID ) { return $ this -> owner -> $ groupType ( ) ; } $ title = $ this -> owner -> Email . ' ' . $ type ; $ group = SimpleMemberList :: get ( ) -> filter ( array ( 'Title' => ...
gets the group that this user s friends belong to
11,903
protected function resolveFactory ( string $ factory_class ) : FactoryInterface { if ( $ this -> factoryClass == $ factory_class ) { if ( empty ( $ this -> factory ) ) { $ this -> factory = $ this -> factoryResolver -> getFactoryInstance ( $ this -> factoryClass ) ; } return $ this -> factory ; } return $ this -> facto...
Resolves the factory class string into a FactoryInterface object .
11,904
protected function validateForbidden ( $ input , $ key ) { $ flat = NestedArray :: flat ( $ input ) ; return ! array_key_exists ( $ key , $ flat ) ; }
A validation rule . It fails if the key was found in the input .
11,905
protected function detectRules ( AppliesToResource $ resource ) { if ( ! $ this -> ruleDetector ) { throw new UnConfiguredException ( "You have to assign a rule detector to detect rules" ) ; } return $ this -> ruleDetector -> detectRules ( $ resource , $ this -> relations ) ; }
Try to detect rules for the resource of this validator .
11,906
protected function filterDetectedRules ( array $ rules , AppliesToResource $ resource ) { if ( ! $ this -> typeProvider ) { return $ rules ; } $ filteredRules = [ ] ; foreach ( $ rules as $ key => $ rule ) { if ( ! $ type = $ this -> xType ( $ key ) ) { continue ; } if ( $ this -> shouldRemoveRules ( $ key , $ type ) )...
Apply some filtering on the detected rules . If they are provided by a TypeProvider they contain really all keys also readonly
11,907
protected function shouldRemoveRules ( $ key , XType $ type ) { if ( $ type instanceof SequenceType ) { return true ; } if ( $ type -> isComplex ( ) ) { return true ; } return false ; }
Return true if rules for a key should be removed from the detected rules
11,908
protected function buildRules ( ) { if ( $ this -> rules ) { return $ this -> rules ; } if ( $ resource = $ this -> resource ( ) ) { $ this -> rules = $ this -> filterDetectedRules ( $ this -> detectRules ( $ resource ) , $ resource ) ; } return $ this -> rules ; }
This method is called just to have a hook to build initial rules .
11,909
protected function toBaseAndOwnRules ( array $ parsedRules ) { $ ownRules = [ ] ; $ baseRules = [ ] ; $ own = $ this -> getSnakeCaseMethods ( ) ; foreach ( $ parsedRules as $ key => $ keyRules ) { foreach ( $ keyRules as $ ruleName => $ parameters ) { if ( isset ( $ own [ $ ruleName ] ) ) { ( array ) $ ownRules [ $ key...
Split the rules into rules of this class and other rules .
11,910
protected function isSnakeCaseCallableMethod ( $ method , $ prefix ) { if ( in_array ( $ method , [ 'validateByBaseValidator' , 'validateByOwnMethods' ] ) ) { return false ; } return $ this -> parentIsSnakeCaseCallableMethod ( $ method , $ prefix ) ; }
Overwritten to skip the two validateBy ... methods .
11,911
protected function validateByOwnMethods ( Validation $ validation , array $ input , array $ ownRules , AppliesToResource $ resource = null , $ locale = null ) { foreach ( $ ownRules as $ key => $ keyRules ) { $ vars = [ 'input' => $ input , 'key' => $ key , 'value' => Helper :: value ( $ input , $ key ) , 'resource' =>...
Perform all validation by the custom methods of this class
11,912
protected function validateByOwnMethod ( $ ruleName , array $ vars , array $ parameters ) { $ method = $ this -> getMethodBySnakeCaseName ( $ ruleName ) ; $ methodParams = Lambda :: mergeArguments ( [ $ this , $ method ] , $ vars , $ parameters ) ; return call_user_func_array ( [ $ this , $ method ] , $ methodParams ) ...
Perform the validation by an own validator method .
11,913
protected function collectRelations ( array $ flat ) { $ relations = [ ] ; foreach ( $ flat as $ key => $ value ) { if ( $ relation = $ this -> getRelationName ( $ key ) ) { $ relations [ ] = $ relation ; } } return array_values ( array_unique ( $ relations ) ) ; }
Collects all relation keys
11,914
protected function getRelationName ( $ key ) { if ( strpos ( $ key , '.' ) === false ) { return '' ; } $ path = explode ( '.' , $ key ) ; array_pop ( $ path ) ; return implode ( '.' , $ path ) ; }
Return the relation name of a key . Just pop the last segment
11,915
public function locate ( $ filename ) { $ basename = preg_replace ( '~\.[^.]+$~' , '' , basename ( $ filename ) ) ; if ( isset ( $ this -> map [ $ basename ] ) ) { return $ this -> root . '/' . $ this -> map [ $ basename ] ; } return null ; }
Locate a definition file
11,916
public function loadMODX ( ) { if ( static :: $ modx ) { return static :: $ modx ; } if ( isset ( static :: $ config [ 'MODX_CONFIG_PATH' ] ) && file_exists ( static :: $ config [ 'MODX_CONFIG_PATH' ] ) ) { require_once static :: $ config [ 'MODX_CONFIG_PATH' ] ; } elseif ( defined ( 'MODX_CONFIG_PATH' ) && file_exists...
Loads a new modX instance
11,917
public function pop ( ) { $ member = $ this -> getConnection ( ) -> getClient ( ) -> spop ( $ this -> name ) ; $ this -> _data = null ; $ this -> _count = null ; return $ member ; }
Removes and returns a random item from the set
11,918
public function move ( $ destination , $ item ) { if ( $ destination instanceof ARedisSet ) { $ destination -> _count = null ; $ destination -> _data = null ; $ destination = $ destination -> name ; } $ this -> _count = null ; $ this -> _data = null ; return $ this -> getConnection ( ) -> getClient ( ) -> smove ( $ thi...
Moves an item from this redis set to another
11,919
public function getData ( $ forceRefresh = false ) { if ( $ forceRefresh || $ this -> _data === null ) { $ this -> _data = $ this -> getConnection ( ) -> getSlave ( ) -> smembers ( $ this -> name ) ; } return $ this -> _data ; }
Gets all the members in the set
11,920
public function listDirectory ( $ path , $ recursive = false , $ withHidden = true ) { $ dirs = $ this -> formatDirsAndFiles ( $ this -> laravelFS -> directories ( $ path , $ recursive ) ) ; $ files = $ this -> formatDirsAndFiles ( $ this -> laravelFS -> files ( $ path , $ recursive ) ) ; $ dirsAndFiles = $ this -> mer...
Return all names in an directory . Files and dirs .
11,921
public static function getFileCommand ( ) : \ stdClass { return ( ( self :: $ fileCommand == null ) ? self :: $ fileCommand = json_decode ( file_get_contents ( __DIR__ . '/Configs/commands.json' ) ) : self :: $ fileCommand ) ; }
Get command file content
11,922
public function normalize ( ) { $ this -> input = str_replace ( str_split ( $ this -> badCharacters ) , '' , $ this -> input ) ; $ this -> inputLength = mb_strlen ( $ this -> input , $ this -> encoding ) ; return $ this ; }
Removes useless characters from the whole input string .
11,923
public function peek ( $ length = null , $ start = null ) { $ this -> lastPeekResult = null ; $ this -> nextConsumeLength = null ; if ( ! $ this -> hasLength ( ) ) { return ; } $ length = $ length !== null ? $ length : 1 ; $ start = $ start !== null ? $ start : 0 ; if ( ! is_int ( $ length ) || $ length < 1 ) { throw n...
Peeks one or multiple characters without moving the pointer forward .
11,924
public function match ( $ pattern , $ modifiers = null , $ ignoredSuffixes = null ) { $ modifiers = $ modifiers ? : '' ; $ ignoredSuffixes = $ ignoredSuffixes ? : "\n" ; $ matches = null ; $ this -> lastMatchResult = null ; $ this -> nextConsumeLength = null ; $ result = preg_match ( "/^$pattern/$modifiers" , $ this ->...
Matches current input string against a regular expression .
11,925
public function consume ( $ length = null ) { $ length = $ length ? : $ this -> nextConsumeLength ; if ( $ length === null ) { $ this -> throwException ( 'Failed to consume: No length given. Peek or match first.' ) ; } $ consumedPart = mb_substr ( $ this -> input , 0 , $ length , $ this -> encoding ) ; $ this -> input ...
Consumes part of the input string and advances internal counters .
11,926
public function readWhile ( $ callback , $ peekLength = null ) { if ( ! is_callable ( $ callback ) ) { throw new \ InvalidArgumentException ( 'Argument 1 passed to Reader->readWhile needs to be callback' ) ; } if ( ! $ this -> hasLength ( ) ) { return ; } if ( $ peekLength === null ) { $ peekLength = 1 ; } $ result = '...
Reads part of a string until it doesn t match the given callback anymore .
11,927
public function peekChars ( $ chars ) { return in_array ( $ this -> peek ( ) , is_array ( $ chars ) ? $ chars : str_split ( $ chars ) , true ) ; }
Peeks one byte and checks if it equals the given characters .
11,928
public function peekAlphaIdentifier ( array $ allowedChars = null ) { $ allowedChars = $ allowedChars ? : [ '_' ] ; return $ this -> peekAlpha ( ) || $ this -> peekChars ( $ allowedChars ) ; }
Peeks one byte and checks if it could be a valid alphabetical identifier .
11,929
public function readIdentifier ( $ prefix = null , $ allowedChars = null ) { if ( $ prefix ) { if ( $ this -> peek ( mb_strlen ( $ prefix ) ) !== $ prefix ) { return ; } $ this -> consume ( ) ; } elseif ( ! $ this -> peekAlphaIdentifier ( $ allowedChars ) ) { return ; } return $ this -> readWhile ( function ( ) use ( $...
Reads an upcoming alpha - numeric identifier in a string .
11,930
public function readString ( array $ escapeSequences = null , $ raw = false ) { if ( ! $ this -> peekQuote ( ) ) { return ; } $ quoteStyle = $ this -> consume ( ) ; $ char = null ; $ string = '' ; $ closed = false ; while ( $ this -> hasLength ( ) ) { $ char = $ this -> peek ( ) ; $ this -> consume ( ) ; if ( $ char ==...
Reads an enclosed string correctly .
11,931
public function readExpression ( array $ breaks = null , array $ brackets = null ) { if ( ! $ this -> hasLength ( ) ) { return ; } $ breaks = $ breaks ? : [ ] ; $ brackets = $ brackets ? : $ this -> expressionBrackets ; $ expression = '' ; $ char = null ; $ bracketStack = [ ] ; while ( $ this -> hasLength ( ) ) { $ exp...
Reads a code - expression that applies bracket counting correctly .
11,932
protected function getPregErrorText ( $ code = null ) { $ code = $ code ? : preg_last_error ( ) ; if ( ! isset ( self :: $ pregErrors [ $ code ] ) ) { $ code = PREG_NO_ERROR ; } return self :: $ pregErrors [ $ code ] ; }
Returns a describing text for the last PREG error that happened .
11,933
protected function throwException ( $ message ) { $ path = $ this -> getPath ( ) ; $ exception = new ReaderException ( new SourceLocation ( null , $ this -> line , $ this -> offset ) , sprintf ( "Failed to read: %s \nNear: %s%s\nLine: %s \nOffset: %s \nPosition: %s" , $ message , $ this -> peek ( 20 ) , $ path ? "\nFil...
Throws an exception that contains useful debugging information .
11,934
private function getPackageDevName ( string $ package ) { $ bundle = explode ( "/" , $ package ) [ 1 ] ; $ explode = explode ( "-" , $ bundle ) ; $ package_name = "" ; foreach ( $ explode as $ string ) { $ package_name .= ucfirst ( $ string ) ; } return $ package_name ; }
this method send path on dev mode to correct write package name
11,935
public function getBaseBundlePath ( string $ package = "piou-piou/ribs-admin-bundle" ) : string { $ path = explode ( "/" , __DIR__ ) ; array_pop ( $ path ) ; $ dev_mode = $ this -> container -> getParameter ( "ribs_admin" ) [ "dev_mode" ] ; if ( $ dev_mode === true ) { $ package = "lib/" . $ this -> getPackageDevName (...
this method send base bundle path related to ribs - admin
11,936
public function submit ( ) { $ uri = isset ( $ _GET [ "uri" ] ) ? $ _GET [ "uri" ] : "/" ; $ paths = explode ( "/" , $ uri ) ; if ( $ uri == "/" ) { $ res = array_key_exists ( "/" , $ this -> _controladores ) ; if ( $ res != "" && $ res == 1 ) { foreach ( $ this -> _controladores as $ ruta => $ controller ) { if ( $ ru...
funcion o metodo que se ejecuta cada vez que se envia la peticion en la url
11,937
protected function parseWikilink ( $ markdown ) { if ( preg_match ( '/^\[\[(.+?)\]\]/' , $ markdown , $ matches ) ) { return [ [ 'wikilink' , $ this -> parseInline ( $ matches [ 1 ] ) ] , strlen ( $ matches [ 0 ] ) ] ; } return [ [ 'text' , $ markdown [ 0 ] . $ markdown [ 1 ] ] , 2 ] ; }
Parses the wikilink feature .
11,938
public function errors ( array $ messages ) : string { if ( ! $ messages ) { return '' ; } $ messages = $ this -> c :: markdown ( $ messages , [ 'no_p' => true ] ) ; return $ markup = '<ul><li>' . implode ( '</li><li>' , $ messages ) . '</li></ul>' ; }
Errors markup .
11,939
private function getRouteArguments ( array $ options = [ ] ) { $ routeArguments = [ ] ; foreach ( $ options as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> options ) ) { $ this -> options [ $ key ] = $ value ; continue ; } $ routeArguments [ $ key ] = $ value ; } return $ routeArguments ; }
Get the route arguments from provided options
11,940
static public function checkDate ( string $ date , string $ format = 'Y-m-d' ) : bool { $ d = DateTime :: createFromFormat ( $ format , $ date ) ; return $ d && $ d -> format ( $ format ) == $ date ; }
Check date validity . Return true on success or false on failure .
11,941
public function xType ( $ root , $ path = null ) { $ class = is_object ( $ root ) ? get_class ( $ root ) : $ root ; $ isClass = is_string ( $ class ) && class_exists ( $ class ) ; if ( $ isClass && $ type = $ this -> getClassXType ( $ root , $ class , $ path ) ) { return $ type ; } if ( ! $ isClass ) { $ value = $ path...
Returns a xtype object for an object property . If path is null return the Xtype for the whole class
11,942
protected function getClassXType ( $ root , $ class , $ path ) { if ( $ type = $ this -> getFromCache ( $ class , $ path ) ) { return $ type ; } $ root = is_object ( $ root ) ? $ root : new $ root ; if ( isset ( $ this -> classCache [ $ class ] ) ) { return null ; } $ classType = $ root instanceof SelfExplanatory ? $ t...
Try to load a xtype of an object
11,943
protected function prepare ( ) { parent :: prepare ( ) ; if ( ! $ this -> hasBodyStream ( ) ) { if ( false === $ stream = tmpfile ( ) ) { throw new RuntimeException ( "Can't create temporary file." ) ; } fwrite ( $ stream , $ this -> getBody ( ) ) ; rewind ( $ stream ) ; $ this -> setBody ( $ stream ) ; } $ this -> add...
Prepare current request to being executed
11,944
public function toStream ( $ string ) { if ( ! $ this -> hash ) { fwrite ( $ this -> stream , $ string ) ; return $ this -> stream ; } return $ this -> mergeStream ( $ string , $ this -> stream ) ; }
Covert string + stream holder to stream
11,945
protected function autoAssignAttributes ( ) { if ( ! $ this -> filesystem -> exists ( $ this -> url ) ) { return ; } $ blob = $ this -> filesystem -> read ( $ this -> url ) ; $ this -> fillAttributes ( $ this -> serializer -> deserialize ( $ blob , $ this -> deserializeOptions ) ) ; }
Load the data from filesystem
11,946
public function create ( $ domain , $ type , $ protocol ) { $ this -> socket = socket_create ( $ domain , $ type , $ protocol ) ; if ( ! $ this -> socket ) { throw new \ Exception ( 'Could not create socket' ) ; } }
Creates new socket connection
11,947
public function sendMessage ( $ message , $ server , $ port , $ flags = 0 ) { $ send = socket_sendto ( $ this -> socket , $ message , strlen ( $ message ) , $ flags , $ server , $ port ) ; if ( $ send === false ) { throw new \ RuntimeException ( 'Message could not be sent' ) ; } return $ send ; }
Send a message using the socket to a server
11,948
private function addQuery ( $ query , array $ params ) { $ q = $ this -> queryBuilder -> interpolateQuery ( $ query , $ params ) ; self :: $ queries [ ] = $ q ; $ trace = $ q . "\n\n" ; foreach ( debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) as $ i => $ t ) { $ trace .= '#' . $ i . ' ' ; if ( isset ( $ t [ 'file' ] )...
Trace back where the query originated from
11,949
public function sqlInsertMultiple ( $ into , array $ properties , $ replace = false ) { if ( $ replace ) { $ sql = 'REPLACE' ; } else { $ sql = 'INSERT' ; } $ insert_values = [ ] ; $ attributes = array_shift ( $ properties ) ; $ count = count ( $ attributes ) ; $ sql .= ' INTO ' . $ into . ' (' . implode ( ', ' , $ att...
Requires positional parameters .
11,950
public function sqlUpdate ( $ table , array $ properties , $ where , array $ where_params = [ ] , $ limit = null ) { $ attributes = [ ] ; foreach ( $ properties as $ attribute => $ value ) { $ attributes [ ] = $ attribute . ' = :U' . $ attribute ; if ( array_key_exists ( ':U' . $ attribute , $ where_params ) ) { throw ...
Requires named parameters .
11,951
public static function url ( $ id , $ module_id = '' ) { $ absolute_urls = false ; if ( $ module_id == '' ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( ! is_null ( $ module ) ) { $ module_id = $ module -> id ; $ absolute_urls = $ module -> absolute_wikilinks ; } } if ( $ module_id != '' ) { retur...
Returns a url to a page
11,952
public static function title ( $ id ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( ! is_null ( $ module ) ) { $ controller = \ Yii :: $ app -> controller ; if ( ! is_null ( $ controller ) ) { if ( $ controller -> id == 'page' ) { $ repo = $ controller -> getFlywheelRepo ( ) ; $ page = $ repo -> qu...
Returns the title of a page
11,953
public static function checkTimezoneDefault ( string $ timezoneAllowed , bool $ errOnMisMatch = false ) : bool { $ time_default = new \ DateTime ( ) ; $ tz_default = $ time_default -> getTimezone ( ) -> getName ( ) ; if ( ( $ timezoneAllowed == 'UTC' || $ timezoneAllowed == 'Z' ) && ( $ tz_default == 'UTC' || $ tz_defa...
Check that default timezone is equivalent of arg timezoneAllowed .
11,954
public function diffConstant ( \ DateTimeInterface $ dateTime , bool $ allowUnEqualTimezones = false ) : TimeIntervalConstant { $ baseline = $ this ; $ deviant = $ dateTime ; $ tz_utc = null ; if ( $ this -> timezoneName != 'UTC' ) { $ tz_utc = new \ DateTimeZone ( 'UTC' ) ; $ baseline = new \ DateTime ( $ this -> form...
Get interval as constant immutable object a wrapped DateInterval with user - friendy methods for getting signed total .
11,955
public function setToFirstDayOfMonth ( int $ month = null ) : Time { if ( $ this -> frozen ) { throw new \ RuntimeException ( get_class ( $ this ) . ' is read-only, frozen.' ) ; } if ( $ month !== null ) { if ( $ month < 1 || $ month > 12 ) { throw new \ InvalidArgumentException ( 'Arg month[' . $ month . '] isn\'t nul...
Set to first day of a month .
11,956
public function modifyDate ( int $ years , int $ months = 0 , int $ days = 0 ) : Time { if ( $ this -> frozen ) { throw new \ RuntimeException ( get_class ( $ this ) . ' is read-only, frozen.' ) ; } if ( $ years ) { $ year = ( int ) $ this -> format ( 'Y' ) ; $ month = ( int ) $ this -> format ( 'm' ) ; $ day = ( int )...
Add to or subtract from one or more date parts .
11,957
public function modifyTime ( int $ hours , int $ minutes = 0 , int $ seconds = 0 , int $ microseconds = 0 ) : Time { if ( $ this -> frozen ) { throw new \ RuntimeException ( get_class ( $ this ) . ' is read-only, frozen.' ) ; } $ modifiers = [ ] ; if ( $ hours ) { $ modifiers [ ] = ( $ hours > 0 ? '+' : '-' ) . abs ( $...
Add to or subtract from one or more time parts .
11,958
public function monthLengthDays ( int $ month , int $ year = null ) : int { switch ( $ month ) { case 1 : case 3 : case 5 : case 7 : case 8 : case 10 : case 12 : return 31 ; case 4 : case 6 : case 9 : case 11 : return 30 ; case 2 : return ! date ( 'L' , $ year === null ? $ this -> getTimestamp ( ) : mktime ( 1 , 1 , 1 ...
Number of days in a month of year .
11,959
public function toISOZonal ( string $ precision = '' ) : string { switch ( $ precision ) { case '' : $ minor = '' ; break ; case 'milliseconds' : $ minor = '.' . $ this -> format ( 'v' ) ; break ; case 'microseconds' : $ minor = '.' . $ this -> format ( 'u' ) ; break ; default : throw new \ InvalidArgumentException ( '...
To ISO - 8601 with timezone marker optionally with milli - or microseconds precision .
11,960
public function toISOUTC ( string $ precision = '' ) : string { switch ( $ precision ) { case '' : $ minor = '' ; break ; case 'milliseconds' : $ minor = '.' . $ this -> format ( 'v' ) ; break ; case 'microseconds' : $ minor = '.' . $ this -> format ( 'u' ) ; break ; default : throw new \ InvalidArgumentException ( 'Ar...
To ISO - 8601 UTC optionally with milli - or microseconds precision .
11,961
public function setJsonSerializePrecision ( string $ precision ) : Time { if ( $ this -> frozen ) { throw new \ RuntimeException ( get_class ( $ this ) . ' is read-only, frozen.' ) ; } switch ( $ precision ) { case '' : case 'milliseconds' : case 'microseconds' : $ this -> jsonSerializePrecision = $ precision ; return ...
Set precision of JSON serialized representation .
11,962
public static function & getComponents ( ) : array { if ( empty ( self :: $ runtimeComponents ) ) { foreach ( self :: getAddons ( ) as $ addon ) { self :: $ runtimeComponents = array_merge ( self :: $ runtimeComponents , $ addon -> getComponents ( ) ) ; } } return self :: $ runtimeComponents ; }
Get all the components for all configured addons .
11,963
public static function getRequestFilters ( bool $ weigh = true ) : array { $ filters = array ( ) ; $ components = self :: getComponents ( ) ; foreach ( $ components as $ component ) { if ( ! $ component -> isRequestFilter ( ) ) { continue ; } $ filters [ ] = $ component -> getInstance ( ) ; } if ( $ weigh ) { usort ( $...
Get all classes configured by addons which implement the RequestFilter interface .
11,964
public static function getAddonByIdentifier ( string $ identifier ) { foreach ( self :: getAddons ( ) as $ addon ) { if ( $ addon -> getIdentifier ( ) == $ identifier ) { return $ addon ; } } return null ; }
Get one of the configured addons by its identifier .
11,965
public static function getAddonHavingComponentWithIdentifier ( string $ identifier ) { $ addons = self :: getAddons ( ) ; foreach ( $ addons as $ addon ) { foreach ( $ addon -> getComponents ( ) as $ component ) { if ( empty ( $ component -> getIdentifier ( ) ) ) { continue ; } if ( $ component -> getIdentifier ( ) == ...
Get one of the configured addons having a component with the given identifier .
11,966
public static function getComponentWithIdentifier ( string $ identifier ) { $ components = self :: getComponents ( ) ; foreach ( $ components as $ component ) { if ( empty ( $ component -> getIdentifier ( ) ) ) { continue ; } if ( $ component -> getIdentifier ( ) == $ identifier ) { return $ component ; } } return null...
Get a component with the given identifier from one of the configured addons .
11,967
public static function getComponentsUsingHook ( string $ hookId ) : array { $ componentsUsingHook = array ( ) ; $ components = self :: getComponents ( ) ; foreach ( $ components as $ component ) { if ( ! $ component -> hasHookWithId ( $ hookId ) ) { continue ; } $ componentsUsingHook [ ] = $ component ; } return $ comp...
Get all components that are configured to be called when invoking a hook .
11,968
public static function getAddonProvidingClazz ( string $ clazz ) { $ addons = self :: getAddons ( ) ; foreach ( $ addons as $ addon ) { if ( empty ( $ addon -> getComponents ( ) ) ) { continue ; } foreach ( $ addon -> getComponents ( ) as $ component ) { if ( empty ( $ component -> getClass ( ) ) ) { continue ; } if ( ...
Get addon configured to provide a certain class .
11,969
public static function getAddonProvidingClazzOrNamespace ( string $ clazzOrNamespace ) { $ addons = self :: getAddons ( ) ; foreach ( $ addons as $ addon ) { if ( empty ( $ addon -> getComponents ( ) ) ) { continue ; } foreach ( $ addon -> getComponents ( ) as $ component ) { if ( ! empty ( $ component -> getClass ( ) ...
Get addon configured to provide a certain class or namespace .
11,970
public static function doesComponentExist ( string $ addonComponentIdentifier ) : bool { $ component = self :: getComponentWithIdentifier ( $ addonComponentIdentifier ) ; return ( ! empty ( $ component ) ) ; }
Check if an addon exists having a component with the given identifier .
11,971
public static function getAddonTemplateFilePath ( string $ path , string $ addonNameOrId = null ) { if ( $ addonNameOrId != null ) { $ addon = self :: getAddonHavingComponentWithIdentifier ( $ addonNameOrId ) ; return $ addon -> getTemplateFilePath ( $ path ) ; } $ addons = self :: getAddons ( ) ; foreach ( $ addons as...
Find a template among all configured addons or in a specific addon .
11,972
public static function searchAddonClassFile ( string $ class ) { $ addon = self :: getAddonProvidingClazzOrNamespace ( $ class ) ; if ( ! empty ( $ addon ) ) { $ classFile = self :: searchAddonClassFileInAddon ( $ class , $ addon ) ; if ( $ classFile !== false ) { return $ classFile ; } } $ addons = self :: getAddons (...
Try to find the file for the given classname among all configured addons . Supports PSR - 0 and PSR - 4 with a somewhat custom implementation .
11,973
public static function searchAddonClassFileInAddon ( string $ class , Addon $ addon ) { $ classWithNamespaceToLoad = str_replace ( '\\' , '/' , $ class ) ; $ namespaceToLoad = dirname ( $ classWithNamespaceToLoad ) ; $ classToLoad = basename ( $ classWithNamespaceToLoad ) ; $ classFileName = $ classToLoad . EXT_PHP ; $...
Try to find the file for the given classname in the given addon . Supports PSR - 0 and PSR - 4 with a somewhat custom implementation .
11,974
public static function getComponentClassInstance ( string $ componentId ) { if ( ! isset ( self :: $ componentInstances [ $ componentId ] ) ) { $ component = self :: getComponentWithIdentifier ( $ componentId ) ; if ( is_null ( $ component ) ) { return null ; } self :: $ componentInstances [ $ componentId ] = $ compone...
Get instance of the component with the given identifier .
11,975
public static function invokeHook ( string $ hookId , array $ arguments = array ( ) ) : bool { $ componentsUsingHook = self :: getComponentsUsingHook ( $ hookId ) ; foreach ( $ componentsUsingHook as $ addonComponent ) { $ addon = self :: getComponentClassInstance ( $ addonComponent -> getIdentifier ( ) ) ; if ( $ addo...
Call a hook . Invoking all functions configured for that hook depending on their result .
11,976
public static function executeComponentFunction ( string $ nameOrId , string $ function , $ arguments = array ( ) ) { $ module = self :: getComponentClassInstance ( $ nameOrId ) ; if ( method_exists ( $ module , $ function ) ) { $ tag = new TemplateTag ( ( array ) $ arguments ) ; return $ module -> $ function ( $ tag )...
Execute a function inside a component .
11,977
protected function setImageinfoParams ( ) { $ this -> logger -> debug ( 'Base:setImageinfoParams' ) ; $ this -> setParam ( 'prop' , 'imageinfo' ) ; $ this -> setParam ( 'iiprop' , 'url|size|mime|thumbmime|user|userid|sha1|timestamp|extmetadata' ) ; $ this -> setParam ( 'iiextmetadatafilter' , 'LicenseShortName|UsageTer...
Set API parameters for an imageinfo query
11,978
protected function getImageinfoResponse ( ) { $ this -> logger -> debug ( 'Base:getImageinfoResponse' ) ; $ this -> setImageinfoParams ( ) ; $ this -> send ( ) ; return Tools :: flatten ( $ this -> getResponse ( [ 'query' , 'pages' ] ) ) ; }
Get API response from a files - info request
11,979
public function requestViaNoticeMarkup ( string $ app_slug ) : string { if ( ! ( $ App = $ this -> s :: getAppsBySlug ( ) [ $ app_slug ] ?? null ) ) { return '' ; } return $ App -> c :: getTemplate ( 's-core/admin/notices/license-key-request.php' ) -> parse ( ) ; }
Request via notice markup .
11,980
public static function defaultProvider ( ) { $ data = \ ILAB_Aws \ load_compiled_json ( __DIR__ . '/../data/endpoints.json' ) ; $ prefixData = \ ILAB_Aws \ load_compiled_json ( __DIR__ . '/../data/endpoints_prefix_history.json' ) ; $ mergedData = self :: mergePrefixData ( $ data , $ prefixData ) ; return new self ( $ m...
Creates and returns the default SDK partition provider .
11,981
public function display ( string $ code , string $ message ) { if ( defined ( "IUMIO_FCM" ) && IUMIO_FCM === true ) { return ( $ this -> displayConsole ( $ code , $ message ) ) ; } $ libf = \ iumioFramework \ Core \ Requirement \ Environment \ FEnv :: get ( "host.web.components.libs.framework" ) ; $ title = $ this -> c...
Display server error to user
11,982
public function displayConsole ( string $ code , string $ message ) { $ str_additionnal = "\n\n" ; if ( $ this -> type_error != null ) { $ str_additionnal .= " \nPHP Error type : " . $ this -> type_error ; } if ( $ this -> file_error != null ) { $ str_additionnal .= " \nFile : " . $ this -> file_error ; } if ( $ this -...
Display on console
11,983
public function displayOverride ( string $ code , string $ message ) { $ sm = SmartyEngineTemplate :: getSmartyInstance ( "iumio" ) ; $ sm -> assign ( array ( "code" => $ code , "message" => $ message , "er_object" => $ this ) ) ; $ sm -> display ( $ code . SmartyEngineTemplate :: $ viewExtention ) ; }
Display exception error override
11,984
final public static function checkFileLogExist ( string $ path ) : bool { if ( ! file_exists ( $ path ) ) { return ( ( file_put_contents ( $ path , "" ) != false ) ? true : false ) ; } if ( ! is_readable ( $ path ) ) { return ( false ) ; } if ( ! is_writable ( $ path ) ) { return ( false ) ; } return ( true ) ; }
Check if file log exist
11,985
final private function checkExceptionOverride ( int $ code ) : int { if ( file_exists ( FEnv :: get ( "framework.overrides" ) . "Exceptions/views/$code" . SmartyEngineTemplate :: $ viewExtention ) && FEnv :: get ( "framework.env" ) == "prod" ) { return ( 1 ) ; } return ( 0 ) ; }
Check if Exception template is override
11,986
public function generate ( $ env , $ example , array $ app = [ ] ) { $ result = false ; $ envValues = $ this -> getValuesFromFile ( $ env , false ) ; $ exampleValues = $ this -> getValuesFromFile ( $ example ) ; $ allValues = array_merge ( $ exampleValues , $ envValues , $ app ) ; $ content = '' ; foreach ( $ allValues...
Generate a . env file
11,987
public function getValuesFromFile ( $ file , $ failOnMissing = true ) { $ result = [ ] ; if ( ! FileSystem :: isFileReadable ( $ file ) ) { if ( $ failOnMissing ) { throw new RuntimeException ( "Path [$file] is not a readable file" ) ; } return $ result ; } $ file = file ( $ file ) ; if ( empty ( $ file ) ) { return $ ...
Get . env values from a given file
11,988
public function toDefinitionObject ( ) { $ definition = array ( 'type' => $ this -> type -> getName ( ) ) ; if ( $ this -> id != null ) { $ definition [ 'id' ] = $ this -> id ; } if ( $ this -> label != null ) { $ definition [ 'label' ] = $ this -> label ; } return ( object ) $ definition ; }
Get an object representation of this column definition
11,989
public function import ( Asset $ asset ) : Asset { $ fileContent = $ this -> fileLoader -> loadFile ( $ asset , FileLoader :: MODE_PROD ) ; $ fileType = $ this -> fileTypeRegistry -> getFileType ( $ asset ) ; $ asset -> setHash ( \ base64_encode ( \ hash ( "sha256" , $ fileContent , true ) ) , $ fileType -> shouldInclu...
Imports the given asset
11,990
public function run ( & $ params , $ pObj ) { if ( isset ( $ params [ 'options' ] ) && isset ( $ params [ 'options' ] [ 'fields' ] ) ) { $ fields = is_array ( $ params [ 'options' ] [ 'fields' ] ) ? $ params [ 'options' ] [ 'fields' ] : [ $ params [ 'options' ] [ 'fields' ] ] ; $ glue = isset ( $ params [ 'options' ] [...
Run the user function .
11,991
public function lstTimeZoneCountries ( string $ continent ) : array { $ allCountries = $ this -> lstTimeZone ( ) ; $ countries = [ ] ; foreach ( $ allCountries as $ country ) { if ( strpos ( $ country , $ continent ) !== false ) { $ countries [ ] = $ country ; } } return $ countries ; }
List all available country for a continent
11,992
public function humanReadable ( bool $ returnDateAndTime = true ) : string { $ current = new Dates ; $ diff = parent :: diff ( $ current ) ; $ parsedTxt = new class { public $ date = '' ; public $ time = '' ; } ; if ( $ current == $ this ) { $ this -> humanDateNow ( $ parsedTxt ) ; } elseif ( $ this -> humanDateIsYeste...
Transform a date to a human readable format
11,993
protected function humanDateIsYesterdayOrTomorrow ( \ DateInterval $ diff , \ DateTime $ current ) : bool { if ( ( $ diff -> d === 1 && $ diff -> m === 0 && $ diff -> y === 0 ) === false ) { return false ; } $ twoDays = clone $ current ; if ( $ diff -> invert === 0 ) { $ twoDays -> modify ( '-2 days' ) ; } else { $ two...
Check if the date to read for humanReadable is yesterday or tomorrow .
11,994
protected function humanDateToday ( $ parsedTxt , \ DateInterval $ diff ) { $ textKey = 'today_past' ; if ( $ diff -> invert === 1 ) { $ textKey = 'today_future' ; } $ time = '' ; if ( $ diff -> h === 0 && $ diff -> i === 0 ) { $ time .= $ diff -> s . 's' ; } elseif ( $ diff -> h === 0 ) { $ time .= $ diff -> i . 'min'...
Format date to human readable when date is today
11,995
protected function humanDateYesterday ( $ parsedTxt ) { $ currentClass = get_called_class ( ) ; $ parsedTxt -> date = $ currentClass :: $ humanReadableI18n [ 'yesterday' ] ; $ parsedTxt -> time = $ currentClass :: $ humanReadableI18n [ 'time_part' ] ; $ time = $ this -> format ( $ currentClass :: $ humanReadableFormats...
Format date to human readable when date is yesterday
11,996
protected function humanDateOther ( $ parsedTxt , \ DateTime $ current ) { $ currentClass = get_called_class ( ) ; $ dateFormat = $ currentClass :: $ humanReadableFormats [ 'dateDifferentYear' ] ; if ( $ current -> format ( 'Y' ) === $ this -> format ( 'Y' ) ) { $ dateFormat = $ currentClass :: $ humanReadableFormats [...
Format date to human readable when date is not now today or yesterday
11,997
public static function callMethod ( $ objectOrClass , string $ methodName , ... $ args ) { $ objectOrClass = self :: getObject ( $ objectOrClass ) ; $ closure = function ( string $ methodName , ... $ args ) { if ( \ method_exists ( $ this , $ methodName ) ) { return $ this -> $ methodName ( ... $ args ) ; } throw new \...
Calls a private or protected method of an object .
11,998
public static function errorMessage ( object $ object , string $ part , bool $ forMethod ) : string { return sprintf ( static :: EXCEPTION_TEMPLATE , \ get_class ( $ object ) , $ part , $ forMethod ? static :: METHOD : static :: PROPERTY ) ; }
Creates an error message .
11,999
public static function getValue ( $ objectOrClass , string $ propertyName ) { $ objectOrClass = self :: getObject ( $ objectOrClass ) ; $ closure = function ( ) use ( $ propertyName ) { if ( \ property_exists ( $ this , $ propertyName ) ) { $ class = new \ ReflectionClass ( typeOf ( $ this ) ) ; $ property = $ class ->...
Gets a value of a private or protected property of an object .