idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
11,100
public function range ( $ start = 0 , $ stop = - 1 ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } return $ this -> getConnection ( ) -> getSlave ( ) -> lrange ( $ this -> name , $ start , $ stop ) ; }
Gets a range of items in the list
11,101
public function trim ( $ start , $ stop ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } return $ this -> getConnection ( ) -> getSlave ( ) -> ltrim ( $ this -> name , $ start , $ stop ) ? true : false ; }
Trims the list so that it will only contain the specified range of items
11,102
public function getCount ( ) { if ( $ this -> _count === null ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ this -> _count = ( int ) $ this -> getConnection ( ) -> getSlave ( ) -> lSize ( $ this -> name ) ; } return $ this -> _count ; }
Gets the number of items in the list
11,103
public function getData ( $ forceRefresh = false ) { if ( $ forceRefresh || $ this -> _data === null ) { $ this -> _data = $ this -> range ( 0 , - 1 ) ; } return $ this -> _data ; }
Gets all the members in the list
11,104
public function copyFrom ( $ data ) { if ( is_array ( $ data ) || ( $ data instanceof \ Traversable ) ) { if ( $ this -> _count > 0 ) $ this -> clear ( ) ; if ( $ data instanceof CList ) $ data = $ data -> _data ; foreach ( $ data as $ item ) { $ this -> add ( $ item ) ; } } else if ( $ data !== null ) throw new Invali...
Copies iterable data into the list . Note existing data in the list will be cleared first .
11,105
public function basePath ( $ dir = '' ) { return $ dir == '' ? $ this -> basePath : $ this -> basePath . DIRECTORY_SEPARATOR . rtrim ( $ dir , '\/' ) ; }
Get the base path of the current Pails application .
11,106
public function getAccessToken ( ) { if ( $ accessToken = $ this -> cache -> get ( static :: SESSION_ACCESS_TOKEN_KEY ) ) { if ( ! $ accessToken -> hasExpired ( ) ) { return $ accessToken ; } } $ accessToken = $ this -> authClient -> getAccessToken ( 'client_credentials' ) ; $ ttl = $ accessToken -> getExpires ( ) - ti...
Get AccessToken from AS or session
11,107
public static function appendNamespaces ( string $ description ) { $ treeBuilder = new TreeBuilder ( "namespaces" ) ; $ node = \ method_exists ( $ treeBuilder , "getRootNode" ) ? $ treeBuilder -> getRootNode ( ) : $ treeBuilder -> root ( "namespaces" ) ; $ node -> scalarPrototype ( ) -> end ( ) -> validate ( ) -> ifTru...
Appends the entries config entry
11,108
public function __isset ( $ name ) { if ( $ this -> has ( $ name , true ) ) { return true ; } else { return parent :: __isset ( $ name ) ; } }
Checks if a property value is null . This method overrides the parent implementation by checking if the named component is loaded .
11,109
protected function registerProjectConfigEvents ( ) { if ( ! version_compare ( Craft :: $ app -> getVersion ( ) , '3.1' , '>=' ) ) { return ; } Craft :: $ app -> projectConfig -> onAdd ( 'patronProviders.{uid}' , [ ProjectConfigHandler :: class , 'handleChangedProvider' ] ) -> onUpdate ( 'patronProviders.{uid}' , [ Proj...
Register project config events if we re able to
11,110
public function initSystems ( array $ options ) : self { $ appSystemList = $ this -> obtainAppSystemList ( ) ; $ this -> declaredOptions = $ options ; $ this -> runTasks = new \ BFW \ RunTasks ( [ ] , 'BfwApp' ) ; foreach ( $ appSystemList as $ name => $ className ) { if ( $ name === 'ctrlRouterLink' ) { continue ; } $...
Initialize all components
11,111
protected function initAppSystem ( string $ name , string $ className ) { if ( ! class_exists ( $ className ) ) { throw new Exception ( 'The appSystem class ' . $ className . ' not exist.' , self :: ERR_APP_SYSTEM_CLASS_NOT_EXIST ) ; } $ appSystem = new $ className ; if ( $ appSystem instanceof SystemInterface === fals...
Instantiate the appSystem declared only if they implement the interface . If the system should be run we add him to the runTasks object .
11,112
public function addDefaultTagsToEntity ( IsTaggableInterface $ taggable ) { return $ taggable -> setTags ( array_merge ( $ this -> defaultTags , $ taggable -> getTags ( ) ) ) ; }
Adds the default tags to a taggable entity
11,113
public function getCurrentBranchName ( ) { try { $ branch = $ this -> extractFromCommand ( 'git branch -a' , function ( $ value ) { if ( isset ( $ value [ 0 ] ) && $ value [ 0 ] === '*' ) { return trim ( substr ( $ value , 1 ) ) ; } return false ; } ) ; if ( is_array ( $ branch ) ) { return $ branch [ 0 ] ; } } catch (...
Gets name of current branch git branch + magic
11,114
public function hasChanges ( ) { $ this -> begin ( ) ; $ lastLine = exec ( 'git status' ) ; $ this -> end ( ) ; return ( strpos ( $ lastLine , 'nothing to commit' ) ) === false ; }
Exists changes? git status + magic
11,115
public function pullWithInfo ( $ remote = null ) { $ result = $ this -> extractFromCommand ( "git pull $remote" , 'trim' ) ; $ result = implode ( PHP_EOL , $ result ) ; $ result = trim ( $ result ) ; return $ result ; }
Pull changes from a remote
11,116
public function push ( $ remote = null , array $ params = null ) { if ( ! is_array ( $ params ) ) { $ params = [ ] ; } return $ this -> begin ( ) -> run ( "git push $remote" , $ params ) -> end ( ) ; }
Push changes to a remote
11,117
public function addRemote ( $ name , $ url , array $ params = null ) { return $ this -> begin ( ) -> run ( 'git remote add' , $ params , $ name , $ url ) -> end ( ) ; }
Adds new remote repository
11,118
public function send ( array $ campaign ) { $ this -> assertValidCampaign ( $ campaign ) ; $ request = new Request ( 'campaigns' ) ; $ request -> addSubresource ( [ 'name' => 'send' ] ) ; $ request -> setParams ( $ campaign ) ; $ response = $ this -> client -> post ( $ request ) ; $ this -> assertSuccessResponse ( $ re...
Send campaign .
11,119
private function assertValidCampaign ( array $ campaign ) { if ( ! isset ( $ campaign [ 'subject' ] ) ) { throw new InvalidArgumentException ( 'subject field should be set' ) ; } if ( ! isset ( $ campaign [ 'from' ] ) ) { throw new InvalidArgumentException ( 'from field should be set' ) ; } if ( ! isset ( $ campaign [ ...
Check if campaign is correctly formated
11,120
public static function create ( string $ name , $ value , int $ expire = 1209600 ) { $ cookieText = 'Set-Cookie: ' . $ name . '=' . $ value ; $ expireTime = new \ DateTime ; $ expireTime -> modify ( '+ ' . $ expire . ' second' ) ; $ cookieText .= '; Expires=' . $ expireTime -> format ( 'D, d M Y H:i:s e' ) ; $ cookieTe...
Create a cookie
11,121
public static function __initialize ( ) : bool { $ env = ( new ModuleManager ( ) ) -> getCurrentEnv ( ) ; $ base = realpath ( __DIR__ . '/../../../../../../' ) . DIRECTORY_SEPARATOR ; self :: __setPaths ( $ base , $ env , '' , true ) ; FEnv :: set ( "framework.fcm.config.commands.file" , $ base . "vendor/iumio/framewor...
Initialize a envinronment framework paths
11,122
protected function parseUrl ( array $ attributes ) : void { if ( isset ( $ attributes [ 'url' ] ) ) $ this -> setUrl ( $ attributes [ 'url' ] ) ; if ( isset ( $ attributes [ 'route' ] ) ) $ this -> route ( ... Arr :: wrap ( $ attributes [ 'route' ] ) ) ; if ( isset ( $ attributes [ 'action' ] ) ) $ this -> action ( ......
Parse the url attribute .
11,123
public static function createFromToken ( TagToken $ token ) : Tag { $ tagName = $ token -> getTagName ( ) ; $ attribute = $ token -> getAttribute ( ) ; return new Tag ( $ tagName , $ attribute ) ; }
Creates tag from a tag token .
11,124
public function setTitle ( $ prefix ) { $ this -> addHook ( function ( $ document ) use ( $ prefix ) { $ title = $ document -> getTitle ( ) ; if ( $ title ) { $ title = $ prefix . ' - ' . $ title ; } else { $ title = $ prefix ; } $ document -> addHeaderNode ( new RawNode ( '<title>' . htmlspecialchars ( $ title ) . '</...
Sets the document title prefix
11,125
public function enableInteractive ( $ password , $ directory = 'data' ) { $ this -> copy ( __DIR__ . '/static/interactive.php' ) ; $ this -> addHook ( function ( $ document ) { $ jss = array ( 'slidey.interactive.js' , 'slidey.poll.js' ) ; foreach ( $ jss as $ js ) { $ document -> addJs ( '/slidey/js/' . $ js ) ; } } )...
Enable the interactive mode
11,126
public function addCss ( $ css ) { $ this -> addHook ( function ( $ document ) use ( $ css ) { $ document -> addCss ( '/' . $ css ) ; } ) ; return $ this ; }
Adds a stylesheet to the final document
11,127
public function getImportsWithDependencies ( array $ imports ) { $ toLoad = [ ] ; foreach ( $ imports as $ import ) { $ dependencies = $ this -> map [ $ import ] ?? null ; if ( null !== $ dependencies ) { foreach ( $ dependencies as $ dependency ) { $ toLoad [ $ dependency ] = true ; } } else { $ toLoad [ $ import ] = ...
Returns the imports with all dependencies
11,128
public function get ( $ key ) { if ( isset ( $ this -> conf [ $ key ] ) ) { return ( string ) $ this -> conf [ $ key ] ; } return null ; }
Get a config variable .
11,129
public function compress ( LocalFileNodeInterface $ node , array $ options = [ ] ) { $ pathInfo = pathinfo ( $ node -> getPath ( ) ) ; if ( ! $ node -> exists ( ) ) { throw new InvalidArgumentException ( "The file: $node does not exist" ) ; } $ outputFile = $ node -> getClone ( ) -> setPath ( $ pathInfo [ 'dirname' ] ....
Compress a file and return the new file
11,130
public function addToRunSteps ( string $ name , $ runStepsToAdd ) : self { $ this -> runSteps [ $ name ] = $ runStepsToAdd ; return $ this ; }
Add a new run step to the list
11,131
public function run ( ) { $ prefix = $ this -> notifyPrefix ; $ this -> addNotification ( $ prefix . '_start_run_tasks' ) ; foreach ( $ this -> runSteps as $ actionName => $ stepInfos ) { $ context = null ; if ( $ stepInfos -> context !== null ) { $ context = $ stepInfos -> context ; } if ( $ stepInfos -> callback === ...
Run all steps declared and notify for each step Call the callback if declared for each step
11,132
public function sendNotify ( string $ action , $ context = null ) { \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'RunTask notify' , [ 'prefix' => $ this -> notifyPrefix , 'action' => $ action ] ) ; $ this -> addNotification ( $ action , $ context ) ; }
Send a notification to all observers connected to the subject
11,133
public static function generateStepItem ( $ context = null , $ callback = null ) { return new class ( $ context , $ callback ) { public $ context ; public $ callback ; public function __construct ( $ context , $ callback ) { $ this -> context = $ context ; $ this -> callback = $ callback ; } } ; }
Generate the anonymous class with the structure to use for each item
11,134
protected function overwriteRecipientsIfNeeded ( MessageContract $ message ) { if ( ! $ overwrittenTo = $ this -> overwrittenTo ( ) ) { return ; } $ message -> clearRecipientHeaders ( ) ; foreach ( $ overwrittenTo as $ to ) { $ message -> to ( $ to ) ; } }
Clears all recipients of the mail and replaces them with overwrittenTo if it was set .
11,135
protected function parseRecipients ( $ toArgs ) { if ( count ( $ toArgs ) > 1 ) { return $ toArgs ; } if ( is_array ( $ toArgs [ 0 ] ) ) { return $ toArgs [ 0 ] ; } if ( is_string ( $ toArgs [ 0 ] ) ) { return ( array ) $ toArgs [ 0 ] ; } if ( $ toArgs [ 0 ] instanceof Traversable ) { return $ toArgs [ 0 ] ; } if ( is_...
Parses the recipients to something traversable .
11,136
protected function mergeTransportResult ( ResultContract $ transportResult , ResultContract $ mailerResult ) { if ( ! $ mailerResult instanceof SendResult ) { throw new InvalidArgumentException ( 'mergeTransportResult can only merge Ems\Mail\SendResult' ) ; } $ mailerResult -> increment ( count ( $ transportResult ) ) ...
Merges the result of a transport send operation into a global one .
11,137
public function getAllEnvActivity ( ) { $ directory = array ( ) ; $ iterator = new DirectoryIterator ( FEnv :: get ( "framework.cache" ) ) ; foreach ( $ iterator as $ dir_info ) { if ( $ dir_info -> isDir ( ) && ! $ dir_info -> isDot ( ) ) { $ octal_perms = substr ( sprintf ( '%o' , $ dir_info -> getPerms ( ) ) , - 4 )...
Get all cache directory
11,138
public function checkFolderIsEmptyOrNot ( string $ folderName ) : bool { $ files = array ( ) ; if ( $ handle = opendir ( $ folderName ) ) { while ( false !== ( $ file = readdir ( $ handle ) ) ) { if ( $ file != "." && $ file != ".." ) { $ files [ ] = $ file ; } } closedir ( $ handle ) ; } return ( ( count ( $ files ) =...
Check if directory is empty or not
11,139
public function folderSize ( string $ dir ) : int { $ size = 0 ; foreach ( glob ( rtrim ( $ dir , '/' ) . '/*' , GLOB_NOSORT ) as $ each ) { $ size += is_file ( $ each ) ? filesize ( $ each ) : $ this -> folderSize ( $ each ) ; } return ( $ size ) ; }
Get size folder
11,140
public function contract ( FileNodeCollectionInterface $ files , FileNodeInterface $ target , array $ options = [ ] ) { $ this -> options = $ options ; if ( ! $ this -> canContract ( $ files , $ target ) ) { throw new \ InvalidArgumentException ( "The supplied files are not valid" ) ; } $ this -> log ( LogLevel :: INFO...
Do the expansion and return a collection
11,141
public function findOrCreate ( array $ tags ) { $ foundTags = $ this -> findWhereIn ( [ 'tag' , $ tags ] ) ; $ returnTags = [ ] ; if ( $ foundTags ) { foreach ( $ foundTags as $ tag ) { $ pos = array_search ( $ tag -> tag , $ tags ) ; if ( $ pos !== false ) { $ returnTags [ ] = $ tag ; unset ( $ tags [ $ pos ] ) ; } } ...
Find existing tags or create if they don t exist .
11,142
public function bySlug ( $ slug , $ attributes = [ '*' ] ) { $ model = $ this -> findBy ( 'slug' , $ slug , $ attributes ) ; if ( is_null ( $ model ) ) { abort ( 404 ) ; } return $ model ; }
Get single model by Slug where status = 1 .
11,143
public function fire ( $ nativeJob , array $ data ) { if ( ! isset ( $ data [ 'operation' ] ) ) { throw new UnderflowException ( "Operation not set in data." ) ; } $ arguments = isset ( $ data [ 'arguments' ] ) ? $ this -> decodeArguments ( $ data [ 'arguments' ] ) : [ ] ; $ lambda = new Lambda ( $ data [ 'operation' ]...
Perform the serialized operation .
11,144
public function getValue ( $ forceRefresh = false ) { if ( $ this -> _value === null || $ forceRefresh ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ this -> _value = ( int ) $ this -> getConnection ( ) -> getSlave ( ) -> get ( $ this -> name )...
Gets the value of the counter
11,145
public function increment ( $ byAmount = 1 ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } return $ this -> _value = ( int ) $ this -> getConnection ( ) -> getClient ( ) -> incrBy ( $ this -> name , $ byAmount ) ; }
Increments the counter by the given amount
11,146
public function decrement ( $ byAmount = 1 ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } return $ this -> _value = ( int ) $ this -> getConnection ( ) -> getClient ( ) -> decrBy ( $ this -> name , $ byAmount ) ; }
Decrements the counter by the given amount
11,147
public function copyFrom ( $ data ) { if ( is_array ( $ data ) || ( $ data instanceof \ Traversable ) ) { $ this -> clear ( ) ; foreach ( $ data as $ item ) { $ this -> _d [ ] = $ item ; ++ $ this -> _c ; } } elseif ( $ data !== null ) throw new Exception ( \ Yii :: t ( 'yii' , 'Queue data must be an array or an object...
Copies iterable data into the queue . Note existing data in the list will be cleared first .
11,148
public function persistPoll ( ) { $ data = '<?php return ' . var_export ( $ this -> poll , true ) . ';' ; file_put_contents ( $ this -> directory . '/poll.php' , $ data ) ; }
Persist poll data
11,149
public function startPoll ( $ id , $ size ) { if ( $ size > 12 ) $ size = 12 ; $ this -> state -> poll = array ( 'id' => $ id , 'size' => $ size , 'opened' => 1 , 'answers' => array ( ) ) ; $ voteDir = $ this -> state -> directory . '/votes' ; if ( is_dir ( $ voteDir ) ) { foreach ( scanDir ( $ voteDir ) as $ file ) { ...
Starts a poll
11,150
public function votePoll ( $ vote ) { $ id = session_id ( ) ; $ voteDir = $ this -> state -> directory . '/votes' ; $ poll = & $ this -> state -> poll ; $ vote = ( int ) $ vote ; if ( $ poll [ 'opened' ] && $ vote >= 0 && $ vote < $ poll [ 'size' ] ) { file_put_contents ( $ voteDir . '/' . $ id , $ vote ) ; } }
Vote for the poll
11,151
public function infoPoll ( ) { $ poll = $ this -> state -> poll ; $ voteDir = $ this -> state -> directory . '/votes' ; $ poll [ 'count' ] = count ( scanDir ( $ voteDir ) ) - 2 ; if ( $ poll [ 'opened' ] ) { unset ( $ poll [ 'answers' ] ) ; } else { $ answers = array ( ) ; for ( $ i = 0 ; $ i < $ poll [ 'size' ] ; $ i ...
Info for the poll
11,152
public function run ( ) { $ response = null ; $ action = isset ( $ _SERVER [ 'PATH_INFO' ] ) ? $ _SERVER [ 'PATH_INFO' ] : '' ; switch ( $ action ) { case '/login' : $ password = isset ( $ _GET [ 'password' ] ) ? $ _GET [ 'password' ] : null ; if ( $ password && sha1 ( $ password ) == $ this -> config [ 'password' ] ) ...
Process the interactive request
11,153
public static function createIcon ( string $ icon , array $ arguments = null ) { $ element = Html :: el ( "i" ) ; if ( $ icon == "b" or $ icon == "l" or $ icon == "s" or $ icon == "r" ) { $ class = [ "fa" . $ icon ] ; } else { $ class = [ "fa fa-" . $ icon ] ; } if ( isset ( $ arguments ) ) { foreach ( $ arguments as $...
Renders Font Awesome icon .
11,154
public function add ( $ key , $ value ) { if ( ! $ this -> _r ) { if ( $ key === null ) $ this -> _d [ ] = $ value ; else $ this -> _d [ $ key ] = $ value ; } else throw new Exception ( Yii :: t ( 'yii' , 'The map is read only.' ) ) ; }
Adds an item into the map . Note if the specified key already exists the old value will be overwritten .
11,155
public function remove ( $ key ) { if ( ! $ this -> _r ) { if ( isset ( $ this -> _d [ $ key ] ) ) { $ value = $ this -> _d [ $ key ] ; unset ( $ this -> _d [ $ key ] ) ; return $ value ; } else { unset ( $ this -> _d [ $ key ] ) ; return null ; } } else throw new Exception ( Yii :: t ( 'yii' , 'The map is read only.' ...
Removes an item from the map by its key .
11,156
public static function fromProperties ( array $ properties ) { $ copy = new self ( ) ; foreach ( self :: getPropertyNames ( ) as $ name ) { if ( isset ( $ properties [ $ name ] ) ) { $ copy -> { 'set' . ucfirst ( $ name ) } ( $ properties [ $ name ] ) ; } } return $ copy ; }
Create message from array of properties
11,157
public function hasChanged ( $ entity ) { $ hashId = $ this -> getHashId ( $ entity ) ; if ( ! isset ( $ this -> originalData [ $ hashId ] ) ) { throw new OrmException ( "Entity is not registered" ) ; } if ( isset ( $ this -> comparators [ get_class ( $ entity ) ] ) ) { return $ this -> hasChangedUsingComparisonFunctio...
Gets whether or not an entity has changed since it was registered
11,158
public function startTracking ( $ entity ) { $ hashId = $ this -> getHashId ( $ entity ) ; $ this -> originalData [ $ hashId ] = clone $ entity ; }
Starts tracking an entity
11,159
protected function hasChangedUsingReflection ( $ entity ) { $ hashId = $ this -> getHashId ( $ entity ) ; $ currentEntityReflection = new ReflectionClass ( $ entity ) ; $ currentProperties = $ currentEntityReflection -> getProperties ( ) ; $ currentPropertiesAsHash = [ ] ; $ originalData = $ this -> originalData [ $ ha...
Checks to see if an entity has changed using reflection
11,160
public function getOriginal ( $ entity ) { $ hashId = $ this -> getHashId ( $ entity ) ; $ originalData = $ this -> originalData [ $ hashId ] ; return $ originalData ; }
Gets the original version of an entity for change detection
11,161
public function onConstruct ( ) { $ this -> userLinkedSourcesModel = new UserLinkedSources ( ) ; $ this -> userModel = new Users ( ) ; if ( ! isset ( $ this -> config -> jwt ) ) { throw new Exception ( 'You need to configure your app JWT' ) ; } }
Setup for this controller
11,162
protected function getSearchAndReplace ( array $ matches , array $ data ) { $ count = count ( $ matches ) ; $ alreadySetted = [ ] ; $ search = [ ] ; $ replace = [ ] ; for ( $ i = 0 , $ m = 0 ; $ i < $ count ; ++ $ i ) { if ( isset ( $ alreadySetted [ $ matches [ $ i ] ] ) ) { continue ; } $ value = $ this -> extractVal...
Get two arrays suitable for str_replace to replace all variables .
11,163
protected function cleanKey ( $ key ) { return mb_substr ( $ key , mb_strlen ( $ this -> preDelimiter ) , mb_strlen ( $ key ) - mb_strlen ( $ this -> postDelimiter ) - 1 ) ; }
Cleans the delimiters out of key .
11,164
public function sync ( $ jobs ) { $ updates = 0 ; foreach ( $ jobs as $ job ) { $ args = $ job -> arguments ( ) ; if ( ! isset ( $ args [ 0 ] ) || ! is_scalar ( $ args [ 0 ] ) || ! isset ( $ this -> tasks [ $ args [ 0 ] ] ) ) { continue ; } $ task = $ this -> tasks [ $ args [ 0 ] ] ; $ task -> state = $ job -> state ( ...
Sync the task states with the passed jobs .
11,165
protected function callUntilNotNull ( $ args = [ ] ) { foreach ( $ this -> extensions ( ) as $ name ) { $ result = $ this -> callExtension ( $ name , $ args ) ; if ( $ result !== null ) { return $ result ; } } return null ; }
Call all extensions until one returns not null and return the result
11,166
protected function collectExtensions ( $ name ) { $ extensions = [ ] ; foreach ( $ this -> extensions ( ) as $ pattern ) { if ( $ this -> patternMatches ( $ pattern , $ name ) ) { $ extensions [ ] = $ this -> getExtension ( $ pattern ) ; } } return $ extensions ; }
This method is for collecting extensions WHICH NAMES are patterns .
11,167
public function tail ( LocalFile $ file , $ lines , array $ options = [ ] ) { $ this -> options = $ options ; $ this -> lines = $ lines ; $ postfix = $ this -> getOption ( 'postfix' , 'tail' ) ; $ output = $ this -> getTargetFile ( $ file , $ postfix ) ; $ this -> log ( LogLevel :: INFO , "Retrieving the last {lines} f...
Tail a file
11,168
public function getClient ( ) { if ( $ this -> _client === null ) { $ this -> _client = new \ Redis ; $ this -> _client -> connect ( $ this -> hostname , $ this -> port , $ this -> database ) ; $ slaveenable = false ; if ( $ this -> enableSlaves ) { while ( count ( $ this -> slaves ) > 0 ) { $ this -> _slave = new \ Re...
Gets the redis client
11,169
protected function createLink ( Release $ release ) { $ line = '' ; $ link = $ release -> getLink ( ) ; if ( $ link !== null ) { $ linkName = $ release -> getLinkName ( ) ; $ name = $ release -> getName ( ) ; $ reference = ( $ linkName === null ) ? $ name : $ linkName ; $ line = "[$reference] $link\n" ; } return $ line...
Creates the needed link text for a Release .
11,170
public function renderRelease ( Release $ release ) { $ name = $ release -> getName ( ) ; if ( $ release -> getLink ( ) !== null ) { $ name = "[$name]" ; } if ( $ release -> getLinkName ( ) !== null ) { $ name .= "[{$release->getLinkName()}]" ; } $ content = "\n## $name" ; $ content .= $ this -> addDate ( $ release ) ;...
Converts a Release into its text representation .
11,171
public function renderType ( $ type , $ changes ) { $ content = '' ; if ( count ( $ changes ) > 0 ) { $ content = "### $type\n" . '- ' . implode ( "\n- " , $ changes ) . "\n" ; } return $ content . "\n" ; }
Converts a list of changes with a given type back into text .
11,172
protected function addDate ( Release $ release ) { $ content = '' ; $ date = $ release -> getDate ( ) ; if ( $ date !== null ) { $ content = ' - ' . $ date -> format ( 'Y-m-d' ) ; } return $ content ; }
Adds the date to a Release title for rendering if the Release has a date .
11,173
protected function arrayValue ( $ key , $ arrayKey , $ value = null ) { $ array = $ this [ $ key ] ; $ is = is_array ( $ array ) ; if ( null !== $ value ) { if ( ! $ is ) { $ array = array_key_exists ( $ key , self :: DEFAULTS ) ? self :: DEFAULTS [ $ key ] : $ this :: DEFAULTS [ $ key ] ; } $ array [ $ arrayKey ] = $ ...
Allow to set an array value in the collection
11,174
protected function getMessage ( $ key , $ ruleName , array $ keyRules , array $ keyTitles , array $ customMessages = [ ] ) { if ( in_array ( $ ruleName , $ this -> sizeRules ) ) { return $ this -> getSizeMessage ( $ key , $ ruleName , $ keyRules , $ keyTitles , $ customMessages ) ; } if ( $ customMessage = $ this -> ge...
Parse a message
11,175
protected function getSizeMessage ( $ key , $ ruleName , array $ keyRules , array $ keyTitles , array $ customMessages ) { $ type = $ this -> getRuleType ( $ keyRules ) ; return $ this -> getMessage ( $ key , "$ruleName.$type" , $ keyRules , $ keyTitles , $ customMessages ) ; }
Parse a size message . Special handling because of different messages for strings numbers ...
11,176
protected function getRuleType ( array $ keyRules ) { if ( $ this -> hasRule ( $ keyRules , $ this -> numericRules ) ) { return 'numeric' ; } if ( $ this -> hasRule ( $ keyRules , 'array' ) ) { return 'array' ; } if ( $ this -> hasRule ( $ keyRules , 'file' ) ) { return 'file' ; } return 'string' ; }
Classify the rule type
11,177
protected function replacements ( $ ruleName , array $ keyRules ) { $ ruleKey = str_contains ( $ ruleName , '.' ) ? explode ( '.' , $ ruleName ) [ 0 ] : $ ruleName ; if ( ! isset ( $ keyRules [ $ ruleKey ] [ 0 ] ) ) { return [ ] ; } if ( ! isset ( $ this -> placeholders [ $ ruleKey ] ) ) { return [ $ ruleKey => $ keyRu...
Build the parameter replacements to parse the messages .
11,178
public function setLocaleList ( array $ localeList ) { $ this -> localeList = [ ] ; foreach ( $ localeList as $ locale ) { $ this -> localeList [ ] = LocaleValidate :: assertValidLocale ( $ locale ) ; } return $ this ; }
set locale list .
11,179
public function recursiveScandir ( string $ dir ) { $ contents = array ( ) ; foreach ( scandir ( $ dir ) as $ file ) { if ( $ file == '.' || $ file == '..' ) { continue ; } $ path = $ dir . DIRECTORY_SEPARATOR . $ file ; if ( is_dir ( $ path ) ) { $ contents = array_merge ( $ contents , $ this -> recursiveScandir ( $ p...
Scan directory and subdirectory
11,180
protected function assignBaseAppPaths ( PathFinder $ paths ) { $ emsResources = ( string ) $ this -> emsResourcesPath ( ) ; $ paths -> map ( 'app' , $ this -> appPath ( ) , $ this -> url ( ) ) ; $ paths -> map ( 'assets' , $ this -> publicPath ( ) , $ this -> url ( ) ) ; $ paths -> map ( 'ems::resources' , $ emsResourc...
Assign the base application paths
11,181
protected function autoInjectDependendies ( HasInjectMethods $ object ) { $ reflection = new ReflectionClass ( $ object ) ; foreach ( $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ method ) { if ( strpos ( $ method -> getName ( ) , 'inject' ) !== 0 ) { continue ; } $ parameters = $ method -> getParam...
Auto Inject all dependencies
11,182
public function postParam ( $ name = null , $ default = null ) { return $ this -> getData ( $ this -> request -> getParsedBody ( ) , $ name , $ default ) ; }
Gets the post parameter that was submitted with provided name
11,183
public function queryParam ( $ name = null , $ default = null ) { return $ this -> getData ( $ this -> request -> getQueryParams ( ) , $ name , $ default ) ; }
Gets the URL query parameter with provided name
11,184
public function routeParam ( $ name = null , $ default = null ) { return $ this -> getData ( $ this -> route -> attributes , $ name , $ default ) ; }
Gets the route parameter with provided name
11,185
public function redirect ( $ location , array $ options = [ ] ) { $ this -> disableRendering ( ) ; $ location = ( string ) $ this -> uriGenerator -> generate ( $ location , $ options ) ; $ response = new Response ( 302 , '' , [ 'Location' => $ location ] ) ; $ this -> setResponse ( $ response ) ; }
Sets a redirection header in the HTTP response
11,186
public function allowMaxConditions ( $ max ) { if ( $ this -> _maxConditions ) { throw new BadMethodCallException ( 'You can only set the maximum conditions only once.' ) ; } $ this -> _maxConditions = $ max ; $ this -> _allowNesting = false ; $ this -> checkRestrictions ( ) ; return $ this ; }
Restrict the maximum number of conditions added to this group . CAUTION Because of the complex effects of this restriction nesting is automatically forbidden if setting some max conditions .
11,187
protected function findExpressions ( array $ attributes , $ expressions = null ) { $ search = [ 'string' => isset ( $ attributes [ 'string' ] ) ? $ attributes [ 'string' ] : '*' , 'name' => isset ( $ attributes [ 'name' ] ) ? $ attributes [ 'name' ] : '*' , 'operator' => isset ( $ attributes [ 'operator' ] ) ? $ attrib...
Find expressions by its name string representation operator class or operand .
11,188
protected function allExpressions ( array $ expressions = null , & $ all = null ) { $ expressions = $ expressions ? : $ this -> expressions ( ) ; $ all = $ all ? : [ ] ; foreach ( $ expressions as $ expression ) { $ all [ ] = $ expression ; if ( $ expression instanceof HasExpressions ) { $ this -> allExpressions ( $ ex...
Recursively collect all expressions .
11,189
public function importOnHoldValue ( $ locale , $ key , $ value ) { $ stats = app ( ImportSingleTranslation :: class ) -> disableOverwriteProtection ( ) -> dry ( $ this -> dry ) -> import ( $ locale , $ key , $ value ) -> getStats ( ) ; $ this -> pushToStats ( key ( $ stats ) , reset ( $ stats ) ) ; $ this -> removeFrom...
Import an existing entry that was put on hold due to overwrite protection
11,190
public function build ( $ method , Url $ url , array $ headers ) { if ( ( $ scheme = self :: isAllowedScheme ( ( string ) $ url -> scheme ( ) ) ) === false ) { throw new UnknownProtocolException ( sprintf ( "You can't request a transfer on unsupported protocol '%s'!" , $ url -> scheme ( ) ) ) ; } $ scheme = ucfirst ( $...
Build a new request from parameters
11,191
private static function isAllowedScheme ( $ scheme ) { if ( preg_match ( AbstractRequest :: HTTP , $ scheme ) === 1 ) { return 'http' ; } elseif ( preg_match ( AbstractRequest :: FTP , $ scheme ) === 1 ) { return 'ftp' ; } elseif ( preg_match ( AbstractRequest :: SSH , $ scheme ) === 1 ) { return 'ssh' ; } else { retur...
Validate scheme by checking if its an allowed one
11,192
final public static function create ( string $ classname , array $ options = array ( ) ) { $ re = new FrameworkReflection ( ) ; return ( $ re -> __simpleReturned ( $ classname , $ options ) ) ; }
Create an object with specific class name
11,193
protected function selfFormat ( XType $ type , $ value , $ view , $ lang ) { if ( $ type instanceof BoolType ) { return $ this -> formatBool ( $ type , $ value , $ view , $ lang ) ; } if ( $ type instanceof UnitType ) { return $ this -> formatUnit ( $ type , $ value , $ view , $ lang ) ; } if ( $ type instanceof Number...
Do the formatting by this class .
11,194
protected function getFormatter ( XType $ type ) { $ name = $ type -> getName ( ) ; if ( isset ( $ this -> formatterCache [ $ name ] ) ) { return $ this -> formatterCache [ $ name ] ; } $ class = get_class ( $ type ) ; if ( isset ( $ this -> formatterCache [ $ class ] ) ) { return $ this -> formatterCache [ $ class ] ;...
Get the right formatter from extensions or itself .
11,195
protected function createOwnExtension ( ) { $ this -> ownExtension = function ( XType $ type , $ value , $ view , $ lang ) { return $ this -> selfFormat ( $ type , $ value , $ view , $ lang ) ; } ; }
Creates the callable which does the own formatting .
11,196
public function createPlugin ( $ pid , $ plugin , $ attrs = [ ] ) { if ( isset ( $ attrs [ 'form' ] ) ) { $ flexFormSheets = [ ] ; foreach ( $ attrs [ 'form' ] as $ sheet => $ setup ) { $ flexFormSheets [ $ sheet ] = [ ] ; foreach ( $ setup as $ key => $ value ) { $ flexFormSheets [ $ sheet ] [ $ key ] = [ 'vDEF' => $ ...
Create a plugin element .
11,197
public function createFluidContent ( $ pid , $ vendor , $ ext , $ file , $ attrs = [ ] ) { if ( isset ( $ attrs [ 'form' ] ) ) { $ flexFormDef = [ ] ; foreach ( $ attrs [ 'form' ] as $ key => $ value ) { $ flexFormDef [ $ key ] = [ 'vDEF' => $ value ] ; } $ attrs [ 'pi_flexform' ] = [ 'data' => [ 'options' => [ 'lDEF' ...
Create a Fluid Content element .
11,198
public static function build ( AbstractRequest $ request ) { $ name = get_class ( $ request ) ; if ( ! isset ( self :: $ loaded [ $ name ] ) ) { self :: $ loaded [ $ name ] = new CurlHandle ( ) ; } else { self :: $ loaded [ $ name ] -> reset ( ) ; } self :: $ loaded [ $ name ] -> prepare ( $ request ) ; return self :: ...
Build the Handle instance based on the given request
11,199
private function route ( ServerRequestInterface $ request ) { $ route = $ request -> getAttribute ( 'route' , false ) ; if ( ! $ route instanceof Route ) { throw new BadHttpStackConfigurationException ( "Dispatcher works with router middleware in order to process incoming requests. " . "Please check that the HTTP stack...
Get route attribute from request