idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
12,500 | public function deactivate ( $ key , $ section = null ) { if ( is_null ( $ section ) ) { $ pieces = explode ( '.' , $ key ) ; $ section = $ pieces [ 0 ] ; $ key = $ pieces [ 1 ] ; } return $ this -> model -> deactivateSetting ( $ section , $ key ) ; } | Deactivates a setting |
12,501 | public function clearCache ( ) { $ this -> _data = null ; if ( $ this -> frontCache instanceof Cache ) { $ this -> frontCache -> delete ( $ this -> cacheKey ) ; } if ( $ this -> cache instanceof Cache ) { return $ this -> cache -> delete ( $ this -> cacheKey ) ; } return true ; } | Clears the settings cache on demand . If you haven t configured cache this does nothing . |
12,502 | public function getRawConfig ( ) { if ( $ this -> _data === null ) { if ( $ this -> cache instanceof Cache ) { $ data = $ this -> cache -> get ( $ this -> cacheKey ) ; if ( $ data === false ) { $ data = $ this -> model -> getSettings ( ) ; $ this -> cache -> set ( $ this -> cacheKey , $ data ) ; } } else { $ data = $ t... | Returns the raw configuration array |
12,503 | public static function nullifyStrings ( & $ values ) { foreach ( $ values as $ key => $ value ) { if ( is_array ( $ values ) ) { $ item = & $ values [ $ key ] ; } else if ( is_object ( $ values ) ) { $ item = & $ values -> { $ key } ; } else { $ item = null ; } if ( is_array ( $ item ) or is_object ( $ item ) ) { Value... | Changes form values from empty strings to null . |
12,504 | protected function createJob ( Task $ task , Lambda $ operation , array $ operationArgs ) { $ queue = $ this -> queue ; if ( isset ( $ this -> attributes [ 'plannedStart' ] ) && $ this -> attributes [ 'plannedStart' ] ) { $ queue = $ queue -> at ( $ this -> attributes [ 'plannedStart' ] ) ; } if ( isset ( $ this -> att... | Create a job in the queue to run the task . |
12,505 | public static function isEnabled ( ) : bool { $ file = JsonListener :: open ( FEnv :: get ( "framework.config.core.config.file" ) ) ; if ( true === property_exists ( $ file , "locale_enabled" ) && true === $ file -> locale_enabled ) { JsonListener :: close ( FEnv :: get ( "framework.config.core.config.file" ) ) ; retur... | Check if locale is enabled from framework instance |
12,506 | public static function disableLocale ( ) : bool { $ file = JsonListener :: open ( FEnv :: get ( "framework.config.core.config.file" ) ) ; if ( true === property_exists ( $ file , "locale_enabled" ) && true === $ file -> locale_enabled ) { $ file -> locale_enabled = false ; JsonListener :: put ( FEnv :: get ( "framework... | Disable locale for framework instance |
12,507 | public static function getAll ( ) : array { $ arr = [ ] ; if ( false === self :: isEnabled ( ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Cannot get locale from : Global locale mode is not enabled." , "solution" => "Please enable the locale mode in framework.config.json to use it from your app... | Get all local |
12,508 | public function applyMatchLocale ( string $ indexlocale ) : void { $ locale = $ this -> applocale ; $ values = ( ( array ) $ locale -> getValues ( ) ) ; $ key = array_search ( $ indexlocale , ( array ) $ values [ 0 ] ?? [ ] ) ; if ( null === $ key || false === $ key ) { throw new Server500 ( new \ ArrayObject ( array (... | Apply a locale |
12,509 | public static function resolver ( string $ locale ) : string { $ file = JsonListener :: open ( FEnv :: get ( "app.config.file" ) ) ; if ( true === property_exists ( $ file , "locale_enabled" ) && true === $ file -> locale_enabled ) { $ vals = $ file -> locale_values ; return ( $ vals [ 0 ] -> $ locale ) ; } throw new S... | Resolve the correct locale url from locale key |
12,510 | public function trans ( string $ value , string $ lang = null ) : ? string { $ locale = $ this -> applocale ; if ( null !== $ lang ) { $ this -> applyMatchLocale ( $ lang ) ; } if ( in_array ( $ locale -> getTranstype ( ) , $ this -> transType ) ) { switch ( $ locale -> getTranstype ( ) ) { case 'poedit' : return ( _ (... | Translate a word |
12,511 | public function getAllApps ( ) : \ stdClass { $ file = JL :: open ( FEnv :: get ( "framework.config.core.apps.file" ) ) ; foreach ( $ file as $ one ) { $ one -> link_edit_save = $ this -> generateRoute ( "iumio_manager_app_manager_edit_save_app" , array ( "appname" => $ one -> name ) , null , true ) ; $ one -> link_aut... | Get all apps |
12,512 | public function getStatisticsApp ( ) : array { $ f = $ this -> getAllApps ( ) ; $ fc = 0 ; $ fenable = 0 ; $ fprefix = 0 ; foreach ( $ f as $ one ) { if ( $ one -> enabled == "yes" ) { $ fenable ++ ; } if ( $ one -> prefix != "" ) { $ fprefix ++ ; } $ fc ++ ; } return ( array ( "number" => $ fc , "prefixed" => $ fprefi... | Get app statistics |
12,513 | public function switchDefaultActivity ( string $ appname ) : Renderer { $ file = JL :: open ( FEnv :: get ( "framework.config.core.apps.file" ) ) ; foreach ( $ file as $ one => $ val ) { if ( $ val -> isdefault == "yes" ) { $ val -> isdefault = "no" ; $ val -> update = new \ DateTime ( 'UTC' ) ; } if ( $ val -> name ==... | Switch app to default |
12,514 | public function exportActivity ( string $ appname ) : Renderer { $ appconfig = null ; $ file = JL :: open ( FEnv :: get ( "framework.config.core.apps.file" ) ) ; foreach ( $ file as $ one => $ val ) { if ( $ val -> name == $ appname ) { $ appconfig = $ val ; break ; } } if ( $ appconfig == null ) { throw new Server500 ... | export one app |
12,515 | public function getAppConfigActivity ( string $ appname ) { $ g = AppConfig :: getInstance ( $ appname ) ; return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "result" => $ g -> getConfig ( ) ) ) ) ; } | Get the app configuration |
12,516 | protected function unserializeError ( ) { if ( ! $ error = call_user_func ( $ this -> errorGetter ) ) { return false ; } if ( $ error [ 'file' ] != __FILE__ ) { return false ; } if ( strpos ( $ error [ 'message' ] , 'unserialize(' ) !== 0 ) { return false ; } return $ error [ 'message' ] ; } | Return the error that did occur when unserialize was called |
12,517 | public static function process ( $ uploadedFile , $ path ) { if ( ! $ uploadedFile || $ uploadedFile -> hasError ) { throw new Exception ( 'Failed to upload file' ) ; } $ chunk = ( int ) Yii :: $ app -> request -> getBodyParam ( 'chunk' , 0 ) ; $ totalChunks = ( int ) Yii :: $ app -> request -> getBodyParam ( 'chunks' ... | Processes a chunked file upload . |
12,518 | public static function tag ( $ name , $ content = '' , $ options = [ ] ) { if ( $ name === NULL || $ name === FALSE ) { return $ content ; } $ html = "<$name" . static :: renderTagAttributes ( $ options ) . '>' ; return isset ( static :: $ voidElements [ strtolower ( $ name ) ] ) ? $ html : "$html$content</$name>" ; } | Generates a complete HTML tag . |
12,519 | public static function cssStyleFromArray ( array $ style ) { $ result = '' ; foreach ( $ style as $ name => $ value ) { $ result .= "$name: $value; " ; } return $ result === '' ? NULL : rtrim ( $ result ) ; } | Converts a CSS style array into a string representation . |
12,520 | public function toObject ( bool $ recursive = false ) : \ stdClass { $ o = new \ stdClass ( ) ; if ( ! $ recursive ) { foreach ( $ this -> explorableIndex as $ property ) { $ o -> { $ property } = $ this -> { $ property } ; } } else { foreach ( $ this -> explorableIndex as $ property ) { $ value = $ this -> { $ propert... | Dumps publicly readable properties to standard object . |
12,521 | static public function isAuthor ( $ request ) { if ( ! User_Precondition :: isLogedIn ( $ request ) ) { return false ; } if ( $ request -> user -> hasPerm ( 'tenant.owner' ) || $ request -> user -> hasPerm ( 'cms.editor' ) || $ request -> user -> hasPerm ( 'cms.author' ) ) { return true ; } return false ; } | Check if the user is an author . |
12,522 | static public function editorRequired ( $ request ) { $ res = User_Precondition :: loginRequired ( $ request ) ; if ( true !== $ res ) { return $ res ; } if ( $ request -> user -> hasPerm ( 'tenant.owner' ) || $ request -> user -> hasPerm ( 'cms.editor' ) ) { return true ; } return false ; } | Check if the user is an editor . |
12,523 | public function buildRelationXTypeInfo ( Model $ model , $ key ) { $ relation = $ model -> $ key ( ) ; switch ( true ) { case $ relation instanceof BelongsTo : return $ this -> buildBelongsToInfo ( $ key , $ relation ) ; case $ relation instanceof BelongsToMany : return $ this -> buildBelongsToManyInfo ( $ key , $ rela... | Return an array describing the xtype of a relational property |
12,524 | public function setPath ( string $ path ) { $ this -> path = $ path ; $ this -> contentPath = $ this -> path . DIR_CONTENT_BASENAME ; $ this -> templatesPath = $ this -> contentPath . DIR_TEMPLATES_BASENAME ; $ this -> templates = File :: listFilesRecursively ( $ this -> templatesPath , false , EXT_PART , EXT_PAGE ) ; ... | Set the absolute path to the addon s directory . |
12,525 | public function read ( $ locale , array $ excluded = [ ] ) { $ this -> translations = collect ( ) ; $ files = $ this -> filesystem -> listContents ( $ locale ) ; foreach ( $ files as $ file ) { $ filename = substr ( $ file [ 'path' ] , strrpos ( $ file [ 'path' ] , '/' ) ) ; $ filename = ltrim ( $ filename , '/' ) ; $ ... | Read the lang files for a specific locale |
12,526 | protected function cookie ( $ arg1 = null , $ arg2 = null , $ arg3 = 0 ) { if ( is_null ( $ arg1 ) ) { return BLCookie :: get ( ) ; } if ( ! is_null ( $ arg2 ) ) { BLCookie :: set ( $ arg1 , $ arg2 , $ arg3 ) ; } if ( is_array ( $ arg1 ) ) { BLCookie :: set ( $ arg1 ) ; } return BLCookie :: get ( $ arg1 ) ; } | Cookie & Session |
12,527 | public function url ( ) { if ( isset ( $ this -> values [ 'url' ] ) && $ this -> values [ 'url' ] instanceof UrlContract ) { return $ this -> values [ 'url' ] ; } throw new UnConfiguredException ( 'No url was given by the paginator. Did you peform Paginator::setBaseUrl()?' ) ; } | Return the url to this page . |
12,528 | public function dump ( ) { $ isFirst = $ this -> dumpFlag ( 'first' , $ this -> isFirst ( ) ) ; $ isCurrent = $ this -> dumpFlag ( 'current' , $ this -> isCurrent ( ) ) ; $ isPrevious = $ this -> dumpFlag ( 'prev' , $ this -> isPrevious ( ) ) ; $ isNext = $ this -> dumpFlag ( 'next' , $ this -> isNext ( ) ) ; $ isLast ... | Just a helper method for debugging . |
12,529 | protected function findModuleName ( ) { $ pathExploded = explode ( '/' , $ this -> sourcePath ) ; $ this -> name = $ pathExploded [ ( count ( $ pathExploded ) - 1 ) ] ; $ this -> targetSrcPath = MODULES_DIR . $ this -> name ; $ this -> targetConfigPath = CONFIG_DIR . $ this -> name ; } | Find the module name and declare path to target directories install . |
12,530 | public function loadInfos ( ) { $ this -> findModuleName ( ) ; $ infos = $ this -> obtainInfosFromModule ( ) ; $ this -> checkPropertySrcPath ( $ infos ) ; $ this -> sourceSrcPath = $ infos -> srcPath ; $ this -> sourceConfigPath = $ infos -> srcPath ; if ( property_exists ( $ infos , 'configFiles' ) ) { $ this -> conf... | Load module infos from files |
12,531 | protected function checkPropertySrcPath ( \ stdClass $ infos ) : bool { if ( ! property_exists ( $ infos , 'srcPath' ) ) { throw new Exception ( 'srcPath must be present into bfwModulesInfos.json file' . ' for the module ' . $ this -> name , $ this :: ERR_LOAD_NO_PROPERTY_SRCPATH ) ; } if ( empty ( $ infos -> srcPath )... | Somes check about the property srcPath . |
12,532 | public function install ( bool $ reinstall ) { if ( empty ( $ this -> sourceSrcPath ) ) { $ this -> loadInfos ( ) ; } $ this -> forceReinstall = $ reinstall ; \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'Installing module.' , [ 'name' => $ this -> name ] ) ; $ this -> displayMsg... | Run module install |
12,533 | protected function createSymbolicLink ( ) { $ this -> displayMsgInCli ( ' > Create symbolic link ... ' ) ; $ alreadyCreated = file_exists ( $ this -> targetSrcPath ) ; if ( $ alreadyCreated && $ this -> forceReinstall === true ) { $ this -> displayMsgInCli ( '[Force Reinstall: Remove symlink] ' ) ; $ alreadyCreated = f... | Create symlink into project module directory |
12,534 | protected function copyConfigFiles ( ) { $ this -> displayMsgNLInCli ( ' > Copy config files : ' ) ; if ( $ this -> configFilesList === [ ] ) { $ this -> displayMsgInCli ( ' >> ' ) ; $ this -> displayMsgNLInCli ( 'No config file declared. Pass' , 'yellow' , 'bold' ) ; return ; } $ this -> createConfigDirectory ( ) ; $ ... | Create a directory into project config directory for the module and copy all config files declared to him |
12,535 | protected function createConfigDirectory ( ) { $ this -> displayMsgInCli ( ' >> Create config directory for this module ... ' ) ; $ alreadyExist = file_exists ( $ this -> targetConfigPath ) ; if ( $ alreadyExist && $ this -> forceReinstall === true ) { $ this -> displayMsgInCli ( '[Force Reinstall: Remove directory] ' ... | Create a directory into project config directory for the module |
12,536 | protected function removeRecursiveDirectory ( string $ dirPath ) : bool { $ itemList = array_diff ( scandir ( $ dirPath ) , [ '.' , '..' ] ) ; foreach ( $ itemList as $ itemName ) { $ itemPath = $ dirPath . '/' . $ itemName ; if ( is_dir ( $ itemPath ) ) { $ this -> removeRecursiveDirectory ( $ itemPath ) ; } else { un... | Remove folders recursively |
12,537 | protected function copyConfigFile ( string $ configFileName ) { $ this -> displayMsgInCli ( ' >> Copy ' . $ configFileName . ' ... ' ) ; $ sourceFile = realpath ( $ this -> sourceConfigPath . '/' . $ configFileName ) ; $ targetFile = realpath ( $ this -> targetConfigPath ) . '/' . $ configFileName ; if ( file_exists ( ... | Copy a config file into config directory for the module |
12,538 | protected function checkInstallScript ( ) { $ this -> displayMsgNLInCli ( ' > Check install specific script :' ) ; if ( empty ( $ this -> sourceInstallScript ) || $ this -> sourceInstallScript === false ) { $ this -> displayMsgInCli ( ' >> ' ) ; $ this -> displayMsgNLInCli ( 'No specific script declared. Pass' , 'yello... | Check if a specific install script is declared for the module and if the value is true use the default script name runInstallModule . php . |
12,539 | public function runInstallScript ( string $ scriptName ) { $ this -> displayMsgInCli ( ' >> ' ) ; $ this -> displayMsgNLInCli ( 'Execute script ' . $ scriptName , 'yellow' , 'bold' ) ; require_once ( $ this -> sourcePath . '/' . $ scriptName ) ; $ this -> displayMsgNLInCli ( '' ) ; } | Run the module specific install script |
12,540 | protected function storeBinding ( $ abstract , $ concrete , $ shared ) { $ this -> bindings [ $ abstract ] = [ 'concrete' => $ this -> checkAndReturnCallable ( $ concrete ) , 'shared' => $ shared , ] ; return $ this ; } | Stores the binding inside the bindings . |
12,541 | public static function classAutoLoader ( string $ class ) { self :: ensureDefines ( ) ; $ coreBaseNamespace = str_replace ( '\\' , '/' , __NAMESPACE__ ) . '/' ; $ classWithNamespaceToLoad = str_replace ( '\\' , '/' , $ class ) ; $ classWithRelativeNamespaceToLoad = str_replace ( $ coreBaseNamespace , '' , $ classWithNa... | Xentriq s autoloader function . Supports PSR - 0 and PSR - 4 in addition to a somewhat custom implementation for loading classes from addons . |
12,542 | public static function route ( ) { $ startTime = TimeUtils :: getTimestamp ( ) ; set_exception_handler ( 'Xentriq\Core\Xentriq::exceptionHandler' ) ; set_error_handler ( 'Xentriq\Core\Xentriq::errorHandler' , ( E_ERROR | E_RECOVERABLE_ERROR | E_NOTICE ) ) ; self :: ensureDefines ( ) ; if ( ! DISABLE_DEFAULT_RESPONSE_HE... | Entry point for routing requests through Xentriq . Initialises all required components and tries to render the correct template for the request . |
12,543 | private static function routeAction ( ) { $ actionQueryString = Request :: getInputValue ( "do" , false , true ) ; $ actionQuery = Actions :: parseActionQueryString ( $ actionQueryString ) ; Addons :: executeComponentFunction ( $ actionQuery -> name , $ actionQuery -> method , @ $ actionQuery -> arguments ) ; } | Routes action and executes the requested function . |
12,544 | public static function exceptionHandler ( $ exception ) { if ( DEBUG ) { self :: outputErrorHtml ( $ exception -> getMessage ( ) , @ $ exception -> timestamp , $ exception -> getFile ( ) , $ exception -> getLine ( ) , $ exception ) ; } elseif ( $ exception instanceof ConfigurationException ) { self :: outputErrorHtml (... | Xentriq s exception handler . |
12,545 | public static function errorHandler ( $ errno , $ errstr , $ file , $ line , $ context ) : bool { if ( error_reporting ( ) === 0 ) { return false ; } error_log ( $ errstr . PHP_EOL . "\tOrigin: " . $ file . ':' . $ line ) ; if ( DEBUG ) { self :: outputErrorHtml ( $ errstr , time ( ) , $ file , $ line ) ; } return true... | Xentriq s error handler . |
12,546 | private static function outputErrorHtml ( string $ message , $ timestamp , string $ file = 'unknown' , $ line = '?' , $ exception = null ) { if ( empty ( $ timestamp ) ) { $ timestamp = time ( ) ; } $ traceHtml = '' ; if ( is_string ( $ exception ) ) { $ traceHtml = '<p>' . nl2br ( $ exception ) . '</p>' ; } if ( ! is_... | Output block of HTML for displaying error information . |
12,547 | public static function trace ( $ message , $ category = 'application' ) { if ( YII_DEBUG ) { static :: getLogger ( ) -> log ( $ message , Logger :: LEVEL_TRACE , $ category ) ; } } | Logs a trace message . Trace messages are logged mainly for development purpose to see the execution work flow of some code . |
12,548 | public function actionCreate ( $ parent = null ) { $ model = new Area ( ) ; if ( ! is_null ( $ parent ) ) { $ parent = Area :: findOne ( [ 'id' => $ parent ] ) ; if ( $ parent ) { $ model -> parent = $ parent -> id ; $ model -> parent_name = $ parent -> name ; } } if ( Yii :: $ app -> request -> isAjax && $ model -> lo... | Creates a new Area model . If creation is successful the browser will be redirected to the view page . |
12,549 | public function setBlockedIPTable ( $ table ) { if ( is_string ( $ table ) ) { $ this -> blocked_ip_table = filter_var ( $ table , FILTER_SANITIZE_STRING ) ; } return $ this ; } | Change the default table name where the IP list is located |
12,550 | public function setBlockedRangeTable ( $ table ) { if ( is_string ( $ table ) ) { $ this -> blocked_range_table = filter_var ( $ table , FILTER_SANITIZE_STRING ) ; } return $ this ; } | Change the default table name where the IP Range list is located |
12,551 | public function setBlockedISOTable ( $ table ) { if ( is_string ( $ table ) ) { $ this -> blocked_iso_countries = filter_var ( $ table , FILTER_SANITIZE_STRING ) ; } return $ this ; } | Change the default table name where the ISO Country list is located |
12,552 | public function isIPBlocked ( $ ip ) { return ( $ this -> isIPBlockedList ( $ ip ) || $ this -> isIPBlockedRange ( $ ip ) || $ this -> isISOBlocked ( $ ip ) ) ; } | Checks to see if the given IP is Blocked by listing or range |
12,553 | public function isISOBlocked ( $ ip ) { return $ this -> db -> select ( $ this -> getBlockedISOTable ( ) , [ 'iso' => $ this -> getIPCountryISO ( $ ip ) ] ) ; } | Check to see if the ISO county of the IP is blocked |
12,554 | public function addRangetoBlock ( $ start , $ end ) { return $ this -> db -> insert ( $ this -> getBlockedRangeTable ( ) , [ 'ip_start' => $ start , 'ip_end' => $ end ] ) ; } | Adds a IP range to block in the database where any IP between the start and end values should be blocked |
12,555 | public function removeRangeFromBlock ( $ id , $ start = NULL , $ end = NULL ) { if ( is_numeric ( $ id ) ) { $ where = [ 'id' => $ id ] ; } else { $ where = [ 'ip_start' => $ start , 'ip_end' => $ end ] ; } return $ this -> db -> delete ( $ this -> getBlockedRangeTable ( ) , $ where , 1 ) ; } | Removes a blocked range from the database |
12,556 | public function getIPCountryISO ( $ ip ) { try { $ search = $ this -> geoIP -> country ( $ ip ) ; if ( is_object ( $ search ) ) { return $ search -> country -> isoCode ; } } catch ( \ Exception $ e ) { } return false ; } | Returns the ISO county of an IP address |
12,557 | public function addISOCountryBlock ( $ iso ) { if ( ! empty ( trim ( $ iso ) ) && is_string ( $ iso ) ) { return $ this -> db -> insert ( $ this -> getBlockedISOTable ( ) , [ 'iso' => trim ( $ iso ) ] ) ; } return false ; } | Add an ISO country to the blocked list |
12,558 | public function removeISOCountryBlock ( $ iso ) { if ( ! empty ( trim ( $ iso ) ) && is_string ( $ iso ) ) { return $ this -> db -> delete ( $ this -> getBlockedISOTable ( ) , [ 'iso' => trim ( $ iso ) ] ) ; } return false ; } | Remove an ISO country from the blocked list |
12,559 | protected function callAllListeners ( $ args = [ ] ) { $ args = ( array ) $ args ; array_map ( function ( $ event ) use ( $ args ) { $ this -> callListeners ( $ event , $ args ) ; } , array_keys ( $ this -> listeners ) ) ; } | Calls all listeners regardless of their names . |
12,560 | protected function callListener ( callable $ listener , array $ args = [ ] ) { switch ( count ( $ args ) ) { case 0 : return call_user_func ( $ listener ) ; case 1 : return call_user_func ( $ listener , $ args [ 0 ] ) ; case 2 : return call_user_func ( $ listener , $ args [ 0 ] , $ args [ 1 ] ) ; case 3 : return call_u... | Call one listener . |
12,561 | public function getConsoleBanner ( Console $ console ) { $ version = \ Cathedral \ Builder \ Version :: VERSION ; $ version_date = \ Cathedral \ Builder \ Version :: VERSION_DATE ; return "Cathedral/BuilderCLI $version ($version_date)" ; } | This method is defined in ConsoleBannerProviderInterface |
12,562 | public function getSeparator ( ) { if ( ! $ this -> separator && $ this -> getFilePath ( ) ) { $ this -> separator = $ this -> detector -> separator ( $ this -> firstLines ( ) , $ this -> getDelimiter ( ) ) ; $ this -> separatorWasDetected = true ; } return $ this -> separator ; } | Return the column separator |
12,563 | protected function readNext ( $ handle , $ chunkSize ) { if ( feof ( $ handle ) ) { return null ; } $ row = $ this -> readRow ( $ handle , $ chunkSize ) ; if ( ! $ this -> startAtRow && $ this -> hasHeader && ! $ this -> headerRowSkipped ) { $ this -> headerRowSkipped = true ; return $ this -> readNext ( $ handle , $ c... | Read the next row and return it . Skip empty lines . |
12,564 | protected function readRow ( $ handle , $ chunkSize ) { $ row = str_getcsv ( $ this -> readLine ( $ handle , 0 ) , $ this -> separator , $ this -> delimiter ) ; if ( $ this -> isSkippableRow ( $ row ) ) { return [ ] ; } if ( ! $ this -> hasHeader ) { return array_map ( function ( $ value ) { return $ this -> convertEnc... | Read the next row from the file |
12,565 | protected function onFileChanged ( ) { $ this -> firstLinesRaw = null ; $ this -> firstLines = null ; if ( $ this -> separatorWasDetected ) { $ this -> separator = '' ; $ this -> separatorWasDetected = false ; } if ( $ this -> headerWasDetected ) { $ this -> setHeader ( [ ] ) ; $ this -> headerWasDetected = false ; } } | Empty first line cache if file did change |
12,566 | protected function newCountInstance ( ) { $ instance = new static ( $ this -> getFilePath ( ) , $ this -> getFilesystem ( ) , $ this -> getDetector ( ) , clone $ this -> getLineReader ( ) ) ; return $ instance -> setDelimiter ( $ this -> getDelimiter ( ) ) -> setSeparator ( $ this -> getSeparator ( ) ) -> setHeader ( $... | Create an instance of this reader just for the line count |
12,567 | protected function convertEncoding ( $ data ) { if ( ! $ this -> shouldConvert ) { return $ data ; } return $ this -> stringConverter -> convert ( "$data" , 'utf-8' , $ this -> getOption ( self :: ENCODING ) ) ; } | Converts encoding if needed . |
12,568 | protected function updateConversion ( ) { $ this -> convertFrom = strtoupper ( $ this -> getOption ( self :: ENCODING ) ) ; $ this -> shouldConvert = $ this -> convertFrom != 'UTF-8' ; } | Update the convertion options . This is handled like this for performance reasons . |
12,569 | public function encode ( $ value ) { switch ( true ) { case is_null ( $ value ) : return $ this -> encodeString ( '' , self :: T_NULL ) ; case is_bool ( $ value ) : return $ this -> encodeString ( $ value ? 'true' : 'false' , self :: T_BOOL ) ; case is_int ( $ value ) : return $ this -> encodeString ( $ value , self ::... | Encodes the value as a tagged netstring . |
12,570 | public function decode ( $ tnetstring ) { if ( ! $ tnetstring ) { throw new InvalidArgumentException ( "Can't decode an empty tnetstring." ) ; } $ remaining = $ tnetstring ; $ values = array ( ) ; while ( $ remaining ) { list ( $ size , $ data ) = explode ( ':' , $ remaining , 2 ) ; $ size = intval ( $ size ) ; $ paylo... | Decodes the value or values from the tagged netstring . |
12,571 | public function create ( $ pid , $ attrs = [ ] ) { $ table = $ this -> getTable ( ) ; $ newUid = 'NEW_' . uniqid ( $ table ) ; $ this -> dh -> stripslashes_values = 0 ; $ this -> dh -> start ( [ $ table => [ $ newUid => array_merge ( $ attrs , [ 'pid' => $ pid ] ) ] ] , null ) ; $ this -> dh -> process_datamap ( ) ; if... | Create a new record under the given PID . |
12,572 | public function onChannel ( $ pattern , $ callback , $ priority = 0 ) { $ handler = new EventListener ( $ pattern , $ callback ) ; $ this -> dispatcher -> addListener ( 'message.channel' , array ( $ handler , 'testAndExecute' ) , $ priority ) ; return $ this ; } | Adds an event handler to the list for when someone talks in a channel . |
12,573 | public function onMessages ( $ pattern , $ callback , $ priority = 0 ) { return $ this -> onChannel ( $ pattern , $ callback , $ priority ) -> onPrivateMessage ( $ pattern , $ callback , $ priority ) ; } | Adds event handlers to the list for both channel messages and private messages . |
12,574 | public function onServer ( $ command , $ callback , $ priority = 0 ) { $ handler = new EventListener ( null , $ callback ) ; $ this -> dispatcher -> addListener ( 'server.' . $ command , array ( $ handler , 'testAndExecute' ) , $ priority ) ; return $ this ; } | Adds event handler to the list of server messages . |
12,575 | public function getPidfile ( ) { $ resource = false ; if ( isset ( $ this -> pidfile ) && is_readable ( $ this -> pidfile ) ) { $ resource = fopen ( $ this -> pidfile , 'r' ) ; } return $ resource ? $ resource : null ; } | Returns the location of the pid file . |
12,576 | public function loadPlugin ( AbstractPlugin $ plugin ) { $ name = $ plugin -> getName ( ) ; $ this -> log -> addDebug ( '--- Loading plugin ' . $ name . PHP_EOL ) ; $ plugin -> init ( ) ; $ this -> plugins [ $ name ] = $ plugin ; return $ this ; } | Loads a plugin . See the README for plugin documentation . |
12,577 | public function getPlugin ( $ name ) { if ( ! isset ( $ this -> plugins [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Plugin %s is not registered' ) ) ; } return $ this -> plugins [ $ name ] ; } | Retrieves a plugin with the given name . |
12,578 | private function connect ( ) { $ server = $ this -> config [ 'server' ] ; if ( isset ( $ this -> config [ 'ssl' ] ) && $ this -> config [ 'ssl' ] == true ) { $ server = 'ssl://' . $ server ; } stream_set_blocking ( STDIN , 0 ) ; $ this -> socket = fsockopen ( $ server , $ this -> config [ 'port' ] ) ; return ( bool ) $... | Connects to the IRC server . |
12,579 | private function login ( ) { if ( isset ( $ this -> config [ 'connection_password' ] ) ) { $ this -> send ( Response :: pass ( $ this -> config [ 'connection_password' ] ) ) ; } $ this -> send ( Response :: nick ( $ this -> config [ 'nick' ] ) ) ; $ this -> send ( Response :: user ( $ this -> config [ 'username' ] , $ ... | Logs in to the IRC server with the user info in the config . |
12,580 | private function join ( ) { if ( ! is_array ( $ this -> config [ 'channels' ] ) ) { $ this -> config [ 'channels' ] = array ( $ this -> config [ 'channels' ] ) ; } $ channels = array ( ) ; $ passwords = array ( ) ; $ without_passwords = array ( ) ; foreach ( $ this -> config [ 'channels' ] as $ channel ) { if ( is_arra... | Joins the channels specified in the config . |
12,581 | private function listen ( ) { do { $ data = fgets ( $ this -> socket , 512 ) ; if ( ! empty ( $ data ) ) { $ request = $ this -> receive ( $ data ) ; $ cmd = strtolower ( $ request -> getCommand ( ) ) ; if ( $ cmd === 'privmsg' ) { $ event_name = 'message.' . ( $ request -> isPrivateMessage ( ) ? 'private' : 'channel' ... | Driver of the bot ; listens for messages responds to them accordingly . |
12,582 | private function setupLogger ( ) { $ this -> log = new Logger ( 'philip' ) ; if ( isset ( $ this -> config [ 'debug' ] ) && $ this -> config [ 'debug' ] == true ) { $ log_path = isset ( $ this -> config [ 'log' ] ) ? $ this -> config [ 'log' ] : false ; if ( ! $ log_path ) { throw new \ Exception ( "If debug is enabled... | Sets up the logger but only if debug is enabled . |
12,583 | private function writePidfile ( ) { if ( isset ( $ this -> config [ 'write_pidfile' ] ) && $ this -> config [ 'write_pidfile' ] ) { if ( ! isset ( $ this -> config [ 'pidfile' ] ) ) { throw new \ Exception ( 'Please supply a pidfile location.' ) ; } $ this -> pidfile = $ this -> config [ 'pidfile' ] ; if ( $ pidfile = ... | If Philip is configured to write a pid file open it and write the pid into it . |
12,584 | private function addDefaultHandlers ( ) { $ log = $ this -> log ; $ this -> onPing ( function ( Event $ event ) { $ event -> addResponse ( Response :: pong ( $ event -> getRequest ( ) -> getMessage ( ) ) ) ; } ) ; $ this -> onError ( function ( Event $ event ) use ( $ log ) { $ log -> debug ( "--- ERROR: {$event->getRe... | Loads default event handlers for basic IRC commands that won t be unique to each bot . |
12,585 | public function query ( QueryInterface $ query , $ return = false ) { DebuggerUtility :: var_dump ( $ this -> queryParser -> parseQuery ( $ query ) , null , 8 , false , true , $ return ) ; } | Dump a query . |
12,586 | public static final function fcm ( string $ string , string $ separator = '_' ) : string { return ltrim ( preg_replace_callback ( '/\\\?[A-Z][A-Za-z0-9]+?/' , function ( $ Macthes ) use ( $ separator ) { return $ separator . ltrim ( strtolower ( $ Macthes [ 0 ] ) , '\\' ) ; } , $ string ) , $ separator ) ; } | Convert any string from camel case to a string with a given delimiter . |
12,587 | public static final function tons ( string $ string , string $ separator = '.' ) : string { return implode ( '\\' , array_map ( 'ucfirst' , preg_split ( '/' . implode ( '|' , array_map ( function ( $ separator ) { return preg_quote ( $ separator , '/' ) ; } , array_pad ( array_slice ( func_get_args ( ) , 1 ) , 1 , '.' ... | Convert any separated string to qualifier name . |
12,588 | public static final function frns ( string $ string , string $ separator = '.' ) : string { return implode ( $ separator , preg_split ( '/\\\/' , trim ( strtolower ( $ string ) ) , - 1 , PREG_SPLIT_NO_EMPTY ) ) ; } | Convert any qualifier name to a string with a given delimiter . |
12,589 | public static function create ( string $ cstName , $ cstValue ) { if ( defined ( $ cstName ) ) { throw new Exception ( 'The constant ' . $ cstName . ' is already defined.' , self :: ERR_ALREADY_DEFINED ) ; } define ( $ cstName , $ cstValue ) ; } | Create a new constant if not exist |
12,590 | public function getSubjectByName ( string $ subjectName ) : \ SplSubject { if ( ! array_key_exists ( $ subjectName , $ this -> subjectList ) ) { throw new Exception ( 'The subject ' . $ subjectName . ' is not in the list.' , self :: ERR_SUBJECT_NAME_NOT_EXIST ) ; } return $ this -> subjectList [ $ subjectName ] ; } | Obtain a subject object with this name |
12,591 | public function addSubject ( \ SplSubject $ subject , $ subjectName = null ) : self { if ( $ subjectName === null ) { $ subjectName = get_class ( $ subject ) ; } if ( array_key_exists ( $ subjectName , $ this -> subjectList ) && $ this -> subjectList [ $ subjectName ] !== $ subject ) { throw new \ Exception ( 'A subjec... | Add a new subject to the list |
12,592 | public function removeSubject ( \ SplSubject $ subject ) : self { $ key = array_search ( $ subject , $ this -> subjectList , true ) ; if ( $ key === false ) { throw new Exception ( 'The subject has not been found.' , self :: ERR_SUBJECT_NOT_FOUND ) ; } unset ( $ this -> subjectList [ $ key ] ) ; return $ this ; } | Remove a subject from the list |
12,593 | protected function validateByBaseValidator ( Validation $ validation , array $ input , array $ baseRules , AppliesToResource $ resource = null , $ locale = null ) { $ laravelRules = $ this -> toLaravelRules ( $ baseRules ) ; $ illuminateValidator = $ this -> buildValidator ( $ input , $ laravelRules ) ; if ( ! $ illumi... | Perform all validation by the the base validator |
12,594 | protected function parametersOfUniqueConstraint ( $ key , array $ originalParameters , AppliesToResource $ resource = null ) { if ( ! $ resource instanceof Entity ) { return $ originalParameters ; } if ( ! $ resource instanceof EloquentModel ) { return $ originalParameters ; } if ( strpos ( $ key , '.' ) !== false ) { ... | Calculate the unique parameters for the uniqueParameters . |
12,595 | protected function toLaravelRules ( array $ parsedRules ) { $ laravelRules = [ ] ; foreach ( $ parsedRules as $ key => $ keyRules ) { $ laravelRules [ $ key ] = [ ] ; foreach ( $ keyRules as $ ruleName => $ parameters ) { $ separator = $ parameters ? ':' : '' ; $ laravelRules [ $ key ] [ ] = $ ruleName . $ separator . ... | Convert the ems rules into the laravel format |
12,596 | public static function createUploadedFile ( $ file , int $ size = null , int $ error = \ UPLOAD_ERR_OK , string $ clientFilename = null , string $ clientMediaType = null ) : UploadedFileInterface { return new UploadedFile ( $ file , $ clientFilename , $ clientMediaType , $ size , $ error ) ; } | Create a new uploaded file . If a string is used to create the file a temporary resource will be created with the content of the string . If a size is not provided it will be determined by checking the size of the file . |
12,597 | protected function ensureRequiredAttributes ( array $ spec = [ ] ) { if ( ! isset ( $ spec [ 'attributes' ] ) ) { throw new MissingAttributeException ( sprintf ( 'The attribute "attributes" is not defined, but required.' ) ) ; } $ required = [ 'type' , 'name' ] ; foreach ( $ required as $ key ) { if ( ! isset ( $ spec ... | Internal function to ensure that all required attributes are available . |
12,598 | public function toContainer ( string $ uri = '' ) : string { $ uri = $ uri ? $ this -> c :: mbLTrim ( $ uri , '/' ) : '' ; $ uri = $ uri ? '/' . $ uri : '' ; return $ url = 'https://' . $ this -> App :: CORE_CONTAINER_DOMAIN . $ uri ; } | URL to core container . |
12,599 | public function preInit ( & $ config ) { if ( ! isset ( $ config [ 'id' ] ) ) { throw new InvalidConfigException ( 'The "id" configuration for the Application is required.' ) ; } if ( isset ( $ config [ 'basePath' ] ) ) { $ this -> setBasePath ( $ config [ 'basePath' ] ) ; unset ( $ config [ 'basePath' ] ) ; } else { t... | Pre - initializes the application . This method is called at the beginning of the application constructor . It initializes several important application properties . If you override this method please make sure you call the parent implementation . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.