idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
232,100
function Generate ( ) { if ( $ this -> cacher -> MustUseCache ( ) ) { $ this -> xml = $ this -> cacher -> GetFromCache ( ) ; return ; } $ this -> AddAllPages ( ) ; $ this -> xml = $ this -> sitemap -> SaveXml ( ) ; if ( $ this -> cacher -> MustStoreToCache ( ) ) { $ this -> cacher -> StoreToCache ( $ this -> xml ) ; } ...
Generates the xml by pulling it from cache or generating it
232,101
private function AddAllPages ( ) { $ page = $ this -> pageTree -> TopMost ( ) ; while ( $ page ) { $ this -> AddPageBranch ( $ page ) ; $ page = $ this -> pageTree -> NextOf ( $ page ) ; } }
The entry point for fetching all pages as sitemap
232,102
private function AddPageBranch ( Page $ page ) { $ this -> AddPage ( $ page ) ; $ child = $ this -> pageTree -> FirstChildOf ( $ page ) ; while ( $ child ) { $ this -> AddPageBranch ( $ child ) ; $ child = $ this -> pageTree -> NextOf ( $ child ) ; } }
Adds a page and all of its children
232,103
private function AddPage ( Page $ page ) { if ( ! $ this -> PageAllowed ( $ page ) ) { return ; } $ params = FrontendRouter :: GatherParams ( $ page -> GetUrl ( ) ) ; if ( count ( $ params ) == 0 ) { $ changeFreq = ChangeFrequency :: ByValue ( $ page -> GetSitemapChangeFrequency ( ) ) ; $ priority = $ page -> GetSitema...
Adds a single page to the sitemap
232,104
public function action ( string $ message , string $ link , string $ class = 'btn btn-primary' ) : Mail { $ this -> body .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"{$class}\"><tbody> <tr> <td align=\"left\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tbody> ...
Create a action
232,105
public function view ( string $ view , array $ data = [ ] ) : Mail { $ this -> viewLocation = $ view ; $ this -> viewArgs = $ data ; return $ this ; }
Set view email view
232,106
public function send ( ? string $ message = null , ? string $ subject = null ) { if ( $ message != null ) { $ this -> body = $ message ; } if ( $ subject != null ) { $ this -> subject = $ subject ; } if ( $ this -> viewLocation != null || $ this -> viewLocation !== '' ) { $ this -> render ( $ this -> viewLocation , $ t...
Finally send the email!!!
232,107
protected static function xmlToArray ( \ SimpleXMLElement $ xml ) { $ arr = array ( ) ; foreach ( $ xml as $ element ) { $ tag = $ element -> getName ( ) ; $ ele = get_object_vars ( $ element ) ; if ( ! empty ( $ ele ) ) { $ arr [ $ tag ] = $ element instanceof \ SimpleXMLElement ? static :: xmlToArray ( $ element ) : ...
Convert SimpleXML object to array
232,108
protected function RenderArea ( $ name ) { $ area = $ this -> areas [ $ name ] ; if ( ! $ area ) { throw new \ InvalidArgumentException ( "Invalid area name $name" ) ; } $ layoutAreaRenderer = new LayoutAreaRenderer ( $ area ) ; $ result = $ layoutAreaRenderer -> Render ( ) ; $ pageAreaRenderer = new PageAreaRenderer (...
Renders the area with the given name
232,109
function Render ( ) { self :: $ currentPage = $ this -> page ; self :: $ Title = self :: $ currentPage -> GetTitle ( ) ; self :: $ Description = self :: $ currentPage -> GetDescription ( ) ; self :: $ Keywords = self :: $ currentPage -> GetKeywords ( ) ; if ( $ this -> page -> GetType ( ) == ( string ) PageType :: NotF...
Renders the complete page by requiring the page layout
232,110
protected function getRoute ( $ destination ) { $ destinationPieces = explode ( '/' , $ destination ) ; $ mappingNode = $ this -> routeMapping ; $ argValues = array ( ) ; foreach ( $ destinationPieces as $ destinationPiece ) { if ( isset ( $ mappingNode [ $ destinationPiece ] ) ) { $ mappingNode = $ mappingNode [ $ des...
Get Route for given destination
232,111
public function addMapping ( $ destinationPattern , $ controllerClass , $ actionName ) { $ mapping = new Route \ Mapping ( $ destinationPattern , $ controllerClass , $ actionName ) ; $ this -> reverseMapping [ $ controllerClass ] [ $ actionName ] = $ mapping ; $ destinationPieces = explode ( '/' , $ destinationPattern ...
Add route mapping
232,112
public function outputAction ( $ startTime , $ showProfiler ) { $ data = [ 'showProfiler' => $ showProfiler ] ; if ( $ showProfiler ) { $ data = [ 'showProfiler' => true , 'memory' => \ Shade \ Converter :: formatBytes ( memory_get_usage ( true ) ) , 'memoryPeak' => \ Shade \ Converter :: formatBytes ( memory_get_peak_...
Output profiler information
232,113
public function header ( $ name , $ value = null ) { if ( $ value === null ) { $ this -> headers [ ] = $ name ; } else { $ this -> headers [ ] = $ this -> headerString ( $ name , $ value ) ; } return $ this ; }
Header kodu ekler mesaja
232,114
public static function ToChar ( $ value , $ provider = null ) { if ( $ value instanceof \ DateTime ) { $ value = Convert :: ToString ( $ value , $ provider ) ; if ( is_null ( $ value ) ) return null ; } if ( is_string ( $ value ) && strlen ( $ value ) ) { return $ value [ 0 ] ; } else if ( is_numeric ( $ value ) ) { $ ...
Converts the value of this instance to an equivalent Unicode character using the specified culture - specific formatting information .
232,115
public static function ChangeType ( $ value , $ conversionType , $ provider = null ) { return Convert :: ToType ( $ value , $ conversionType , $ provider ) ; }
ChangeType an alias for ToType
232,116
public static function ToDateTime ( $ value , $ provider = null ) { if ( $ value instanceof \ DateTime ) return $ value ; if ( is_string ( $ value ) ) { $ timestamp = strtotime ( $ value ) ; if ( $ timestamp === false ) return null ; $ dt = new \ DateTime ( ) ; $ dt -> setTimestamp ( $ timestamp ) ; return $ dt ; } $ v...
Converts the value of this instance to an equivalent DateTime using the specified culture - specific formatting information .
232,117
public static function ToDecimal ( $ value , $ provider = null ) { return is_double ( $ value ) ? DecimalValue :: FromFloat ( $ value ) : new DecimalValue ( $ value ) ; }
Converts the value of this instance to an equivalent System . Decimal number using the specified culture - specific formatting information .
232,118
public static function ToDouble ( $ value , $ provider = null ) { if ( $ value instanceof \ DateTime ) { return NAN ; } else if ( ( is_numeric ( $ value ) && $ value == INF ) || ( is_string ( $ value ) && strtoupper ( $ value ) == "INF" ) ) { return INF ; } else if ( ( is_numeric ( $ value ) && $ value == - INF ) || ( ...
Converts the value of this instance to an equivalent double - precision floating - point number using the specified culture - specific formatting information .
232,119
public static function ToString ( $ value , $ provider = null ) { if ( $ value instanceof XPath2Item ) { return $ value -> getValue ( ) ; } if ( $ value instanceof \ DateTime ) { $ collator = \ Collator :: create ( null ) ; $ locale = $ collator -> getLocale ( \ Locale :: VALID_LOCALE ) ; $ dateTime = \ IntlDateFormatt...
Converts the value of this instance to an equivalent System . String using the specified culture - specific formatting information .
232,120
public static function ToInt ( $ value , $ provider = null ) { if ( $ value instanceof ValueProxy ) { return $ value -> ToInt ( $ provider ) ; } if ( $ value instanceof XPath2Item ) { return Convert :: ToInt ( $ value -> getTypedValue ( ) , $ provider ) ; } if ( is_numeric ( $ value ) ) { if ( $ value > PHP_INT_MAX ) r...
Converts the value of this instance to an equivalent integer using the specified culture - specific formatting information .
232,121
public function updateUserSettings ( FilterUserFieldsEvent $ userfields_filter ) { $ settings_manager = $ userfields_filter -> getContainer ( ) -> get ( 'acs.setting_manager' ) ; $ user = $ userfields_filter -> getContainer ( ) -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ; $ fields_template = $ userfie...
Create new added fields to user or missing fields
232,122
public function toArray ( $ sheet_name , $ ext = false ) { if ( ! $ ext ) { $ ext = pathinfo ( $ sheet_name , PATHINFO_EXTENSION ) ; } switch ( $ ext ) { case 'csv' : $ reader = ReaderFactory :: create ( Type :: CSV ) ; break ; case 'ods' : $ reader = ReaderFactory :: create ( Type :: ODS ) ; break ; case 'xlsx' : $ re...
Converte uma planilha para array
232,123
public function toSheet ( $ array , $ sheet_name , $ ext = false ) { if ( ! $ ext ) { $ ext = pathinfo ( $ sheet_name , PATHINFO_EXTENSION ) ; } switch ( $ ext ) { case 'csv' : $ writer = WriterFactory :: create ( Type :: CSV ) ; break ; case 'ods' : $ writer = WriterFactory :: create ( Type :: ODS ) ; break ; case 'xl...
Converte um array de dados para uma planilha
232,124
public static function dump ( $ data = null , $ export = false ) { if ( false === is_bool ( $ export ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ export ) ) , E_USER_ERROR ) ; } if ( $ data === null || ( true === is_string ( $ data...
Advanced debugging of variables
232,125
public static function time ( $ key = null ) { if ( null !== $ key && false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( count ( static :: $ time ) === 0 ) { static :: $ time =...
Calculate process times by adding new times an exporting them
232,126
public function has ( string $ key ) : bool { $ key = $ this -> getKey ( $ key , true ) ; return isset ( $ this -> headers [ $ key ] ) ; }
Determine whether a particular header exists
232,127
protected function getKey ( string $ key , bool $ register = false ) : string { $ lowercaseKey = strtolower ( $ key ) ; if ( isset ( $ this -> keyMap [ $ lowercaseKey ] ) ) { $ key = $ this -> keyMap [ $ lowercaseKey ] ; } elseif ( $ register ) { $ this -> keyMap [ $ lowercaseKey ] = $ key ; } return $ key ; }
Retrieve a key that can be used in a hashmap to prevent duplicate keys
232,128
public function addMultiple ( array $ headers ) : HeaderCollection { foreach ( $ headers as $ key => $ value ) { $ key = $ this -> getKey ( $ key , true ) ; \ sndsgd \ Arr :: addValue ( $ this -> headers , $ key , $ value ) ; } return $ this ; }
Add multiple headers
232,129
public function get ( string $ key ) : string { $ key = $ this -> getKey ( $ key ) ; $ value = $ this -> headers [ $ key ] ?? "" ; return is_array ( $ value ) ? implode ( ", " , $ value ) : $ value ; }
Get a header value
232,130
public function getMultiple ( string ... $ keys ) : array { $ ret = [ ] ; foreach ( $ keys as $ key ) { $ ret [ ] = $ this -> get ( $ key ) ; } return $ ret ; }
Get multiple header values
232,131
public function getStringifiedArray ( ) : array { $ ret = [ ] ; foreach ( $ this -> headers as $ header => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( ", " , $ value ) ; } $ ret [ ] = "$header: $value" ; } return $ ret ; }
Retrieve an array of headers as strings
232,132
public function map ( $ type , $ transformation ) { if ( ! is_callable ( $ transformation ) ) throw new InvalidTransformationException ( 'Transformations must be callable objects' ) ; foreach ( ( array ) $ type as $ t ) { $ this -> getMatcher ( ) -> rule ( 'type' , $ t , $ transformation ) ; } return $ this ; }
Register a map for the compiler that matches on type
232,133
public function post2faRegisterDisplayForm ( Request $ request ) { if ( config ( 'lasallecmsusermanagement.auth_users_registration_front_end_require_terms_of_service' ) ) { if ( ! $ request -> input ( 'terms-of-service' ) ) { return redirect ( ) -> route ( 'auth.register' ) -> withInput ( $ request -> only ( 'name' , '...
The front - end 2FA registration form comes here .
232,134
public function findAll ( ) { $ files = array ( ) ; foreach ( new \ DirectoryIterator ( $ this -> path ) as $ file ) { if ( $ file -> isDot ( ) ) { continue ; } $ files [ ] = $ file -> getFilename ( ) ; } sort ( $ files ) ; return $ files ; }
Find all releases
232,135
public function tileUrlFunction ( $ text , $ extension = 'png' ) { $ router = $ this -> container -> get ( 'router' ) ; $ url = $ router -> generate ( 'tile' , [ 'text' => $ text , 'extension' => $ extension , ] ) ; return $ url ; }
Creates the QR code URL corresponding to the given message and extension .
232,136
public function typeAction ( $ contentDocument , $ _format , Request $ request ) { if ( ! $ contentDocument || ! $ contentDocument instanceof Page ) { throw new NotFoundHttpException ( 'Content not found' ) ; } if ( $ this -> container -> has ( 'profiler' ) ) { $ this -> container -> get ( 'profiler' ) -> disable ( ) ;...
This action is mapped in the controller_by_type map
232,137
public function getMessage ( $ type , $ id = null ) { $ result = null ; if ( null === $ id ) { if ( array_key_exists ( $ type , $ this -> messages ) ) { $ result = $ this -> messages [ $ type ] ; if ( ! $ this -> persistMessages ) { unset ( $ this -> messages [ $ type ] ) ; } } } if ( null !== $ id ) { if ( array_key_e...
Retrieve a message
232,138
public static function equalWithin ( $ a , $ b , $ delta ) { if ( is_infinite ( $ a ) xor is_infinite ( $ b ) ) { return false ; } if ( is_nan ( $ a ) || is_nan ( $ b ) || is_nan ( $ delta ) ) { return false ; } return abs ( $ a - $ b ) <= $ delta ; }
Are two numbers equal within given delta .
232,139
protected function compile ( ) { parent :: compile ( ) ; if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] == 'bootstrap_customizable' ) { $ container = ColumnSet :: prepareContainer ( $ this -> columnset_id ) ; if ( $ container ) { $ this -> Template -> column = $ container [ $ this -> sc_sortid ] [ 0 ] . ' col_' . ( $ ...
extends subcolumns compile method for generating dynamically column set
232,140
public function getFluidRendererForTemplate ( string $ template , string $ format = 'html' ) { $ configurationManager = $ this -> objectManager -> get ( ConfigurationManagerInterface :: class ) ; $ configuration = $ configurationManager -> getConfiguration ( ConfigurationManagerInterface :: CONFIGURATION_TYPE_FRAMEWORK...
Gets a Fluid renderer for a template .
232,141
public function merge ( array $ members ) { foreach ( $ members as $ offset => $ value ) { $ this -> offsetSet ( $ offset , $ value ) ; } return $ this ; }
Merge a array of potential members into the flock replacing as required
232,142
public function add ( ) { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { foreach ( $ arg as $ value ) { $ this [ ] = $ value ; } } else { $ this [ ] = $ arg ; } } return $ this ; }
Add items to this flock
232,143
public function remove ( $ member ) { if ( false !== $ key = array_search ( $ member , $ this -> members , true ) ) { unset ( $ this -> members [ $ key ] ) ; } return $ this ; }
Remove a member from the flock
232,144
private function makeCheckCallback ( $ check ) { if ( is_callable ( $ check ) ) { $ this -> check = $ check ; $ this -> type = $ this -> makeCallbackHumanReadable ( $ check ) ; return ; } if ( is_object ( $ check ) ) { $ class = get_class ( $ check ) ; } elseif ( is_string ( $ check ) ) { $ class = ( string ) $ check ;...
Make check callback for flock
232,145
private function makeCallbackHumanReadable ( Callable $ callback ) { if ( is_string ( $ callback ) ) { return $ callback ; } elseif ( is_array ( $ callback ) ) { return sprintf ( "%s::%s" , is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] , $ callback [ 1 ] ) ; } elseif ( ! ( $ callbac...
Return a string which is a best human readable representation the callback possible
232,146
private function isPathWritable ( ) : bool { if ( ! file_exists ( $ this -> path ) ) { return is_writable ( dirname ( $ this -> path ) ) ; } return is_writable ( $ this -> path ) ; }
Return whether the path is writable .
232,147
private function write ( array $ compiled ) : void { $ tmp = tempnam ( sys_get_temp_dir ( ) , 'quanta' ) ; if ( $ tmp !== false ) { file_put_contents ( $ tmp , vsprintf ( '<?php%s%sreturn %s;%s' , [ PHP_EOL , PHP_EOL , Utils :: ArrayStr ( $ compiled ?? [ ] ) , PHP_EOL , ] ) ) ; rename ( $ tmp , $ this -> path ) ; } }
Write the given compiled factories array to a unique temporary file and move it to the compiled file path .
232,148
public function compiled ( callable $ callable ) : string { if ( ! $ this -> compiler ) { $ this -> compiler = new Compiler ( new AstAnalyzerAdapter ( new AstAnalyzer ) ) ; } return ( $ this -> compiler ) ( $ callable ) ; }
Return a string representation of the given callable .
232,149
public function getContext ( ) { if ( ! $ this -> locked ) { throw new Exception \ LogicException ( 'Context is not yet available. You must first call handleRequest()' ) ; } if ( null === $ this -> context ) { $ this -> context = new Context \ Context ( ) ; $ this -> context -> setVisibleColumns ( array_keys ( $ this -...
Returns the context .
232,150
public function sortElements ( ) { $ sort = function ( $ a , $ b ) { $ aPos = $ a -> getConfig ( ) -> getPosition ( ) ; $ bPos = $ b -> getConfig ( ) -> getPosition ( ) ; if ( $ aPos == $ bPos ) { return 0 ; } return $ aPos > $ bPos ? 1 : - 1 ; } ; uasort ( $ this -> columns , $ sort ) ; uasort ( $ this -> filters , $ ...
Sorts the columns and filers .
232,151
private function getSelectionMode ( ) { if ( null !== $ mode = $ this -> config -> getSelectionMode ( ) ) { return $ mode ; } if ( $ this -> config -> isBatchable ( ) && ! empty ( $ this -> actions ) ) { return Util \ Config :: SELECTION_MULTIPLE ; } if ( $ this -> config -> isExportable ( ) && $ this -> config -> hasE...
Returns the table s selection mode .
232,152
protected function fixTableSource ( $ refTbl ) { $ outS = [ ] ; if ( substr ( $ refTbl , 0 , 1 ) !== '`' ) { $ outS [ ] = '`' ; } $ psT = strpos ( $ refTbl , '.`' ) ; if ( $ psT !== false ) { $ refTbl = substr ( $ refTbl , $ psT + 2 , strlen ( $ refTbl ) - $ psT ) ; } $ outS [ ] = $ refTbl ; if ( substr ( $ refTbl , - ...
Adjust table name with proper sufix and prefix
232,153
protected function handleFeatures ( $ fieldName , $ features ) { $ rOly = $ this -> handleFeaturesSingle ( $ fieldName , $ features , 'readonly' ) ; $ rDbld = $ this -> handleFeaturesSingle ( $ fieldName , $ features , 'disabled' ) ; $ rNl = [ ] ; if ( isset ( $ features [ 'include_null' ] ) && in_array ( $ fieldName ,...
Manages features flag
232,154
private function handleFeaturesSingle ( $ fieldName , $ features , $ featureKey ) { $ fMap = [ 'readonly' => [ 'readonly' , 'class' , 'input_readonly' ] , 'disabled' => [ 'disabled' ] ] ; $ aReturn = [ ] ; if ( array_key_exists ( $ featureKey , $ features ) ) { if ( array_key_exists ( $ fieldName , $ features [ $ featu...
Handles the features
232,155
private function handleMySqlVersionConsistenly ( ) { if ( substr ( $ this -> mySQLconnection -> server_info , - 7 ) === 'MariaDB' ) { $ strVersionParts = explode ( '.' , explode ( '-' , $ this -> mySQLconnection -> server_info ) [ 1 ] ) ; return $ this -> getTwoDecimalsNumber ( $ strVersionParts [ 0 ] ) . $ this -> get...
Ensures a consistent output of version for MySQL as well as MariaDB
232,156
protected function setVariableTypeForMySqlStatements ( $ variabaleValue ) { $ sReturn = 'b' ; if ( is_int ( $ variabaleValue ) ) { $ sReturn = 'i' ; } elseif ( is_double ( $ variabaleValue ) ) { $ sReturn = 'd' ; } elseif ( is_string ( $ variabaleValue ) ) { $ sReturn = 's' ; } return $ sReturn ; }
Detects what kind of variable has been transmitted to return the identifier needed by MySQL statement preparing
232,157
protected function validateBounds ( ) { $ connection = $ this -> model -> getConnection ( ) ; $ grammar = $ connection -> getQueryGrammar ( ) ; $ tableName = $ this -> model -> getTable ( ) ; $ primaryKeyName = $ this -> model -> getKeyName ( ) ; $ parentColumn = $ this -> model -> getQualifiedParentColumnName ( ) ; $ ...
Validates bounds of the nested tree structure . It will perform checks on the lft rgt and parent_id columns . Mainly that they re not null rights greater than lefts and that they re within the bounds of the parent .
232,158
protected function validateDuplicates ( ) { return ( ! $ this -> duplicatesExistForColumn ( $ this -> model -> getQualifiedLeftColumnName ( ) ) && ! $ this -> duplicatesExistForColumn ( $ this -> model -> getQualifiedRightColumnName ( ) ) ) ; }
Checks that there are no duplicates for the lft and rgt columns .
232,159
protected function validateRoots ( ) { $ roots = forward_static_call ( [ get_class ( $ this -> model ) , 'roots' ] ) -> get ( ) ; if ( $ this -> model -> isScoped ( ) ) return $ this -> validateRootsByScope ( $ roots ) ; return $ this -> isEachRootValid ( $ roots ) ; }
For each root of the whole nested set tree structure checks that their lft and rgt bounds are properly set .
232,160
protected function keyForScope ( $ model ) { return implode ( '-' , array_map ( function ( $ column ) use ( $ model ) { $ value = $ model -> getAttribute ( $ column ) ; if ( is_null ( $ value ) ) return 'NULL' ; return $ value ; } , $ model -> getScopedColumns ( ) ) ) ; }
Builds a single string for the given scope columns values . Useful for making array keys for grouping .
232,161
function parse ( ) { $ name_without_parens = preg_replace ( '/[{}]/' , '' , $ this -> full_name ) ; $ parts = explode ( '::' , $ name_without_parens ) ; $ name_without_case_keys = trim ( $ parts [ 0 ] ) ; array_shift ( $ parts ) ; $ this -> case_keys = array_map ( 'trim' , $ parts ) ; $ parts = explode ( ':' , $ name_w...
Parses token name elements
232,162
public function contextForLanguage ( $ language , $ opts = array ( ) ) { if ( count ( $ this -> context_keys ) > 0 ) { $ ctx = $ language -> contextByKeyword ( $ this -> context_keys [ 0 ] ) ; } else { $ ctx = $ language -> contextByTokenName ( $ this -> short_name ) ; } return $ ctx ; }
For transform tokens we can only use the first context key if it is not mapped in the context itself .
232,163
public static function tokenObject ( $ token_values , $ token_name ) { if ( $ token_values == null ) return null ; if ( ! array_key_exists ( $ token_name , $ token_values ) ) return null ; $ token_object = $ token_values [ $ token_name ] ; if ( is_array ( $ token_object ) ) { if ( \ Tr8n \ Utils \ ArrayUtils :: isHash ...
Returns an object from values hash .
232,164
public function tokenValueFromArrayParam ( $ token_data , $ language , $ options = array ( ) ) { if ( count ( $ token_data ) == 0 ) return $ this -> error ( "Invalid number of params of an array" ) ; $ object = $ token_data [ 0 ] ; $ method = count ( $ token_data ) > 1 ? $ token_data [ 1 ] : null ; if ( is_array ( $ ob...
gets the value based on various evaluation methods
232,165
public function tokenValue ( $ token_values , $ language , $ options = array ( ) ) { if ( isset ( $ token_values [ $ this -> short_name ] ) ) { $ object = $ token_values [ $ this -> short_name ] ; } else { $ object = Config :: instance ( ) -> defaultToken ( $ this -> short_name , 'data' ) ; } if ( $ object === null ) r...
Returns a value from values hash .
232,166
public function substitute ( $ label , $ token_values , $ language , $ options = array ( ) ) { $ token_value = $ this -> tokenValue ( $ token_values , $ language , $ options ) ; return str_replace ( $ this -> full_name , $ token_value , $ label ) ; }
Main substitution function
232,167
public static function findFilters ( $ om , array $ filters , $ all = false ) { if ( ! $ om instanceof EntityManagerInterface || ( empty ( $ filters ) && ! $ all ) ) { return [ ] ; } $ all = ( $ all && ! empty ( $ filters ) ) ? false : $ all ; $ enabledFilters = self :: getEnabledFilters ( $ om ) ; return self :: doFin...
Get the list of SQL Filter name must to be disabled .
232,168
public static function getEnabledFilters ( $ om ) { $ filters = [ ] ; if ( $ om instanceof EntityManagerInterface ) { $ enabledFilters = $ om -> getFilters ( ) -> getEnabledFilters ( ) ; foreach ( $ enabledFilters as $ name => $ filter ) { if ( ! $ filter instanceof EnableFilterInterface || ( $ filter instanceof Enable...
Get the enabled sql filters .
232,169
public static function isEnabled ( $ om , $ name ) { if ( $ om instanceof EntityManagerInterface ) { $ sqlFilters = $ om -> getFilters ( ) ; if ( $ sqlFilters -> isEnabled ( $ name ) ) { $ filter = $ sqlFilters -> getFilter ( $ name ) ; return ! $ filter instanceof EnableFilterInterface || ( $ filter instanceof EnableF...
Check if the filter is enabled .
232,170
protected static function doFindFilters ( array $ filters , array $ enabledFilters , $ all ) { $ reactivateFilters = [ ] ; foreach ( $ enabledFilters as $ name => $ filter ) { if ( \ in_array ( $ name , $ filters , true ) || $ all ) { $ reactivateFilters [ ] = $ name ; } } return $ reactivateFilters ; }
Do find filters .
232,171
public function setFileFormats ( array $ formats ) { $ this -> file_formats = array ( ) ; foreach ( $ formats as $ mime => $ writer ) $ this -> addFileFormat ( $ mime , $ writer ) ; return $ this ; }
Set the available file formats - replacing the previous list
232,172
public function forceMimeType ( string $ mime ) { if ( ! isset ( $ this -> file_formats [ $ mime ] ) ) { throw new \ InvalidArgumentException ( "Cannot force output without a writer available: " . $ mime ) ; } $ this -> file_formats = [ $ mime => $ this -> file_formats [ $ mime ] ] ; return $ this ; }
Reduce the list of available file formats to a single one
232,173
public function addFileFormat ( string $ mime_type , $ writer_class ) { if ( is_string ( $ writer_class ) ) { if ( ! class_exists ( $ writer_class ) || ! ( is_subclass_of ( $ writer_class , AbstractWriter :: class , $ writer_class ) ) ) { throw new InvalidArgumentException ( "Class {$writer_class} does not exist or doe...
Add a file format that this writer can output . This can be used to add a custom mime - type - > writer mapping . If the format is already registered it is overwritten .
232,174
public function output ( string $ mime ) { $ pprint = $ this -> pretty_printing ; $ classname = $ this -> file_formats [ $ mime ] ?? "NullWriter" ; $ output = "" ; try { if ( $ classname instanceof AbstractWriter ) $ writer = $ classname ; elseif ( class_exists ( $ classname ) ) $ writer = new $ classname ( $ pprint ) ...
Output the response data in the selected format
232,175
public function findOrFail ( $ id ) { if ( $ model = $ this -> find ( $ id ) ) { return $ model ; } throw ( new ModelNotFoundException ) -> setModel ( get_class ( $ this -> getModel ( ) ) ) ; }
Find and throw an exception if model not found
232,176
public function render ( array $ vars = array ( ) ) { $ templateFile = $ this -> getTemplateRouter ( ) -> findTemplateFile ( $ this -> getRequest ( ) ) ; if ( $ templateFile ) { return $ this -> getAppController ( ) -> render ( $ templateFile , $ vars ) ; } return $ this -> getAppController ( ) -> error404 ( ) ; }
renders the template associated with the current route .
232,177
public function redirect ( array $ flashes = array ( ) ) { foreach ( $ flashes as $ type => $ message ) { $ this -> getAppController ( ) -> flash ( ) -> add ( $ type , $ message ) ; } return $ this -> getAppController ( ) -> redirect ( $ this -> getRequest ( ) -> getRequestUri ( ) ) ; }
redirects to the same same uri .
232,178
public function setStatusCode ( $ statusCode ) { $ statusCode = ( int ) $ statusCode ; if ( $ statusCode < 100 || $ statusCode >= 600 ) { throw new \ Exception ( "Invalid status code: {$statusCode}." ) ; } $ this -> statusCode = $ statusCode ; return $ this ; }
Sets the status code .
232,179
protected function getStatusMessage ( $ code ) { return ( isset ( $ this -> statusMessages [ $ code ] ) ? $ this -> statusMessages [ $ code ] : $ this -> statusMessages [ 500 ] ) ; }
Gets the HTTP status message for a status code .
232,180
public function removeHypertextRoute ( $ name ) { if ( isset ( $ this -> hypertextRoutes [ $ name ] ) ) { unset ( $ this -> hypertextRoutes [ $ name ] ) ; } return $ this ; }
Removes a hypertext route by name .
232,181
public function output ( $ isFinal = false ) { if ( $ this -> finalOutput ) { return ; } $ this -> finalOutput = $ isFinal ; header ( "HTTP/1.1 {$this->statusCode} {$this->getStatusMessage($this->statusCode)}" ) ; header ( "Cache-Control: no-cache, must-revalidate" ) ; header ( "Expires: 0" ) ; $ this -> hypertextRoute...
Outputs the current response in the correct response type and sets the headers .
232,182
public function process ( ) { if ( $ this -> configuration -> getUseAuthorization ( ) ) { if ( $ this -> uri != '/token' && $ this -> uri != '/authorize' && ! $ this -> tokenServer -> verifyResourceRequest ( \ OAuth2 \ Request :: createFromGlobals ( ) ) ) { $ data = $ this -> tokenServer -> getResponse ( ) -> getRespon...
Processes the API by calling the execute method on the router .
232,183
public function handleOptionsRequest ( ) { $ allow = '' ; foreach ( $ this -> router -> getMethodsByRoute ( $ this -> uri ) as $ method ) { $ allow .= strtoupper ( $ method ) . ',' ; } $ allow = substr ( $ allow , 0 , strlen ( $ allow ) - 1 ) ; header ( 'Allow: ' . $ allow ) ; $ this -> setResponse ( '' ) ; }
Handles an HTTP OPTIONS requests . Returns available methods for the current route .
232,184
protected function addRoutes ( ) { $ this -> router -> add ( '/' , [ $ this , 'unknownEndpoint' ] ) ; if ( $ this -> configuration -> getUseAuthorization ( ) ) { $ this -> router -> add ( '/token' , [ $ this , 'token' ] ) ; if ( $ this -> configuration -> getAuthorizationMode ( ) >= 2 ) { $ this -> router -> add ( '/au...
Adds default routes for the API regarding tokens . These routes can be overridden in the child API class .
232,185
private function createTokenServer ( ) { try { $ storage = new \ OAuth2 \ Storage \ Pdo ( [ 'dsn' => $ this -> configuration -> getDsn ( ) , 'username' => $ this -> configuration -> getUsername ( ) , 'password' => $ this -> configuration -> getPassword ( ) , ] ) ; $ server = new \ OAuth2 \ Server ( $ storage ) ; if ( $...
Creates the new token server . Sets the connection to the database and grant types .
232,186
public function token ( ) { $ response = $ this -> tokenServer -> handleTokenRequest ( \ OAuth2 \ Request :: createFromGlobals ( ) ) ; $ data = $ response -> getResponseBody ( 'json' ) ; $ data = json_decode ( $ data , true ) ; $ this -> response = $ data ; $ this -> statusCode = $ response -> getStatusCode ( ) ; $ thi...
Handles generating tokens for clients .
232,187
public function authorize ( ) { $ request = \ OAuth2 \ Request :: createFromGlobals ( ) ; $ response = new \ OAuth2 \ Response ( ) ; if ( ! $ this -> tokenServer -> validateAuthorizeRequest ( $ request , $ response ) ) { $ data = $ response -> getResponseBody ( 'json' ) ; $ data = json_decode ( $ data , true ) ; $ this...
Handles authorizing clients to receive an OAuth2 access token .
232,188
protected function secondsRemainingOnLockout ( Request $ request ) { return UniversalBuilder :: resolveClass ( RateLimiter :: class ) -> availableIn ( $ this -> getThrottleKey ( $ request ) ) ; }
Get the lockout seconds .
232,189
public function getShortcodes ( ) { $ shortcodes = array_map ( function ( $ replacement ) { return "[{$replacement}]" ; } , $ this -> replacements ) ; return collect ( array_combine ( $ shortcodes , $ this -> replacements ) ) ; }
Get the replacements shortcodes .
232,190
protected function mergeReplacements ( array $ replacements ) { return $ this -> getShortcodes ( ) -> transform ( function ( $ key ) use ( $ replacements ) { return Arr :: get ( $ replacements , $ key ) ; } ) -> filter ( ) ; }
Merge replacements .
232,191
public function highlight ( $ content , $ replacement = '<code>[\1]</code>' ) { return preg_replace ( '/\[(' . $ this -> getShortcodes ( ) -> values ( ) -> implode ( '|' ) . ')\]/' , $ replacement , $ content ) ; }
Highlight the replacement .
232,192
protected function processResponseType ( $ response = null ) { if ( $ response instanceof Response ) { $ this -> response = $ response ; } elseif ( is_string ( $ response ) || is_numeric ( $ response ) ) { $ this -> response -> setContent ( $ response ) ; } elseif ( is_array ( $ response ) ) { $ this -> response = new ...
Process the Response Type .
232,193
public function offsetSet ( $ offset , $ segment ) { if ( is_null ( $ offset ) ) { $ this -> segments [ ] = ( string ) $ segment ; } else { $ this -> segments [ $ offset ] = ( string ) $ segment ; } }
Set the segment at a given offset .
232,194
public static function implode ( $ segments , $ separator = self :: SEPARATOR ) { return ( string ) Uzi :: join ( $ separator , $ segments , true ) ; }
Join the segments of a key into a string
232,195
public function getRelationManager ( EntityContract $ entity ) { $ key = $ entity -> { $ this -> getRelationKey ( ) } ; if ( ! isset ( $ this -> relations [ $ key ] ) ) { return null ; } $ class = $ this -> relations [ $ key ] ; return new $ class ( $ this -> getManager ( ) -> getAgent ( ) ) ; }
Retrieve relation manager .
232,196
public function addHook ( Hook $ hook ) { if ( isset ( $ this -> hooks [ $ hook -> name ] ) === false ) { $ this -> logger -> debug ( "Adding definition for hook '{$hook->name}' for the first time." ) ; $ this -> hooks [ $ hook -> name ] = [ ] ; } $ this -> hooks [ $ hook -> name ] [ ] = $ hook -> definition ; }
Add hook definition to container
232,197
public function exec ( string $ name ) { if ( isset ( $ this -> hooks [ $ name ] ) === false ) { $ this -> logger -> debug ( "No hook definitions found for '{$name}'. Available hook " . "definitions" , [ array_keys ( $ this -> hooks ) ] ) ; return null ; } $ return = [ ] ; $ params = array_merge ( $ this -> params , ar...
Execute hook definition
232,198
public function createAndBindForm ( Request $ request , $ type , $ data = null , array $ options = array ( ) ) { $ form = $ this -> createForm ( $ type , $ data , $ options ) ; $ form -> submit ( $ request ) ; return $ form ; }
Creates binds and returns a Form instance from the type of the form .
232,199
protected function renderAttribute ( $ attribute , $ index ) { if ( is_string ( $ this -> template ) ) { return strtr ( $ this -> template , [ '{label}' => $ attribute [ 'label' ] , '{value}' => $ this -> formatter -> format ( $ attribute [ 'value' ] , $ attribute [ 'format' ] ) , ] ) ; } else { return call_user_func (...
Renders a single attribute .