idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
56,900
|
public static function setBaseDir ( $ path ) { $ path = realpath ( rtrim ( $ path , '/\\ ' ) ) ; if ( $ path === false ) { throw new \ InvalidArgumentException ( "cat`t get real path: seems like path does`t exists: $path" ) ; } return static :: $ baseDir = $ path ; }
|
Sets path of the directory where config files are stored .
|
56,901
|
public function register ( ) { $ events = $ this -> app -> config ( 'event' ) ; foreach ( $ events as $ name => $ handlers ) { $ this -> events [ $ name ] = $ handlers ; } }
|
Bootstrap registered events
|
56,902
|
public function listen ( $ event , $ handler ) { if ( array_key_exists ( $ event , $ this -> broadcast ) ) { $ eventObject = $ this -> getEventObject ( $ event , $ this -> broadcast [ $ event ] ) ; if ( is_callable ( $ handler ) ) { call_user_func_array ( $ handler , [ $ eventObject ] ) ; } else { call_user_func_array ( [ $ this -> app -> make ( $ handler ) , 'listen' ] , [ $ eventObject ] ) ; } } }
|
Event listener to listen broadcast
|
56,903
|
protected function execute ( $ event ) { foreach ( $ this -> events [ $ event ] as $ handler ) { $ this -> listen ( $ event , $ handler ) ; } }
|
Listening all broadcast events
|
56,904
|
protected function getEventObject ( $ event , $ data ) { $ eventClass = new ReflectionClass ( $ this -> getEventClass ( $ event ) ) ; return $ eventClass -> newInstanceArgs ( $ data ) ; }
|
Get event class object
|
56,905
|
public static function getDefaultInputOptions ( ) { $ inputOptions = array ( new InputOption ( 'filter' , null , InputOption :: VALUE_REQUIRED | InputOption :: VALUE_IS_ARRAY , 'A string pattern used to match entities that should be mapped' ) , new InputOption ( 'force' , 'f' , null , 'Override existing extension' ) , new InputOption ( 'round-trip' , 'r' , null , 'Roundtrip existing extension' ) , ) ; return $ inputOptions ; }
|
Get command options for all environments .
|
56,906
|
private function mergeDefaults ( $ options ) { $ defaults = $ this -> defaults ; if ( ! empty ( $ defaults [ 'headers' ] ) && ! empty ( $ options [ 'headers' ] ) ) { $ lkeys = [ ] ; foreach ( array_keys ( $ options [ 'headers' ] ) as $ k ) { $ lkeys [ strtolower ( $ k ) ] = true ; } foreach ( $ defaults [ 'headers' ] as $ key => $ value ) { if ( ! isset ( $ lkeys [ strtolower ( $ key ) ] ) ) { $ options [ 'headers' ] [ $ key ] = $ value ; } } unset ( $ defaults [ 'headers' ] ) ; } $ result = array_replace_recursive ( $ defaults , $ options ) ; foreach ( $ options as $ k => $ v ) { if ( $ v === null ) { unset ( $ result [ $ k ] ) ; } } return $ result ; }
|
Merges default options into the array passed by reference .
|
56,907
|
public function execute ( $ command ) { $ retValue = $ this -> _conn -> query ( $ command ) -> fetchAll ( ) ; if ( $ this -> error ( $ this -> _conn -> error ( ) ) ) return array ( ) ; else return $ retValue ; }
|
Execute Command in DataBase
|
56,908
|
public static function template ( $ template , $ parameters , $ startChar = '%' , $ endChar = '%' ) { foreach ( $ parameters as $ key => $ value ) { $ template = str_replace ( $ startChar . $ key . $ endChar , $ value , $ template ) ; } return $ template ; }
|
Replace %key% from template string with their value from parameters array
|
56,909
|
public function process ( ContainerBuilder $ container ) { $ this -> addFilters ( $ container , 'pre' ) ; $ this -> addFilters ( $ container , 'post' ) ; $ this -> addFilters ( $ container , 'output' ) ; }
|
You can modify the container here before it is dumped to PHP code . r
|
56,910
|
public function bind ( $ eventName , $ callback , $ mode = self :: BINDING_MODE_LAST ) { $ alias = false ; if ( $ callback instanceof AliasedCallback ) { $ alias = $ callback -> getAlias ( ) ; $ callback = $ callback -> getCallback ( ) ; if ( ! isset ( $ this -> aliases [ $ alias ] ) ) { $ this -> aliases [ $ alias ] = & $ callback ; } else { throw new EventException ( sprintf ( 'Alias "%s" is already bound to another callback' , $ alias ) , EventException :: INVALID_CALLBACK ) ; } } else { if ( is_string ( $ callback ) && ! is_callable ( $ callback ) ) { if ( isset ( $ this -> aliases [ $ callback ] ) ) { $ alias = $ callback ; $ callback = $ this -> aliases [ $ callback ] ; } } else { $ alias = false ; } } if ( ! is_callable ( $ callback ) && ! $ callback instanceof CallbacksAggregate && ! class_exists ( $ callback ) ) { throw new EventException ( 'Callback must be a callable, an invokable class name, a service reference or a CallbacksAggregate' , EventException :: INVALID_CALLBACK ) ; } if ( ! isset ( $ this -> listeners [ $ eventName ] ) || $ mode == self :: BINDING_MODE_REPLACE ) { $ this -> listeners [ $ eventName ] = [ ] ; } switch ( $ mode ) { case self :: BINDING_MODE_FIRST : if ( $ alias ) { $ this -> listeners [ $ eventName ] = array_merge ( [ $ alias => $ callback ] , $ this -> listeners [ $ eventName ] ) ; } else { array_unshift ( $ this -> listeners [ $ eventName ] , $ callback ) ; } break ; case self :: BINDING_MODE_REPLACE : case self :: BINDING_MODE_LAST : if ( $ alias ) { $ this -> listeners [ $ eventName ] [ $ alias ] = $ callback ; } else { $ this -> listeners [ $ eventName ] [ ] = $ callback ; } break ; } return $ this ; }
|
Attaches a callback to an event
|
56,911
|
private function loop ( ) { $ c = $ this -> controller ; if ( is_callable ( [ $ c , 'throttle' ] ) ) { $ throttle = function ( ) use ( $ c ) { return $ c -> throttle ( ) ; } ; } else { $ throttle = function ( ) { return $ this -> throttle ( ) ; } ; } while ( $ c -> signal ( ) ) { $ c -> process ( ) ; time_nanosleep ( 0 , $ throttle ( ) ) ; } }
|
Execute the primary daemon runtime loop
|
56,912
|
public function throttle ( ) { if ( ( time ( ) - $ this -> lastCpuCheck ) >= $ this -> cpuCheckFrequency ) { $ load = sys_getloadavg ( ) ; if ( $ load [ 0 ] / $ this -> cpuCount >= $ this -> cpuTarget ) { $ this -> pause += $ this -> throttleSensitivity ; $ this -> controller -> notify ( 'Daemon throttling down' ) ; } else { $ this -> pause -= $ this -> throttleSensitivity ; $ this -> controller -> notify ( 'Daemon throttling up' ) ; } $ this -> lastCpuCheck = time ( ) ; } if ( $ this -> pause < 1 ) { $ this -> pause = 1 ; } return $ this -> pause ; }
|
Determine the throttle execution time available to the public
|
56,913
|
public function buildForm ( FormBuilderInterface $ builder , array $ options ) { $ builder -> addEventListener ( FormEvents :: PRE_SET_DATA , function ( FormEvent $ event ) use ( $ builder , $ options ) { if ( empty ( $ options [ 'templates' ] ) ) { return ; } $ event -> getForm ( ) -> add ( '_template' , ChoiceType :: class , array ( 'required' => true , 'choices' => $ options [ 'templates' ] , ) ) ; } ) ; }
|
Static component form definition .
|
56,914
|
public static function installConfig ( ) { $ conf_tgt = self :: get ( 'app_config_filepath' ) ; $ i18n_tgt = self :: get ( 'app_i18n_filepath' ) ; if ( false === @ file_exists ( $ conf_tgt ) ) { $ conf_src = self :: getPath ( 'config' ) . self :: $ _defaults [ 'filenames' ] [ 'app_config' ] ; if ( false === @ copy ( $ conf_src , $ conf_tgt ) ) { throw new \ Exception ( sprintf ( 'Can not copy distributed configuration file to "%s"!' , self :: getPath ( 'app_config' , true ) ) ) ; } } if ( false === @ file_exists ( $ i18n_tgt ) ) { $ i18n_src = self :: getPath ( 'config' ) . self :: $ _defaults [ 'filenames' ] [ 'app_i18n' ] ; if ( false === @ copy ( $ i18n_src , $ i18n_tgt ) ) { throw new \ Exception ( sprintf ( 'Can not copy distributed language file to "%s"!' , self :: getPath ( 'app_i18n' , true ) ) ) ; } } return true ; }
|
Install WebDocBook s config files
|
56,915
|
public static function isWorkflowMessage ( $ aMessageName ) { $ match = array ( ) ; preg_match ( static :: MESSAGE_PARTS_PATTERN , $ aMessageName , $ match ) ; if ( isset ( $ match [ 'message' ] ) ) { $ choices = array_merge ( static :: $ commandSuffixes , static :: $ eventSuffixes ) ; return in_array ( $ match [ 'message' ] , $ choices ) ; } return false ; }
|
Is given message name a processing command or processing event
|
56,916
|
public static function isProcessingCommand ( $ aMessageName ) { $ match = array ( ) ; preg_match ( static :: MESSAGE_PARTS_PATTERN , $ aMessageName , $ match ) ; if ( isset ( $ match [ 'message' ] ) ) { return in_array ( $ match [ 'message' ] , static :: $ commandSuffixes ) ; } return false ; }
|
Is given message name a processing command
|
56,917
|
public static function isProcessingEvent ( $ aMessageName ) { $ match = array ( ) ; preg_match ( static :: MESSAGE_PARTS_PATTERN , $ aMessageName , $ match ) ; if ( isset ( $ match [ 'message' ] ) ) { return in_array ( $ match [ 'message' ] , static :: $ eventSuffixes ) ; } return false ; }
|
Is given message name a processing event
|
56,918
|
protected static function append ( $ path ) { if ( is_dir ( $ path ) ) { $ env = ( is_admin ( ) ) ? 'admin' : 'front' ; static :: requireFiles ( $ path ) ; static :: requireFiles ( $ path . "/{$env}" ) ; return true ; } return false ; }
|
Validate the path and require common and environment files
|
56,919
|
public static function requireFiles ( $ path ) { $ dir = new \ DirectoryIterator ( $ path ) ; foreach ( $ dir as $ file ) { if ( ! $ file -> isDot ( ) || ! $ file -> isDir ( ) ) { $ file_extension = pathinfo ( $ file -> getFilename ( ) , PATHINFO_EXTENSION ) ; if ( $ file_extension === 'php' ) { static :: $ names [ ] = $ file -> getBasename ( '.php' ) ; include_once $ file -> getPath ( ) . DS . $ file -> getBasename ( ) ; } } } }
|
Scan the directory at the given path and include all files . Only 1 level iteration .
|
56,920
|
public function publishScaffoldTemplates ( ) { $ templateType = config ( 'jiyis.laravel_generator.templates' , 'core-templates' ) ; $ templatesPath = base_path ( 'vendor/jiyis/' . $ templateType . '/templates/scaffold' ) ; return $ this -> publishDirectory ( $ templatesPath , $ this -> templatesDir . '/scaffold' , 'jiyis-generator-templates/scaffold' , true ) ; }
|
Publishes templates .
|
56,921
|
public function prepareSession ( NativeSession $ session , Injector $ injector ) { if ( $ this -> canSessionStart ( ) && $ this -> isCli ( ) === false ) { $ this -> startSession ( ) ; } }
|
Initialize the session
|
56,922
|
public function findLocaleFile ( $ file ) { $ app = $ this -> service -> getKernel ( ) -> getApplication ( ) ; $ locale = $ app -> getLocalization ( ) -> getLocale ( ) ; $ repo = $ this -> service -> getResourceRepository ( ) ; $ workDownLanguageTag = function ( $ locale , $ next ) use ( $ repo , $ file ) { if ( strpos ( $ locale , '-' ) === false ) { return null ; } $ locale = implode ( '-' , array_slice ( explode ( '-' , $ locale ) , 0 , - 1 ) ) ; $ filename = str_replace ( '{locale}' , $ locale , $ file ) ; if ( ! $ repo -> contains ( $ filename ) ) { $ filename = $ next ( $ locale , $ next ) ; } return $ filename ; } ; $ filename = $ workDownLanguageTag ( $ locale , $ workDownLanguageTag ) ; if ( $ filename === null ) { $ filename = str_replace ( '{locale}' , 'en' , $ file ) ; if ( ! $ repo -> contains ( $ filename ) ) { $ filename = null ; } } return $ filename ; }
|
Finds a localized file by working down the language - tag using the apps associated locale and finally english as fallback
|
56,923
|
public function loadLocaleFile ( $ file , $ domain ) { $ filename = $ this -> findLocaleFile ( $ file ) ; if ( $ filename !== null ) { $ locale = $ this -> getLocaleFromFilename ( $ filename ) ; $ translator = $ this -> service -> getTranslator ( ) ; $ translator -> addResource ( 'json' , $ filename , $ locale , $ domain ) ; } }
|
Load a locale file into the translator
|
56,924
|
public function check ( string $ password , string $ hashedPassword ) : bool { return $ hashedPassword === $ this -> hash ( $ password ) ; }
|
Check hash . Generate hash for user provided password and check against existing hash .
|
56,925
|
public function set ( ) { try { $ this -> loadEnv ( ) ; $ this -> setPhpIni ( getenv ( 'WP_ENV' ) ? : 'development' ) ; $ this -> setConfig ( getenv ( 'WP_ENV' ) ? : 'development' ) ; $ this -> registerMuLoaderLoader ( ) ; $ this -> registerMultiSitePath ( ) ; } catch ( \ RuntimeException $ e ) { die ( '<h1>Configuration could not be loaded.</h1>' ) ; } return $ this ; }
|
Set the local WordPress configuration
|
56,926
|
public function getConfig ( $ config ) { return getenv ( $ config ) ? : $ this -> getDefault ( $ config , $ this -> getEnvConfig ( "config.{$config}" , WP_ENV ) ) ; }
|
Get a config value
|
56,927
|
protected function loadEnv ( ) { try { $ this -> dotenv -> load ( ) ; $ this -> dotenv -> required ( $ this -> required ) ; } catch ( \ InvalidArgumentException $ e ) { } }
|
Use Dotenv to set required environment variables from . env file in root
|
56,928
|
protected function setPhpIni ( $ env = 'development' ) { foreach ( $ this -> getPhpIni ( $ env ) as $ varname => $ newvalue ) { ini_set ( $ varname , $ newvalue ) ; } }
|
Set custom PHP ini settings
|
56,929
|
protected function setConfig ( $ env = 'development' ) { define ( 'WP_ENV' , $ env ) ; $ configs = array_merge ( $ this -> minimal , array_keys ( $ this -> getArrayDot ( $ this -> config , "config" , [ ] ) ) , array_keys ( $ this -> getArrayDot ( $ this -> config , "env.{$env}.config" , [ ] ) ) ) ; foreach ( $ configs as $ config ) { if ( ! defined ( $ config ) ) { define ( $ config , $ this -> getConfig ( $ config ) ) ; } } }
|
Set the WordPress configuration constants
|
56,930
|
protected function getJsonConfig ( $ file ) { $ configFile = $ this -> path . DIRECTORY_SEPARATOR . $ file ; if ( ! file_exists ( $ this -> path . DIRECTORY_SEPARATOR . $ file ) ) { trigger_error ( "Couldn't load Autobahn config from `{$configFile}`: File not found." , E_USER_NOTICE ) ; return [ ] ; } $ config = json_decode ( file_get_contents ( $ configFile ) , true ) ; if ( is_null ( $ config ) ) { trigger_error ( "'Couldn't load Autobahn config from `{$configFile}`: Invalid JSON (" . json_last_error_msg ( ) . ")." , E_USER_WARNING ) ; } return $ config ; }
|
Get the contents of the local configuration file
|
56,931
|
protected function getDefault ( $ name , $ real ) { if ( ! is_null ( $ real ) ) { return $ real ; } if ( isset ( $ this -> defaults [ $ name ] ) ) { return $ this -> defaults [ $ name ] ; } switch ( $ name ) { case 'WP_CONTENT_DIR' : return $ this -> path . PUBLIC_DIR . CONTENT_DIR ; case 'WP_SITEURL' : return WP_HOME . WORDPRESS_DIR ; case 'WP_CONTENT_URL' : return WP_HOME . CONTENT_DIR ; case 'ABSPATH' : return $ this -> path . PUBLIC_DIR . WORDPRESS_DIR . DIRECTORY_SEPARATOR ; default : return $ real ; } }
|
Get default config value if real one does not exist
|
56,932
|
protected function getEnvConfig ( $ name , $ env = 'development' ) { $ default = $ this -> getArrayDot ( $ this -> config , $ name , null ) ; $ env = $ this -> getArrayDot ( $ this -> config , "env.{$env}.{$name}" , null ) ; if ( is_array ( $ default ) && is_array ( $ env ) ) { return array_replace_recursive ( $ default , $ env ) ; } if ( ! is_null ( $ env ) ) { return $ env ; } return $ default ; }
|
Get the environment depend config value in dot syntax
|
56,933
|
protected function registerMuLoaderLoader ( ) { if ( defined ( 'WPMU_LOADER' ) ) { $ this -> addFilter ( 'muplugins_loaded' , function ( ) { if ( defined ( 'WPMU_LOADER' ) && file_exists ( WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . WPMU_LOADER ) ) { require_once ( WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . WPMU_LOADER ) ; } } , PHP_INT_MIN ) ; } }
|
Register the mu - loader loader with wordpress action array
|
56,934
|
protected function addFilter ( $ tag , $ function_to_add , $ priority = 10 , $ accepted_args = 1 ) { global $ wp_filter ; $ idx = $ this -> filterBuildUniqueId ( $ function_to_add ) ; $ wp_filter [ $ tag ] [ $ priority ] [ $ idx ] = array ( 'function' => $ function_to_add , 'accepted_args' => $ accepted_args ) ; return true ; }
|
Add a WordPress filter before WordPress is loaded
|
56,935
|
public function launch ( ) { if ( $ this -> _app_root === null ) { throw new FemtoException ( 'You must define the application route first, do so by calling $femto->setAppRoot($dir)' ) ; } try { $ this -> _request_uri = str_replace ( array ( '?' , $ _SERVER [ 'QUERY_STRING' ] ) , '' , $ _SERVER [ 'REQUEST_URI' ] ) ; $ this -> _loadPage ( trim ( $ this -> _request_uri === '/' ? 'index' : $ this -> _request_uri , '/' ) ) ; } catch ( FemtoPageNotFoundException $ e ) { header ( 'HTTP/1.1 404 Not Found' ) ; $ this -> _resetTemplate ( ) ; try { $ this -> _loadPage ( '404' ) ; } catch ( Exception $ e ) { } } catch ( Exception $ e ) { ob_end_clean ( ) ; header ( 'HTTP/1.1 500 Internal Server Error' ) ; $ this -> _resetTemplate ( ) ; $ this -> _loadPage ( '500' , array ( 'e' => $ e ) ) ; } }
|
The Femto application launcher used in the index . php file
|
56,936
|
public function getConfig ( $ type , $ variable ) { if ( ! isset ( $ this -> _config [ $ type ] ) ) { $ config = $ this -> _loadFile ( $ type , 'config' ) ; if ( ! is_array ( $ config ) ) { throw new FemtoException ( "Unable to parse config of type '{$type}'" ) ; } $ this -> _config [ $ type ] = $ config ; } if ( isset ( $ this -> _config [ $ type ] [ $ variable ] ) ) { return $ this -> _config [ $ type ] [ $ variable ] ; } throw new FemtoException ( "Unable to locate config variable '{$variable}' of type '{$type}' in file " . $ this -> _getFilePath ( $ type , 'config' ) ) ; }
|
Helper function used to retrieve config variables
|
56,937
|
public function useTemplate ( $ name , $ variables = false ) { $ this -> template = $ name ; $ this -> _template_vars = $ variables ? $ variables : array ( ) ; }
|
Can be called from pages to specifiy a template that they want to use
|
56,938
|
public function getUrlPart ( $ part_number ) { $ request_uri = array_filter ( explode ( '/' , $ this -> _request_uri ) , function ( $ part ) { return ! empty ( $ part ) ; } ) ; return ! empty ( $ request_uri [ $ part_number ] ) ? $ request_uri [ $ part_number ] : null ; }
|
Returns a part of the url or null if it doesn t exist
|
56,939
|
private function _loadPage ( $ page , $ variables = false ) { ob_start ( ) ; $ this -> page = $ page ; $ this -> _loadFile ( $ this -> page , 'page' , $ variables ) ; if ( $ this -> template !== null ) { $ this -> _template_content = ob_get_clean ( ) ; ob_start ( ) ; $ this -> _loadFile ( $ this -> template , 'template' , $ this -> _template_vars ) ; } ob_end_flush ( ) ; }
|
Tries to load a page
|
56,940
|
private function _getFilePath ( $ file , $ type ) { if ( ! in_array ( $ type , array ( 'page' , 'template' , 'fragment' , 'config' ) ) ) { throw new FemtoException ( "The type of file '{$type}' is not supported by Femto" ) ; } $ file = str_replace ( '..' , '' , $ file ) ; $ type = $ type === 'config' ? $ type : "{$type}s" ; return "{$this->_app_root}/{$type}/{$file}.php" ; }
|
Helper function to return the file path for a file of a given type
|
56,941
|
public function create ( $ blueprint ) { $ name = $ blueprint -> name ; $ type = $ blueprint -> type ; if ( ! isset ( $ this -> count [ $ name ] ) ) { $ this -> count [ $ name ] = 0 ; } $ count = ++ $ this -> count [ $ name ] ; $ values = $ blueprint -> values ( ) ; $ strings = array_map ( function ( $ value ) use ( $ count ) { return str_replace ( '#{sn}' , str_pad ( $ count , 4 , '0' , STR_PAD_LEFT ) , $ value ) ; } , $ blueprint -> strings ( ) ) ; $ relationships = $ blueprint -> relationships ( ) ; foreach ( $ relationships as $ key => $ relationship ) { $ relationships [ $ key ] = $ relationship -> create ( $ blueprint -> persisted ) ; } $ values = array_merge ( $ values , $ strings , $ relationships ) ; $ dependencies = array_map ( function ( $ value ) use ( $ values ) { return $ value -> meet ( $ values ) ; } , $ blueprint -> dependencies ( ) ) ; $ values = array_merge ( $ values , $ dependencies ) ; $ object = $ this -> to_object ( $ name , $ values ) ; if ( false == $ blueprint -> persisted ) { return $ object ; } \ Phactory :: triggers ( ) -> beforeSave ( $ name , $ type , $ object ) ; $ object = $ this -> save_object ( $ name , $ object ) ; \ Phactory :: triggers ( ) -> afterSave ( $ name , $ type , $ object ) ; return $ object ; }
|
Converts a blueprint array into a persisted object
|
56,942
|
function write ( ) { if ( strlen ( $ this -> query ) ) { $ this -> query .= " " ; } $ this -> query .= array_reduce ( func_get_args ( ) , array ( $ this , "reduce" ) ) ; return $ this ; }
|
Append to the query string
|
56,943
|
function param ( $ param , $ type = null ) { if ( $ param instanceof ExpressibleInterface ) { $ param = $ param -> get ( ) ; } if ( $ param instanceof Expr ) { return ( string ) $ param ; } $ this -> params [ ] = $ param ; $ this -> types [ ] = $ type ; return "\$" . count ( $ this -> params ) ; }
|
Write a param placeholder and push the param onto the param list
|
56,944
|
private function connect ( ) { $ memcache = new Memcached ( ) ; $ memcache -> addServer ( $ this -> host , $ this -> port ) ; if ( null !== $ this -> prefix ) { $ memcache -> setOption ( Memcached :: OPT_PREFIX_KEY , $ this -> prefix ) ; } $ this -> memcached = $ memcache ; }
|
Connect to Memcache .
|
56,945
|
private function setSplit ( $ key , $ value ) { $ values = str_split ( $ value , self :: VALUE_SPLIT_SIZE ) ; $ to_set = array ( ) ; $ to_set [ $ key ] = self :: VALUE_SPLIT . count ( $ values ) ; foreach ( $ values as $ part_nr => $ v ) { $ to_set [ $ key . $ part_nr ] = $ v ; } if ( false === $ this -> memcached -> setMulti ( $ to_set ) ) { $ msg = sprintf ( 'Unable to store split values for key "%s": %s.' , $ key , $ this -> memcached -> getResultMessage ( ) ) ; $ this -> getLogger ( ) -> log ( LogLevel :: NOTICE , $ msg ) ; throw new \ RuntimeException ( $ msg ) ; } return $ value ; }
|
Split a value in different parts and add them one by one .
|
56,946
|
private function getSplit ( $ key , $ parts ) { $ keys = array ( ) ; for ( $ i = 0 ; $ i < $ parts ; $ i ++ ) { $ keys [ ] = $ key . $ i ; } $ values = $ this -> memcached -> getMulti ( $ keys ) ; if ( false === $ values ) { $ msg = sprintf ( 'Unable to retrieve split key "%s": %s.' , $ key , $ this -> memcached -> getResultMessage ( ) ) ; $ this -> getLogger ( ) -> log ( LogLevel :: NOTICE , $ msg ) ; throw new \ RuntimeException ( $ msg ) ; } $ value = implode ( '' , $ values ) ; return $ value ; }
|
Retrieve the individual parts of a split value .
|
56,947
|
private function removeSplit ( $ key , $ parts ) { $ keys = array ( ) ; $ keys [ ] = $ key ; for ( $ i = 0 ; $ i < $ parts ; $ i ++ ) { $ keys [ ] = $ key . $ i ; } if ( false === $ this -> memcached -> deleteMulti ( $ keys ) ) { $ msg = sprintf ( 'Unable to remove split values for key "%s": %s.' , $ key , $ this -> memcached -> getResultMessage ( ) ) ; $ this -> getLogger ( ) -> log ( LogLevel :: NOTICE , $ msg ) ; throw new \ RuntimeException ( $ msg ) ; } }
|
Remove the individual items of a split value .
|
56,948
|
private function getNumberOfParts ( $ key , $ value ) { $ parts = substr ( $ value , strlen ( self :: VALUE_SPLIT ) ) ; if ( ! ctype_digit ( $ parts ) || $ parts > PHP_INT_MAX ) { throw new \ RuntimeException ( 'Number of parts in split value for key "' . $ key . '" is invalid.' ) ; } return ( int ) $ parts ; }
|
Returns the number if parts for the split value .
|
56,949
|
protected function setConfig ( array $ config = array ( ) ) { $ this -> config = $ config ; if ( isset ( $ config [ 'prefix' ] ) ) { $ this -> prefix = $ config [ 'prefix' ] ; } if ( isset ( $ config [ 'host' ] ) ) { $ this -> host = $ config [ 'host' ] ; } if ( isset ( $ config [ 'port' ] ) ) { $ this -> port = $ config [ 'port' ] ; } return $ this ; }
|
Set the configuration .
|
56,950
|
private function __disconnect ( ) { if ( is_null ( $ this -> memcache ) ) { return ; } $ this -> memcache -> close ( ) ; $ this -> memcache = null ; return true ; }
|
Disconnects from a sharded server host
|
56,951
|
public function setCacheDir ( $ dir ) { $ this -> cacheDir = $ dir ; if ( ! is_dir ( $ this -> cacheDir ) ) { $ this -> createDir ( $ this -> cacheDir ) ; } }
|
Sets cache directory path
|
56,952
|
public function assign ( $ name , $ value = null ) { if ( is_string ( $ name ) ) { return $ this -> data [ $ name ] = $ value ; } if ( is_array ( $ name ) ) { return $ this -> assignFromArray ( $ name ) ; } throw new \ InvalidArgumentException ( "Invalid data type for key, '" . gettype ( $ name ) . "' given." ) ; }
|
Assings a variable to the template file
|
56,953
|
protected function assignFromArray ( $ data ) { if ( ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( "Invalid data type: argument should be array, '" . gettype ( $ name ) . "' given." ) ; } foreach ( $ data as $ key => $ value ) { $ this -> assign ( $ key , $ value ) ; } }
|
Multiple variable assignment
|
56,954
|
public function store ( $ message , $ bucket ) { $ resolver = new Resolver ( $ this -> configDirectory ) ; $ driver = $ resolver -> getDriver ( ) ; if ( true === $ driver -> store ( $ message , $ bucket ) ) { return true ; } return false ; }
|
Store the notifications
|
56,955
|
public function fetch ( $ bucket ) { $ resolver = new Resolver ( $ this -> configDirectory ) ; $ driver = $ resolver -> getDriver ( ) ; return $ driver -> fetch ( $ bucket ) ; }
|
Fetch the notifications
|
56,956
|
public function publishPact ( $ providerName , $ consumerName , $ version , $ contract ) { $ request = null ; if ( $ contract instanceof \ JsonSerializable ) { $ request = $ this -> requestBuilder -> createPublishPactRequestFromObject ( $ this -> baseUrl , $ consumerName , $ providerName , $ version , $ contract ) ; } else if ( is_string ( $ contract ) ) { $ request = $ this -> requestBuilder -> createPublishPactRequestFromFile ( $ this -> baseUrl , $ consumerName , $ providerName , $ version , $ contract ) ; } if ( ! $ request ) { throw new PactBrokerException ( "Can't publish contract file. Contract in wrong type." ) ; } $ response = $ this -> client -> sendRequest ( $ request ) ; $ this -> checkIfResponseIsCorrect ( $ response ) ; return $ response ; }
|
Publishes pact to pact broker
|
56,957
|
public function tagVersion ( $ consumerName , $ version , $ tagName ) { $ request = $ this -> requestBuilder -> createTagVersionRequest ( $ this -> baseUrl , $ consumerName , $ version , $ tagName ) ; $ response = $ this -> client -> sendRequest ( $ request ) ; $ this -> checkIfResponseIsCorrect ( $ response ) ; return $ response ; }
|
Tags version with specific name
|
56,958
|
public function retrievePact ( $ providerName , $ consumerName , $ version , $ tagName = null , ResponseFormatter $ responseFormatter = null ) { $ request = $ this -> requestBuilder -> createRetrievePactRequest ( $ this -> baseUrl , $ consumerName , $ providerName , $ version , $ tagName ) ; $ response = $ this -> client -> sendRequest ( $ request ) ; $ this -> checkIfResponseIsCorrect ( $ response ) ; return new Contract ( $ response -> getHeader ( 'X-Pact-Consumer-Version' ) ? $ response -> getHeader ( 'X-Pact-Consumer-Version' ) [ 0 ] : '' , $ responseFormatter ? $ responseFormatter -> format ( $ response ) : $ response ) ; }
|
Retrieve contract by version or tag name
|
56,959
|
public function retrieveLastAddedPact ( ResponseFormatter $ responseFormatter = null ) { $ request = $ this -> requestBuilder -> createRetrieveLastAddedPact ( $ this -> baseUrl ) ; $ response = $ this -> client -> sendRequest ( $ request ) ; $ this -> checkIfResponseIsCorrect ( $ response ) ; return new Contract ( $ response -> getHeader ( 'X-Pact-Consumer-Version' ) ? $ response -> getHeader ( 'X-Pact-Consumer-Version' ) [ 0 ] : '' , $ responseFormatter ? $ responseFormatter -> format ( $ response ) : $ response ) ; }
|
Retrieves last added contract to the broker for all providers .
|
56,960
|
private function checkIfResponseIsCorrect ( ResponseInterface $ response ) { if ( ! in_array ( $ response -> getStatusCode ( ) , [ 200 , 201 , 202 , 204 ] ) ) { throw new PactBrokerException ( 'Response_code: ' . $ response -> getStatusCode ( ) . ' Response_data:' . $ response -> getBody ( ) -> getContents ( ) ) ; } }
|
Check if response is correct
|
56,961
|
public function validate ( ... $ validate ) { if ( $ this -> validate === [ ] ) { $ this -> validate = $ validate ; } else { $ this -> validate = array_merge ( $ this -> validate , $ validate ) ; } return $ this ; }
|
Defines validate rules .
|
56,962
|
public function where ( $ column , String $ value = NULL , String $ logical = 'and' ) { $ this -> settings [ 'where' ] = true ; $ this -> settings [ 'whereValue' ] = $ value ; $ this -> settings [ 'whereColumn' ] = $ column ; Singleton :: class ( 'ZN\Database\DB' ) -> where ( $ column , $ value , $ logical ) ; return $ this ; }
|
Database Where Clause
|
56,963
|
public function action ( String $ url = NULL ) { $ this -> settings [ 'attr' ] [ 'action' ] = IS :: url ( $ url ) ? $ url : Request :: getSiteURL ( $ url ) ; return $ this ; }
|
Sets Form Action
|
56,964
|
public function enctype ( String $ enctype ) { if ( isset ( $ this -> enctypes [ $ enctype ] ) ) { $ enctype = $ this -> enctypes [ $ enctype ] ; } $ this -> _element ( __FUNCTION__ , $ enctype ) ; return $ this ; }
|
Sets Form Enctype
|
56,965
|
public function option ( $ key , String $ value = NULL ) { if ( is_array ( $ key ) ) { $ this -> settings [ 'option' ] = $ key ; } else { $ this -> settings [ 'option' ] [ $ key ] = $ value ; } return $ this ; }
|
Sets select options
|
56,966
|
protected function setJavascriptValidation ( $ name , $ lang , $ rule = NULL , $ param = [ ] ) { $ this -> getJavascriptValidationFunction [ $ name ] = $ function = $ name . md5 ( $ name ) ; $ this -> validate [ ] = $ rule ? : $ lang ; return $ this -> onkeyup ( $ function . '(this, ' . Base :: suffix ( implode ( ', ' , $ param ) , ', ' ) . '\'' . $ this -> setCustomValidity ( $ lang ) . '\')' ) -> required ( ) ; }
|
Protected set javascript validation
|
56,967
|
protected function onInvalidEventPattern ( $ pattern , $ key , $ check = [ ] , $ type = NULL ) { $ this -> validate [ ] = $ type ? : $ key ; return $ this -> onInvalidEventPatternWithoutValidate ( $ pattern , $ key , $ check ) ; }
|
Protected on invalid event pattern
|
56,968
|
protected function onInvalidEventPatternWithoutValidate ( $ pattern , $ key , $ check = [ ] ) { return $ this -> required ( ) -> pattern ( $ pattern ) -> onInvalidEventCustomValidity ( $ key , $ check ) ; }
|
Protected on invalid event pattern without validate
|
56,969
|
protected function onInvalidEventAttributeValidate ( $ key , $ check = [ ] , $ rule = NULL ) { $ this -> validate [ ] = $ rule ? : $ key ; return $ this -> required ( ) -> onInvalidEventCustomValidity ( $ key , $ check ) ; }
|
Protected on invalid event attribute validate
|
56,970
|
protected function onInvalidEventCustomValidity ( $ key , $ check = [ ] ) { $ this -> vMethodMessages .= $ this -> setCustomValidity ( $ key , $ check ) . ' ' ; return $ this ; }
|
Protected on invalid event custom validity
|
56,971
|
protected function getVMethodMessages ( ) { if ( $ this -> vMethodMessages !== NULL ) { $ this -> oninvalid ( 'setCustomValidity(\'' . rtrim ( $ this -> vMethodMessages ) . '\')' ) -> oninput ( 'setCustomValidity(\'\')' ) -> validate ( ... $ this -> validate ) ; $ this -> vMethodMessages = NULL ; } }
|
Protected get validate method messages
|
56,972
|
protected function setCustomValidity ( $ key , $ check = [ ] ) { $ message = NULL ; if ( is_scalar ( $ key ) ) { $ message = $ this -> getValidationLangValue ( $ key , $ check ) ; } else foreach ( $ key as $ k => $ c ) { $ message .= $ this -> getValidationLangValue ( $ k , $ c ) . ' ' ; } return rtrim ( $ message ) ; }
|
Protected set custom validity
|
56,973
|
protected function _getrow ( $ type , $ value , & $ attributes ) { if ( $ row = ( $ this -> settings [ 'getrow' ] ?? NULL ) ) { $ rowval = $ row -> { $ attributes [ 'name' ] } ?? NULL ; if ( $ type === 'textarea' || $ type === 'select' ) { return $ value ? : $ rowval ; } $ attributes [ 'value' ] = $ value ? : $ rowval ; if ( $ type === 'radio' && $ value == $ rowval ) { $ attributes [ 'checked' ] = 'checked' ; } if ( $ type === 'checkbox' ) { if ( Json :: check ( $ rowval ) ) { $ rowval = json_decode ( $ rowval , true ) ; if ( in_array ( $ value , $ rowval ) ) { $ attributes [ 'checked' ] = 'checked' ; } } else { if ( ! empty ( $ rowval ) ) { $ attributes [ 'checked' ] = 'checked' ; } } } } return $ value ; }
|
Protected Get Row
|
56,974
|
public function getProspectService ( ) { if ( ! $ this -> prospectService ) { $ this -> prospectService = $ this -> getServiceLocator ( ) -> get ( 'playgroundflow_prospect_service' ) ; } return $ this -> prospectService ; }
|
Retrieve service prospect instance
|
56,975
|
public function getUserDomainService ( ) { if ( ! $ this -> userDomainService ) { $ this -> userDomainService = $ this -> getServiceLocator ( ) -> get ( 'playgroundflow_user_domain_service' ) ; } return $ this -> userDomainService ; }
|
Retrieve service userdomain instance
|
56,976
|
public function getLeaderboardService ( ) { if ( ! $ this -> leaderboardService ) { $ this -> leaderboardService = $ this -> getServiceLocator ( ) -> get ( 'playgroundreward_leaderboard_service' ) ; } return $ this -> leaderboardService ; }
|
Retrieve service leaderboardservice instance
|
56,977
|
public static function toArray ( $ mixed , $ depth = 1 , $ whitelist = [ ] , $ blacklist = [ ] ) { if ( $ depth < 0 ) { return NULL ; } if ( is_array ( $ mixed ) || $ mixed instanceof Traversable ) { $ anArray = [ ] ; foreach ( $ mixed as $ key => $ value ) { if ( is_array ( $ value ) || $ value instanceof Traversable ) { $ anArray [ ] = self :: toArray ( $ value , $ depth - 1 , $ whitelist , $ blacklist ) ; } elseif ( is_object ( $ value ) ) { $ anArray [ ] = self :: arrayizor ( $ value , $ depth , $ whitelist , $ blacklist ) ; } else { $ anArray [ $ key ] = $ value ; } } return $ anArray ; } elseif ( is_object ( $ mixed ) ) { return self :: arrayizor ( $ mixed , $ depth , $ whitelist , $ blacklist ) ; } else { return $ mixed ; } }
|
Serializes our Doctrine Entities
|
56,978
|
private static function arrayizor ( $ anObject , $ depth , $ whitelist = [ ] , $ blacklist = [ ] ) { $ nextDepth = $ depth - 1 ; $ clazzName = get_class ( $ anObject ) ; $ reflectionClass = new ReflectionClass ( $ anObject ) ; $ clazzProps = $ reflectionClass -> getProperties ( ) ; if ( is_a ( $ anObject , 'Doctrine\ORM\Proxy\Proxy' ) ) { $ parent = $ reflectionClass -> getParentClass ( ) ; $ clazzName = $ parent -> getName ( ) ; $ clazzProps = $ parent -> getProperties ( ) ; } $ anArray = [ ] ; foreach ( $ clazzProps as $ prop ) { if ( @ count ( $ whitelist [ $ clazzName ] ) > 0 ) { if ( ! @ in_array ( $ prop -> name , $ whitelist [ $ clazzName ] ) ) { continue ; } } elseif ( @ count ( $ blacklist [ $ clazzName ] > 0 ) ) { if ( @ in_array ( $ prop -> name , $ blacklist [ $ clazzName ] ) ) { continue ; } } $ method_name = 'get' . ucfirst ( $ prop -> name ) ; if ( method_exists ( $ anObject , $ method_name ) ) { $ aValue = $ anObject -> $ method_name ( ) ; } else { $ prop -> setAccessible ( true ) ; $ aValue = $ prop -> getValue ( $ anObject ) ; } if ( $ aValue instanceof DateTime ) { $ anArray [ $ prop -> name ] = $ aValue -> format ( 'Y-m-d H:i:s' ) ; continue ; } if ( is_object ( $ aValue ) || is_array ( $ aValue ) ) { $ anArray [ $ prop -> name ] = Serializor :: toArray ( $ aValue , $ nextDepth , $ whitelist , $ blacklist ) ; continue ; } $ anArray [ $ prop -> name ] = $ aValue ; } return $ anArray ; }
|
This does all the heavy lifting of actually converting to an array
|
56,979
|
public function prepare ( ContentInterface $ content , ThemeInterface $ theme , $ templateTypeName = null ) { $ this -> contextStack -> push ( $ this -> contextBuilder -> setContent ( $ content ) -> setTheme ( $ theme ) -> setTemplateTypeName ( $ templateTypeName ) -> createContext ( ) ) ; return $ this ; }
|
Prepare a rendering context from given content and theme .
|
56,980
|
public function output ( ) { if ( $ this -> status === null ) { $ this -> status = ( empty ( $ this -> body ) || $ this -> method === 'HEAD' ) ? HttpResponse :: HTTP_NO_CONTENT : HttpResponse :: HTTP_OK ; } if ( $ this -> method === 'HEAD' || ! HttpResponse :: canHaveBody ( $ this -> status ) ) { $ content_type = 'HEAD' ; } elseif ( is_array ( $ this -> body ) ) { $ content_type = 'application/json' ; } else { $ content_type = $ this -> headers [ 'Content-Type' ] ?? null ; } Utils :: checkOutput ( $ content_type ) ; if ( $ this -> zlib_compression && $ content_type !== 'HEAD' ) { ini_set ( 'zlib.output_compression' , 1 ) ; } header ( HttpResponse :: getHeader ( $ this -> status ) ) ; foreach ( $ this -> headers as $ key => $ value ) { header ( "$key: " . implode ( ',' , ( array ) $ value ) ) ; } if ( $ content_type !== 'HEAD' ) { if ( is_array ( $ this -> body ) ) { echo json_encode ( $ this -> body , JSON_PRETTY_PRINT ) ; } else { echo $ this -> body ; } } }
|
Outputs Response content
|
56,981
|
public function needsRehash ( string $ password ) : bool { return password_needs_rehash ( $ password , $ this -> hashType , $ this -> hashOptions ) ; }
|
Returns true if the password need to be rehashed due to the password being created with anything else than the passwords generated by this class .
|
56,982
|
public function bind ( $ abstract , $ concrete = null , $ shared = false ) { if ( is_array ( $ abstract ) ) { list ( $ abstract , $ alias ) = $ this -> extractAlias ( $ abstract ) ; $ this -> alias ( $ abstract , $ alias ) ; } if ( is_null ( $ concrete ) ) { $ concrete = $ abstract ; } if ( ! $ concrete instanceof \ Closure ) { $ concrete = function ( $ c ) use ( $ abstract , $ concrete ) { $ method = ( $ abstract == $ concrete ) ? 'build' : 'make' ; return $ c -> $ method ( $ concrete ) ; } ; } $ this -> bindings [ $ abstract ] = compact ( 'concrete' , 'shared' ) ; }
|
Register a binding with the ioc .
|
56,983
|
public function offsetSet ( $ key , $ value ) { if ( ! $ value instanceof \ Closure ) { $ value = function ( ) use ( $ value ) { return $ value ; } ; } $ this -> bind ( $ key , $ value ) ; }
|
Set the value at a given offset .
|
56,984
|
private function registerCommandBus ( ) { $ this -> app -> bindShared ( 'Flyingfoxx\CommandCenter\CommandBus' , function ( $ app ) { $ main = $ app -> make ( 'Flyingfoxx\CommandCenter\MainCommandBus' ) ; $ application = $ app -> make ( 'Flyingfoxx\CommandCenter\CommandApplication' ) ; $ translator = $ app -> make ( 'Flyingfoxx\CommandCenter\CommandTranslator' ) ; $ validation = new ValidationCommandBus ( $ main , $ application , $ translator ) ; return $ validation ; } ) ; }
|
Register the desired command bus implementation .
|
56,985
|
public function getParent ( ) { if ( ( $ this -> parent === null ) && $ this -> getParentId ( ) ) { $ this -> parent = $ this -> termFactory -> create ( $ this -> getParentId ( ) , $ this -> taxonomy ) ; } return $ this -> parent ; }
|
Get the parent term of this term .
|
56,986
|
public function getChildren ( ) { $ children = array ( ) ; $ wpTerms = get_terms ( $ this -> taxonomy -> getName ( ) , array ( 'hide_empty' => false , 'parent' => ( int ) $ this -> getId ( ) ) ) ; foreach ( $ wpTerms as $ termData ) { $ children [ ] = $ this -> termFactory -> create ( $ termData , $ this -> taxonomy ) ; } return $ children ; }
|
Return array of direct child terms of this term .
|
56,987
|
private function _getApiUri ( $ hostname , $ storeId , $ major , $ minor ) { return sprintf ( Radial_Core_Helper_Data :: URI_FORMAT , $ hostname , $ major , $ minor , $ storeId , self :: AD_VAL_SERVICE , self :: AD_VAL_OPERATION , '' , 'xml' ) ; }
|
Get the URI of the API endpoint for the AdVal request using the provided hostname store id and version .
|
56,988
|
public function getParamOrFallbackValue ( Zend_Controller_Request_Abstract $ request , $ param , $ useDefaultParam , $ configPath ) { $ paramValue = $ request -> getParam ( $ param ) ; $ useFallback = $ request -> getParam ( $ useDefaultParam ) ; if ( is_null ( $ paramValue ) || $ useFallback ) { return $ this -> getConfigSource ( $ request , $ useFallback ) -> getConfig ( $ configPath ) ; } return trim ( $ paramValue ) ; }
|
Get the value from the request or via the config fallback .
|
56,989
|
public function getConfigSource ( Zend_Controller_Request_Abstract $ request , $ useFallback = false ) { $ store = $ request -> getParam ( 'store' ) ; $ website = $ request -> getParam ( 'website' ) ; if ( $ store ) { $ storeObj = Mage :: app ( ) -> getStore ( $ store ) ; return $ useFallback ? $ storeObj -> getWebsite ( ) : $ storeObj ; } if ( $ website ) { $ websiteObj = Mage :: app ( ) -> getWebsite ( $ website ) ; return $ useFallback ? Mage :: app ( ) -> getStore ( null ) : $ websiteObj ; } return Mage :: app ( ) -> getStore ( null ) ; }
|
Get the source of configuration for the request . Should use the store or website specified in the request params . If neither is present should use the default store .
|
56,990
|
public function process ( ) { $ ajax = [ ] ; foreach ( $ this -> commands as $ cmd ) { if ( $ cmd instanceof DomCommandInterface && empty ( $ cmd -> getSelector ( ) ) ) { $ cmd -> setSelector ( 'body' ) ; } $ fa = [ 'f' => $ cmd -> getFunction ( ) , 'a' => $ cmd -> getArgs ( ) ] ; if ( $ cmd instanceof DomCommandInterface ) { $ ajax [ 'dom' ] [ $ cmd -> getSelector ( ) ] [ ] = $ fa ; } else { $ ajax [ 'act' ] [ ] = $ fa ; } } return ! empty ( $ ajax ) ? json_encode ( $ ajax ) : '' ; }
|
Builds the ajax command structure
|
56,991
|
private function extractDefaultResolver ( AggregateResolver $ aggregate ) : void { if ( $ this -> resolver instanceof DefaultResolver ) { return ; } $ resolver = $ aggregate -> fetchByType ( DefaultResolver :: class ) ; if ( $ resolver instanceof AggregateResolver ) { $ queue = $ resolver -> getIterator ( ) ; $ resolver = $ queue -> top ( ) ; } $ this -> resolver = $ resolver ; }
|
Extract and compose the DefaultResolver found in an AggregateResolver .
|
56,992
|
private function mergeParams ( string $ name , $ vars ) { $ globalDefaults = isset ( $ this -> defaultParams [ TemplateRendererInterface :: TEMPLATE_ALL ] ) ? $ this -> defaultParams [ TemplateRendererInterface :: TEMPLATE_ALL ] : [ ] ; $ templateDefaults = isset ( $ this -> defaultParams [ $ name ] ) ? $ this -> defaultParams [ $ name ] : [ ] ; $ defaults = ArrayUtils :: merge ( $ globalDefaults , $ templateDefaults ) ; foreach ( array_reverse ( $ this -> paramListeners ) as $ listener ) { $ result = $ listener ( $ vars , $ defaults ) ; if ( null !== $ result && ! is_scalar ( $ result ) ) { return $ result ; } } return $ vars ; }
|
Merge passed and default parameters .
|
56,993
|
private function mergeObjectParams ( $ params , array $ defaults ) { if ( ! is_object ( $ params ) ) { return ; } foreach ( $ defaults as $ key => $ value ) { if ( ! isset ( $ params -> { $ key } ) && ! method_exists ( $ params , $ key ) ) { $ params -> { $ key } = $ value ; } } return $ params ; }
|
Merge defaults with a view model object .
|
56,994
|
public function fieldTypesToFilter ( $ arrFields ) { foreach ( $ arrFields as $ key => & $ properties ) { if ( isset ( $ properties [ 'filter' ] ) || ! isset ( $ properties [ 'type' ] ) || ! isset ( $ this -> typesToFilter [ $ properties [ 'type' ] ] ) ) continue ; $ properties = $ properties + $ this -> typesToFilter [ $ properties [ 'type' ] ] ; } return $ arrFields ; }
|
Return array of filters created out of the types of the fields . If the field already has any filter defined nothing will happen .
|
56,995
|
public function filterErrors ( $ arrData , $ arrFilters , $ bolStrict = true ) { return $ this -> getErrors ( $ this -> filter ( $ arrData , $ arrFilters , $ bolStrict ) ) ; }
|
Filters an array of values and returns an array with error messages
|
56,996
|
private function filterArray ( $ arrData , $ arrFilters ) { foreach ( $ arrFilters as $ key => & $ F ) { if ( is_int ( $ F ) ) $ F = array ( 'filter' => $ F ) ; elseif ( ! isset ( $ F [ 'filter' ] ) ) { unset ( $ arrFilters [ $ key ] ) ; continue ; } elseif ( is_string ( $ F [ 'filter' ] ) ) { try { $ intF = @ constant ( $ F [ 'filter' ] ) ; } catch ( \ Exception $ e ) { continue ; } if ( $ intF ) $ F [ 'filter' ] = $ intF ; else { continue ; } } elseif ( isset ( $ F [ 'required' ] ) ) { if ( ! $ F [ 'required' ] && ( string ) $ arrData [ $ key ] == '' ) { unset ( $ arrFilters [ $ key ] ) ; continue ; } } $ F [ 'value' ] = isset ( $ arrData [ $ key ] ) ? $ arrData [ $ key ] : null ; if ( ! isset ( $ F [ 'field' ] ) ) $ F [ 'field' ] = $ key ; } $ arrCallbacks = array ( ) ; $ arrValidators = array ( ) ; foreach ( $ arrFilters as $ key => $ filter ) { if ( isset ( $ this -> filters [ $ filter [ 'filter' ] ] ) ) { $ arrValidators [ $ key ] = $ filter + $ this -> filters [ $ filter [ 'filter' ] ] ; $ arrValidators [ $ key ] [ 'filter' ] = $ this -> filters [ $ filter [ 'filter' ] ] [ 'filter' ] ; } elseif ( isset ( $ this -> callbacks [ $ filter [ 'filter' ] ] ) ) $ arrCallbacks [ $ key ] = $ filter ; else $ arrValidators [ $ key ] = $ filter ; } $ validate = array ( ) ; foreach ( $ arrCallbacks as $ key => $ filter ) $ validate [ $ key ] = call_user_func ( $ this -> callbacks [ $ filter [ 'filter' ] ] , $ filter ) ; $ validate = $ validate + filter_var_array ( $ arrData , $ arrValidators ) ; $ res = array ( ) ; foreach ( $ arrFilters as $ key => $ filter ) { $ result = isset ( $ validate [ $ key ] ) ? $ validate [ $ key ] : null ; if ( is_null ( $ result ) || ( $ filter != FILTER_VALIDATE_BOOLEAN && ( bool ) $ result == false ) ) $ res [ $ key ] = $ filter ; } return $ res ; }
|
Filters an array of values
|
56,997
|
public function getError ( $ error , $ opts = array ( ) ) { if ( is_array ( $ error ) && isset ( $ error [ 'filter' ] ) ) { return $ this -> getErrorMessage ( $ error [ 'filter' ] , $ error + $ opts ) ; } elseif ( is_int ( $ error ) ) { return $ this -> getErrorMessage ( $ error , $ opts ) ; } else { return $ this -> getErrorMessage ( 0 , $ opts ) ; } }
|
Returns a single error message for a validator
|
56,998
|
public function select ( $ filename ) { $ ext = substr ( strrchr ( $ filename , "." ) , 1 ) ; foreach ( $ this -> renders as $ renderer ) { if ( $ renderer -> can_use ( $ ext ) ) { return $ renderer ; } } throw new \ Exception ( 'Render not available for this extension.' ) ; }
|
Select a render by the extension of the file .
|
56,999
|
function getAccessMode ( ) { if ( ! $ this -> accessMode ) $ this -> accessMode = new AccessMode ( self :: DEFAULT_ACCESS_MODE ) ; return $ this -> accessMode ; }
|
Get Open Access Mode
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.