idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
59,100
protected function getConnection ( $ node_type ) { switch ( $ node_type ) { case self :: CONN_TYPE_MASTER : $ this -> write_conn = new \ PDO ( $ this -> _master_dsn , $ this -> _master_username , $ this -> _master_password , $ this -> _master_options ) ; break ; case self :: CONN_TYPE_SLAVE : $ this -> read_conn = new ...
Establish mysql connection
59,101
public function CountryNice ( ) { $ config = SiteConfig :: current_site_config ( ) ; return Zend_Locale :: getTranslation ( $ config -> Country , "territory" , i18n :: get_locale ( ) ) ; }
Get the full translated country name
59,102
public function fill ( $ data ) { if ( ! $ this -> object ) { throw new InvalidArgumentException ( 'There are no object to be mapped' ) ; } if ( ! is_object ( $ data ) ) { throw new InvalidArgumentException ( 'Data should be an object' ) ; } $ data = $ this -> extractData ( $ data ) ; $ allowed = $ this -> extractAllow...
Fill object from object
59,103
private function extractAllowedAttributes ( ReflectionClass $ reflection ) : array { $ allowed = [ ] ; foreach ( $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ method ) { if ( ! $ this -> isGetMethod ( $ method ) ) { continue ; } $ name = $ this -> getAttributeName ( $ method ) ; if ( $ this -> isExc...
Extract allowed attributes .
59,104
private function isExclude ( string $ key ) : bool { if ( ! empty ( $ this -> excludes ) && in_array ( $ key , $ this -> excludes , true ) ) { return true ; } if ( ! empty ( $ this -> only ) && ! in_array ( $ key , $ this -> only , true ) ) { return true ; } return false ; }
Check whether current key is excluded .
59,105
private function extractData ( object $ data ) : array { if ( $ data instanceof \ stdClass ) { return ( array ) $ data ; } $ extracted = [ ] ; $ reflection = new \ ReflectionObject ( $ data ) ; foreach ( $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ method ) { if ( ! $ this -> isGetMethod ( $ method...
Extract the object data to array .
59,106
private function getAttributeName ( ReflectionMethod $ method ) : string { return lcfirst ( substr ( $ method -> name , 0 === strpos ( $ method -> name , 'is' ) ? 2 : 3 ) ) ; }
Get the attribute name from method .
59,107
public function setTolerance ( $ tolerance = 0.20 ) { if ( $ tolerance < 0 || $ tolerance > 1 ) { return false ; } $ this -> _tolerance = round ( $ tolerance , 2 ) ; return $ this ; }
Set fault tolerance for what is considered similar .
59,108
public function similarity ( $ string = null , $ cmp = null , $ language = 'french' ) { if ( empty ( $ string ) || empty ( $ cmp ) ) { return false ; } if ( strlen ( $ string ) > 255 || strlen ( $ cmp ) > 255 ) { return false ; } $ processedStr = $ this -> phoneme ( $ string , $ language ) ; $ processedCmp = $ this -> ...
Compare 2 strings to see how similar they are .
59,109
public function phoneme ( $ string = '' , $ language = 'french' ) { $ parts = explode ( ' ' , $ string ) ; $ phonemes = array ( ) ; foreach ( $ parts as $ p ) { $ p = $ this -> partCases ( Inflector :: lower ( $ p ) ) ; $ phon = $ this -> $ language ( $ p ) ; if ( $ phon != ' ' && strlen ( $ phon ) ) { array_push ( $ p...
Transform a given string into its phoneme equivalent .
59,110
public function getEtags ( ) { $ etag = '' ; if ( $ this -> data instanceof ArrayableInterface ) { $ this -> data = $ this -> data -> toArray ( ) ; } foreach ( $ this -> data as $ item ) { $ item = new Resource ( $ item ) ; $ etag .= $ item -> getEtag ( ) ; unset ( $ item ) ; } return md5 ( $ etag ) ; }
Return ETag based on collection of items
59,111
protected function makeCharacteristicsDDL ( ) { return implode ( " " , array_filter ( [ $ this -> deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC' , $ this -> dataAccess , ! empty ( $ this -> sqlSecurity ) ? 'SQL SECURITY ' . $ this -> sqlSecurity : null , ! empty ( $ this -> comment ) ? "\nCOMMENT '" . addslashes...
Make the portion of the routine DDL statement that describes deterministic sql security and comment .
59,112
protected function createWorker ( $ service ) { return $ this -> getServiceBroker ( ) -> service ( $ service ) -> context ( $ this -> command -> getContext ( ) ) ; }
Create service worker
59,113
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( $ this -> Default ) { foreach ( $ this -> Contact ( ) -> Locations ( ) as $ location ) { if ( $ location -> ID != $ this -> ID && $ location -> Default ) { $ location -> Default = false ; $ location -> write ( ) ; } } } }
If we have assigned this as a default location loop through other locations and disable default .
59,114
public function getConnectionsFromResource ( ) : Array { $ baseDir = dirname ( __DIR__ ) ; $ configLocation = $ baseDir . '/config.php' ; if ( ! file_exists ( $ configLocation ) && class_exists ( Config :: class ) ) { $ resourceConfig = Config :: get ( 'database' ) ; } else { $ resourceConfig = include $ configLocation...
Loads connection configuration .
59,115
public function getConnection ( $ serviceName ) { if ( empty ( $ this -> connectionPool [ $ serviceName ] ) ) { $ this -> initConnection ( $ serviceName ) ; } return $ this -> connectionPool [ $ serviceName ] ; }
Gets a service client connection by service name
59,116
public function initConnection ( $ serviceName ) { $ connection = $ this -> clientFactory -> createServiceClient ( $ serviceName ) ; $ this -> connectionPool [ $ serviceName ] = $ connection ; return $ this ; }
Initialize service client connection by service name
59,117
public function dispatch ( MessageInterface $ message ) { $ builder = $ this -> notificationBuilder ; $ notifications = $ builder -> buildNotifications ( $ message ) ; foreach ( $ notifications as $ notification ) { $ this -> sendNotification ( $ notification ) ; } return $ this ; }
Build notification and send it to notification service
59,118
public function dispatchAll ( MessageCollection $ messages ) { $ collection = $ messages -> getMessageCollection ( ) ; while ( $ collection -> valid ( ) ) { $ message = $ collection -> current ( ) ; $ this -> dispatch ( $ message ) ; $ collection -> next ( ) ; } return $ this ; }
Tries to dispatch all messages to notification service
59,119
public function sendNotification ( Notification $ notification ) { try { $ connection = $ this -> getConnection ( $ notification -> getType ( ) ) ; $ connection -> setNotification ( $ notification ) ; $ this -> logger -> info ( sprintf ( "Dispatching notification id: %s" , $ notification -> getIdentifier ( ) ) ) ; $ th...
Tries to connect and send a notification
59,120
public function loadFeedback ( ) { $ serviceName = NotificationServices :: APPLE_PUSH_NOTIFICATIONS_SERVICE ; try { $ this -> logger -> info ( sprintf ( "Querying the feedback service '%s'" , $ serviceName ) ) ; $ connection = $ this -> initFeedbackConnection ( $ serviceName ) ; $ this -> responseHandler -> addResponse...
Tries to connect and load feedback data
59,121
public function validateamqpAction ( ) { $ request = $ this -> getRequest ( ) ; $ configMap = Mage :: getModel ( 'radial_amqp/config' ) ; $ hostname = $ this -> _validatorHelper -> getParamOrFallbackValue ( $ request , self :: HOSTNAME_PARAM , self :: HOSTNAME_USE_DEFAULT_PARAM , $ configMap -> getPathForKey ( 'hostnam...
Test connecting to the AMQP server
59,122
protected function _getSourceStore ( ) { $ configSource = $ this -> _validatorHelper -> getConfigSource ( $ this -> getRequest ( ) ) ; if ( $ configSource instanceof Mage_Core_Model_Website ) { return $ configSource -> getDefaultStore ( ) ; } return $ configSource ; }
Get a store context to use as the source of configuration .
59,123
protected function buildName ( $ name ) { $ name = preg_replace ( '/([A-Z]{1})/' , ' $1' , $ name ) ; $ name = ucfirst ( $ name ) ; return trim ( $ name ) ; }
Humanize name adding a space before each capital
59,124
protected function findCommand ( \ ReflectionMethod $ reflectionMethod ) { $ parameters = $ reflectionMethod -> getParameters ( ) ; foreach ( $ parameters as $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( null !== $ class && true === $ class -> implementsInterface ( 'RomaricDrigon\OrchestraBundle\Domain\C...
Look if we have a parameter of type CommandInterface and then return its precise class name
59,125
private function buildGlobalErrors ( array $ errors , $ msg ) { if ( ! empty ( $ errors ) ) { $ msg .= sprintf ( '%s- errors:' , PHP_EOL ) ; foreach ( $ errors as $ error ) { $ msg .= sprintf ( '%s - %s' , PHP_EOL , $ error ) ; } } return $ msg ; }
Build the global errors and returns the exception message .
59,126
private function buildChildrenErrors ( array $ childrenErrors , $ msg ) { if ( ! empty ( $ childrenErrors ) ) { $ msg .= PHP_EOL . '- children:' ; foreach ( $ childrenErrors as $ child => $ errors ) { $ msg .= sprintf ( '%s - %s' , PHP_EOL , $ child ) ; $ msg .= sprintf ( '%s - errors:' , PHP_EOL ) ; foreach ( $ er...
Build the children errors and returns the exception message .
59,127
public function fetch_assoc ( $ sql ) { if ( empty ( $ sql ) ) return false ; $ res = $ this -> query ( $ sql ) ; $ result = @ mysql_fetch_assoc ( $ res ) ; $ this -> free ( $ res ) ; return $ result ; }
fetches an associative array
59,128
public function fetch_assoc_list ( $ sql , $ assign_by = null ) { if ( empty ( $ sql ) ) return false ; $ result = array ( ) ; $ res = $ this -> query ( $ sql ) ; if ( empty ( $ res ) ) return false ; while ( ( $ row = @ mysql_fetch_assoc ( $ res ) ) !== false ) { if ( ! empty ( $ assign_by ) ) { $ result [ $ row [ $ a...
simple wrapper for those lazy bastards who don t wanna control their own ressources
59,129
public function fetch_object ( $ sql ) { if ( empty ( $ sql ) ) return false ; $ res = $ this -> query ( $ sql ) ; $ result = @ mysql_fetch_object ( $ res ) ; $ this -> free ( $ res ) ; return $ result ; }
fetches an object of the current row
59,130
public function fetch_string ( $ sql ) { if ( empty ( $ sql ) ) return false ; $ res = $ this -> query ( $ sql ) ; $ row = @ mysql_fetch_array ( $ res ) ; return ( string ) $ row [ 0 ] ; }
fetches a string wrapper for easy use
59,131
public function map ( array $ methods , $ pattern , $ callable ) { $ callable = is_string ( $ callable ) ? $ this -> resolveCallable ( $ callable ) : $ callable ; if ( $ callable instanceof Closure ) { $ callable = $ callable -> bindTo ( $ this ) ; } $ route = $ this -> container -> get ( 'router' ) -> map ( $ methods ...
Add route with multiple methods .
59,132
public function group ( $ pattern , $ callable ) { $ group = $ this -> container -> get ( 'router' ) -> pushGroup ( $ pattern , $ callable ) ; $ group -> setContainer ( $ this -> container ) ; $ group ( $ this ) ; $ this -> container -> get ( 'router' ) -> popGroup ( ) ; return $ group ; }
Route Groups .
59,133
public function hasWidget ( $ nameOrWidget ) { $ name = $ nameOrWidget instanceof WidgetInterface ? $ nameOrWidget -> getName ( ) : $ nameOrWidget ; return array_key_exists ( $ name , $ this -> widgets ) ; }
Returns whether the dashboard has the widget or not .
59,134
public function addWidget ( WidgetInterface $ widget ) { if ( $ this -> hasWidget ( $ widget ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Widget "%s" is already registered.' , $ widget -> getName ( ) ) ) ; } $ this -> widgets [ $ widget -> getName ( ) ] = $ widget ; return $ this ; }
Adds the widget .
59,135
public function filter ( ) { $ args = func_get_args ( ) ; $ filter_function = array_shift ( $ args ) ; array_unshift ( $ args , $ this ) ; if ( method_exists ( $ this -> _class_name , $ filter_function ) ) { return call_user_func_array ( [ $ this -> _class_name , $ filter_function ] , $ args ) ; } }
Add a custom filter to the method chain specified on the model class . This allows custom queries to be added to models . The filter should take an instance of the One wrapper as its first argument and return an instance of the One wrapper . Any arguments passed to this method after the name of the filter will be passe...
59,136
public static function for_table ( $ table_name , $ connection_name = parent :: DEFAULT_CONNECTION ) { self :: _setupDb ( $ connection_name ) ; return new self ( $ table_name , [ ] , $ connection_name ) ; }
Factory method return an instance of this class bound to the supplied table name .
59,137
protected function _createModelInstance ( $ One ) { if ( $ One === false ) { return false ; } $ model = new $ this -> _class_name ( ) ; $ model -> set_one ( $ One ) ; return $ model ; }
Method to create an instance of the model class associated with this wrapper and populate it with the supplied One instance .
59,138
public function find_many ( ) { $ results = parent :: find_many ( ) ; foreach ( $ results as $ key => $ result ) { $ results [ $ key ] = $ this -> _createModelInstance ( $ result ) ; } return $ results ; }
Wrap One s find_many method to return an array of instances of the class associated with this wrapper instead of the raw One class .
59,139
protected function _hasOneOrMany ( $ associated_class_name , $ foreign_key_name = null , $ foreign_key_name_in_current_models_table = null , $ connection_name = null ) { $ base_table_name = self :: _getTableName ( get_class ( $ this ) ) ; $ foreign_key_name = self :: _buildForeignKeyName ( $ foreign_key_name , $ base_t...
Internal method to construct the queries for both the has_one and has_many methods . These two types of association are identical ; the only difference is whether find_one or find_many is used to complete the method chain .
59,140
protected function has_one ( $ associated_class_name , $ foreign_key_name = null , $ foreign_key_name_in_current_models_table = null , $ connection_name = null ) { return $ this -> _hasOneOrMany ( $ associated_class_name , $ foreign_key_name , $ foreign_key_name_in_current_models_table , $ connection_name ) ; }
Helper method to manage one - to - one relations where the foreign key is on the associated table .
59,141
protected function has_many ( $ associated_class_name , $ foreign_key_name = null , $ foreign_key_name_in_current_models_table = null , $ connection_name = null ) { return $ this -> _hasOneOrMany ( $ associated_class_name , $ foreign_key_name , $ foreign_key_name_in_current_models_table , $ connection_name ) ; }
Helper method to manage one - to - many relations where the foreign key is on the associated table .
59,142
protected function belongs_to ( $ associated_class_name , $ foreign_key_name = null , $ foreign_key_name_in_associated_models_table = null , $ connection_name = null ) { $ associated_table_name = self :: _getTableName ( self :: $ auto_prefix_models . $ associated_class_name ) ; $ foreign_key_name = self :: _buildForeig...
Helper method to manage one - to - one and one - to - many relations where the foreign key is on the base table .
59,143
protected function has_many_through ( $ associated_class_name , $ join_class_name = null , $ key_to_base_table = null , $ key_to_associated_table = null , $ key_in_base_table = null , $ key_in_associated_table = null , $ connection_name = null ) { $ base_class_name = get_class ( $ this ) ; if ( is_null ( $ join_class_n...
Helper method to manage many - to - many relationships via an intermediate model . See README for a full explanation of the parameters .
59,144
public function create ( $ field , AbstractPost $ post ) { $ data = get_field_object ( $ field , $ post -> getId ( ) ) ; return $ this -> createFromField ( $ data ) ; }
Create a new custom field object .
59,145
public function createFromField ( $ field , $ value = null ) { if ( ! is_array ( $ field ) ) { return new NullField ; } if ( $ value !== null ) { $ field [ 'value' ] = $ value ; } return $ this -> resolve ( $ field [ 'type' ] , $ field ) ; }
Create a new custom field object from an existing set of field data .
59,146
protected function resolve ( $ type , array $ data ) { if ( $ this -> registered ( $ type ) ) { $ f = $ this -> registry [ $ type ] ; if ( $ f instanceof Closure ) { return $ f ( $ data , $ this -> app ) ; } else { return new $ f ( $ data ) ; } } else { throw new Exception ( "Field type $type not registered" ) ; } }
Resolve a field object using its type from the registered factory functions .
59,147
public static function getClasses ( $ version ) { if ( false === in_array ( $ version , self :: getVersions ( ) ) ) { throw new \ LogicException ( sprintf ( "Version is not supported. Available: %s" , implode ( ", " , self :: getVersions ( ) ) ) ) ; } $ version = explode ( "." , $ version ) ; $ subVersion = $ version [...
Get Icon Classes
59,148
public function lock ( ) { $ this -> _validate ( ) ; $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] = true ; return true ; }
Lock the namespace this will prevent removal of keys
59,149
public function unlock ( ) { $ this -> _validate ( ) ; $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] = false ; return true ; }
Unlock the namespace this will allow removal of keys
59,150
public function isLocked ( ) { $ this -> _validate ( ) ; if ( $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] == true ) { return true ; } return false ; }
Check if a namespace is currently locked .
59,151
public function set ( $ name , $ value ) { if ( ! $ this -> isLocked ( ) ) { $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] [ $ name ] = $ value ; return true ; } return false ; }
Set a value in the current namespace
59,152
public function get ( $ name ) { $ this -> _validate ( ) ; if ( array_key_exists ( $ name , $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] ) ) { return $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] [ $ name ] ; } return false ; }
Retrieve a single value from the namespace
59,153
public function getAll ( ) { $ this -> _validate ( ) ; if ( array_key_exists ( $ this -> _namespaceName , $ _SESSION [ $ this -> publicStorage ] [ 'store' ] ) ) { return $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] ; } return false ; }
Retrieve the entire namespace
59,154
public function remove ( $ name ) { $ this -> _validate ( ) ; if ( ! $ this -> isLocked ( ) ) { if ( ! $ this -> get ( $ name ) ) { return true ; } unset ( $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] [ $ name ] ) ; return true ; } return false ; }
Remove an key from the namespace
59,155
public function removeAll ( ) { $ this -> _validate ( ) ; if ( ! $ this -> isLocked ( ) ) { $ _SESSION [ $ this -> publicStorage ] [ 'store' ] [ $ this -> _namespaceName ] = array ( ) ; return true ; } return false ; }
Clear all values currently held in this namespace
59,156
protected function setup ( ) { if ( array_key_exists ( $ this -> secretStorage , $ _SESSION ) ) { if ( ! is_array ( $ _SESSION [ $ this -> secretStorage ] ) ) { $ _SESSION [ $ this -> secretStorage ] = array ( 'locks' => array ( $ this -> _namespaceName => false ) ) ; } else { if ( ! array_key_exists ( $ this -> _names...
Ensure the session contains the data we expect to see .
59,157
private function collectPayload ( ) { if ( $ this -> payloadLength === 0 ) { $ this -> logger -> debug ( "Skipping payload collection [expected length === 0]" ) ; return true ; } $ this -> logger -> debug ( "Trying to collect payload..." ) ; if ( ! $ this -> headersCollected ) { throw new LogicException ( "Cannot colle...
Collects payload from buffer . Masked packets are decoded .
59,158
protected function setAttribute ( string $ value , \ DOMElement $ node , array $ classesMetadata ) { if ( array_key_exists ( $ value , $ classesMetadata ) ) { $ node -> setAttribute ( 'service' , $ value ) ; } elseif ( class_exists ( $ value ) ) { $ node -> setAttribute ( 'class' , $ value ) ; } else { $ node -> setAtt...
Set XML property or method argument value .
59,159
public function buildXMLConfig ( array $ classesMetadata , string $ path ) { foreach ( $ classesMetadata as $ alias => $ classMetadata ) { $ dom = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ dom -> preserveWhiteSpace = false ; $ dom -> formatOutput = true ; $ root = $ dom -> createElement ( "dependencies" ) ; $ dom -> ap...
Build class xml config from class metadata .
59,160
public static function filterByKeys ( $ array , array $ keysInc = null , array $ keysExc = null ) { if ( $ keysInc !== null ) { $ array = array_intersect_key ( $ array , array_flip ( $ keysInc ) ) ; } if ( $ keysExc ) { $ array = array_diff_key ( $ array , array_flip ( $ keysExc ) ) ; } return $ array ; }
Filters items by given keys .
59,161
public function canCreate ( ContainerInterface $ container , $ requestedName ) { $ namespace = $ this -> getConfig ( $ container ) [ 'namespace' ] ; $ ar = explode ( '_' , $ requestedName ) ; return ( count ( $ ar ) >= 2 && array_key_exists ( $ ar [ 0 ] , $ namespace ) && $ ar [ 1 ] === 'model' ) ; }
Determine if we can create a Model with name
59,162
public function jsonSerialize ( ) : stdClass { $ object = ( object ) object_get_properties ( $ this , $ this instanceof DynamicEntity ) ; $ event = $ this -> dispatchEvent ( new Event \ ToJson ( $ this , $ object ) ) ; $ data = i \ type_check ( $ event -> getPayload ( ) , stdClass :: class , new UnexpectedValueExceptio...
Prepare entity for JsonSerialize encoding
59,163
public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( $ template = $ this -> getTemplate ( $ request , $ event -> getController ( ) ) ) { $ request -> attributes -> set ( '_template' , $ template ) ; } }
Handles Kernel Controller events
59,164
public function onKernelView ( GetResponseForControllerResultEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ response = $ event -> getResponse ( ) ; $ parameters = $ event -> getControllerResult ( ) ; if ( ! $ response instanceof Response && $ template = $ request -> attributes -> get ( '_template' ) ) { re...
Handles Kernel View events
59,165
protected function getTemplate ( Request $ request , $ controller ) { if ( $ request -> attributes -> has ( '_template' ) ) { return null ; } $ format = $ request -> attributes -> get ( '_format' , 'html' ) ; $ templates = [ ] ; if ( $ controllerInfo = $ this -> parseController ( $ controller ) ) { $ template = sprintf...
Get template from the given request and controller
59,166
protected function parseController ( $ controller ) { if ( ! is_array ( $ controller ) || ! is_object ( $ controller [ 0 ] ) || ! isset ( $ controller [ 1 ] ) ) { return null ; } if ( ! preg_match ( '#Controller\\\(.+)Controller$#' , get_class ( $ controller [ 0 ] ) , $ matches ) ) { return null ; } return [ 'name' => ...
Parse controller to extract its name
59,167
protected function templateExists ( $ template ) { try { $ class = $ this -> templating -> getTemplateClass ( $ template ) ; } catch ( Twig_Error_Loader $ e ) { return false ; } return $ template ; }
Does the given template exists?
59,168
protected function _render ( ) { try { $ template = $ this -> _getTemplate ( ) ; $ context = $ this -> _getContextFor ( $ template ) ; return $ this -> _renderTemplate ( $ template , $ context ) ; } catch ( RootException $ e ) { throw $ this -> _throwCouldNotRenderException ( $ this -> __ ( 'Could not render template' ...
Renders an internal template .
59,169
public function doctype ( $ doctype = null ) { if ( null !== $ doctype ) { switch ( $ doctype ) { case static :: XHTML11 : case static :: XHTML1_STRICT : case static :: XHTML1_TRANSITIONAL : case static :: XHTML1_FRAMESET : case static :: XHTML_BASIC1 : case static :: XHTML1_RDFA : case static :: XHTML1_RDFA11 : case s...
Set or retrieve doctype
59,170
public static function getInstance ( $ arrAccepted = array ( ) , $ strDefault = 'de' ) { if ( self :: $ instance === NULL ) self :: $ instance = new self ( $ arrAccepted , $ strDefault ) ; return self :: $ instance ; }
Return the current instance
59,171
private function fileFormatDir ( $ strDirectory , $ strSlash = DIRECTORY_SEPARATOR ) { return substr ( $ strDirectory , - 1 ) != $ strSlash ? $ strDirectory . $ strSlash : $ strDirectory ; }
Makes sure the directory ends with a slash
59,172
public function load ( $ strSourcePath , $ strCachePath = false , $ bolStore = true ) { $ strSourcePath = $ this -> fileFormatDir ( $ strSourcePath ) ; $ strLang = self :: init ( $ this -> arrAccepted , $ this -> strDefault , $ bolStore ) ; $ this -> strCurrent = $ strLang ; if ( $ strCachePath ) { $ strCachePath = $ t...
Initialized the language variable
59,173
public function get ( $ strKey , $ bolReturnPath = true ) { $ data = $ this -> arrData ; foreach ( explode ( '.' , $ strKey ) as $ p ) { if ( isset ( $ data [ $ p ] ) ) $ data = $ data [ $ p ] ; else return $ bolReturnPath ? $ this -> returnKey ( $ strKey ) : false ; } if ( is_array ( $ data ) ) return $ bolReturnPath ...
Gets a variable value
59,174
public function getDateFormat ( $ strKey ) { $ format = $ this -> get ( $ strKey , false ) ; return $ format ? preg_replace ( '/%([A-Za-z%])/' , '$1' , $ format ) : 'Y-m-d H:i' ; }
Returns a date string without % for PHP compatibiltiy
59,175
public function insert ( $ strKey , $ arrReplace ) { $ data = $ this -> arrData ; foreach ( explode ( '.' , $ strKey ) as $ p ) { if ( isset ( $ data [ $ p ] ) ) $ data = $ data [ $ p ] ; else return $ this -> returnKey ( $ strKey ) . '(' . json_encode ( $ arrReplace ) . ')' ; } $ arrSearch = array ( ) ; $ arrValues = ...
Gets a variable value and replaces placeholders contained in it
59,176
public function replace ( $ strTemplate ) { preg_match_all ( $ this -> regex , $ strTemplate , $ matches ) ; $ arrReplace = array ( ) ; foreach ( $ matches [ 1 ] as $ match ) { $ arrReplace [ ] = $ this -> get ( $ match ) ; } return str_replace ( $ matches [ 0 ] , $ arrReplace , $ strTemplate ) ; }
Insert placeholders into a string
59,177
public function init ( $ arrAccepted , $ strDefault , $ bolStore = true ) { $ strLang = isset ( $ _GET [ 'lang' ] ) ? $ _GET [ 'lang' ] : ( isset ( $ _SESSION [ 'lang' ] ) ? $ _SESSION [ 'lang' ] : ( isset ( $ _COOKIE [ 'lang' ] ) ? $ _COOKIE [ 'lang' ] : false ) ) ; if ( ! $ strLang || ! in_array ( $ strLang , $ arrAc...
Initialized the language variable and stores it in the session
59,178
public static function askBrowser ( $ arrAccepted , $ strDefault = 'de' ) { $ res = array ( 'lang' => $ strDefault , 'other' => array ( ) ) ; try { $ lang_variable = ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : null ) ; if ( empty ( $ lang_variable ) ) return $ res ; $ accep...
Returns the accepted browser language
59,179
public function getWebSrvUser ( ) { $ result = '' ; if ( $ this -> isOsWindows ( ) ) { return $ result ; } $ cmd = "ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1 2>/dev/null" ; $ output = [ ] ; $ exitCode = - 1 ; exec ( $ cmd , $ output , $ exitCode ) ; if ( ( $ e...
Return WEB server user .
59,180
public function getWebSrvUserGroup ( $ username = null ) { $ result = '' ; if ( $ this -> isOsWindows ( ) || empty ( $ username ) ) { return $ result ; } $ cmd = 'groups ' . $ username . ' | head -1 | cut -d\ -f1 2>/dev/null' ; $ output = [ ] ; $ exitCode = - 1 ; exec ( $ cmd , $ output , $ exitCode ) ; if ( ( $ exitC...
Return group of user .
59,181
public function isAppInstalled ( $ configKey = null , $ createMarkerFile = true ) { $ pathMarkerFileIsInstalled = $ this -> getPathMarkerFileIsInstalled ( ) ; if ( $ this -> _checkMarkerFile ( $ pathMarkerFileIsInstalled ) ) { return true ; } $ installTasks = $ this -> _modelConfigInstaller -> getListInstallerTasks ( )...
Check application is installed successfully
59,182
public function isAppReadyToInstall ( ) { $ checkPHPversion = $ this -> checkPhpVersion ( ) ; if ( $ checkPHPversion === false ) { return false ; } $ checkPHPextensions = $ this -> checkPhpExtensions ( true ) ; if ( $ checkPHPextensions === false ) { return false ; } return true ; }
Check application is ready to install
59,183
public function checkPhpVersion ( ) { $ phpVesion = $ this -> _modelConfigInstaller -> getPhpVersionConfig ( ) ; if ( empty ( $ phpVesion ) ) { return null ; } $ result = true ; foreach ( $ phpVesion as $ phpVesionItem ) { if ( ! is_array ( $ phpVesionItem ) ) { continue ; } $ phpVesionItem += [ '' , null ] ; list ( $ ...
Check version of PHP
59,184
public function getListDbConn ( $ path = null ) { if ( empty ( $ path ) ) { $ path = APP ; } $ configFile = $ path . 'Config' . DS . 'database.php' ; $ connections = [ ] ; if ( file_exists ( $ configFile ) ) { $ connections = array_keys ( ConnectionManager :: enumConnectionObjects ( ) ) ; } return $ connections ; }
Return list of configured database connection .
59,185
public function checkConnectDb ( $ path = null , $ returnBool = false ) { $ connections = $ this -> getListDbConn ( $ path ) ; if ( empty ( $ connections ) ) { return null ; } $ cfgConnections = $ this -> _modelConfigInstaller -> getListDbConnConfigs ( ) ; if ( empty ( $ cfgConnections ) ) { return null ; } $ connectio...
Check connections to database
59,186
public function checkSymLinksExists ( ) { $ symlinksList = $ this -> _modelConfigInstaller -> getListSymlinksCreation ( ) ; if ( empty ( $ symlinksList ) ) { return true ; } foreach ( $ symlinksList as $ link => $ target ) { if ( empty ( $ link ) ) { continue ; } if ( ! file_exists ( $ link ) || ( ! is_link ( $ link ) ...
Check symbolic links exists
59,187
public function checkCronJobsExists ( ) { if ( $ this -> isOsWindows ( ) ) { return true ; } $ apacheUser = $ this -> getWebSrvUser ( ) ; if ( empty ( $ apacheUser ) ) { return false ; } $ cronjobsList = $ this -> _modelConfigInstaller -> getListCronJobsCreation ( ) ; if ( empty ( $ cronjobsList ) ) { return true ; } $...
Check cron jobs exists
59,188
protected function _removeMarkerFile ( $ path ) { if ( empty ( $ path ) ) { return false ; } $ oFile = new File ( $ path , false ) ; if ( ! $ oFile -> exists ( ) ) { return false ; } return $ oFile -> delete ( ) ; }
Remove marker file
59,189
public function createProxyEvent ( Event $ event ) { if ( $ event instanceof GetResponseForControllerResultEvent ) { $ silexEvent = new PostDispatchEvent ( $ event ) ; } elseif ( $ event instanceof GetResponseEvent ) { $ silexEvent = new RequestEvent ( $ event ) ; } elseif ( $ event instanceof FilterControllerEvent ) {...
Create proxy event for given Symfony dispatcher event
59,190
final public static function database ( Configuration $ configuration ) { try { $ dbh = Database :: init ( $ configuration ) ; $ dbh -> connect ( ) ; $ manager = $ dbh -> getSchemaManager ( ) ; $ manager -> getTable ( $ configuration -> get ( 'database-jobs-table' ) ) ; $ manager -> getTable ( $ configuration -> get ( ...
Check if database is available and initialized correctly
59,191
protected function getActiveRecordCriteriaByName ( $ serviceLocator , $ name ) { $ criteria = $ serviceLocator -> get ( $ name ) ; if ( ! $ criteria instanceof AbstractCriteria ) { throw new Exception \ ServiceNotCreatedException ( sprintf ( 'Instance of type %s is invalid; must implement %s' , ( is_object ( $ criteria...
Retrieve PaginableCriteriaInterface object from config
59,192
protected function authFail ( $ message = null ) { $ this -> error ( $ message ) ; $ this -> view -> response [ 'auth_fail' ] = TRUE ; return FALSE ; }
Set response for an authentication failure
59,193
public function useTemplate ( $ template_name = false ) { $ templates = $ this -> getTemplates ( ) ; if ( $ template_name == false ) { $ template_name = $ templates [ 0 ] -> name ; } if ( $ template_name ) { $ this -> { $ template_name } ( ) ; } }
Add the fields defined for a specific template .
59,194
public function getTemplates ( ) { $ templates_array = [ ] ; $ templates_trait = new \ ReflectionClass ( 'App\GeoTemplates' ) ; $ templates = $ templates_trait -> getMethods ( ) ; if ( ! count ( $ templates ) ) { abort ( '403' , 'No templates have been found.' ) ; } return $ templates ; }
Get all defined templates .
59,195
public function getTemplatesArray ( ) { $ templates = $ this -> getTemplates ( ) ; foreach ( $ templates as $ template ) { $ templates_array [ $ template -> name ] = $ this -> crud -> makeLabel ( $ template -> name ) ; } return $ templates_array ; }
Get all defined template as an array .
59,196
protected function validateType ( $ embedType ) { $ valid = [ 'one' , 'many' ] ; if ( ! in_array ( $ embedType , $ valid ) ) { throw MetadataException :: invalidRelType ( $ embedType , $ valid ) ; } return true ; }
Validates the embed type .
59,197
public function castRowValues ( array & $ row ) { foreach ( $ row as $ field_name => $ value ) { $ row [ $ field_name ] = $ this -> castValue ( $ field_name , $ value ) ; } }
Cast row value to native PHP types based on caster settings .
59,198
public function castValue ( $ field_name , $ value ) { if ( $ value === null ) { return null ; } switch ( $ this -> getTypeByFieldName ( $ field_name ) ) { case self :: CAST_INT : return ( int ) $ value ; case self :: CAST_FLOAT : return ( float ) $ value ; case self :: CAST_STRING : return ( string ) $ value ; case se...
Cast a single value .
59,199
public function getTypeByFieldName ( $ field_name ) { if ( isset ( $ this -> dictated [ $ field_name ] ) ) { return $ this -> dictated [ $ field_name ] ; } if ( substr ( $ field_name , 0 , 3 ) === 'is_' || in_array ( substr ( $ field_name , 0 , 4 ) , [ 'has_' , 'had_' , 'was_' ] ) || in_array ( substr ( $ field_name , ...
Return type by field name .