idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
51,500
protected function getLocaleCurrency ( Request $ request ) { $ currentLocale = $ request -> getLocale ( ) ; $ locale = $ this -> container -> get ( 'locale.repository' ) -> findOneBy ( [ 'code' => $ currentLocale ] ) ; if ( null !== $ locale && $ locale -> getCurrency ( ) instanceof Currency ) { return $ locale -> getC...
Returns the currency code for active locale
51,501
public function asString ( ) { $ display = function ( $ lines , $ length , $ loop = 0 ) use ( & $ display ) { $ output = '' ; foreach ( $ lines as $ line ) { $ line = is_a ( $ line , 'Deflection\Element\AbstractElement' ) ? $ line -> getElement ( ) : $ line ; if ( is_array ( $ line ) ) { $ output .= $ display ( $ line ...
Returns class definition as a string
51,502
private function streamView ( $ response ) { if ( Response :: isError ( $ response ) && ! $ response -> getBody ( ) instanceof ViewStream ) { $ response = $ this -> setErrorView ( $ response ) ; return $ response ; } return $ response ; }
fill up contents for VIEW and ERROR responses .
51,503
private function setErrorView ( $ response ) { if ( Response :: isServerError ( $ response ) && $ this -> logger ) { $ this -> logger -> error ( 'received a server error response: ' . $ response -> getStatusCode ( ) ) ; } $ stream = $ this -> error -> getStream ( $ response -> getStatusCode ( ) , $ response -> getData ...
render error pages .
51,504
public function call ( $ resource , $ params = array ( ) , $ method = 'GET' ) { if ( ! empty ( $ params ) && is_array ( $ params ) ) { $ queryString = http_build_query ( $ params ) ; } else { $ queryString = '' ; } $ requestUrl = self :: API_URL . $ resource . ( ( strtolower ( $ method ) == 'get' ) ? '?' . $ queryStrin...
Make an api request
51,505
public function webform ( $ action , $ params , $ friends = array ( ) ) { $ url = self :: WEBFORM_URL . $ action ; $ header = sprintf ( "Authorization: Basic %s\r\n" , base64_encode ( $ this -> getAuthenticationString ( ) ) ) ; $ header .= "Content-type: application/x-www-form-urlencoded\r\n" ; $ params = http_build_qu...
Make a request to the Web Form API .
51,506
public function addClass ( string $ class ) : Tag { if ( ! isset ( $ this -> attributes [ 'class' ] ) ) { $ this -> attributes [ 'class' ] = $ class ; } else { $ this -> attributes [ 'class' ] .= " $class" ; } return $ this ; }
Convenience method to add a class to a tag .
51,507
static public function start ( $ name ) { if ( ! ObjectManager :: getInstance ( ) -> get ( Config :: class ) -> getValue ( 'profile' ) ) { return ; } if ( ! isset ( self :: $ profileNames [ $ name ] ) ) { self :: $ profileNames [ $ name ] = 0 ; } $ realName = $ name . '_' . self :: $ profileNames [ $ name ] ++ ; array_...
Set start point for a new profile
51,508
static public function end ( $ name ) { if ( ! ObjectManager :: getInstance ( ) -> get ( Config :: class ) -> getValue ( 'profile' ) ) { return ; } if ( $ name != self :: getName ( self :: $ currentProfileNames [ count ( self :: $ currentProfileNames ) - 1 ] ) ) { throw new \ Exception ( sprintf ( 'Not an expected end ...
Set end point for an exist profile
51,509
public function buildMenu ( ItemInterface $ node , ItemEntity $ item ) { if ( $ item -> getPath ( ) && $ this -> fs -> exists ( $ item -> getPath ( ) ) ) { $ node -> addChild ( 'Fill folder' , [ 'route' => 'item_folder_filler_fill' , 'routeParameters' => [ 'id' => $ item -> getId ( ) , 'name' => $ item -> getUrlName ( ...
Build menu for plugin
51,510
protected function getCover ( ItemEntity $ item ) { $ from = $ this -> root . $ item -> getDownloadPath ( ) . '/' . $ item -> getCover ( ) ; if ( ! $ this -> fs -> exists ( $ from ) ) { return '' ; } $ target = $ item -> getPath ( ) . '/' ; $ filename = self :: COVER_FILENAME . '.' . pathinfo ( $ item -> getCover ( ) ,...
Get cover filename
51,511
protected function getInfo ( ItemEntity $ item ) { $ filename = self :: INFO_FILENAME . '.html' ; if ( is_file ( $ item -> getPath ( ) ) ) { return dirname ( $ item -> getPath ( ) ) . pathinfo ( $ item -> getPath ( ) , PATHINFO_FILENAME ) . '-' . $ filename ; } else { return $ item -> getPath ( ) . '/' . $ filename ; }...
Get info filename
51,512
private function isEventSupported ( Event $ event ) : bool { $ supported = false ; foreach ( $ this -> getSupportedEventTypes ( ) as $ supportedEventType ) { if ( \ is_a ( $ event , $ supportedEventType ) ) { $ supported = true ; break ; } } return $ supported ; }
Is event supported .
51,513
public function dateTime ( $ value , $ type = NULL ) { $ apend = "" ; switch ( $ type ) { case 'time' : $ apend = 'time' ; break ; case 'timestamp' : $ apend = 'timestamp' ; break ; case 'date' : $ apend = 'date' ; break ; case 'datetime' : $ apend = 'datetime' ; break ; case 'year' : $ apend = 'year(4)' ; break ; defa...
dateTime description ]
51,514
public function value ( $ value = null ) { if ( null !== $ value && false === is_string ( $ value ) && false === is_numeric ( $ value ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or number, "%s" given' , __METHOD__ , gettype ( $ value ) ) , E_USER_ERROR ) ; } $ this -> va...
Set a new value for input
51,515
public function name ( $ name = null ) { if ( null !== $ name && false === is_string ( $ name ) && false === is_numeric ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or number, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } $ this -> name = $...
Set a new name for input
51,516
public function attributes ( $ attributes ) { if ( false === is_array ( $ attributes ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ attributes ) ) , E_USER_ERROR ) ; } $ this -> attributes = array_merge ( $ this -> attributes , $ attri...
Set new attributes for input
51,517
public function filled ( $ filled ) { if ( false === is_bool ( $ filled ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ filled ) ) , E_USER_ERROR ) ; } $ this -> filled = $ filled ; return $ this ; }
Set if input should be automaticly filled or not
51,518
public function onerror ( $ attributes ) { if ( false === is_array ( $ attributes ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ attributes ) ) , E_USER_ERROR ) ; } if ( true === isset ( $ this -> attributes [ 'name' ] ) ) { $ helper =...
Merges the given attributes with the already existing attributes on error
51,519
private function fill ( ) { if ( true === $ this -> filled ) { if ( true === isset ( $ this -> attributes [ 'name' ] ) ) { if ( true === Request :: isPost ( ) ) { $ this -> attributes [ 'value' ] = Request :: fromPost ( $ this -> attributes [ 'name' ] ) ; } } } }
Sets the value if allowed
51,520
public function set ( $ key , $ value , $ params = array ( ) ) { $ expire = 0 ; $ path = null ; $ domain = null ; $ secure = false ; $ httponly = false ; if ( isset ( $ params [ 'expire' ] ) ) { $ expire = $ params [ 'expire' ] ; } if ( isset ( $ params [ 'path' ] ) ) { $ path = $ params [ 'path' ] ; } if ( isset ( $ p...
Set variable to storage
51,521
public function delete ( $ key ) { if ( isset ( $ _COOKIE [ $ key ] ) ) { unset ( $ _COOKIE [ $ key ] ) ; setcookie ( $ key , '' , time ( ) - 3600 ) ; } }
Remove variable from storage
51,522
public function getDataSource ( string $ source ) : Source { switch ( $ source ) { case 'form' : case 'forms' : return $ this -> getDataSources ( ) -> getFormsDataSource ( ) ; break ; case 'entry' : case 'entries' : return $ this -> getDataSources ( ) -> getEntryDataSource ( ) ; break ; case 'entryValue' : case 'entryV...
Get a form form entry or form entry value data source .
51,523
public static function instantiate ( $ className , array $ namedArguments ) { $ reflectionClass = new ReflectionClass ( $ className ) ; $ parameters = $ reflectionClass -> getConstructor ( ) -> getParameters ( ) ; $ positionalDefaultFilledArguments = array ( ) ; foreach ( $ parameters as $ parameter ) { if ( isset ( $ ...
Instantiate a class with named arguments .
51,524
public function create ( $ name , $ callback ) { $ this -> _name = $ name ; $ this -> _class = $ callback ( ) ; $ GLOBALS [ 'providers' ] [ $ this -> _name ] = $ this -> _class ; }
Creates the provider and registers the provider to the global area .
51,525
public function set ( $ id , $ data , $ lifeTime = 0 ) { if ( ! function_exists ( 'apc_store' ) ) { throw new ApcCacheException ( 'function [apc_store] not found !' ) ; } return apc_store ( $ id , $ data , $ lifeTime ) ; }
Set and store cache key with data content in cache key
51,526
protected function validateFilename ( $ filename , $ path ) { $ fileParts = explode ( '.' , $ filename ) ; if ( count ( $ fileParts ) > 1 ) { $ extension = end ( $ fileParts ) ; array_pop ( $ fileParts ) ; $ fileNameWithoutExtension = implode ( '-' , $ fileParts ) ; $ fileNameWithoutExtension = StringUtil :: slugify ( ...
Converts filename to lowercase remove non - ascii chars And adds - copy if the file already exists
51,527
public function pushData ( EntityInterface $ entity ) { if ( $ this -> isMany ( ) ) { $ this -> data [ ] = $ entity ; return $ this ; } $ this -> data = $ entity ; return $ this ; }
Applys the relationship data .
51,528
public function render ( ) { $ parse = true ; if ( $ this -> getFile ( ) -> exists ( ) ) { if ( $ this -> getFile ( ) -> entity ( ) -> getModificationTime ( ) >= @ filemtime ( $ this -> viewmodel -> getFile ( ) ) ) { $ parse = false ; } } if ( true === $ parse ) { $ this -> parse ( ) ; $ this -> write ( ) ; } return $ ...
Renders the view model
51,529
public function getFileName ( ) { if ( null === $ this -> filename && null !== $ this -> viewmodel ) { $ this -> filename = md5 ( $ this -> viewmodel -> getFile ( ) ) ; } return $ this -> filename ; }
Generates filename and returns it
51,530
public function getFile ( ) { if ( null === $ this -> file ) { $ file = $ this -> getFileName ( ) ; $ this -> file = new File ( $ this -> directory . $ file ) ; } return $ this -> file ; }
Create file object from current directory and file and returns it
51,531
private function parse ( ) { $ lines = file ( $ this -> viewmodel -> getFile ( ) ) ; $ this -> code = '' ; $ classes = [ 'MatchEcho' , 'MatchForeach' , 'MatchEndForeach' , 'MatchFor' , 'MatchEndFor' , 'MatchIf' , 'MatchIsset' , 'MatchNotIsset' , 'MatchEmpty' , 'MatchNotEmpty' , 'MatchElseIf' , 'MatchElse' , 'MatchEndIf...
Convert template file to string
51,532
public static function partial ( $ template , array $ vars = array ( ) ) { $ template = new Template ( $ template , null , $ vars ) ; return trim ( $ template -> render ( ) ) ; }
Include partial .
51,533
public static function setPathCompiled ( $ pathCompiled = '/tmp/Eureka/tpl' ) { $ pathCompiled = rtrim ( $ pathCompiled , '/' ) . '/' ; if ( ! file_exists ( $ pathCompiled ) || ! is_dir ( $ pathCompiled ) ) { if ( ! mkdir ( $ pathCompiled , 0755 , true ) ) { throw new \ Exception ( 'Cannot create directory for template...
Set path for compiled templates .
51,534
protected function __update ( ) { parent :: __update ( ) ; if ( $ this -> count ( ) && $ this -> attribute instanceof DOMAttr ) { $ this -> attribute -> value = ( string ) $ this ; } }
Updates the HTML attribute that DOMTokenList represents
51,535
public function __toAttribute ( ) { if ( $ this -> count ( ) ) { $ attr = null ; if ( is_string ( $ this -> attribute ) ) { $ attr = $ this -> attribute ; } elseif ( $ this -> attribute instanceof DOMAttr ) { $ attr = $ this -> attribute -> name ; } if ( $ attr ) { $ values = htmlspecialchars ( ( string ) $ this , ENT_...
Retrieves the HTML attribute and concatenated list of the tokens .
51,536
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ drv = $ params -> getDriver ( ) ; $ source = array ( ) ; if ( $ table = $ this -> getTable ( ) ) $ source [ ] = "FROM " . $ drv -> toSQL ( $ params , $ table ) ; foreach ( $ this -> getJoins ( ) as $ join ) $ source [ ] = $ drv -> toSQL ( $ params ...
Write a select query as SQL query syntax
51,537
protected function hasBasicAuth ( $ request ) : bool { if ( $ request -> headers -> has ( 'Authorization' ) && starts_with ( $ request -> header ( 'Authorization' ) , 'Basic ' ) ) { return true ; } return false ; }
Check if request has Basic Authentication header
51,538
public function generate ( GeneratorInterface $ generator ) { $ callback = function ( ) use ( $ generator ) { $ handler = Handler :: create ( $ generator ) ; $ handler -> generate ( ) ; } ; return $ callback ( ) ; }
Generates a document from given configuration using given generator .
51,539
public function parseYamlStaging ( $ yamlFile ) { $ container = ! ( property_exists ( get_called_class ( ) , 'container' ) ) ? $ this -> getContainer ( ) : $ this -> container ; $ capitalizer = $ container -> get ( 'rch_capistrano.capitalizer' ) ; $ params = Yaml :: parse ( file_get_contents ( $ yamlFile ) ) ; return $...
Read staging parameters from YAML staging file .
51,540
public function execute ( IDS_Report $ data ) { if ( ! isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ _SERVER [ 'REQUEST_URI' ] = substr ( $ _SERVER [ 'PHP_SELF' ] , 1 ) ; if ( isset ( $ _SERVER [ 'QUERY_STRING' ] ) && $ _SERVER [ 'QUERY_STRING' ] ) { $ _SERVER [ 'REQUEST_URI' ] .= '?' . $ _SERVER [ 'QUERY_STRING' ] ; } }...
Stores given data into the database
51,541
public function isWithin ( \ Coast \ Path $ parent ) { $ path = $ this -> _name ; $ parts = \ explode ( PATH_SEPARATOR , ( string ) $ parent ) ; foreach ( $ parts as $ part ) { if ( \ preg_match ( '/^' . \ preg_quote ( $ part , '/' ) . '/' , $ path ) ) { return true ; } } return false ; }
Check if path is within another
51,542
public function toAbsolute ( \ Coast \ Path $ base ) { if ( ! $ this -> isRelative ( ) || ! $ base -> isAbsolute ( ) ) { throw new \ Exception ( "Path '{$this}' is not relative or base path '{$base}' is not absolute" ) ; } $ source = explode ( '/' , ( string ) $ base ) ; $ target = explode ( '/' , $ this -> _name ) ; $...
Get absolute path from relative path .
51,543
public function toRelative ( \ Coast \ Path $ base ) { if ( ! $ this -> isAbsolute ( ) || ! $ base -> isAbsolute ( ) ) { throw new \ Exception ( "Source path '{$this}' is not absolute or base path '{$base}' is not absolute" ) ; } $ source = explode ( '/' , ( string ) $ base ) ; $ target = explode ( '/' , $ this -> _nam...
Get relative path from absolute path .
51,544
public function toReal ( ) { if ( ! $ this -> isAbsolute ( ) ) { throw new \ Exception ( "Path '{$this}' is not absolute" ) ; } $ target = explode ( '/' , $ this -> _name ) ; $ name = [ ] ; foreach ( $ target as $ part ) { if ( $ part == '..' ) { array_pop ( $ name ) ; } else if ( $ part != '.' ) { $ name [ ] = $ part ...
Reduce absolute path with relative parts to real path .
51,545
public function init ( ) { if ( $ this -> dataProvider === null ) { throw new InvalidConfigException ( 'The "dataProvider" property must be set.' ) ; } if ( $ this -> emptyText === null ) { $ this -> emptyText = Yii :: t ( 'yii' , 'No results found.' ) ; } if ( ! isset ( $ this -> options [ 'id' ] ) ) { $ this -> optio...
Initializes the view .
51,546
protected function buildConnectString ( $ driver , array $ arguments ) { $ options = array_map ( function ( $ key ) use ( $ arguments ) { return sprintf ( '%s=%s' , $ key , $ arguments [ $ key ] ) ; } , array_keys ( $ arguments ) ) ; return $ driver . ':' . implode ( ';' , $ options ) ; }
Build a connection string from the given arguments .
51,547
public function getAllElements ( $ elementType ) { $ iterator = new \ DirectoryIterator ( $ this -> getUserSubDirectory ( "{$elementType}s" ) ) ; $ allElements = [ ] ; foreach ( $ iterator as $ file ) { if ( $ file -> isDir ( ) || ( "twig" !== $ file -> getExtension ( ) ) ) { continue ; } $ reference = "@{$elementType}...
Returns a list of all elements
51,548
public function getListedElements ( $ elementType ) { $ allElements = $ this -> getAllElements ( $ elementType ) ; usort ( $ allElements , function ( Element $ element1 , Element $ element2 ) { return strnatcasecmp ( $ element1 -> getKey ( ) , $ element2 -> getKey ( ) ) ; } ) ; return array_filter ( $ allElements , fun...
Returns the listed elements
51,549
public function getElement ( $ key , $ elementType ) { $ elements = $ this -> getAllElements ( $ elementType ) ; return array_key_exists ( $ key , $ elements ) ? $ elements [ $ key ] : null ; }
Returns the preview by key
51,550
public function isFullPageElementType ( $ key ) { return array_key_exists ( $ key , $ this -> elementTypes ) ? $ this -> elementTypes [ $ key ] [ "isFullPage" ] : null ; }
Returns whether the given element type is full page
51,551
public static function __callstatic ( $ method , $ arguments ) { $ route = new Route ( ) ; if ( false === is_callable ( [ $ route , $ method ] ) ) { return trigger_error ( sprintf ( 'Call to undefined method %s::%s' , __CLASS__ , $ method ) , E_USER_ERROR ) ; } $ route = call_user_func_array ( [ $ route , $ method ] , ...
Creates a new route and calls the dynamic given method if exists
51,552
public static function setUrl ( $ url ) { if ( false === is_string ( $ url ) && false === $ url instanceof URLParser ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or instance of sFire\\Utils\\URLParser, "%s" given' , __METHOD__ , gettype ( $ url ) ) , E_USER_ERROR ) ; } if (...
Set the current URL
51,553
public static function routeExists ( $ identifier , $ domain = null ) { if ( false === is_string ( $ identifier ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ identifier ) ) , E_USER_ERROR ) ; } if ( null !== $ domain && false === is_...
Check if a Route exists by identifier with optional domain
51,554
public static function domainExists ( $ domain ) { if ( false === is_string ( $ domain ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ domain ) ) , E_USER_ERROR ) ; } $ routes = static :: getRoutes ( ) ; foreach ( $ routes as $ route )...
Checks if a given domain exists
51,555
public static function getRoute ( $ identifier = null ) { if ( null !== $ identifier && false === is_string ( $ identifier ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ identifier ) ) , E_USER_ERROR ) ; } if ( null !== $ identifier )...
Gets the current route or a route based on identifier
51,556
public static function addGroup ( $ group ) { if ( false === is_array ( $ group ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ group ) ) , E_USER_ERROR ) ; } static :: $ group [ ] = $ group ; }
Add a new group element to the stack
51,557
public static function getGroup ( ) { $ attr = [ ] ; foreach ( static :: $ group as $ group ) { $ attr = static :: arrayRecursiveMerge ( $ attr , $ group ) ; } return $ attr ; }
Return all the groups as one merged array
51,558
public static function getErrorRoute ( $ type , $ index = 0 ) { if ( false === ( '-' . intval ( $ type ) == '-' . $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } if ( false === ( '-' . intval ( $ i...
Retrieve a route from the error route stack . Default the first on the stack or route with optional index
51,559
public static function addErrorRoute ( $ type , Route $ route , $ default = false ) { if ( false === ( '-' . intval ( $ type ) == '-' . $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } static :: $ e...
Adds a new error route to the error routes stack
51,560
public static function setRedirect ( $ bool ) { if ( null !== $ bool && false === is_bool ( $ bool ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ bool ) ) , E_USER_ERROR ) ; } static :: $ isRedirect = $ bool ; }
Set the redirect
51,561
private static function arrayRecursiveMerge ( $ array1 , $ array2 ) { if ( false === is_array ( $ array1 ) || false === is_array ( $ array2 ) ) { return $ array2 ; } foreach ( $ array2 as $ key => $ value ) { $ array1 [ $ key ] = static :: arrayRecursiveMerge ( @ $ array1 [ $ key ] , $ value ) ; } return $ array1 ; }
Recursive merge arrays
51,562
private static function request ( ) { if ( $ uri = Request :: getUri ( ) ) { $ url = '' ; $ host = null ; if ( ! ( $ scheme = Request :: getScheme ( ) ) ) { $ scheme = 'php' ; $ host = '127.0.0.1' ; Request :: setScheme ( $ scheme ) ; } $ url .= $ scheme . '://' ; if ( $ hostname = Request :: getHost ( ) ) { $ url .= $...
Try to add the request uri
51,563
private static function format ( ) { $ routes = static :: getRoutes ( ) ; foreach ( $ routes as $ identifier => $ route ) { $ url = preg_quote ( $ route -> getUrl ( ) , '/' ) ; if ( $ prefix = $ route -> getPrefix ( ) ) { $ url = $ prefix [ 'url' ] . $ url ; } if ( preg_match_all ( '#(\\\/)*\\\{([a-zA-Z0-9_.]+)(\\\\\?)...
Formats all the routes urls to a regex pattern that sFire understands to match the current url to the route url
51,564
public function getOutput ( String $ file = null ) : Array { $ file = ( $ file ) ? $ file : $ this -> _logFile ; if ( file_exists ( $ file ) ) { return file ( $ file ) ; } throw new \ RunTimeException ( "file not found!" ) ; }
end kill method
51,565
protected function setProperty ( string $ key , array $ data , & $ property , $ default = null ) : void { if ( isset ( $ data [ $ key ] ) ) { $ property = $ data [ $ key ] ; return ; } if ( $ default !== null ) { $ property = $ default ; } }
Checks the given key is set in the data array if so the given property is set with the value .
51,566
private function addCSRFTokenField ( ) { $ this -> nonceValue = $ this -> createNonce ( ) ; $ nonce = new FormField ( FormField :: TYPE_HIDDEN ) ; $ nonce -> setName ( 'nonce' ) -> setValue ( $ this -> createNonce ( ) ) -> setValidationCallback ( function ( $ value ) { if ( function_exists ( 'wp_verify_nonce' ) ) { if ...
Add CSRF token hidden input field
51,567
public function populateFields ( ) { if ( count ( $ this -> submittedData ) < 1 ) { return ; } array_map ( function ( FormField & $ field ) { if ( isset ( $ this -> submittedData [ $ field -> getName ( ) ] ) ) { $ raw = $ this -> submittedData [ $ field -> getName ( ) ] ; $ sanitized = $ field -> sanitize ( $ raw ) ; $...
populates form from POST after submission
51,568
public function addFields ( array $ fields ) { array_walk ( $ fields , function ( $ field , $ key ) { $ this -> addField ( $ key , $ field ) ; } ) ; }
Add fields to the form
51,569
public static function generateSalt ( $ length = 32 ) { $ salt = '' ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) $ salt .= chr ( rand ( 0 , 127 ) ) ; return $ salt ; }
Generates a random string which can be used to salt the password
51,570
protected function filterConfig ( string $ name , $ value = null ) { $ class = 'filterConfig' . ucfirst ( $ name ) ; if ( method_exists ( $ this , $ class ) === true ) { $ value = call_user_func ( [ $ this , $ class ] , $ value ) ; } return $ value ; }
Filter a configuration attribute value as it s being set .
51,571
public function loadConfig ( string $ file ) : self { if ( file_exists ( $ file ) === false ) { throw new \ RuntimeException ( 'No such config file.' ) ; } $ data = json_decode ( file_get_contents ( $ file ) , true ) ; if ( $ data === null ) { throw new \ RuntimeException ( 'Invalid config file.' ) ; } return $ this ->...
Set configuration from a JSON file .
51,572
public function table ( $ table , \ Closure $ callback ) { try { parent :: create ( $ table , $ callback ) ; } catch ( \ Exception $ e ) { try { parent :: table ( $ table , $ callback ) ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; } } }
Create table if not exist .
51,573
protected function isDynamic ( array $ attributeNames ) { foreach ( $ attributeNames as $ name ) { if ( isset ( $ this -> __attr [ $ name ] ) ) { return true ; } } return false ; }
Check if any of the given attribute names refers to a dynamic attribute .
51,574
protected function createIterator ( $ subject ) { if ( $ subject === NULL ) { return new \ ArrayIterator ( [ ] ) ; } if ( is_array ( $ subject ) ) { return new \ ArrayIterator ( $ subject ) ; } if ( $ subject instanceof \ Generator ) { return $ subject ; } if ( $ subject instanceof \ Iterator ) { $ subject -> rewind ( ...
Create an iterator from the given input will create an ArrayIterator backed by an empty array when the input is NULL .
51,575
public function status ( $ message , $ link = null ) { $ this -> response = $ this -> fb -> post ( '/me/feed' , [ 'message' => $ message , 'link' => $ link , ] ) ; return $ this ; }
Create a status .
51,576
public function photo ( $ source , $ caption = null ) { $ this -> response = $ this -> fb -> post ( '/me/photos' , [ 'source' => new FacebookFile ( $ source ) , 'caption' => $ caption , ] ) ; return $ this ; }
Create a photo .
51,577
public function photos ( array $ sources , $ caption = null ) { $ images = $ this -> unpublishedPhotos ( $ sources ) ; $ this -> response = $ this -> fb -> post ( '/me/feed' , array_merge ( [ 'message' => $ caption , ] , $ images ) ) ; return $ this ; }
Create multiple photos .
51,578
protected function unpublishedPhotos ( array $ sources ) { $ images = [ ] ; foreach ( $ sources as $ index => $ source ) { $ response = $ this -> fb -> post ( '/me/photos' , [ 'source' => new FacebookFile ( $ source ) , 'published' => false , ] ) -> getDecodedBody ( ) ; $ images [ "attached_media[{$index}]" ] = sprintf...
Create unpublished photos .
51,579
public function getId ( ) { if ( is_null ( $ this -> response ) ) { return false ; } return $ this -> explodeId ( $ this -> response -> getDecodedBody ( ) ) ; }
Get facebook response id .
51,580
protected function explodeId ( array $ body ) { if ( isset ( $ body [ 'post_id' ] ) ) { $ key = 'post_id' ; } elseif ( isset ( $ body [ 'id' ] ) ) { $ key = 'id' ; } else { return false ; } return array_combine ( [ 'id' , 'fbid' ] , explode ( '_' , $ body [ $ key ] ) ) ; }
Explode facebook response id field .
51,581
final public function file ( $ _ ) { $ args = func_get_args ( ) ; if ( count ( $ args ) > 3 ) { for ( $ i = 3 ; $ i < count ( $ args ) ; $ i ++ ) { unset ( $ args [ $ i ] ) ; } } switch ( count ( $ args ) ) { case 1 : $ this -> viewFile [ 2 ] = Util :: camelToHyphen ( $ args [ 0 ] ) ; break ; case 2 : $ this -> viewFil...
Determines which action s view to use instead of current s
51,582
final public function getViewFile ( $ addOthers = true ) { if ( $ addOthers ) { if ( ! isset ( $ this -> viewFile [ 0 ] ) ) $ this -> viewFile [ 0 ] = ucfirst ( Util :: hyphenToCamel ( engineGet ( 'module' ) ) ) ; if ( ! isset ( $ this -> viewFile [ 1 ] ) ) $ this -> viewFile [ 1 ] = Util :: camelToHyphen ( engineGet (...
Fetches the view file array
51,583
final public function url ( $ module , $ controller = null , $ action = null , array $ params = array ( ) , $ hash = null ) { $ module = ucfirst ( Util :: hyphenToCamel ( $ module ) ) ; $ moduleOptions = engineGet ( 'config' , 'modules' , $ module , false ) ; $ module = ( isset ( $ moduleOptions [ 'alias' ] ) ) ? $ mod...
Fetches the relative path to a resource
51,584
final public function getOutput ( $ module , $ controller , $ action , array $ params = array ( ) , $ partial = true ) { $ view = new View ( ) ; $ controllerClass = ucfirst ( \ Util :: hyphenToCamel ( $ module ) ) . '\Controllers\\' . ucfirst ( \ Util :: hyphenToCamel ( $ controller ) ) . 'Controller' ; $ controllerCla...
Fetches the output of an action
51,585
public static function getNameForOrdinal ( $ enumType , $ ordinal ) { $ constants = $ enumType :: values ( ) ; $ result = null ; foreach ( $ constants as $ constant ) { if ( $ constant -> getOrdinal ( ) === $ ordinal ) { $ result = $ constant -> getName ( ) ; break ; } } return $ result ; }
Returns the name of the enumeration constant of the specified enumeration type with the specified ordinal .
51,586
public static function getOrdinalForName ( $ enumType , $ name ) { $ constants = $ enumType :: values ( ) ; $ result = null ; foreach ( $ constants as $ constant ) { if ( $ constant -> getName ( ) === $ name ) { $ result = $ constant -> getOrdinal ( ) ; break ; } } return $ result ; }
Returns the ordinal of the enumeration constant of the specified enumeration type with the specified name .
51,587
public static function isDefinedName ( $ enumType , $ name ) { $ names = $ enumType :: names ( ) ; $ result = false ; foreach ( $ names as $ item ) { if ( $ item === $ name ) { $ result = true ; break ; } } return $ result ; }
Checks whether an enumeration constant with the specified name exists in the specified enumeration type .
51,588
public static function isDefinedOrdinal ( $ enumType , $ ordinal ) { $ constants = $ enumType :: values ( ) ; $ result = false ; foreach ( $ constants as $ constant ) { if ( $ constant -> getOrdinal ( ) === $ ordinal ) { $ result = true ; break ; } } return $ result ; }
Checks whether an enumeration constant with the specified ordinal exists in the specified enumeration type .
51,589
public function split ( array $ arguments = array ( ) ) { $ splittedArguments = new AppendIterator ( ) ; foreach ( $ this -> _options [ 'Period' ] as $ Date ) { $ _arguments = $ arguments ; $ _arguments [ '--range' ] = $ Date -> format ( Configure :: read ( 'Task.dateFormat' ) ) ; $ splittedArguments -> append ( $ this...
Split arguments by date range
51,590
public function csrf ( ) { if ( ! $ this -> csrf ) { $ this -> csrf = \ Dependency :: resolve ( 'security.csrf' , array ( $ this -> config , \ Application :: getInstance ( ) -> getSession ( ) ) ) ; } return $ this -> csrf ; }
Returns a Csrf instance
51,591
public function unregisterResource ( $ type ) { if ( isset ( $ this -> smarty -> registered_resources [ $ type ] ) ) { unset ( $ this -> smarty -> registered_resources [ $ type ] ) ; } }
Unregisters a resource
51,592
public function unregisterCacheResource ( $ type ) { if ( isset ( $ this -> smarty -> registered_cache_resources [ $ type ] ) ) { unset ( $ this -> smarty -> registered_cache_resources [ $ type ] ) ; } }
Unregisters a cache resource
51,593
public function expired ( string $ key ) : bool { try { return $ this -> storage -> expired ( $ key ) ; } catch ( BadPacketException $ e ) { return true ; } }
Determines whether an item is present in the cache and life time expired .
51,594
public function attach ( callable $ stage , callable $ fallback = null ) { $ this -> storage -> attach ( $ this -> marshalClosure ( $ stage ) , [ 'fallback' => is_callable ( $ fallback ) ? $ this -> marshalClosure ( $ fallback ) : null ] ) ; }
Attaches a stage and assigns a fallback to the attached stage .
51,595
private function hasRequest ( $ params , $ variables , $ i = null ) : array { foreach ( $ params as $ key => $ param ) { $ class = '\\' . $ param -> getType ( ) ; if ( class_exists ( $ class ) && new $ class ( ) instanceof Request ) { $ i = $ key ; } } if ( $ i !== null ) $ variables = $ this -> insert ( $ variables , ...
Check if the request class exists and insert it if it doesn t
51,596
protected function clean ( $ meta = null ) { if ( $ meta && ! ( $ meta instanceof StorageMeta ) ) { $ meta = $ this -> getMeta ( $ meta ) ; } if ( ! $ meta || empty ( $ meta -> token ) ) $ this -> cache = [ ] ; else foreach ( $ this -> cache as $ i => $ _ ) { if ( empty ( $ i ) || $ i == $ meta -> token [ 0 ] || strpos...
Clean the search cache based on the index
51,597
public static function fromNative ( ) { $ args = \ func_get_args ( ) ; if ( \ count ( $ args ) < 2 || \ count ( $ args ) > 3 ) { throw new \ BadMethodCallException ( 'You must provide 2 to 3 arguments: 1) latitude, 2) longitude, 3) valid ellipsoid type (optional)' ) ; } $ coordinate = new BaseCoordinate ( array ( $ arg...
Returns a new Coordinate object from native PHP arguments
51,598
public function sameValueAs ( ValueObjectInterface $ coordinate ) { if ( false === Util :: classEquals ( $ this , $ coordinate ) ) { return false ; } return $ this -> getLatitude ( ) -> sameValueAs ( $ coordinate -> getLatitude ( ) ) && $ this -> getLongitude ( ) -> sameValueAs ( $ coordinate -> getLongitude ( ) ) && $...
Tells whether tow Coordinate objects are equal
51,599
public function toDecimalMinutes ( ) { $ coordinate = self :: getBaseCoordinate ( $ this ) ; $ convert = new Convert ( $ coordinate ) ; $ dm = $ convert -> toDecimalMinutes ( ) ; return new StringLiteral ( $ dm ) ; }
Returns a decimal minutes representation of the coordinate