idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
240,000
public function get_file_attr ( $ file , $ attr , $ type = null ) { $ file_atts = $ this -> get_file ( $ file ) ; if ( false === $ file_atts || false === isset ( $ file_atts -> $ attr ) ) { return false ; } if ( isset ( $ type ) && $ type !== $ file_atts -> type ) { return false ; } return $ file_atts -> $ attr ; }
Get a piece of information about a file .
240,001
public function set_file_attr ( $ file , $ attr , $ value , $ recursive = false ) { $ file_atts = $ this -> get_file ( $ file ) ; if ( false === $ file_atts ) { return false ; } if ( 'contents' === $ attr ) { if ( 'file' === $ file_atts -> type ) { $ file_atts -> size = mb_strlen ( $ value , '8bit' ) ; } else { return ...
Set the value of file attribute .
240,002
protected function set_file_attr_recursive ( $ file , $ attr , $ value ) { if ( 'dir' === $ file -> type ) { foreach ( $ file -> contents as $ sub => $ atts ) { $ this -> set_file_attr_recursive ( $ atts , $ attr , $ value ) ; } } $ file -> $ attr = $ value ; }
Set the value of file attribute recursively .
240,003
public function set_cwd ( $ cwd ) { $ file = $ this -> get_file ( $ cwd ) ; if ( false === $ file || 'dir' !== $ file -> type ) { return false ; } $ this -> cwd = $ this -> normalize_path ( $ cwd ) ; if ( empty ( $ this -> cwd ) ) { $ this -> cwd = '/' ; } return true ; }
Set the current working directory .
240,004
public function copy ( $ source , $ destination ) { $ source = $ this -> get_file ( $ source ) ; if ( false === $ source ) { return false ; } $ destination_parent = $ this -> get_file ( dirname ( $ destination ) ) ; $ filename = basename ( $ destination ) ; if ( false === $ destination_parent ) { return false ; } $ des...
Copy a file or directory .
240,005
public function move ( $ source , $ destination ) { if ( false === $ this -> copy ( $ source , $ destination ) ) { return false ; } $ this -> delete ( $ source ) ; return true ; }
Move a file or directory .
240,006
public function run ( ) { $ this -> make ( 'Sun\Bootstrap\Provider' ) -> registerRoute ( ) ; $ this -> route -> register ( ) ; $ httpMethod = $ this -> make ( 'Sun\Contracts\Http\Request' ) -> method ( ) ; $ uri = $ this -> make ( 'Sun\Contracts\Routing\UrlGenerator' ) -> getUri ( ) ; $ data = $ this -> route -> dispat...
To run application
240,007
public function base_path ( $ path = null ) { return empty ( $ path ) ? $ this -> path : $ this -> path . $ path ; }
To get application base directory path
240,008
public function app_path ( $ path = null ) { return empty ( $ path ) ? $ this -> base_path ( ) . DIRECTORY_SEPARATOR . 'app' : $ this -> base_path ( ) . 'app' . $ path ; }
To get application app directory path
240,009
public function loadAlien ( ) { $ alien = $ this -> config -> getAlien ( ) ; foreach ( $ alien as $ alias => $ namespace ) { class_alias ( $ namespace , $ alias ) ; } }
To load alien
240,010
public function getNamespace ( ) { if ( ! is_null ( $ this -> appNamespace ) ) { return $ this -> appNamespace ; } $ composer = json_decode ( file_get_contents ( base_path ( ) . '/composer.json' ) ) ; foreach ( $ composer -> autoload -> { "psr-4" } as $ namespace => $ path ) { if ( realpath ( app_path ( ) ) === realpat...
To get application namespace
240,011
protected function bootstrap ( ) { $ this -> make ( 'Sun\Bootstrap\Application' ) -> bootstrap ( ) ; $ this -> make ( 'Sun\Bootstrap\HandleExceptions' ) -> bootstrap ( ) ; $ this -> make ( 'Sun\Bootstrap\Route' ) -> bootstrap ( ) ; $ this -> make ( 'Sun\Bootstrap\Provider' ) -> bootstrap ( ) ; $ this -> route = $ this ...
Bootstrap application required class
240,012
protected function registerBindings ( ) { $ binding = config ( 'binding' ) ? : [ ] ; foreach ( $ binding as $ contract => $ implementation ) { $ this -> bind ( $ contract , $ implementation ) ; } }
To register all bindings
240,013
public function config ( $ location ) { $ keys = explode ( '.' , $ location ) ; $ filename = 'get' . strtoupper ( array_shift ( $ keys ) ) ; $ location = implode ( '.' , $ keys ) ; if ( empty ( $ location ) ) { return $ this -> config -> { $ filename } ( ) ; } return $ this -> config -> { $ filename } ( $ location ) ; ...
To get configuration
240,014
public function registerHook ( IHookProvider $ prov , $ moduleName , $ loadBefore = null ) { $ found = false ; if ( is_a ( $ prov , '\\pff\\Iface\\IBeforeHook' ) ) { $ found = $ this -> addHook ( $ this -> _beforeController , $ prov , $ moduleName , $ loadBefore ) ; } if ( is_a ( $ prov , '\\pff\\Iface\\IAfterHook' ) )...
Registers a hook provider
240,015
public function renderResourceButton ( $ resource , $ action = 'view' , array $ options = [ ] , array $ attributes = [ ] ) { if ( $ this -> helper -> isGranted ( $ resource , $ action ) ) { $ options = array_merge ( $ this -> getButtonOptions ( $ action ) , $ options ) ; $ label = null ; if ( array_key_exists ( 'label'...
Renders a resource action button .
240,016
function isPlainText ( $ s ) { $ arrfailAt = array ( "*" , "fonttbl" , "colortbl" , "datastore" , "themedata" ) ; for ( $ i = 0 ; $ i < count ( $ arrfailAt ) ; $ i ++ ) { if ( ! empty ( $ s [ $ arrfailAt [ $ i ] ] ) ) { return false ; } } return true ; }
For example there may be a description of font or color palette etc .
240,017
public function actions ( $ actions ) { $ substitutes = $ this -> config ( 'substitutes' ) ; foreach ( $ actions as $ name => $ config ) { if ( array_key_exists ( $ name , $ substitutes ) ) { $ actions [ $ name ] [ 'title' ] = '<i class="' . $ substitutes [ $ name ] . '"></i>' ; } } return $ actions ; }
This method replaces a string by an action icon . Mainly used for action icons
240,018
public function allowMethod ( string $ method ) : Route { if ( ! in_array ( $ method , self :: $ supportedMethods ) ) { throw new UnsupportedMethodException ( $ method ) ; } $ this -> methods [ ] = $ method ; return $ this ; }
Allows an HTTP method .
240,019
public function allowMethods ( array $ methods = [ ] ) : Route { $ this -> methods = [ ] ; foreach ( $ methods as $ method ) { $ this -> allowMethod ( $ method ) ; } return $ this ; }
Allows a list of HTTP methods .
240,020
public function getName ( ) : string { if ( $ this -> name === null ) { $ this -> name = $ this -> path ; } return $ this -> name ; }
Returns the name of the route .
240,021
public function getFilesPath ( ) { $ repo = $ this -> getServiceContainer ( ) -> getResourceRepository ( ) ; if ( ! $ repo -> contains ( $ this -> getFilesPuliPath ( ) ) ) { $ dir = new Directory ( $ repo -> get ( '/files' ) -> getFilesystemPath ( ) ) ; $ path = $ dir -> toPath ( ) -> append ( 'managed/' . $ this -> mo...
Returns the path for managed files for this module
240,022
public function getFilesUrl ( $ suffix = '' ) { $ generator = $ this -> getServiceContainer ( ) -> getUrlGenerator ( ) ; return $ generator -> generateUrl ( $ this -> getFilesPuliPath ( ) . '/' . $ suffix ) ; }
Returns the url for a managed file
240,023
public function getPreferences ( ) { if ( $ this -> preferences === null ) { $ this -> preferences = $ this -> service -> getPreferenceLoader ( ) -> getModulePreferences ( $ this -> model -> getId ( ) ) ; } return $ this -> preferences ; }
Returns the module s preferences
240,024
public function getActionModel ( $ actionName ) { if ( isset ( $ this -> actions [ $ actionName ] ) ) { return $ this -> actions [ $ actionName ] [ 'model' ] ; } return mull ; }
Returns the model for the given action name
240,025
public function loadAction ( $ nameOrAction , $ format = null ) { $ model = null ; if ( $ nameOrAction instanceof Action ) { $ model = $ nameOrAction ; $ actionName = $ nameOrAction -> getName ( ) ; } else { $ actionName = $ nameOrAction ; } if ( ! isset ( $ this -> actions [ $ actionName ] ) ) { throw new ModuleExcept...
Loads the given action
240,026
public function hasPermission ( $ action , User $ user = null ) { return $ this -> getServiceContainer ( ) -> getFirewall ( ) -> hasPermission ( $ this -> getName ( ) , $ action , $ user ) ; }
Shortcut for getting permission on the given action in this module
240,027
protected function getMasterConnection ( ) { $ db_config = $ this -> containers [ 'config' ] -> get ( 'mysql' ) ; $ master_db_config = $ db_config [ 'master' ] ; $ this -> _master_db = isset ( $ master_db_config [ 'dbname' ] ) ? $ master_db_config [ 'dbname' ] : '' ; $ this -> _master_host = isset ( $ master_db_config ...
Establish master node mysql connection
240,028
protected function getSlaveConnection ( $ server_hosts = [ ] ) { $ db_config = $ this -> containers [ 'config' ] -> get ( 'mysql' ) ; $ slave_config = $ db_config [ 'slaves' ] ; if ( ! $ server_hosts ) { foreach ( $ slave_config as $ key => $ config ) { $ server_hosts [ $ key ] = $ config [ 'host' ] ; } } if ( $ server...
Establish slave node mysql connection
240,029
protected function getExtraConnection ( $ conn ) { $ dbConfigs = $ this -> containers [ 'config' ] -> get ( 'mysql' ) ; $ dbConfig = $ dbConfigs [ $ conn ] ; $ this -> extraConfigs [ $ conn ] [ '_db' ] = $ dbConfig [ 'dbname' ] ?? '' ; $ this -> extraConfigs [ $ conn ] [ '_host' ] = $ dbConfig [ 'host' ] ?? '' ; $ this...
Establish extra mysql connection
240,030
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
240,031
public function CountryNice ( ) { $ config = SiteConfig :: current_site_config ( ) ; return Zend_Locale :: getTranslation ( $ config -> Country , "territory" , i18n :: get_locale ( ) ) ; }
Get the full translated country name
240,032
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
240,033
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 .
240,034
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 .
240,035
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 .
240,036
private function getAttributeName ( ReflectionMethod $ method ) : string { return lcfirst ( substr ( $ method -> name , 0 === strpos ( $ method -> name , 'is' ) ? 2 : 3 ) ) ; }
Get the attribute name from method .
240,037
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 .
240,038
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 .
240,039
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 .
240,040
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
240,041
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 .
240,042
protected function createWorker ( $ service ) { return $ this -> getServiceBroker ( ) -> service ( $ service ) -> context ( $ this -> command -> getContext ( ) ) ; }
Create service worker
240,043
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 .
240,044
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 .
240,045
public function getConnection ( $ serviceName ) { if ( empty ( $ this -> connectionPool [ $ serviceName ] ) ) { $ this -> initConnection ( $ serviceName ) ; } return $ this -> connectionPool [ $ serviceName ] ; }
Gets a service client connection by service name
240,046
public function initConnection ( $ serviceName ) { $ connection = $ this -> clientFactory -> createServiceClient ( $ serviceName ) ; $ this -> connectionPool [ $ serviceName ] = $ connection ; return $ this ; }
Initialize service client connection by service name
240,047
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
240,048
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
240,049
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
240,050
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
240,051
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
240,052
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 .
240,053
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
240,054
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
240,055
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 .
240,056
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 .
240,057
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
240,058
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
240,059
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
240,060
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
240,061
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 .
240,062
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 .
240,063
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 .
240,064
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 .
240,065
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...
240,066
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 .
240,067
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 .
240,068
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 .
240,069
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 .
240,070
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 .
240,071
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 .
240,072
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 .
240,073
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 .
240,074
public function create ( $ field , AbstractPost $ post ) { $ data = get_field_object ( $ field , $ post -> getId ( ) ) ; return $ this -> createFromField ( $ data ) ; }
Create a new custom field object .
240,075
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 .
240,076
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 .
240,077
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
240,078
public function lock ( ) { $ this -> _validate ( ) ; $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] = true ; return true ; }
Lock the namespace this will prevent removal of keys
240,079
public function unlock ( ) { $ this -> _validate ( ) ; $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] = false ; return true ; }
Unlock the namespace this will allow removal of keys
240,080
public function isLocked ( ) { $ this -> _validate ( ) ; if ( $ _SESSION [ $ this -> secretStorage ] [ 'locks' ] [ $ this -> _namespaceName ] == true ) { return true ; } return false ; }
Check if a namespace is currently locked .
240,081
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
240,082
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
240,083
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
240,084
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
240,085
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
240,086
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 .
240,087
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 .
240,088
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 .
240,089
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 .
240,090
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 .
240,091
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
240,092
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
240,093
public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( $ template = $ this -> getTemplate ( $ request , $ event -> getController ( ) ) ) { $ request -> attributes -> set ( '_template' , $ template ) ; } }
Handles Kernel Controller events
240,094
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
240,095
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
240,096
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
240,097
protected function templateExists ( $ template ) { try { $ class = $ this -> templating -> getTemplateClass ( $ template ) ; } catch ( Twig_Error_Loader $ e ) { return false ; } return $ template ; }
Does the given template exists?
240,098
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 .
240,099
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