idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
52,000
|
public function getIp6array ( $ ip ) { $ hex = unpack ( "H*hex" , inet_pton ( $ ip ) ) ; $ ipStr = substr ( preg_replace ( "/([A-f0-9]{4})/" , "$1:" , $ hex [ 'hex' ] ) , 0 , - 1 ) ; $ ipIntArray = array ( ) ; $ ipStrArray = explode ( ":" , $ ipStr ) ; foreach ( $ ipStrArray as & $ value ) { $ ipIntArray [ ] = hexdec ( $ value ) ; } return $ ipIntArray ; }
|
Ipv6 to array
|
52,001
|
public function account ( ) { $ this -> logger -> debug ( "account: start" ) ; if ( empty ( $ this -> access_key ) ) { throw new \ Exception ( "access key not set" ) ; } $ accountUrl = sprintf ( "%s/%s" , $ this -> api_url , "account" ) ; $ client = new \ GuzzleHttp \ Client ( ) ; $ result = $ client -> post ( $ accountUrl , array ( 'multipart' => array ( array ( 'name' => 'accesskey' , 'contents' => $ this -> access_key ) ) , 'timeout' => $ this -> timeout ) ) ; $ contents = $ result -> getBody ( ) -> getContents ( ) ; $ data = json_decode ( $ contents , true ) ; if ( isset ( $ data [ 'flag' ] ) && $ data [ 'flag' ] > 0 ) { throw new \ Exception ( $ data [ 'errortext' ] ) ; } return $ data ; }
|
Check your subscription
|
52,002
|
public function setUA ( $ ua ) { $ this -> logger -> debug ( 'setting: set useragent string to ' . $ ua ) ; $ this -> ua = $ ua ; return true ; }
|
Set the useragent string
|
52,003
|
public function setIP ( $ ip ) { $ this -> logger -> debug ( 'setting: set IP address to ' . $ ip ) ; $ this -> ip = $ ip ; return true ; }
|
Set the IP address
|
52,004
|
protected function setDBdat ( ) { if ( is_null ( $ this -> dbdat ) ) { $ this -> logger -> debug ( sprintf ( "db: open file: %s" , $ this -> path ) ) ; $ this -> dbdat = new \ SQLite3 ( $ this -> path , SQLITE3_OPEN_READONLY ) ; } }
|
Open DB file
|
52,005
|
protected function setCache ( $ key , $ value ) { $ this -> logger -> debug ( 'LRUcache: set to key' . $ key ) ; $ this -> cache [ $ key ] = $ value ; if ( count ( $ this -> cache ) > $ this -> cacheSize ) { array_shift ( $ this -> cache ) ; } }
|
LRU cashe set
|
52,006
|
protected function getCache ( $ key ) { $ this -> logger -> debug ( 'LRUcache: get key' . $ key ) ; if ( ! isset ( $ this -> cache [ $ key ] ) ) { $ this -> logger -> debug ( 'LRUcache: key' . $ key . ' Not Found' ) ; return null ; } $ tmpValue = $ this -> cache [ $ key ] ; unset ( $ this -> cache [ $ key ] ) ; $ this -> cache [ $ key ] = $ tmpValue ; $ this -> logger -> debug ( 'LRUcache: key' . $ key . ' Found' ) ; return $ tmpValue ; }
|
LRU cashe get
|
52,007
|
public function setDataFile ( $ path ) { if ( false === file_exists ( $ path ) ) { throw new \ Exception ( sprintf ( "%s does not exist" , $ path ) ) ; } $ this -> path = $ path ; return true ; }
|
Set path to sqlite file
|
52,008
|
public function setAccessKey ( $ access_key ) { $ this -> logger -> debug ( 'setting: set accesskey to ' . $ access_key ) ; $ this -> access_key = $ access_key ; return true ; }
|
Set the account access key
|
52,009
|
public function handleRequest ( Request $ request ) : Promise { $ method = $ request -> getMethod ( ) ; $ path = \ rawurldecode ( $ request -> getUri ( ) -> getPath ( ) ) ; $ toMatch = "{$method}\0{$path}" ; if ( null === $ match = $ this -> cache -> get ( $ toMatch ) ) { $ match = $ this -> routeDispatcher -> dispatch ( $ method , $ path ) ; $ this -> cache -> put ( $ toMatch , $ match ) ; } switch ( $ match [ 0 ] ) { case Dispatcher :: FOUND : list ( , $ requestHandler , $ routeArgs ) = $ match ; $ request -> setAttribute ( self :: class , $ routeArgs ) ; return $ requestHandler -> handleRequest ( $ request ) ; case Dispatcher :: NOT_FOUND : if ( $ this -> fallback !== null ) { return $ this -> fallback -> handleRequest ( $ request ) ; } return $ this -> makeNotFoundResponse ( $ request ) ; case Dispatcher :: METHOD_NOT_ALLOWED : return $ this -> makeMethodNotAllowedResponse ( $ match [ 1 ] , $ request ) ; default : throw new \ UnexpectedValueException ( "Encountered unexpected dispatcher code: " . $ match [ 0 ] ) ; } }
|
Route a request and dispatch it to the appropriate handler .
|
52,010
|
private function makeNotFoundResponse ( Request $ request ) : Promise { return $ this -> errorHandler -> handleError ( Status :: NOT_FOUND , null , $ request ) ; }
|
Create a response if no routes matched and no fallback has been set .
|
52,011
|
private function makeMethodNotAllowedResponse ( array $ methods , Request $ request ) : Promise { return call ( function ( ) use ( $ methods , $ request ) { $ response = yield $ this -> errorHandler -> handleError ( Status :: METHOD_NOT_ALLOWED , null , $ request ) ; $ response -> setHeader ( "allow" , \ implode ( ", " , $ methods ) ) ; return $ response ; } ) ; }
|
Create a response if the requested method is not allowed for the matched path .
|
52,012
|
public function merge ( self $ router ) { if ( $ this -> running ) { throw new \ Error ( "Cannot merge routers after the server has started" ) ; } foreach ( $ router -> routes as $ route ) { $ route [ 1 ] = \ ltrim ( $ router -> prefix , "/" ) . $ route [ 1 ] ; $ route [ 2 ] = Middleware \ stack ( $ route [ 2 ] , ... $ router -> middlewares ) ; $ this -> routes [ ] = $ route ; } $ this -> observers -> addAll ( $ router -> observers ) ; }
|
Merge another router s routes into this router .
|
52,013
|
public function prefix ( string $ prefix ) { if ( $ this -> running ) { throw new \ Error ( "Cannot alter routes after the server has started" ) ; } $ prefix = \ trim ( $ prefix , "/" ) ; if ( $ prefix !== "" ) { $ this -> prefix = "/" . $ prefix . $ this -> prefix ; } }
|
Prefix all currently defined routes with a given prefix .
|
52,014
|
public function addRoute ( string $ method , string $ uri , RequestHandler $ requestHandler , Middleware ... $ middlewares ) { if ( $ this -> running ) { throw new \ Error ( "Cannot add routes once the server has started" ) ; } if ( $ method === "" ) { throw new \ Error ( __METHOD__ . "() requires a non-empty string HTTP method at Argument 1" ) ; } if ( $ requestHandler instanceof ServerObserver ) { $ this -> observers -> attach ( $ requestHandler ) ; } if ( ! empty ( $ middlewares ) ) { foreach ( $ middlewares as $ middleware ) { if ( $ middleware instanceof ServerObserver ) { $ this -> observers -> attach ( $ middleware ) ; } } $ requestHandler = Middleware \ stack ( $ requestHandler , ... $ middlewares ) ; } $ this -> routes [ ] = [ $ method , \ ltrim ( $ uri , "/" ) , $ requestHandler ] ; }
|
Define an application route .
|
52,015
|
public function stack ( Middleware ... $ middlewares ) { if ( $ this -> running ) { throw new \ Error ( "Cannot set middlewares after the server has started" ) ; } $ this -> middlewares = array_merge ( $ middlewares , $ this -> middlewares ) ; }
|
Specifies a set of middlewares that is applied to every route but will not be applied to the fallback request handler .
|
52,016
|
static function iconv_fallback_iso88591_utf8 ( $ string , $ bom = false ) { if ( function_exists ( 'utf8_encode' ) ) { return utf8_encode ( $ string ) ; } $ newcharstring = '' ; if ( $ bom ) { $ newcharstring .= "\xEF\xBB\xBF" ; } for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i ++ ) { $ charval = ord ( $ string { $ i } ) ; $ newcharstring .= getid3_lib :: iconv_fallback_int_utf8 ( $ charval ) ; } return $ newcharstring ; }
|
ISO - 8859 - 1 = > UTF - 8
|
52,017
|
static function iconv_fallback_utf16be_utf8 ( $ string ) { if ( substr ( $ string , 0 , 2 ) == "\xFE\xFF" ) { $ string = substr ( $ string , 2 ) ; } $ newcharstring = '' ; for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i += 2 ) { $ charval = getid3_lib :: BigEndian2Int ( substr ( $ string , $ i , 2 ) ) ; $ newcharstring .= getid3_lib :: iconv_fallback_int_utf8 ( $ charval ) ; } return $ newcharstring ; }
|
UTF - 16BE = > UTF - 8
|
52,018
|
public function boot ( Application $ app ) { $ app -> on ( KernelEvents :: EXCEPTION , function ( GetResponseForExceptionEvent $ event ) { $ e = $ event -> getException ( ) ; if ( $ e instanceof MethodNotAllowedHttpException && $ e -> getHeaders ( ) [ "Allow" ] === "OPTIONS" ) { $ event -> setException ( new NotFoundHttpException ( "No route found for \"{$event->getRequest()->getMethod()} {$event->getRequest()->getPathInfo()}\"" ) ) ; } } ) ; }
|
Add OPTIONS method support for all routes
|
52,019
|
public function register ( Container $ app ) { $ app [ "cors.allowOrigin" ] = "*" ; $ app [ "cors.allowMethods" ] = null ; $ app [ "cors.allowHeaders" ] = null ; $ app [ "cors.maxAge" ] = null ; $ app [ "cors.allowCredentials" ] = null ; $ app [ "cors.exposeHeaders" ] = null ; $ app [ "allow" ] = $ app -> protect ( new Allow ( ) ) ; $ app [ "options" ] = $ app -> protect ( function ( $ subject ) use ( $ app ) { $ optionsController = function ( ) { return Response :: create ( "" , 204 ) ; } ; if ( $ subject instanceof Controller ) { $ optionsRoute = $ app -> options ( $ subject -> getRoute ( ) -> getPath ( ) , $ optionsController ) -> after ( $ app [ "allow" ] ) ; } else { $ optionsRoute = $ subject -> options ( "{path}" , $ optionsController ) -> after ( $ app [ "allow" ] ) -> assert ( "path" , ".*" ) ; } return $ optionsRoute ; } ) ; $ app [ "cors-enabled" ] = $ app -> protect ( function ( $ subject , $ config = [ ] ) use ( $ app ) { $ optionsController = $ app [ "options" ] ( $ subject ) ; $ cors = new Cors ( $ config ) ; if ( $ subject instanceof Controller ) { $ optionsController -> after ( $ cors ) ; } $ subject -> after ( $ cors ) ; return $ subject ; } ) ; $ app [ "cors" ] = function ( ) use ( $ app ) { $ app [ "options" ] ( $ app ) ; return new Cors ( ) ; } ; }
|
Register the cors function and set defaults
|
52,020
|
protected function initiate ( ) { $ name = $ this -> name ; $ data = [ 'acl' => [ ] , 'actions' => [ ] , 'roles' => [ ] ] ; $ data = \ array_merge ( $ data , $ this -> memory -> get ( "acl_{$name}" , [ ] ) ) ; $ this -> roles -> attach ( $ data [ 'roles' ] ) ; $ this -> actions -> attach ( $ data [ 'actions' ] ) ; foreach ( $ data [ 'acl' ] as $ id => $ allow ) { list ( $ role , $ action ) = \ explode ( ':' , $ id ) ; $ this -> assign ( $ role , $ action , $ allow ) ; } return $ this -> sync ( ) ; }
|
Initiate ACL data from memory .
|
52,021
|
public function canAs ( Authorizable $ user , string $ action ) : bool { $ this -> setUser ( $ user ) ; $ permission = $ this -> can ( $ action ) ; $ this -> revokeUser ( ) ; return $ permission ; }
|
Verify whether current user has sufficient roles to access the actions based on available type of access .
|
52,022
|
public function execute ( string $ type , string $ operation , array $ parameters = [ ] ) { return $ this -> { $ type } -> { $ operation } ( ... $ parameters ) ; }
|
Forward call to roles or actions .
|
52,023
|
protected function resolveDynamicExecution ( string $ method ) : array { $ method = Str :: snake ( $ method , '_' ) ; $ matcher = '/^(add|rename|has|get|remove|fill|attach|detach)_(role|action)(s?)$/' ; if ( ! \ preg_match ( $ matcher , $ method , $ matches ) ) { throw new InvalidArgumentException ( "Invalid keyword [$method]" ) ; } $ type = $ matches [ 2 ] . 's' ; $ multiple = ( isset ( $ matches [ 3 ] ) && $ matches [ 3 ] === 's' ) ; $ operation = $ this -> resolveOperationName ( $ matches [ 1 ] , $ multiple ) ; return [ $ type , $ operation ] ; }
|
Dynamically resolve operation name especially to resolve attach and detach multiple actions or roles .
|
52,024
|
protected function resolveOperationName ( string $ operation , bool $ multiple = true ) : string { if ( ! $ multiple ) { return $ operation ; } elseif ( \ in_array ( $ operation , [ 'fill' , 'add' ] ) ) { return 'attach' ; } return 'detach' ; }
|
Dynamically resolve operation name especially when multiple operation was used .
|
52,025
|
public function setAuthorization ( FactoryContract $ factory ) { $ this -> acl = $ factory -> make ( $ this -> getAuthorizationName ( ) ) ; return $ this ; }
|
Set authorization driver .
|
52,026
|
protected function can ( string $ action , ? Authorizable $ user = null ) : bool { return ! \ is_null ( $ user ) ? $ this -> acl -> canAs ( $ user , $ action ) : $ this -> acl -> can ( $ action ) ; }
|
Resolve if authorization can .
|
52,027
|
protected function canIf ( string $ action , ? Authorizable $ user = null ) : bool { return ! \ is_null ( $ user ) ? $ this -> acl -> canIfAs ( $ user , $ action ) : $ this -> acl -> canIf ( $ action ) ; }
|
Resolve if authorization can if action exists .
|
52,028
|
public function setHeaders ( HeadersInterface & $ headers ) { foreach ( $ this -> data as $ name => $ settings ) { $ this -> setHeader ( $ headers , $ name , $ settings ) ; } }
|
Serialize this collection of cookies into a raw HTTP header
|
52,029
|
public function getReasonPhrase ( ) { if ( isset ( static :: $ messages [ $ this -> status ] ) === true ) { return static :: $ messages [ $ this -> status ] ; } return null ; }
|
Get response reason phrase
|
52,030
|
public function addHeaders ( array $ headers ) { foreach ( $ headers as $ name => $ value ) { $ this -> headers -> add ( $ name , $ value ) ; } }
|
Add multiple header values
|
52,031
|
public function write ( $ body , $ overwrite = false ) { if ( $ overwrite === true ) { $ this -> body -> close ( ) ; $ this -> body = new \ Guzzle \ Stream \ Stream ( fopen ( 'php://temp' , 'r+' ) ) ; } $ this -> body -> write ( $ body ) ; }
|
Append response body
|
52,032
|
public function finalize ( \ Slim \ Interfaces \ Http \ RequestInterface $ request ) { $ sendBody = true ; if ( in_array ( $ this -> status , array ( 204 , 304 ) ) === true ) { $ this -> headers -> remove ( 'Content-Type' ) ; $ this -> headers -> remove ( 'Content-Length' ) ; $ sendBody = false ; } else { $ size = @ $ this -> getSize ( ) ; if ( $ size ) { $ this -> headers -> set ( 'Content-Length' , $ size ) ; } } $ this -> cookies -> setHeaders ( $ this -> headers ) ; if ( $ request -> isHead ( ) === true ) { $ sendBody = false ; } if ( $ sendBody === false ) { $ this -> body -> close ( ) ; $ this -> body = new \ Guzzle \ Stream \ Stream ( fopen ( 'php://temp' , 'r+' ) ) ; } return $ this ; }
|
Finalize response for delivery to client
|
52,033
|
public function send ( ) { if ( headers_sent ( ) === false ) { if ( strpos ( PHP_SAPI , 'cgi' ) === 0 ) { header ( sprintf ( 'Status: %s' , $ this -> getReasonPhrase ( ) ) ) ; } else { header ( sprintf ( '%s %s' , $ this -> getProtocolVersion ( ) , $ this -> getReasonPhrase ( ) ) ) ; } foreach ( $ this -> headers as $ name => $ value ) { foreach ( $ value as $ hVal ) { header ( "$name: $hVal" , false ) ; } } } $ this -> body -> seek ( 0 ) ; while ( $ this -> body -> feof ( ) === false ) { echo $ this -> body -> read ( 1024 ) ; } return $ this ; }
|
Send HTTP response headers and body
|
52,034
|
public function getLoginUrl ( ) { $ params = array ( 'client_id' => $ this -> getClientId ( ) , 'redirect_uri' => $ this -> getRedirectUri ( ) , ) ; if ( $ this -> getScope ( ) ) { $ params [ 'scope' ] = implode ( ',' , $ this -> getScope ( ) ) ; } if ( $ this -> getResponceType ( ) ) { $ params [ 'response_type' ] = $ this -> getResponceType ( ) ; } if ( $ this -> apiVersion ) { $ params [ 'v' ] = $ this -> apiVersion ; } if ( $ this -> state ) { $ params [ 'state' ] = $ this -> state ; } return 'https://oauth.vk.com/authorize?' . http_build_query ( $ params ) ; }
|
Get the login URL for Vkontakte sign in
|
52,035
|
public function authenticate ( $ code = null ) { if ( null === $ code ) { if ( isset ( $ _GET [ 'code' ] ) ) { $ code = $ _GET [ 'code' ] ; } } $ url = 'https://oauth.vk.com/access_token?' . http_build_query ( array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'code' => $ code , 'redirect_uri' => $ this -> getRedirectUri ( ) , ) ) ; $ token = $ this -> curl ( $ url ) ; $ decodedToken = json_decode ( $ token , true ) ; $ decodedToken [ 'created' ] = time ( ) ; $ this -> setAccessToken ( $ decodedToken ) ; return $ this ; }
|
Authenticate user and get access token from server
|
52,036
|
public function setAccessToken ( $ token ) { if ( is_string ( $ token ) ) { $ this -> accessToken = json_decode ( $ token , true ) ; } else { $ this -> accessToken = ( array ) $ token ; } return $ this ; }
|
Set the access token
|
52,037
|
protected function curl ( $ url ) { if ( $ this -> persistentConnect ) { if ( ! is_resource ( static :: $ connection ) ) { static :: $ connection = curl_init ( ) ; } $ ch = static :: $ connection ; } else { $ ch = curl_init ( ) ; } curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , FALSE ) ; if ( $ this -> IPv6Disabled ) { curl_setopt ( $ ch , CURLOPT_IPRESOLVE , CURL_IPRESOLVE_V4 ) ; } $ result = curl_exec ( $ ch ) ; if ( ! $ result ) { $ errno = curl_errno ( $ ch ) ; $ error = curl_error ( $ ch ) ; } if ( ! $ this -> persistentConnect ) { curl_close ( $ ch ) ; } if ( isset ( $ errno ) && isset ( $ error ) ) { throw new \ Exception ( $ error , $ errno ) ; } return $ result ; }
|
Make the curl request to specified url
|
52,038
|
public function keep ( ) { foreach ( $ this -> messages [ 'prev' ] as $ key => $ val ) { $ this -> next ( $ key , $ val ) ; } }
|
Persist flash messages from previous request to the next request
|
52,039
|
public function offsetUnset ( $ key ) { $ keys = $ this -> parseKey ( $ key ) ; $ array = & $ this -> values ; while ( count ( $ keys ) > 1 ) { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ array [ $ key ] ) || ! is_array ( $ array [ $ key ] ) ) { return ; } $ array = & $ array [ $ key ] ; } unset ( $ array [ array_shift ( $ keys ) ] ) ; }
|
Remove nested array value based on a separated key
|
52,040
|
protected function parseKey ( $ key ) { if ( ! isset ( $ this -> keys [ $ key ] ) ) { $ this -> keys [ $ key ] = explode ( $ this -> separator , $ key ) ; } return $ this -> keys [ $ key ] ; }
|
Parse a separated key and cache the result
|
52,041
|
protected function getValue ( $ key , array $ array = array ( ) ) { $ keys = $ this -> parseKey ( $ key ) ; while ( count ( $ keys ) > 0 and ! is_null ( $ array ) ) { $ key = array_shift ( $ keys ) ; $ array = isset ( $ array [ $ key ] ) ? $ array [ $ key ] : null ; } return $ array ; }
|
Get a value from a nested array based on a separated key
|
52,042
|
protected function setValue ( $ key , $ value , array & $ array = array ( ) ) { $ keys = $ this -> parseKey ( $ key , $ this -> separator ) ; $ pointer = & $ array ; while ( count ( $ keys ) > 0 ) { $ key = array_shift ( $ keys ) ; $ pointer [ $ key ] = ( isset ( $ pointer [ $ key ] ) ? $ pointer [ $ key ] : array ( ) ) ; $ pointer = & $ pointer [ $ key ] ; } $ pointer = $ value ; return $ array ; }
|
Set nested array values based on a separated key
|
52,043
|
protected function flattenArray ( array $ array , $ separator = null ) { $ flattened = array ( ) ; if ( is_null ( $ separator ) ) { $ separator = $ this -> separator ; } foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ flattened = array_merge ( $ flattened , $ this -> flattenArray ( $ value , $ key . $ separator ) ) ; } else { $ flattened [ trim ( $ separator . $ key , $ this -> separator ) ] = $ value ; } } return $ flattened ; }
|
Flatten a nested array to a separated key
|
52,044
|
public function setup ( $ event ) : void { $ this -> userRoles = null ; $ this -> events -> forget ( 'orchestra.auth: roles' ) ; $ this -> events -> listen ( 'orchestra.auth: roles' , $ event ) ; }
|
Setup roles event listener .
|
52,045
|
public function setUser ( Authorizable $ user ) { $ userRoles = $ user -> getRoles ( ) ; $ this -> userRoles = $ userRoles ; return $ this ; }
|
Assign user instance .
|
52,046
|
public function getMatchedRoutes ( $ httpMethod , $ resourceUri , $ save = true ) { $ matchedRoutes = array ( ) ; foreach ( $ this -> routes as $ route ) { if ( ! $ route -> supportsHttpMethod ( $ httpMethod ) && ! $ route -> supportsHttpMethod ( "ANY" ) ) { continue ; } if ( $ route -> matches ( $ resourceUri ) ) { $ matchedRoutes [ ] = $ route ; } } if ( $ save === true ) { $ this -> matchedRoutes = $ matchedRoutes ; } return $ matchedRoutes ; }
|
Get route objects that match a given HTTP method and URI
|
52,047
|
public function urlFor ( $ name , $ params = array ( ) ) { if ( ! $ this -> hasNamedRoute ( $ name ) ) { throw new \ RuntimeException ( 'Named route not found for name: ' . $ name ) ; } $ search = array ( ) ; foreach ( $ params as $ key => $ value ) { $ search [ ] = '#:' . preg_quote ( $ key , '#' ) . '\+?(?!\w)#' ; } $ pattern = preg_replace ( $ search , $ params , $ this -> getNamedRoute ( $ name ) -> getPattern ( ) ) ; return preg_replace ( '#\(/?:.+\)|\(|\)|\\\\#' , '' , $ pattern ) ; }
|
Get URL for named route
|
52,048
|
public function getNamedRoutes ( ) { if ( is_null ( $ this -> namedRoutes ) ) { $ this -> namedRoutes = array ( ) ; foreach ( $ this -> routes as $ route ) { if ( $ route -> getName ( ) !== null ) { $ this -> addNamedRoute ( $ route -> getName ( ) , $ route ) ; } } } return new \ ArrayIterator ( $ this -> namedRoutes ) ; }
|
Get external iterator for named routes
|
52,049
|
public function setCallable ( $ callable ) { $ matches = array ( ) ; if ( is_string ( $ callable ) && preg_match ( '!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!' , $ callable , $ matches ) ) { $ class = $ matches [ 1 ] ; $ method = $ matches [ 2 ] ; $ callable = function ( ) use ( $ class , $ method ) { static $ obj = null ; if ( $ obj === null ) { $ obj = new $ class ; } return call_user_func_array ( array ( $ obj , $ method ) , func_get_args ( ) ) ; } ; } if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( 'Route callable must be callable' ) ; } $ this -> callable = $ callable ; }
|
Set route callable
|
52,050
|
public function getParam ( $ index ) { if ( ! isset ( $ this -> params [ $ index ] ) ) { throw new \ InvalidArgumentException ( 'Route parameter does not exist at specified index' ) ; } return $ this -> params [ $ index ] ; }
|
Get route parameter value
|
52,051
|
public function setParam ( $ index , $ value ) { if ( ! isset ( $ this -> params [ $ index ] ) ) { throw new \ InvalidArgumentException ( 'Route parameter does not exist at specified index' ) ; } $ this -> params [ $ index ] = $ value ; }
|
Set route parameter value
|
52,052
|
protected function validateKeyLength ( $ key , $ module ) { $ keySize = strlen ( $ key ) ; $ keySizeMin = 1 ; $ keySizeMax = mcrypt_enc_get_key_size ( $ module ) ; $ validKeySizes = mcrypt_enc_get_supported_key_sizes ( $ module ) ; if ( $ validKeySizes ) { if ( ! in_array ( $ keySize , $ validKeySizes ) ) { throw new \ InvalidArgumentException ( 'Encryption key length must be one of: ' . implode ( ', ' , $ validKeySizes ) ) ; } } else { if ( $ keySize < $ keySizeMin || $ keySize > $ keySizeMax ) { throw new \ InvalidArgumentException ( sprintf ( 'Encryption key length must be between %s and %s, inclusive' , $ keySizeMin , $ keySizeMax ) ) ; } } }
|
Validate encryption key based on valid key sizes for selected cipher and cipher mode
|
52,053
|
protected function throwInitError ( $ code , $ function ) { switch ( $ code ) { case - 4 : throw new \ RuntimeException ( sprintf ( 'There was a memory allocation problem while calling %s::%s' , __CLASS__ , $ function ) ) ; break ; case - 3 : throw new \ RuntimeException ( sprintf ( 'An incorrect encryption key length was used while calling %s::%s' , __CLASS__ , $ function ) ) ; break ; default : if ( is_integer ( $ code ) && $ code < 0 ) { throw new \ RuntimeException ( sprintf ( 'An unknown error was caught while calling %s::%s' , __CLASS__ , $ function ) ) ; } break ; } }
|
Throw an exception based on a provided exit code
|
52,054
|
public function getMethod ( ) { $ method = $ this -> env -> get ( 'REQUEST_METHOD' ) ; $ methodOverride = $ this -> headers -> get ( 'HTTP_X_HTTP_METHOD_OVERRIDE' ) ; if ( ! empty ( $ methodOverride ) ) { $ method = strtoupper ( $ methodOverride ) ; } else if ( $ method === static :: METHOD_POST ) { $ customMethod = $ this -> post ( static :: METHOD_OVERRIDE , false ) ; if ( $ customMethod !== false ) { $ method = strtoupper ( $ customMethod ) ; } } return $ method ; }
|
Get HTTP method
|
52,055
|
public function isFormData ( ) { return ( $ this -> getContentType ( ) == '' && $ this -> getOriginalMethod ( ) === static :: METHOD_POST ) || in_array ( $ this -> getMediaType ( ) , self :: $ formDataMediaTypes ) ; }
|
Does the Request body contain parsed form data?
|
52,056
|
public function getClientIp ( ) { $ keys = array ( 'HTTP_X_FORWARDED_FOR' , 'CLIENT_IP' , 'REMOTE_ADDR' ) ; foreach ( $ keys as $ key ) { if ( $ this -> env -> has ( $ key ) === true ) { return $ this -> env -> get ( $ key ) ; } } return null ; }
|
Get client IP address
|
52,057
|
protected function parsePaths ( ) { if ( is_null ( $ this -> paths ) === true ) { $ scriptName = $ this -> env -> get ( 'SCRIPT_NAME' ) ; $ requestUri = $ this -> env -> get ( 'REQUEST_URI' ) ; $ queryString = $ this -> getQueryString ( ) ; if ( strpos ( $ requestUri , $ scriptName ) !== false ) { $ physicalPath = $ scriptName ; } else { $ physicalPath = str_replace ( '\\' , '' , dirname ( $ scriptName ) ) ; } $ scriptName = rtrim ( $ physicalPath , '/' ) ; $ pathInfo = substr_replace ( $ requestUri , '' , 0 , strlen ( $ physicalPath ) ) ; $ pathInfo = str_replace ( '?' . $ queryString , '' , $ pathInfo ) ; $ pathInfo = '/' . ltrim ( $ pathInfo , '/' ) ; $ this -> paths = array ( ) ; $ this -> paths [ 'physical' ] = $ scriptName ; $ this -> paths [ 'virtual' ] = $ pathInfo ; } return $ this -> paths ; }
|
Parse the physical and virtual paths from the request URI
|
52,058
|
public function detach ( $ keys ) : bool { if ( $ keys instanceof Arrayable ) { $ keys = $ keys -> toArray ( ) ; } foreach ( $ keys as $ key ) { $ this -> remove ( $ key ) ; } return true ; }
|
Remove multiple key to collection .
|
52,059
|
public function filter ( $ request ) : array { if ( \ is_array ( $ request ) ) { return $ request ; } elseif ( $ request === '*' ) { return $ this -> get ( ) ; } elseif ( $ request [ 0 ] === '!' ) { return \ array_diff ( $ this -> get ( ) , [ \ substr ( $ request , 1 ) ] ) ; } return [ $ request ] ; }
|
Filter request .
|
52,060
|
protected function getKeyword ( $ key ) : Keyword { if ( $ key instanceof Keyword ) { return $ key ; } if ( ! isset ( $ this -> cachedKeyword [ $ key ] ) ) { $ this -> cachedKeyword [ $ key ] = Keyword :: make ( $ key ) ; } return $ this -> cachedKeyword [ $ key ] ; }
|
Get keyword instance .
|
52,061
|
public function isStarted ( ) { $ started = false ; if ( version_compare ( phpversion ( ) , '5.4.0' , '>=' ) ) { $ started = session_status ( ) === PHP_SESSION_ACTIVE ? true : false ; } else { $ started = session_id ( ) === '' ? false : true ; } return $ started ; }
|
Is session started?
|
52,062
|
public function get ( ) { $ args = func_get_args ( ) ; return $ this -> mapRoute ( $ args ) -> via ( \ Slim \ Http \ Request :: METHOD_GET , \ Slim \ Http \ Request :: METHOD_HEAD ) ; }
|
Add GET route
|
52,063
|
public function post ( ) { $ args = func_get_args ( ) ; return $ this -> mapRoute ( $ args ) -> via ( \ Slim \ Http \ Request :: METHOD_POST ) ; }
|
Add POST route
|
52,064
|
public function delete ( ) { $ args = func_get_args ( ) ; return $ this -> mapRoute ( $ args ) -> via ( \ Slim \ Http \ Request :: METHOD_DELETE ) ; }
|
Add DELETE route
|
52,065
|
public function options ( ) { $ args = func_get_args ( ) ; return $ this -> mapRoute ( $ args ) -> via ( \ Slim \ Http \ Request :: METHOD_OPTIONS ) ; }
|
Add OPTIONS route
|
52,066
|
public function setCookie ( $ name , $ value , $ time = null , $ path = null , $ domain = null , $ secure = null , $ httponly = null ) { $ settings = array ( 'value' => $ value , 'expires' => is_null ( $ time ) ? $ this -> config ( 'cookies.lifetime' ) : $ time , 'path' => is_null ( $ path ) ? $ this -> config ( 'cookies.path' ) : $ path , 'domain' => is_null ( $ domain ) ? $ this -> config ( 'cookies.domain' ) : $ domain , 'secure' => is_null ( $ secure ) ? $ this -> config ( 'cookies.secure' ) : $ secure , 'httponly' => is_null ( $ httponly ) ? $ this -> config ( 'cookies.httponly' ) : $ httponly ) ; $ this [ 'response' ] -> setCookie ( $ name , $ settings ) ; }
|
Set HTTP cookie to be sent with the HTTP response
|
52,067
|
public function getHooks ( $ name = null ) { if ( ! is_null ( $ name ) ) { return isset ( $ this -> hooks [ ( string ) $ name ] ) ? $ this -> hooks [ ( string ) $ name ] : null ; } else { return $ this -> hooks ; } }
|
Get hook listeners
|
52,068
|
public function clearHooks ( $ name = null ) { if ( ! is_null ( $ name ) && isset ( $ this -> hooks [ ( string ) $ name ] ) ) { $ this -> hooks [ ( string ) $ name ] = array ( array ( ) ) ; } else { foreach ( $ this -> hooks as $ key => $ value ) { $ this -> hooks [ $ key ] = array ( array ( ) ) ; } } }
|
Clear hook listeners
|
52,069
|
public function sendFile ( $ file , $ contentType = false ) { $ fp = fopen ( $ file , "r" ) ; $ this [ 'response' ] -> setBody ( new \ Guzzle \ Stream \ Stream ( $ fp ) ) ; if ( $ contentType ) { $ this [ 'response' ] -> setHeader ( "Content-Type" , $ contentType ) ; } else { if ( file_exists ( $ file ) ) { if ( extension_loaded ( 'fileinfo' ) ) { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ type = $ finfo -> file ( $ file ) ; $ this [ 'response' ] -> setHeader ( "Content-Type" , $ type ) ; } else { $ this [ 'response' ] -> setHeader ( "Content-Type" , "application/octet-stream" ) ; } $ stat = fstat ( $ fp ) ; $ this [ 'response' ] -> setHeader ( "Content-Length" , $ stat [ 'size' ] ) ; } else { $ data = stream_get_meta_data ( $ fp ) ; foreach ( $ data [ 'wrapper_data' ] as $ header ) { list ( $ k , $ v ) = explode ( ": " , $ header , 2 ) ; if ( $ k === "Content-Type" ) { $ this [ 'response' ] -> setHeader ( "Content-Type" , $ v ) ; } else if ( $ k === "Content-Length" ) { $ this [ 'response' ] -> setHeader ( "Content-Length" , $ v ) ; } } } } }
|
Send a File
|
52,070
|
public function sendProcess ( $ command , $ contentType = "text/plain" ) { $ this [ 'response' ] -> setBody ( new \ Guzzle \ Stream \ Stream ( popen ( $ command , 'r' ) ) ) ; $ this [ 'response' ] -> setHeader ( "Content-Type" , $ contentType ) ; }
|
Send a Process
|
52,071
|
protected function dispatchRequest ( \ Slim \ Http \ Request $ request , \ Slim \ Http \ Response $ response ) { try { $ this -> applyHook ( 'slim.before' ) ; ob_start ( ) ; $ this -> applyHook ( 'slim.before.router' ) ; $ dispatched = false ; $ matchedRoutes = $ this [ 'router' ] -> getMatchedRoutes ( $ request -> getMethod ( ) , $ request -> getPathInfo ( ) , false ) ; foreach ( $ matchedRoutes as $ route ) { try { $ this -> applyHook ( 'slim.before.dispatch' ) ; $ dispatched = $ route -> dispatch ( ) ; $ this -> applyHook ( 'slim.after.dispatch' ) ; if ( $ dispatched ) { break ; } } catch ( \ Slim \ Exception \ Pass $ e ) { continue ; } } if ( ! $ dispatched ) { $ this -> notFound ( ) ; } $ this -> applyHook ( 'slim.after.router' ) ; } catch ( \ Slim \ Exception \ Stop $ e ) { } $ response -> write ( ob_get_clean ( ) ) ; $ this -> applyHook ( 'slim.after' ) ; }
|
Dispatch request and build response
|
52,072
|
public function finalize ( ) { if ( ! $ this -> responded ) { $ this -> responded = true ; if ( isset ( $ _SESSION ) ) { $ this [ 'flash' ] -> save ( ) ; if ( $ this -> config ( 'session.encrypt' ) === true ) { $ this [ 'session' ] -> encrypt ( $ this [ 'crypt' ] ) ; } $ this [ 'session' ] -> save ( ) ; } if ( $ this [ 'settings' ] [ 'cookies.encrypt' ] ) { $ this [ 'response' ] -> encryptCookies ( $ this [ 'crypt' ] ) ; } $ this [ 'response' ] -> finalize ( $ this [ 'request' ] ) -> send ( ) ; } }
|
Finalize send response
|
52,073
|
protected function defaultError ( $ e ) { $ this -> contentType ( 'text/html' ) ; if ( $ this [ 'mode' ] === 'development' ) { $ title = 'Slim Application Error' ; $ html = '' ; if ( $ e instanceof \ Exception ) { $ code = $ e -> getCode ( ) ; $ message = $ e -> getMessage ( ) ; $ file = $ e -> getFile ( ) ; $ line = $ e -> getLine ( ) ; $ trace = str_replace ( array ( '#' , '\n' ) , array ( '<div>#' , '</div>' ) , $ e -> getTraceAsString ( ) ) ; $ html = '<p>The application could not run because of the following error:</p>' ; $ html .= '<h2>Details</h2>' ; $ html .= sprintf ( '<div><strong>Type:</strong> %s</div>' , get_class ( $ e ) ) ; if ( $ code ) { $ html .= sprintf ( '<div><strong>Code:</strong> %s</div>' , $ code ) ; } if ( $ message ) { $ html .= sprintf ( '<div><strong>Message:</strong> %s</div>' , $ message ) ; } if ( $ file ) { $ html .= sprintf ( '<div><strong>File:</strong> %s</div>' , $ file ) ; } if ( $ line ) { $ html .= sprintf ( '<div><strong>Line:</strong> %s</div>' , $ line ) ; } if ( $ trace ) { $ html .= '<h2>Trace</h2>' ; $ html .= sprintf ( '<pre>%s</pre>' , $ trace ) ; } } else { $ html = sprintf ( '<p>%s</p>' , $ e ) ; } echo self :: generateTemplateMarkup ( $ title , $ html ) ; } else { echo self :: generateTemplateMarkup ( 'Error' , '<p>A website error has occurred. The website administrator has been notified of the issue. Sorry' . 'for the temporary inconvenience.</p>' ) ; } }
|
Default Error handler
|
52,074
|
public function register ( $ name , ? callable $ callback = null ) : AuthorizationContract { if ( \ is_callable ( $ name ) ) { $ callback = $ name ; $ name = null ; } $ instance = $ this -> make ( $ name ) ; $ callback ( $ instance ) ; return $ instance ; }
|
Register an ACL Container instance with Closure .
|
52,075
|
public function parse ( array $ environment ) { foreach ( $ environment as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } }
|
Parse environment array
|
52,076
|
public function parseHeaders ( EnvironmentInterface $ environment ) { foreach ( $ environment as $ key => $ value ) { $ key = strtoupper ( $ key ) ; if ( strpos ( $ key , 'HTTP_' ) === 0 || in_array ( $ key , $ this -> special ) ) { if ( $ key === 'HTTP_CONTENT_TYPE' || $ key === 'HTTP_CONTENT_LENGTH' ) { continue ; } parent :: set ( $ this -> normalizeKey ( $ key ) , array ( $ value ) ) ; } } }
|
Parse provided headers into this collection
|
52,077
|
public function get ( $ key , $ asArray = false ) { if ( $ asArray ) { return parent :: get ( $ this -> normalizeKey ( $ key ) , array ( ) ) ; } else { return implode ( ', ' , parent :: get ( $ this -> normalizeKey ( $ key ) , array ( ) ) ) ; } }
|
Get data value with key
|
52,078
|
public function add ( $ key , $ value ) { $ header = $ this -> get ( $ key , true ) ; if ( is_array ( $ value ) ) { $ header = array_merge ( $ header , $ value ) ; } else { $ header [ ] = $ value ; } parent :: set ( $ this -> normalizeKey ( $ key ) , $ header ) ; }
|
Add data to key
|
52,079
|
public function normalizeKey ( $ key ) { $ key = strtolower ( $ key ) ; $ key = str_replace ( array ( '-' , '_' ) , ' ' , $ key ) ; $ key = preg_replace ( '#^http #' , '' , $ key ) ; $ key = ucwords ( $ key ) ; $ key = str_replace ( ' ' , '-' , $ key ) ; return $ key ; }
|
Transform header name into canonical form
|
52,080
|
protected function normalizeValue ( $ value , $ original = false ) { if ( is_array ( $ value ) ) { return $ value ; } if ( $ value instanceof Arrayable ) { return $ value -> toArray ( ) ; } return [ $ value => [ ] ] ; }
|
Normalizes a value to make sure it can be processed uniformly .
|
52,081
|
public function observe ( $ class ) { $ className = is_string ( $ class ) ? $ class : get_class ( $ class ) ; if ( ! class_exists ( $ className ) ) { return ; } foreach ( $ this -> getObservableAbilities ( ) as $ ability ) { if ( method_exists ( $ class , $ ability ) ) { $ this -> registerAbility ( $ ability , $ className . '@' . $ ability ) ; } } }
|
Register an observer with the Component .
|
52,082
|
public function registerAbility ( $ ability , $ callback ) { $ this -> abilities -> put ( $ ability , $ this -> makeAbilityCallback ( $ callback ) ) ; }
|
register ability to access .
|
52,083
|
public function getAccesses ( ) { return $ this -> abilities -> mapWithKeys ( function ( $ item , $ key ) { return [ $ key => $ this -> can ( $ key ) ] ; } ) ; }
|
Get all ability .
|
52,084
|
protected function getSmallestVariant ( AttachmentInterface $ attachment ) { $ smallestKey = null ; $ smallest = null ; foreach ( array_get ( $ attachment -> getNormalizedConfig ( ) , 'variants' , [ ] ) as $ variantKey => $ variantSteps ) { if ( ! $ variantSteps ) { continue ; } foreach ( $ variantSteps as $ stepKey => $ step ) { if ( ! in_array ( $ stepKey , $ this -> resizeVariantStepKeys ) ) { continue ; } if ( ! preg_match ( '#(\d+)?x(\d+)?#' , array_get ( $ step , 'dimensions' , '' ) , $ matches ) ) { continue ; } $ smallestForVariant = null ; if ( ( int ) $ matches [ 1 ] > 0 ) { $ smallestForVariant = ( int ) $ matches [ 1 ] ; } if ( ( int ) $ matches [ 2 ] > 0 && ( int ) $ matches [ 2 ] < $ smallestForVariant ) { $ smallestForVariant = ( int ) $ matches [ 2 ] ; } if ( null !== $ smallestForVariant && ( $ smallestForVariant < $ smallest || null === $ smallest ) ) { $ smallestKey = $ variantKey ; $ smallest = $ smallestForVariant ; } break ; } } return $ smallestKey ; }
|
Returns smallest available resize for the attachment .
|
52,085
|
public function field ( ) { $ field = $ this -> getAttribute ( 'field' ) ; if ( $ field || false === $ field ) { return $ field ; } return $ this -> getAttribute ( 'relation' ) ; }
|
Returns the field key .
|
52,086
|
public function columns ( ) : array { $ columns = $ this -> columns ? : [ ] ; if ( ! count ( $ columns ) ) { $ columns = $ this -> getGroupContentColumns ( ) ; } if ( $ remainder = $ this -> getRemainderForColumns ( $ columns ) ) { $ columns [ count ( $ columns ) - 1 ] += $ remainder ; } return $ columns ; }
|
Returns grid column layout as list of twelfths .
|
52,087
|
public function matchesFieldKeys ( array $ keys ) : bool { if ( ! count ( $ keys ) ) return false ; return count ( array_intersect ( $ keys , $ this -> descendantFieldKeys ( ) ) ) > 0 ; }
|
Returns whether any of the children have field keys that appear in a given list of keys .
|
52,088
|
protected function getGroupContentColumns ( ) : array { $ contents = $ this -> getGroupContents ( ) ; $ contentCount = count ( $ contents ) ; $ denominator = floor ( static :: GRID_SIZE_WITHOUT_LABEL / $ contentCount ) ; $ labelWidth = $ denominator > 1 ? 2 : 1 ; $ labelsTotalWidth = $ labelWidth * array_reduce ( $ contents , function ( $ total , $ content ) { return $ total + ( $ content [ 'type' ] !== 'field' ? 1 : 0 ) ; } ) ; $ fieldsCount = array_reduce ( $ contents , function ( $ total , $ content ) { return $ total + ( $ content [ 'type' ] === 'field' ? 1 : 0 ) ; } ) ; $ fieldWidth = ( int ) floor ( ( static :: GRID_SIZE_WITHOUT_LABEL - $ labelsTotalWidth ) / $ fieldsCount ) ; $ columns = [ ] ; foreach ( $ contents as $ content ) { $ columns [ ] = ( $ content [ 'type' ] === 'field' ) ? $ fieldWidth : $ labelWidth ; } return $ columns ; }
|
Returns default column widths based on content types .
|
52,089
|
protected function getGroupContents ( ) : array { $ contents = [ ] ; foreach ( $ this -> children ( ) as $ key => $ child ) { if ( is_string ( $ child ) ) { $ contents [ ] = [ 'key' => $ child , 'type' => 'field' ] ; continue ; } $ contents [ ] = [ 'key' => $ key , 'type' => $ child -> type ( ) ] ; } return $ contents ; }
|
Returns the groups contents with type information .
|
52,090
|
protected function modifyRelationQueryForContext ( Model $ model , $ query ) { $ information = $ this -> getInformationRepository ( ) -> getByModel ( $ model ) ; if ( ! $ information ) { return $ query ; } $ disableScopes = $ information -> meta -> disable_global_scopes ; if ( true === $ disableScopes || is_array ( $ disableScopes ) ) { $ query -> withoutGlobalScopes ( true === $ disableScopes ? null : $ disableScopes ) ; } $ strategy = $ information -> meta -> repository_strategy ; if ( $ strategy ) { $ strategy = $ this -> resolveContextStrategy ( $ strategy ) ; if ( $ strategy ) { $ query = $ strategy -> apply ( $ query , $ information ) ; } } return $ query ; }
|
Modifies the relation query according to the model s CMS information .
|
52,091
|
protected function getFormFieldName ( $ locale = null ) { if ( ! $ locale ) { return $ this -> field -> key ( ) ; } return $ this -> field -> key ( ) . '[' . $ locale . ']' ; }
|
Returns name for the form field input tag .
|
52,092
|
public function read ( $ path ) { try { $ contents = file_get_contents ( $ path ) ; } catch ( Exception $ e ) { throw ( new ModelConfigurationFileException ( "Could not find or open configuraion file at '{$path}'" ) ) -> setPath ( $ path ) ; } if ( '<?php' == substr ( $ contents , 0 , 5 ) ) { try { $ contents = eval ( '?>' . $ contents ) ; } catch ( Exception $ e ) { throw ( new ModelConfigurationFileException ( "Could not interpret CMS model configuration PHP data for '{$path}'" ) ) -> setPath ( $ path ) ; } if ( ! is_array ( $ contents ) ) { throw ( new ModelConfigurationFileException ( "CMS model configuration PHP file did not return an array for '{$path}'" ) ) -> setPath ( $ path ) ; } return $ contents ; } $ json = json_decode ( $ contents , true ) ; if ( null === $ json ) { throw ( new ModelConfigurationFileException ( "Could not interpret CMS model configuration as JSON data for '{$path}'" ) ) -> setPath ( $ path ) ; } return $ json ; }
|
Attempts to retrieve CMS model information array data from a file .
|
52,093
|
public function permissions ( ) { if ( is_array ( $ this -> permissions ) ) { return $ this -> permissions ; } if ( $ this -> permissions ) { return [ $ this -> permissions ] ; } return false ; }
|
Returns permissions required to use the export strategy .
|
52,094
|
protected function modelHasTrait ( $ names ) { if ( ! is_array ( $ names ) ) { $ names = ( array ) $ names ; } return ( bool ) count ( array_intersect ( $ names , $ this -> getTraitNames ( ) ) ) ; }
|
Returns whether the model class uses a trait by a name or list of names .
|
52,095
|
public function initialize ( ModelActionReferenceDataInterface $ data , $ modelClass ) { $ this -> actionData = $ data ; $ this -> modelClass = $ modelClass ; $ this -> performInit ( ) ; return $ this ; }
|
Initializes the strategy instances for further calls .
|
52,096
|
public function getForModelClassByType ( $ modelClass , $ type , $ key , $ targetModel = null ) { $ info = $ this -> getModelInformation ( $ modelClass ) ; if ( ! $ info ) return false ; return $ this -> getForInformationByType ( $ info , $ type , $ key , $ targetModel ) ; }
|
Returns reference data for a model class type and key .
|
52,097
|
public function getForInformationByType ( ModelInformationInterface $ info , $ type , $ key , $ targetModel = null ) { switch ( $ type ) { case 'form.field' : return $ this -> getInformationReferenceDataForFormField ( $ info , $ key , $ targetModel ) ; } return false ; }
|
Returns reference data for model information type and key .
|
52,098
|
public function getNestedModelClassesByType ( ModelInformationInterface $ info , $ type , $ key ) { switch ( $ type ) { case 'form.field' : return $ this -> getInformationReferenceModelClassesForFormField ( $ info , $ key ) ; } return false ; }
|
Returns nested model classes for model information type and key .
|
52,099
|
protected function getNestedReferenceFieldOptionData ( array $ options , $ modelClass ) { $ data = array_get ( $ options , 'models.' . $ modelClass , false ) ; if ( false === $ data || ! is_array ( $ data ) ) { return [ ] ; } return $ data ; }
|
Returns nested reference data for a given model class if possible .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.