idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
17,600
public static function register ( $ alias , $ config ) { if ( is_array ( $ config ) ) { $ name = $ config [ 'class' ] ; $ singleton = ! empty ( $ config [ 'singleton' ] ) ; unset ( $ config [ 'class' ] , $ config [ 'singleton' ] ) ; static :: $ classNames [ $ name ] = static :: $ classAliases [ $ alias ] = [ 'singleton...
Registry class .
17,601
public static function isSingleton ( $ name ) { if ( ! static :: exists ( $ name ) ) { return false ; } if ( empty ( static :: $ classNames [ $ name ] [ 'singleton' ] ) && empty ( static :: $ classAliases [ $ name ] [ 'singleton' ] ) ) { return false ; } return true ; }
Is single of class .
17,602
public function getPagePath ( ) { $ core = $ this -> getLoops ( ) -> getService ( "web_core" ) ; $ page = $ core -> page ; $ pagepath = $ page === $ this ? "" : WebCore :: getPagePathFromClassname ( $ page , $ core -> page_parameter ) ; return implode ( "/" , $ pagepath ? array_merge ( [ $ pagepath ] , $ core -> parame...
Returns the page path
17,603
public function load ( $ id ) { $ this -> isNew = false ; $ dbr = wfGetDB ( DB_SLAVE ) ; $ entity = $ dbr -> selectRow ( static :: $ table , '*' , array ( 'id' => intval ( $ id ) ) ) ; if ( ! $ entity ) { $ this -> error = true ; return false ; throw new Exception ( get_called_class ( ) . ": there is no entity with id ...
Loads entity from database .
17,604
public function count ( $ where = 'all' , $ options = array ( ) ) { $ dbr = wfGetDB ( DB_SLAVE ) ; if ( ! is_array ( $ where ) && $ where == 'all' ) { $ collection = $ dbr -> select ( static :: $ table , 'id' , array ( ) , __METHOD__ , $ options ) ; } else { $ collection = $ dbr -> select ( static :: $ table , 'id' , $...
Count entities . There some code that should be fixed .
17,605
public function save ( $ propvalues = null , $ reserved = false ) { $ dbr = wfGetDB ( DB_MASTER ) ; $ dbr -> begin ( ) ; $ sourceprops = $ this -> properties ; $ insertId = null ; foreach ( $ sourceprops as $ prop => $ type ) { $ sourceprops [ $ prop ] = ( isset ( $ this -> values [ $ prop ] ) ) ? $ this -> values [ $ ...
Save entity instance in database .
17,606
public static function find ( $ where = 'all' , $ options = array ( ) ) { $ dbr = wfGetDB ( DB_SLAVE ) ; if ( ! is_array ( $ where ) && $ where == 'all' ) { $ collection = $ dbr -> select ( static :: $ table , 'id' , array ( ) , __METHOD__ , $ options ) ; } else { $ collection = $ dbr -> select ( static :: $ table , 'i...
Fetch collection of entities
17,607
public function validate ( $ req = array ( ) , $ input = null ) { global $ wgRequest ; if ( ! is_array ( $ req ) ) $ req = array ( $ req ) ; if ( $ input == null ) { $ input = $ wgRequest -> getValues ( ) ; } if ( isset ( $ _POST [ 'title' ] ) ) { $ input [ 'title' ] = htmlspecialchars ( $ _POST [ 'title' ] ) ; } forea...
Invalidates model from request
17,608
private function initTransports ( ) { $ this -> transports = array ( ) ; foreach ( $ this -> loadTransports ( ) as $ transport ) { if ( ! $ transport instanceof TransportInterface ) { throw new \ InvalidArgumentException ( sprintf ( 'Transport %s should implements TransportInterface' , get_class ( $ transport ) ) ) ; }...
Initializes the transports .
17,609
protected function mergeValues ( array $ values , $ merge = true ) { $ this -> values = $ merge ? array_merge ( $ this -> values , $ values ) : $ values ; return $ this ; }
Add values to view
17,610
final protected function error ( $ message , $ status = null , $ nl = true ) { $ this -> io -> error ( $ message , $ status , $ nl ) ; }
Write to STDERR
17,611
final protected function silentRead ( $ prompt = null , $ nl = null ) { if ( $ prompt !== null ) { $ this -> io -> write ( $ prompt , false ) ; } return $ this -> io -> silentReadLine ( $ nl ) ; }
Silent read from STDIN
17,612
public static function create ( Query $ query ) : QueryMessage { $ timestamp = DateTime :: now ( ) ; $ id = MessageId :: generate ( ) ; $ metaData = MetaData :: create ( ) ; return new static ( $ id , $ timestamp , $ query , $ metaData ) ; }
Creates instance for a query
17,613
public function middleware ( ... $ middlewares ) { foreach ( $ middlewares as $ middleware ) { $ this -> currentContext -> addMiddleware ( $ middleware ) ; } return $ this ; }
Adds middleware to the current context
17,614
public function request ( string $ path , int $ methods , $ handler ) { $ path = $ this -> currentContext -> getPrefixedPath ( trim ( $ path , "\n\r\t/ " ) ) ; return $ this -> route ( new Route ( $ path , $ methods ) , $ handler ) ; }
Adds a new route with given path to the current context that accepts the given methods requests .
17,615
private function resultToResponse ( $ result ) : Response { switch ( true ) { case $ result instanceof Response : return $ result ; case is_string ( $ result ) || is_numeric ( $ result ) : return new Response ( $ result ) ; case is_array ( $ result ) || is_object ( $ result ) : return new JsonResponse ( $ result ) ; de...
Transforms any skalar handler result to a ieu \ Http \ Response object
17,616
public function hookFilter ( $ text , $ filter , & $ filtered ) { if ( ! isset ( $ filtered ) && ( ! isset ( $ filter [ 'filter_id' ] ) || $ filter [ 'filter_id' ] === 'xss' ) ) { $ filtered = $ this -> filter ( $ text ) ; } }
Implements hook filter
17,617
public function has ( $ key ) { $ menu = $ this -> getMenu ( $ key ) ; return ! is_null ( $ menu ) && $ menu -> count ( ) > 0 ; }
Check if there are navigation items .
17,618
public function setUrl ( $ url ) { if ( ! str_contains ( $ this -> cells , ':' ) ) { $ this -> sheet -> getCell ( $ this -> cells ) -> getHyperlink ( ) -> setUrl ( $ url ) ; } return $ this ; }
Set cell url
17,619
protected function setColorStyle ( $ styleType , $ color , $ type = false , $ colorType = 'rgb' ) { $ styles = is_array ( $ color ) ? $ color : [ 'type' => $ type , 'color' => [ $ colorType => str_replace ( '#' , '' , $ color ) ] , ] ; return $ this -> setStyle ( $ styleType , $ styles ) ; }
Set the color style
17,620
public function populate ( array $ values = [ ] ) { foreach ( $ values as $ key => $ value ) { $ methodName = "set{$key}" ; if ( method_exists ( $ this , $ methodName ) ) { if ( in_array ( $ key , $ this -> dateTimeKeys ) ) { $ value = new \ DateTime ( $ value , new \ DateTimeZone ( 'UTC' ) ) ; } elseif ( in_array ( $ ...
Populate the class
17,621
public static function subStringBeforeLast ( $ haystack , $ needle , $ n = 1 ) { while ( $ n > 0 ) { $ haystack = substr ( $ haystack , 0 , strrpos ( $ haystack , $ needle ) ) ; $ n -- ; } return $ haystack ; }
Get the substring before the last occurence of a character
17,622
public static function subStringAfterLast ( $ haystack , $ needle , $ n = 1 ) { $ string = "" ; while ( $ n > 0 ) { $ string .= substr ( $ haystack , strrpos ( $ haystack , $ needle ) + 1 ) ; if ( $ n > 1 ) { $ string = $ needle . $ string ; } $ n -- ; } return $ string ; }
Get the substring after the last occurrence of a character
17,623
protected function _containerUnset ( & $ container , $ key ) { $ origKey = $ key ; $ key = $ this -> _normalizeKey ( $ key ) ; if ( is_array ( $ container ) ) { if ( ! isset ( $ container [ $ key ] ) ) { throw $ this -> _createNotFoundException ( $ this -> __ ( 'Key "%1$s" not found' , [ $ key ] ) , null , null , null ...
Unsets a value with the specified key on the given container .
17,624
public static function concat ( $ file ) { $ args = array ( ) ; $ len = func_num_args ( ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ value = func_get_arg ( $ i ) ; $ values = is_array ( $ value ) ? array_values ( $ value ) : array ( $ value ) ; $ args = array_merge ( $ args , $ values ) ; } return rtrim ( preg_replac...
Concatenates filenames .
17,625
public static function getHumanSize ( $ size , $ precision = 1 ) { $ units = array ( " bytes" , "K" , "M" , "G" , "T" , "P" , "E" , "Z" , "Y" ) ; $ pow = 1024 ; $ factor = 0 ; while ( $ size + 1 > $ pow ) { $ size /= $ pow ; $ factor ++ ; } return round ( $ size , $ precision ) . $ units [ $ factor ] ; }
Gets a human readable size .
17,626
public static function getAvailName ( $ dir , $ refname = "" , $ refext = "" ) { $ dir = trim ( $ dir ) ; $ refname = trim ( $ refname ) ; $ refext = ltrim ( trim ( $ refext ) , "." ) ; if ( ! is_dir ( $ dir ) ) { throw new SysException ( "Directory not found: $dir" ) ; } if ( Text :: isEmpty ( $ refname ) ) { $ refnam...
Gets an available name under a given directory .
17,627
public static function getInfo ( $ path ) { $ info = pathinfo ( $ path ) ; return array ( "dirname" => Arr :: get ( $ info , "dirname" , "" ) , "basename" => Arr :: get ( $ info , "basename" , "" ) , "extension" => Arr :: get ( $ info , "extension" , "" ) , "filename" => Arr :: get ( $ info , "filename" , "" ) ) ; }
Gets the information of a file path .
17,628
protected function insertDeveloper ( ) { $ data = $ this -> getPatchData ( ) ; $ create = $ data -> get ( 'gridguyz-core' , 'developer' , 'Do you want to create a developer user? (y/n)' , 'n' , array ( 'y' , 'n' , 'yes' , 'no' , 't' , 'f' , 'true' , 'false' , '1' , '0' ) ) ; if ( in_array ( strtolower ( $ create ) , ar...
Insert developer user
17,629
protected function insertPlatformOwner ( ) { $ data = $ this -> getPatchData ( ) ; $ email = $ data -> get ( 'gridguyz-core' , 'platformOwner-email' , 'Type the platform owner\'s email (must be valid email)' , null , '/^[A-Z0-9\._%\+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i' , 3 ) ; $ displayName = $ data -> get ( 'gridguyz-core...
Insert platform - owner user
17,630
protected function createPasswordHash ( $ password ) { if ( function_exists ( 'password_hash' ) ) { return password_hash ( $ password , PASSWORD_DEFAULT ) ; } if ( ! defined ( 'CRYPT_BLOWFISH' ) ) { throw new Exception \ RuntimeException ( sprintf ( '%s: CRYPT_BLOWFISH algorithm must be enabled' , __METHOD__ ) ) ; } re...
Create password hash
17,631
private function createPasswordSalt ( $ length = 22 ) { static $ chars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) && ( version_compare ( PHP_VERSION , '5.3.4' ) >= 0 || strtoupper ( substr ( PHP_OS , 0 , 3 ) ) !== 'WIN' ) ) { $ bytes = o...
Create password - salt
17,632
protected function insertDefaultMenu ( $ content ) { $ root = $ this -> insertIntoTable ( 'menu' , array ( 'type' => 'container' , 'left' => 1 , 'right' => 4 , ) , true ) ; $ this -> insertIntoTable ( 'menu_label' , array ( 'menuId' => $ root , 'locale' => 'en' , 'label' => 'Default menu' , ) ) ; $ menuContent = $ this...
Insert default menu
17,633
protected function appendCustomizeGlobalExtra ( $ globalExtraCss , $ schema = null ) { $ where = array ( 'rootParagraphId' => null ) ; $ table = 'customize_extra' ; if ( $ schema ) { $ table = array ( $ schema , $ table ) ; } $ current = $ this -> selectFromTable ( $ table , 'extra' , $ where ) ; if ( null === $ curren...
Append global extra css to customize
17,634
protected function mergePackagesConfig ( ) { $ this -> getInstaller ( ) -> mergeConfigData ( 'packages.local' , include __DIR__ . '/../../../../config/default.packages.php' , function ( & $ config ) { if ( ! empty ( $ config [ 'modules' ] [ 'Grid\Core' ] [ 'enabledPackages' ] ) ) { foreach ( $ config [ 'modules' ] [ 'G...
Merge packages config
17,635
public function propertyContextFromReflection ( \ ReflectionProperty $ property , $ original ) { $ property -> setAccessible ( true ) ; $ context = new PropertyContext ( $ property -> name , $ property -> getValue ( $ original ) , $ property -> class ) ; return $ this -> parseAnnotations ( $ context , $ property , $ or...
Responsible for building property representation from \ ReflectionProperties in the form of PropertyContext
17,636
private function parseAnnotations ( PropertyContext $ context , \ ReflectionProperty $ property , $ original ) { $ annot = $ this -> propertyHandler -> getPropertyAnnotation ( $ property ) ; if ( $ annot ) { $ context = $ this -> handleRepresentProperty ( $ property , $ annot , $ context , $ original ) ; } return $ con...
Parses properties for annotations and delegates the handling of those annotations
17,637
private function handleRepresentProperty ( \ ReflectionProperty $ property , Property $ annot , PropertyContext $ context , $ original ) { if ( $ annot -> getName ( ) ) { $ context -> name = $ annot -> getName ( ) ; } if ( $ annot -> getType ( ) ) { $ context -> value = $ this -> propertyHandler -> handleTypeConversion...
Handles dealing with Represent \ Property annotation
17,638
public function registerShortcodes ( ) { if ( ! function_exists ( 'add_shortcode' ) ) { return ; } $ this -> shortcodes -> rewind ( ) ; while ( $ this -> shortcodes -> valid ( ) ) { $ shortcode = $ this -> shortcodes -> current ( ) ; add_shortcode ( $ shortcode -> getName ( ) , array ( $ shortcode , 'getCallback' ) ) ;...
Registers all shortcodes added
17,639
public function subscribe ( IObserver $ observer ) : IObservable { if ( ! \ in_array ( $ observer , $ this -> _observers , true ) ) { $ this -> _observers [ ] = $ observer ; } return $ this ; }
Subscribe a new observer to this observable implementation .
17,640
public function notify ( $ extras = null ) : IObservable { if ( 1 < \ count ( $ this -> _cache ) ) { $ this -> _cache [ ] = $ extras ; } else { $ this -> _cache = $ extras ; } foreach ( $ this -> _observers as $ ob ) { $ ob -> onUpdate ( $ this , $ this -> _cache ) ; } $ this -> _cache = [ ] ; return $ this ; }
Notify all subscribed observers
17,641
public function isFirstCall ( ) { if ( ! $ this -> stepAction && $ this -> stepCollection -> isFirst ( $ this -> stepCollectionIterator -> current ( ) ) ) return true ; else return false ; }
checks if the wizard is first time called
17,642
public function process ( ) { $ currentStep = $ this -> stepCollectionIterator -> current ( ) ; if ( $ this -> stepAction == self :: WIZARD_STEP_ACTION_PREV && ! $ this -> stepCollection -> isFirst ( $ this -> stepCollectionIterator -> current ( ) ) ) { $ currentStep -> leaveToAncestorStep ( ) ; $ this -> stepCollectio...
processing the step
17,643
private function createBreadcrumbItems ( StepController $ step ) { $ viewModel = new ViewModel ( ) ; $ viewModel -> setTemplate ( $ this -> breadcrumbTemplatePath ) ; $ viewModel -> setVariable ( "breadcrumbTitle" , $ step -> getBreadCrumbTitle ( ) ) ; $ viewModel -> setVariable ( "stepNumber" , $ step -> getBreadCrumb...
generate one elementView for the breadcrumb path
17,644
private function initStepViewModel ( ) { $ currentStep = $ this -> stepCollectionIterator -> current ( ) ; $ isFirstStep = $ this -> getSteps ( ) -> isFirst ( $ currentStep ) ; if ( $ isFirstStep ) { $ firstStep = $ this -> getSteps ( ) -> getFirst ( ) ; $ this -> viewModel -> addChild ( $ firstStep -> getViewModel ( )...
init the ViewModel for the wizard
17,645
private function toggleStandardWizardButtons ( $ show = true ) { $ this -> prevButtonViewModel -> setVariable ( "btnClass_extend" , ( ! $ show ? "hide" : "" ) , true ) ; $ this -> nextButtonViewModel -> setVariable ( "btnClass_extend" , ( ! $ show ? "hide" : "" ) , true ) ; }
toggle the visibility of the wizardbutton depending on wether the step is the last one or not
17,646
public static function assertLooselyEquals ( $ actual , $ expected , Throwable $ exception ) { static :: makeAssertion ( $ actual == $ expected , $ exception ) ; return $ actual ; }
Asserts that the given values are loosely equals .
17,647
public static function assertEquals ( $ actual , $ expected , Throwable $ exception ) { static :: makeAssertion ( $ actual === $ expected , $ exception ) ; return $ actual ; }
Asserts that the given values are strictly equals .
17,648
public static function assertLooselyNotEquals ( $ actual , $ expected , Throwable $ exception ) { static :: makeAssertion ( $ actual != $ expected , $ exception ) ; return $ actual ; }
Asserts that the given values are loosely not equals .
17,649
public static function assertNotEquals ( $ actual , $ expected , Throwable $ exception ) { static :: makeAssertion ( $ actual !== $ expected , $ exception ) ; return $ actual ; }
Asserts that the given values are strictly not equals .
17,650
public static function assertGreaterThanOrEquals ( $ actual , $ expected , Throwable $ exception ) : bool { static :: makeAssertion ( $ actual >= $ expected , $ exception ) ; return true ; }
Asserts that the given actual value is greater than or equals the expected value .
17,651
public static function assertGreaterThan ( $ actual , $ expected , Throwable $ exception ) : bool { static :: makeAssertion ( $ actual > $ expected , $ exception ) ; return true ; }
Asserts that the given actual value is strictly greater than the expected value .
17,652
public static function assertLessThanOrEquals ( $ actual , $ expected , Throwable $ exception ) : bool { static :: makeAssertion ( $ actual <= $ expected , $ exception ) ; return true ; }
Asserts that the given actual value is less than or equals the expected value .
17,653
public static function assertLessThan ( $ actual , $ expected , Throwable $ exception ) : bool { static :: makeAssertion ( $ actual < $ expected , $ exception ) ; return true ; }
Asserts that the given actual value is strictly less than the expected value .
17,654
public function output ( $ type = null ) { $ session = $ this -> _di -> getService ( "session" ) ; $ messages = $ session -> get ( "__flash__" ) ; if ( $ messages == null ) { return ; } if ( isset ( $ type ) ) { $ messages_type = implode ( $ messages [ $ type ] ) ; $ messages [ $ type ] = array ( ) ; $ session -> set (...
Returns the messages
17,655
public function contentUriAction ( ) { $ actual = $ this -> getSubDomainModel ( ) -> findActual ( ) ; if ( empty ( $ actual ) ) { $ this -> getResponse ( ) -> setStatusCode ( 404 ) ; return ; } $ uri = $ this -> params ( ) -> fromRoute ( 'uri' ) ; if ( ! mb_check_encoding ( $ uri , 'UTF-8' ) ) { $ this -> getResponse (...
Content - uri action
17,656
public function method ( $ name ) { $ method = new Method ( $ name ) ; $ this -> container -> put ( $ name , $ method ) ; return $ method ; }
Define a new mock method .
17,657
public function parse ( interfaces \ Tokens $ input , values \ Arguments $ arguments , values \ Options $ options ) : void { $ isParsingOptions = true ; $ input = $ input -> all ( ) ; while ( null !== $ token = array_shift ( $ input ) ) { if ( $ isParsingOptions ) { if ( '--' === $ token ) { $ isParsingOptions = false ...
Fill the given Input Arguments and Options based on their definitions and the Argv input given .
17,658
protected function parseLongOption ( string $ token , values \ Options $ options , array & $ input ) : void { $ name = substr ( $ token , 2 ) ; $ value = null ; if ( false !== $ pos = strpos ( $ name , '=' ) ) { $ value = substr ( $ name , $ pos + 1 ) ; $ name = substr ( $ name , 0 , $ pos ) ; } if ( ! isset ( $ value ...
Parses the given token as a long option and adds it to the Options set .
17,659
protected function parseShortOption ( $ token , values \ Options $ options , array & $ input ) : void { if ( empty ( $ shortcut = substr ( $ token , 1 ) ) ) { return ; } foreach ( $ this -> resolveShortOption ( $ shortcut , $ options ) as $ name => $ value ) { $ options -> set ( $ name , $ value ) ; } }
Parses the given token as a short option and adds it to the Options set .
17,660
private function resolveShortOptionSet ( string $ shortcut , definitions \ Options $ definitions ) : array { $ length = strlen ( $ shortcut ) ; $ result = [ ] ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ definition = $ definitions -> getByShortcut ( $ shortcut [ $ i ] ) ; if ( $ definition -> hasValue ( ) ) { $ resu...
Takes a set of short options contained in a string and resolves them to full options and their values depending on the Definitions given .
17,661
public function update ( $ other ) { if ( is_array ( $ other ) ) { $ this -> _array = $ other ; return $ this ; } $ this -> _array = array ( ) ; foreach ( $ other as $ key => $ value ) { $ this -> _array [ $ key ] = $ value ; } return $ this ; }
Updates the values of this hash with the values of other .
17,662
public static function fromKeys ( $ keys ) { $ hash = new Dictionary ( ) ; foreach ( $ keys as $ key ) { $ hash [ $ key ] = NULL ; } return $ hash ; }
Constructs a Hash with the passed keys
17,663
public function getAllowedMethods ( ) { $ result = [ ] ; if ( $ this -> get ) { $ result [ ] = HttpMethods :: GET ; } if ( $ this -> post ) { $ result [ ] = HttpMethods :: POST ; } if ( $ this -> put ) { $ result [ ] = HttpMethods :: PUT ; } if ( $ this -> path ) { $ result [ ] = HttpMethods :: PATCH ; } if ( $ this ->...
Get array of allowed methods for this action
17,664
public function login ( Request $ request ) { $ this -> validateLogin ( $ request ) ; if ( $ this -> hasTooManyLoginAttempts ( $ request ) ) { $ this -> fireLockoutEvent ( $ request ) ; return $ this -> sendLockoutResponse ( $ request ) ; } $ this -> incrementLoginAttempts ( $ request ) ; if ( ! $ this -> attemptLogin ...
Function which login users
17,665
public function showActivation ( string $ token ) { $ message = null ; $ tokenRecord = DB :: table ( 'hc_users_activations' ) -> where ( 'token' , $ token ) -> first ( ) ; if ( is_null ( $ tokenRecord ) ) { $ message = trans ( 'HCACL::users.activation.token_not_exists' ) ; } else { if ( strtotime ( $ tokenRecord -> cre...
Show activation page
17,666
public function send ( ) { if ( ! static :: isSent ( ) ) { static :: call ( 'send' , $ this ) ; foreach ( $ this -> headers as $ header => $ value ) { $ this -> setHttpHeader ( $ header , $ value ) ; } http_response_code ( $ this -> status ) ; echo $ this -> body ; static :: $ sent = true ; return true ; } return false...
Bastelt den Response zusammen und sendet diesen ab sofern er noch nicht abgesendet wurde .
17,667
protected function isAllModulesLoaded ( array $ modules ) { foreach ( $ modules as $ module ) { if ( ! $ this -> isModuleLoaded ( $ module ) ) { return false ; } } return true ; }
Is all modules loaded
17,668
public function isModulesLoaded ( $ modules ) { if ( $ modules instanceof Traversable ) { $ modules = ArrayUtils :: iteratorToArray ( $ modules ) ; } if ( ! is_array ( $ modules ) ) { $ modules = preg_split ( '/\|{1,2}/' , ( string ) $ modules ) ; } foreach ( $ modules as $ module ) { if ( ! is_array ( $ module ) ) { $...
Is any modules loaded
17,669
public static function factory ( $ type ) { if ( $ type instanceof TypeInterface ) return $ type ; if ( strpos ( $ type , "\\" ) === false ) { $ type = ucfirst ( trim ( strval ( $ type ) ) ) ; if ( strripos ( strrev ( $ type ) , strrev ( 'type' ) ) === false ) $ type .= 'Type' ; $ type = "DataEntity\\Type\\" . $ type ;...
Builds type objects
17,670
public static function to_assoc ( $ start = 1 ) { $ segments = array_slice ( static :: segments ( ) , ( $ start - 1 ) ) ; count ( $ segments ) % 2 and $ segments [ ] = null ; return \ Arr :: to_assoc ( $ segments ) ; }
Converts the current URI segments to an associative array . If the URI has an odd number of segments an empty value will be added .
17,671
public static function create ( $ uri = null , $ variables = array ( ) , $ get_variables = array ( ) , $ secure = null ) { $ url = '' ; is_null ( $ uri ) and $ uri = static :: string ( ) ; if ( ! preg_match ( "#^(http|https|ftp)://#i" , $ uri ) ) { $ url .= \ Config :: get ( 'base_url' ) ; if ( $ index_file = \ Config ...
Creates a url with the given uri including the base url
17,672
public static function base ( $ include_index = true ) { $ url = \ Config :: get ( 'base_url' ) ; if ( $ include_index and \ Config :: get ( 'index_file' ) ) { $ url .= \ Config :: get ( 'index_file' ) . '/' ; } return $ url ; }
Gets the base URL including the index_file if wanted .
17,673
public static function build_query_string ( ) { $ params = array ( ) ; foreach ( func_get_args ( ) as $ arg ) { $ arg = is_array ( $ arg ) ? $ arg : array ( $ arg => '1' ) ; $ params = array_merge ( $ params , $ arg ) ; } return http_build_query ( $ params ) ; }
Builds a query string by merging all array and string values passed . If a string is passed it will be assumed to be a switch and converted to string = 1 .
17,674
public static function update_query_string ( $ vars = array ( ) , $ uri = null , $ secure = null ) { if ( ! is_array ( $ vars ) ) { $ vars = array ( $ vars => $ uri ) ; $ uri = null ; } if ( $ uri === null ) { $ uri = static :: current ( ) ; $ vars = array_merge ( \ Input :: get ( ) , $ vars ) ; } return static :: crea...
Updates the query string of the current or passed URL with the data passed
17,675
public function get_segment ( $ segment , $ default = null ) { if ( isset ( $ this -> segments [ $ segment - 1 ] ) ) { return $ this -> segments [ $ segment - 1 ] ; } return \ Fuel :: value ( $ default ) ; }
Get the specified URI segment return default if it doesn t exist .
17,676
public static function enablePdoConnection ( ) { if ( is_null ( self :: $ instance ) ) { global $ wpdb ; $ capsule = new self ( ) ; $ capsule -> addConnection ( [ 'driver' => 'mysql' , 'host' => DB_HOST , 'database' => DB_NAME , 'username' => DB_USER , 'password' => DB_PASSWORD , 'charset' => 'utf8mb4' , 'collation' =>...
Enable PDO for eloquent
17,677
public function getRequest ( ) { if ( null === $ this -> request ) { $ this -> setRequest ( $ this -> getController ( ) -> getRequest ( ) ) ; } return $ this -> request ; }
Get request to be authenticated
17,678
public function getAuthenticationAdapter ( ) { if ( null === $ this -> authenticationAdapter ) { $ authenticationAdapter = $ this -> getAuthenticationService ( ) -> getAdapter ( ) ; $ this -> setAuthenticationAdapter ( $ authenticationAdapter ) ; } return $ this -> authenticationAdapter ; }
Get authentication adapter
17,679
public static function toUriString ( Request $ request ) { $ uri = clone $ request -> getUri ( ) ; $ uri -> setQuery ( array_merge ( $ uri -> getQueryAsArray ( ) , $ request -> getQuery ( ) -> toArray ( ) ) ) ; return $ uri -> toString ( ) ; }
Converts the request into a url .
17,680
public function attach ( ReaderInterface $ reader , $ last = true ) { if ( $ last ) { $ this -> readers [ ] = $ reader ; } else { array_unshift ( $ this -> readers , $ reader ) ; } $ this -> groups = [ ] ; }
Attach a new config reader
17,681
public function detach ( ReaderInterface $ reader ) { if ( ( $ key = array_search ( $ reader , $ this -> readers ) ) !== false ) { unset ( $ this -> readers [ $ key ] ) ; } $ this -> groups = [ ] ; }
Detach a config reader
17,682
public function load ( $ groupName ) { if ( ! count ( $ this -> readers ) ) { throw new \ RuntimeException ( 'No config readers attached' ) ; } if ( ! $ groupName ) { throw new \ InvalidArgumentException ( 'No config group specified' ) ; } if ( ! is_string ( $ groupName ) ) { throw new \ InvalidArgumentException ( 'Con...
Load configuration for a group
17,683
public function registerCall ( $ name , array $ arguments = [ ] ) { $ name = strtolower ( preg_replace ( "/([A-Z]{1})/" , "_$0" , $ name ) ) ; $ this -> calls = array_merge ( $ this -> calls , array_filter ( explode ( "_" , $ name ) ) ) ; if ( count ( $ arguments ) > 0 ) { $ lastIndex = count ( $ this -> calls ) - 1 ; ...
Registers a call .
17,684
protected function findTemplateFile ( $ file ) { $ ext = pathinfo ( $ file , PATHINFO_EXTENSION ) ; $ file = ( $ ext === '' ) ? $ file . '.' . $ this -> getExtension ( ) : $ file ; $ found = false ; foreach ( $ this -> locations as $ location ) { if ( is_file ( $ location . '/' . $ file ) ) { $ found = true ; $ file = ...
Finds the file by looping through locations
17,685
public function validateAuth ( ) { $ response = $ this -> uniRequest -> get ( implode ( [ $ this -> authURL , 'validate/' ] ) , $ this -> headers ) ; if ( in_array ( $ response -> code , $ this -> validCodes ) ) { return $ response ; } else { throw new Exception ( $ response -> body -> message , $ response -> code ) ; ...
Validate Authenticated Session
17,686
public function all ( ) { $ this -> resumeOrStartSession ( ) ; return isset ( $ _SESSION [ $ this -> name ] ) ? $ _SESSION [ $ this -> name ] : [ ] ; }
Get all of the session data .
17,687
public function remove ( $ key ) { if ( isset ( $ _SESSION [ $ this -> name ] [ $ key ] ) ) { $ value = $ _SESSION [ $ this -> name ] [ $ key ] ; unset ( $ _SESSION [ $ this -> name ] [ $ key ] ) ; return $ value ; } return null ; }
Remove an item from the session returning its value .
17,688
public function rollback ( ) : bool { $ sql = 'ROLLBACK' ; if ( ! $ this -> transactionStarted ) { $ event = new TimerEvent ( 'db.query' ) ; $ this -> emitQueryEvent ( $ event , null , $ sql ) ; throw new QueryException ( $ this , $ sql , "Can't rollback unstarted transaction" ) ; } $ this -> query ( $ sql ) ; $ this -...
Rollback a sql transaction .
17,689
public function & __get ( $ property ) { $ getter = 'get' . \ ucfirst ( $ property ) ; if ( \ in_array ( $ property , array ( 'alerts' , 'cfg' , 'status' ) ) ) { return $ this -> { $ property } ; } elseif ( \ method_exists ( $ this , $ getter ) ) { $ return = $ this -> { $ getter } ( ) ; return $ return ; } elseif ( is...
Get protected properties
17,690
public function getField ( $ fieldName ) { $ this -> debug -> group ( __METHOD__ , $ fieldName ) ; $ field = false ; if ( \ preg_match ( '|^(.*?)[/.](.*)$|' , $ fieldName , $ matches ) ) { $ pageName = $ matches [ 1 ] ; $ fieldName = $ matches [ 2 ] ; } else { $ pageName = $ this -> status [ 'currentPageName' ] ; } if ...
Get form field
17,691
public function getInvalidFields ( ) { $ invalidFields = array ( ) ; foreach ( $ this -> currentFields as $ field ) { if ( ! $ field -> isValid ) { $ invalidFields [ ] = $ field ; } } return $ invalidFields ; }
Get list of invalid fields
17,692
public function setCurrentFields ( $ i = null ) { $ this -> debug -> groupCollapsed ( __METHOD__ , $ i ) ; $ this -> debug -> groupUncollapse ( ) ; $ cfg = & $ this -> cfg ; $ status = & $ this -> status ; if ( isset ( $ i ) ) { $ this -> status [ 'submitted' ] = false ; $ this -> persist -> set ( 'i' , $ i ) ; } $ thi...
Set current page
17,693
protected function buildField ( $ fieldProps , $ nameDefault = null ) { $ this -> debug -> group ( __METHOD__ , $ nameDefault ) ; if ( ! isset ( $ fieldProps [ 'attribs' ] [ 'name' ] ) && ! isset ( $ fieldProps [ 'name' ] ) ) { $ fieldProps [ 'attribs' ] [ 'name' ] = $ nameDefault ; } if ( ! empty ( $ fieldProps [ 'new...
Build field object
17,694
protected function buildFields ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ status = & $ this -> status ; $ persist = $ this -> persist ; $ pageI = $ this -> persist -> get ( 'i' ) ; $ submitFieldCount = 0 ; $ keys = \ array_keys ( $ this -> currentFields ) ; foreach ( $ keys as $ k ) { $ field = $ this -...
Build current fields
17,695
private function initPersist ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ this -> persist = new Persist ( $ this -> cfg [ 'name' ] , array ( 'persist' => $ this -> cfg [ 'persist' ] , 'trashCollectable' => $ this -> cfg [ 'trashCollectable' ] , 'userKey' => $ this -> cfg [ 'verifyKey' ] ? ( isset ( $ _REQ...
Initialize persist object
17,696
private function pagesAddEnd ( $ pagesEnd = array ( ) ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ this -> persist -> appendPages ( $ pagesEnd ) ; $ this -> debug -> groupEnd ( ) ; }
Add pages to end of form
17,697
private function pagesAddNext ( $ pagesNext = array ( ) ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ pagesNext = \ array_values ( $ pagesNext ) ; $ pages = $ this -> persist -> get ( 'pages' ) ; $ iCur = $ this -> persist -> get ( 'i' ) ; $ currentPage = $ pages [ $ iCur ] ; $ offset = $ iCur + \ count ( $ ...
Add pages to be seen immediately after current page
17,698
private function processSubmit ( ) { $ this -> debug -> group ( __METHOD__ ) ; $ this -> debug -> groupUncollapse ( ) ; $ cfg = & $ this -> cfg ; $ status = & $ this -> status ; if ( $ status [ 'submitted' ] ) { $ this -> validate ( ) ; if ( \ is_callable ( $ cfg [ 'post' ] ) ) { $ return = \ call_user_func ( $ cfg [ '...
Process submitted values
17,699
private function redirectPost ( ) { if ( ! isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { return ; } if ( ! isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) || $ _SERVER [ 'REQUEST_METHOD' ] != 'POST' ) { return ; } if ( ! $ this -> cfg [ 'prg' ] ) { return ; } if ( ! $ this -> status [ 'submitted' ] ) { return ; } $ this -> debug ...
Stores submitted values in persistence Redirects if submoitted via POST