idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
228,200
public function go ( $ verbose = false ) { $ this -> builder -> setLinks ( $ this -> configuration [ "links" ] ) ; $ this -> builder -> setMatchers ( $ this -> configuration [ "matchers" ] ) ; if ( ! $ this -> builder -> validate ( ) ) { if ( $ verbose ) { $ this -> dumpValueAndArguments ( $ this -> builder -> getLastM...
Explicitly performs the validation .
228,201
protected function dumpValueAndArguments ( Matchers \ AbstractMatcher $ matcher ) { printf ( "Value: %s" . PHP_EOL , $ matcher -> getDumper ( ) -> dump ( $ matcher -> getValue ( ) ) ) ; print ( "Arguments:" . PHP_EOL ) ; foreach ( $ matcher -> getArguments ( ) as $ key => $ argument ) { printf ( " #%s: %s" . PHP_EOL ,...
Dumps given matcher s value and its arguments .
228,202
protected function initialize ( array $ fields ) { $ this -> content = new Content ; $ this -> revision = new Revision ; foreach ( $ fields as $ field => $ settings ) { $ this -> data [ $ field ] = $ this -> initializeField ( $ field , $ settings ) ; } }
Creates the Content Revision and FieldCollections
228,203
protected function initializeField ( $ field , $ settings ) { if ( $ this -> isContentField ( $ field ) || $ this -> isRevisionField ( $ field ) ) { throw new ReservedFieldNameException ( "The field '$field' cannot be used in '" . get_class ( $ this ) . "' as it is a reserved name" ) ; } $ type = $ settings [ 'type' ] ...
Validate configuration and prepare a FieldCollection
228,204
public function newRevision ( $ language_id = null ) { $ created = new static ( $ language_id ? : $ this -> language_id ) ; $ created -> content = $ this -> content ; return $ created ; }
Create a new revision based on the same content ID but without the content . Very useful if you want to add a new language
228,205
protected function setOnField ( FieldCollection $ field , $ value ) { if ( ! is_array ( $ value ) ) { if ( $ field -> getMaxItems ( ) != 1 ) { throw new MultipleFieldAssignmentException ( 'You cannot assign a value to replace a multiple field' ) ; } $ field -> offsetSet ( static :: $ SINGLE_ITEM_KEY , $ value ) ; retur...
Set values on a field
228,206
protected function getFieldTypes ( ) { return ( new Collection ( $ this -> getFields ( ) ) ) -> map ( function ( $ options ) { return $ options [ 'type' ] ; } ) -> values ( ) -> unique ( ) -> map ( function ( $ type ) { return self :: $ types [ $ type ] ; } ) ; }
Get all field types in this Entity .
228,207
protected static function findRevision ( $ id , $ language_id , $ revision_id = null ) { try { if ( is_numeric ( $ revision_id ) && $ revision_id != 0 ) { $ revision = Revision :: findOrFail ( $ revision_id ) ; if ( $ revision -> content_id != $ id ) { throw new RevisionEntityMismatchException ( "This revision doesn't ...
Find the requested Revision .
228,208
public static function find ( $ id , $ language_id , $ revision_id = null ) { $ instance = new static ( $ language_id ) ; try { $ instance -> content = Content :: findOrFail ( $ id ) ; } catch ( ModelNotFoundException $ e ) { throw new EntityNotFoundException ( "The entity with id '$id' doesn't exist" , 0 , $ e ) ; } $...
Find the latest valid revision for this entity
228,209
public function save ( $ newRevision = false , $ publishRevision = true ) { if ( $ newRevision ) { $ revision = new Revision ; $ revision -> language_id = $ this -> revision -> language_id ; $ this -> revision = $ revision ; } DB :: transaction ( function ( ) use ( $ newRevision , $ publishRevision ) { $ this -> saveCo...
Save a revision
228,210
protected function saveRevision ( $ publishRevision ) { if ( ! $ this -> revision -> exists && ! $ publishRevision ) { $ this -> revision -> published = $ publishRevision ; } $ this -> revision -> content_id = $ this -> content -> id ; $ this -> revision -> save ( ) ; if ( $ publishRevision ) { $ this -> unpublishOther...
Save the revision
228,211
protected function unpublishOtherRevisions ( ) { if ( $ this -> content -> wasRecentlyCreated ) { return ; } Revision :: where ( 'content_id' , $ this -> content -> id ) -> where ( 'language_id' , $ this -> revision -> language_id ) -> where ( 'id' , '!=' , $ this -> revision -> id ) -> update ( [ 'published' => false ...
Unpublish the revisions other than this one . Only for the same content_id and language_id
228,212
protected function saveField ( Field $ field , $ newRevision ) { if ( $ newRevision ) { $ field -> id = null ; $ field -> exists = false ; } $ field -> revision_id = $ this -> revision -> id ; $ field -> save ( ) ; }
Save a single field instance
228,213
public function toArray ( ) { $ content = [ 'id' => $ this -> content -> id , '_content' => $ this -> content -> toArray ( ) , '_revision' => $ this -> revision -> toArray ( ) , ] ; foreach ( $ this -> data as $ field => $ data ) { $ content [ $ field ] = $ data -> toArray ( ) ; } return $ content ; }
Convert the Entity to an array .
228,214
public function delete ( $ clear = true ) { $ revisions = Revision :: where ( 'content_id' , $ this -> content -> id ) -> get ( ) ; $ ids = $ revisions -> pluck ( 'id' ) ; $ this -> getFieldTypes ( ) -> each ( function ( $ type ) use ( $ ids ) { $ type :: whereIn ( 'revision_id' , $ ids ) -> delete ( ) ; } ) ; Revision...
Delete this entity and all the underlying Revisions .
228,215
public function deleteRevision ( $ clear = true ) { $ this -> getFieldTypes ( ) -> each ( function ( $ type ) { $ type :: where ( 'revision_id' , $ this -> revision -> id ) -> delete ( ) ; } ) ; if ( $ this -> revision -> published && $ this -> revision -> exists ) { Revision :: where ( 'content_id' , $ this -> content...
Delete the current revision .
228,216
protected function clearFields ( ) { foreach ( array_keys ( $ this -> data ) as $ fieldName ) { $ field = $ this -> data [ $ fieldName ] ; $ field -> clear ( ) ; $ field -> syncOriginal ( ) ; } }
Clear all the fields from their content
228,217
public function publishRevision ( ) { $ this -> revision -> published = true ; $ this -> revision -> save ( ) ; $ this -> unpublishOtherRevisions ( ) ; }
Publish the current revision and unpublish the other revisions of the same language .
228,218
public function dbtable ( $ dbtable = null ) { if ( true === isset ( $ this -> dbtable ) && null === $ dbtable ) { $ dbtable = $ this -> dbtable ; } if ( $ dbtable !== null && false === is_string ( $ dbtable ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __ME...
Loads and stores a new DBTable and returns it
228,219
protected function setDBTable ( $ dbtable ) { if ( false === is_string ( $ dbtable ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ dbtable ) ) , E_USER_ERROR ) ; } $ this -> dbtable = $ dbtable ; }
Set the dbtable
228,220
public function status ( ) { $ status = $ this -> getStatus ( ) ; if ( ! $ status ) { $ this -> writeln ( 'No migrations found.' ) ; return ; } $ this -> writeln ( ' Ran? Name ' ) ; $ this -> writeln ( '--------------' ) ; foreach ( $ status as $ row ) { if ( $ row [ 'migrated' ] ) { $ mark = $ this -> cli -> succes...
Output the migration status table
228,221
public function delete ( ) { if ( ! userHasPermission ( 'admin:blog:post:' . $ this -> blog -> id . ':delete' ) ) { unauthorised ( ) ; } $ iPostId = ( int ) $ this -> uri -> segment ( 6 ) ; $ oPost = $ this -> blog_post_model -> getById ( $ iPostId ) ; if ( ! $ oPost || $ oPost -> blog -> id != $ this -> blog -> id ) {...
Delete a blog post
228,222
public function restore ( ) { if ( ! userHasPermission ( 'admin:blog:post:' . $ this -> blog -> id . ':restore' ) ) { unauthorised ( ) ; } $ iPostId = ( int ) $ this -> uri -> segment ( 6 ) ; if ( $ this -> blog_post_model -> restore ( $ iPostId ) ) { $ oPost = $ this -> blog_post_model -> getById ( $ iPostId ) ; $ thi...
Restore a blog post
228,223
public function callbackValidAudioUrl ( $ sUrl ) { $ sId = $ this -> blog_post_model -> extractSpotifyId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ oFormValidation = Factory :: service ( 'FormValidation' ) ; $ oFormValidation -> set_message ( 'callbackValidAudioUrl' , 'Not a valid Spotify Track UR...
Form Validation callback checks that a Spotify ID can be extracted from the string
228,224
public function callbackValidVideoUrl ( $ sUrl ) { $ sId = $ this -> blog_post_model -> extractYoutubeId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ sId = $ this -> blog_post_model -> extractVimeoId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ oFormValidation = Factory :: servic...
Form Validation callback checks that a YouTube or Vimeo ID can be extracted from the string
228,225
protected function validateType ( $ value ) { if ( ! is_array ( $ value ) && ( ! $ this -> allowFalse || false !== $ value ) ) { $ ex = new InvalidTypeException ( sprintf ( 'Invalid type for path "%s". Expected array, but got %s' , $ this -> getPath ( ) , gettype ( $ value ) ) ) ; if ( $ hint = $ this -> getInfo ( ) ) ...
Validates the type of the value .
228,226
public function getResourceEventName ( ResourceInterface $ resource , $ suffix ) { if ( null !== $ configuration = $ this -> registry -> findConfiguration ( $ resource , false ) ) { return sprintf ( '%s.%s' , $ configuration -> getResourceId ( ) , $ suffix ) ; } return null ; }
Returns the resource event name .
228,227
public function getDatabaseMetadata ( string $ databaseName ) : DatabaseMetadata { if ( ! array_key_exists ( $ databaseName , $ this -> databaseMetadataList ) ) { throw new \ RuntimeException ( 'Server "' . $ this -> host . '" doesn\'t contain database "' . $ databaseName . '"' ) ; } return $ this -> databaseMetadataLi...
Returns database metadata for the specified database .
228,228
public function configure ( ) { $ this -> setName ( $ this -> command ) ; $ this -> setDescription ( $ this -> description ) ; $ this -> arguments ( ) ; }
command interface configure
228,229
public function toMySQLDate ( $ withTime = true ) { if ( $ this -> isHollow ( ) ) { return $ withTime ? '0000-00-00 00:00:00' : '0000-00-00' ; } $ format = $ withTime ? 'Y-m-d H:i:s' : 'Y-m-d' ; return $ this -> format ( $ format ) ; }
Returns date in MySQL format .
228,230
public function addMonths ( $ delta ) { $ interval = new DateInterval ( 'P' . abs ( $ delta ) . 'M' ) ; if ( $ delta > 0 ) { $ this -> add ( $ interval ) ; } elseif ( $ delta < 0 ) { $ this -> sub ( $ interval ) ; } return $ this ; }
Go x months before or ahead .
228,231
public static function getCurrentYear ( $ inUTC = false , $ format = self :: YEAR_FORMAT_LONG ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( $ format ) ; }
Get current year .
228,232
public static function getCurrentMonth ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'n' ) ; }
Get current month .
228,233
public static function getCurrentHour ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'G' ) ; }
Get current hour .
228,234
public static function getCurrentMinutes ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'i' ) ; }
Get current minutes .
228,235
public function targetSerialize ( $ target = self :: SER_DEFAULT , $ params = null ) { return $ this -> format ( $ this -> format ) ; }
Serialize object for given target .
228,236
public function _stringableReplace ( $ search , $ replace , $ subject ) { $ search = $ this -> _normalizeString ( $ search ) ; $ replace = $ this -> _normalizeString ( $ replace ) ; $ subject = $ this -> _normalizeString ( $ subject ) ; return str_replace ( $ search , $ replace , $ subject ) ; }
Replaces occurrences of needle in haystack .
228,237
static function construct ( $ name , $ id , $ aliases = [ ] ) { $ user = new NyaaUser ( ) ; $ user -> name = $ name ; $ user -> id = $ id ; $ user -> aliases = $ aliases ; return $ user ; }
Constructs a new NyaaUser
228,238
static function getKnown ( ) { return [ NyaaUser :: construct ( 'HorribleSubs' , 64513 ) , NyaaUser :: construct ( 'Commie' , 76430 ) , NyaaUser :: construct ( 'Cthuko' , 227226 , [ 'Cthune' ] ) , NyaaUser :: construct ( 'DeadFish' , 169660 ) , NyaaUser :: construct ( 'Coalgirls' , 62260 ) ] ; }
Gets a list of known NyaaUsers
228,239
public function inArray ( ) { $ needle = $ this -> getParameter ( 'value' ) ; $ haystack = $ this -> getParameter ( 'array' ) ; if ( $ haystack instanceof Meta ) { $ haystack = $ haystack -> getMetaValue ( ) ; } if ( is_string ( $ haystack ) ) $ haystack = StringUtils :: smartExplode ( $ haystack ) ; return in_array ( ...
Returns true if value is found in array array
228,240
public function isItTimeYet ( ) { $ now = $ this -> DateFactory -> newLocalDate ( ) ; $ today = strtolower ( $ now -> format ( "D" ) ) ; $ days = $ this -> getParameter ( 'days' ) ; $ date = $ this -> getParameter ( 'date' ) ; $ startTime = $ this -> getParameter ( 'startTime' ) ; $ endTime = $ this -> getParameter ( '...
Returns true if now is within the specified date criteria ; false otherwise . The server timezone is used for all dates .
228,241
public static function applySorting ( $ pagelist , $ sortOrder = null , $ sortBy = null ) { if ( isset ( $ sortOrder ) ) { switch ( $ sortOrder ) { case 'asc' : $ sortOrder = 1 ; break ; case 'desc' : $ sortOrder = - 1 ; break ; default : $ sortOrder = 1 ; break ; } } if ( ! isset ( $ sortBy ) ) { $ sortBy = 'name' ; }...
Sorting method .
228,242
public static function applyFilter ( $ pageList , $ filterFunction = null ) { if ( isset ( $ filterFunction ) ) { $ pageList = array_filter ( $ pageList , $ filterFunction ) ; } return $ pageList ; }
Filter method .
228,243
public static function applyLimit ( $ pageList , $ limit = null ) { if ( isset ( $ limit ) ) { $ pageList = array_slice ( $ pageList , 0 , $ limit ) ; } return $ pageList ; }
Limit method .
228,244
public static function dir ( \ Twig_Environment $ environment , $ dir , $ current , $ sortOrder = null , $ sortBy = 'link' , $ filter = null , $ limit = null , $ userAgentEnabled = false ) { $ pagelist = [ ] ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ dir ) , \ RecursiveIterato...
Static helper method for directory listings .
228,245
public static function files ( \ Twig_Environment $ environment , $ files , $ current , $ sortOrder = null , $ sortBy = null , $ filter = null , $ userAgentEnabled = false ) { $ pagelist = [ ] ; foreach ( $ files as $ file ) { if ( ! strpos ( $ file , $ current ) ) { $ relativePath = Page :: generateRelativePath ( $ fi...
Static helper method for file listings .
228,246
public function build ( ) { $ uri = $ this -> trimTrailingSlashes ( $ this -> request -> getUri ( ) -> getPath ( ) ) ; $ method = mb_strtoupper ( $ this -> request -> getMethod ( ) ) ; foreach ( $ this -> routes [ $ method ] as $ routeUri => $ action ) { $ arguments = $ this -> match ( $ uri , $ routeUri ) ; if ( ! is_...
Handle the route .
228,247
private function triggerAction ( $ action ) : Response { if ( is_callable ( $ action ) ) { return $ this -> returnResponse ( $ this -> container -> call ( $ action ) ) ; } elseif ( is_array ( $ action ) ) { return $ this -> returnResponse ( $ this -> container -> call ( [ $ action [ 'controller' ] , $ action [ 'method'...
Triggers an action .
228,248
private function returnResponse ( $ result ) : Response { if ( $ result instanceof Response ) { return $ result ; } if ( is_array ( $ result ) ) { $ result = json_encode ( $ result ) ; } return new Response ( 200 , [ ] , $ result ) ; }
Returns a Response object .
228,249
private function match ( string $ uri , string $ routeUri ) : ? array { if ( $ uri === $ routeUri ) { return [ ] ; } return $ this -> getArguments ( $ uri , $ routeUri ) ; }
Matches the URI and route .
228,250
private function constructAction ( $ action , array $ arguments = [ ] ) : bool { if ( is_callable ( $ action ) ) { $ this -> pendingAction = $ action ; return true ; } elseif ( is_string ( $ action ) ) { $ actionParts = explode ( '@' , $ action ) ; $ controllerName = 'App\\Http\\Controllers\\' . $ actionParts [ 0 ] ; $...
Construct action before running it .
228,251
private function matchUri ( string $ regex , string $ uri ) : ? array { if ( preg_match_all ( '/' . $ regex . '/' , $ uri , $ uriMatches ) ) { $ uriMatches = array_filter ( $ uriMatches , function ( $ key ) { if ( is_string ( $ key ) ) { return true ; } return false ; } , ARRAY_FILTER_USE_KEY ) ; $ uriMatches = array_m...
Matches the URI .
228,252
private function getArguments ( string $ uri , string $ routeUri ) : ? array { if ( preg_match_all ( '/({[a-z]+:)/i' , $ routeUri , $ matches ) ) { $ regex = str_replace ( '/' , '\/' , str_replace ( '}' , ')' , preg_replace ( '/{([a-z]+):/i' , '(?<$1>' , $ routeUri ) ) ) ; return $ this -> matchUri ( $ regex , $ uri ) ...
Get the arguments for the requested URI .
228,253
protected function inExceptArray ( $ request ) { foreach ( $ this -> except as $ except ) { if ( $ request -> is ( $ except ) ) { return true ; } } return false ; }
Determine if the request has a URI that should be accessible in maintenance mode .
228,254
private function loadSmarty ( ) { if ( is_null ( $ this -> smartyInstance ) ) { $ this -> smartyInstance = new Smarty ( ) ; $ this -> smartyInstance -> setCompileDir ( Core :: $ tempDir . DS . 'Smarty' . DS . 'Compile' ) ; $ this -> smartyInstance -> setCacheDir ( Core :: $ tempDir . DS . 'Smarty' ) ; } }
Loads a Smarty instance if it is not already loaded .
228,255
public function enableSegMatch ( string $ namespace , array $ params = [ ] , string $ prepend = "" , string $ defaultMethod = "index" ) : Dispatcher { $ this -> segBasedMatch = [ "enabled" => true , "uriPrepend" => $ prepend , "controller" => [ "namespace" => $ namespace , "defaultMethod" => $ defaultMethod , "params" ...
Enable segment Based URI Matching
228,256
protected function findRoute ( int $ method , string $ uri ) { $ route = null ; if ( $ uri !== "" || ( $ route = $ this -> routes -> defaultRoute ( ) ) === null ) { return $ this -> checkContainer ( $ method , $ uri ) ; } return $ route ; }
Find matching Route
228,257
protected function checkContainer ( int $ method , string $ uri ) { while ( ( $ route = $ this -> routes -> next ( ) ) !== false ) { if ( ( $ route -> method & $ method ) !== $ method ) { continue ; } if ( preg_match_all ( $ this -> posix2Pcre ( $ route -> uri ) , $ uri , $ matches ) === 0 ) { continue ; } $ this -> lo...
Check Routes Container
228,258
protected function handleNoMatch ( ) { $ result = $ this -> hooks -> exec ( "router.dispatcher.routeNotFound" ) ; if ( $ result instanceof Route ) { $ this -> logger -> info ( "No Route found, hook call produced valid Route object, using it instead." ) ; return $ result ; } elseif ( is_array ( $ result ) ) { foreach ( ...
Handle No Matching Route Found
228,259
protected function posix2Pcre ( string $ regex , array $ names = [ "params" , "named" ] ) : string { $ counters = [ ] ; foreach ( $ names as $ type ) { $ regex = preg_replace_callback ( "~\[:{$type}:\]~" , function ( ) use ( & $ counters , $ type ) { if ( isset ( $ counters [ $ type ] ) === false ) { $ counters [ $ typ...
POSIX named class to PCRE capturing group
228,260
protected function addParams ( array $ matches ) { $ params = [ ] ; foreach ( $ matches as $ key => $ value ) { $ value = $ value [ 0 ] ; if ( strpos ( $ key , "params" ) === 0 ) { $ params [ "parameters" ] = array_merge ( $ params [ "parameters" ] ?? [ ] , explode ( "/" , $ value ) ) ; } if ( strpos ( $ key , "named" ...
Add additional parameters
228,261
public function parse ( $ filepath ) { $ metadata = array ( ) ; $ reflectedClass = $ this -> getReflection ( $ filepath ) ; $ metadata [ 'class' ] = $ reflectedClass -> getName ( ) ; $ propertiesMetadata = $ this -> processPropertiesParsing ( $ reflectedClass ) ; $ metadata = array_merge ( $ metadata , $ propertiesMeta...
ParserInterface implementation Extract className and metadata properties
228,262
protected function getReflection ( $ filepath ) { if ( ! preg_match ( '#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm' , file_get_contents ( $ filepath ) , $ captured ) ) { throw new \ RuntimeException ( 'Unable to find namespace or class declaration' ) ; } $ fqcn = $ captured [ 1 ] . '\\' . $ captured [ 2 ] ; try { $ refl...
Extract the fully qualified namespace and return a ReflectionClass object
228,263
protected function processPropertiesParsing ( \ ReflectionClass $ reflectedClass ) { $ metadata = array ( ) ; $ reflectedProperties = $ reflectedClass -> getProperties ( ) ; foreach ( $ reflectedProperties as $ reflectedProperty ) { if ( $ this -> isBoomgoProperty ( $ reflectedProperty ) ) { $ propertyMetadata = $ this...
Parse class properties for metadata extraction if valid contains valid annotation local tag
228,264
private function isBoomgoProperty ( \ ReflectionProperty $ property ) { $ propertyName = $ property -> getName ( ) ; $ className = $ property -> getDeclaringClass ( ) -> getName ( ) ; $ annotationTag = substr_count ( $ property -> getDocComment ( ) , $ this -> getLocalAnnotation ( ) ) ; if ( 0 < $ annotationTag ) { if ...
Check if an object property has to be processed by Boomgo
228,265
private function parseMetadataProperty ( \ ReflectionProperty $ property ) { $ metadata = array ( ) ; $ tag = '@var' ; $ docComment = $ property -> getDocComment ( ) ; $ occurence = ( int ) substr_count ( $ docComment , $ tag ) ; if ( 1 < $ occurence ) { throw new \ RuntimeException ( sprintf ( '"@var" tag is not uniqu...
Parse Boomgo metadata
228,266
private function getParameters ( $ namespace ) { $ parameters = [ ] ; foreach ( $ this -> parameterRepository -> findBy ( [ 'namespace' => $ namespace ] ) as $ parameter ) { $ parameters [ $ parameter -> getName ( ) ] = $ parameter -> getValue ( ) ; } return $ parameters ; }
Load parameter from database .
228,267
public function get ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_GET ) ; }
Add HTTP GET method route
228,268
public function post ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_POST ) ; }
Add HTTP POST method route
228,269
public function put ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_PUT ) ; }
Add HTTP PUT method route
228,270
public function patch ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_PATCH ) ; }
Add HTTP PATCH method route
228,271
public function delete ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_DELETE ) ; }
Add HTTP DELETE method route
228,272
public function route ( $ url ) { if ( ! isset ( $ this -> routes [ $ this -> getHttpMethod ( ) ] ) ) { throw new RouterException ( "REQUEST_METHOD does not exist : url = $url" ) ; } foreach ( $ this -> routes [ $ this -> getHttpMethod ( ) ] as $ route ) { $ matches = $ route -> match ( $ url ) ; if ( is_array ( $ matc...
Execute a callable of route that matchs the URL
228,273
private function add ( $ path , $ callable , $ name , $ method ) { $ route = new Route ( $ path , $ callable ) ; $ this -> routes [ $ method ] [ ] = $ route ; if ( is_string ( $ callable ) && $ name === null ) { $ name = $ callable ; } if ( $ name ) { $ this -> namedRoutes [ $ name ] = $ route ; } return $ route ; }
Add route to collection of routes implements Fluent design pattern
228,274
public function dontReport ( $ exceptions ) { $ this -> dontReport = array_merge ( $ this -> dontReport , is_array ( $ exceptions ) ? $ exceptions : [ $ exceptions ] ) ; }
Adds an exception to not be reported
228,275
public function report ( Exception $ e ) { if ( ! $ this -> shouldReport ( $ e ) ) return ; try { $ logger = Framework :: log ( ) ; } catch ( Exception $ ex ) { throw $ e ; } $ logger -> error ( $ e ) ; $ level = $ this -> getLevel ( $ e ) ; $ id = UniversalBuilder :: resolveClass ( ExceptionIdentifier :: class ) -> id...
Report or log an Exception .
228,276
protected function getLevel ( Exception $ exception ) { foreach ( array_get ( $ this -> getConfig ( ) , 'levels' , [ ] ) as $ class => $ level ) if ( $ exception instanceof $ class ) return $ level ; return 'error' ; }
Get the exception level .
228,277
protected function shouldReport ( Exception $ e ) { foreach ( $ this -> dontReport as $ type ) if ( $ e instanceof $ type ) return false ; return true ; }
Determine if the Exception is in the do not report list .
228,278
public function render ( $ request , Exception $ e ) { $ transformed = $ this -> getTransformed ( $ e ) ; $ response = method_exists ( $ e , 'getResponse' ) ? $ e -> getResponse ( ) : null ; if ( ! $ response instanceof Response ) try { $ response = $ this -> getResponse ( $ request , $ e , $ transformed ) ; } catch ( ...
Render an Exception into a response .
228,279
protected function toHttpResponse ( $ response , Exception $ e ) { $ response = new Response ( $ response -> getContent ( ) , $ response -> getStatusCode ( ) , $ response -> headers -> all ( ) ) ; return $ response -> withException ( $ e ) ; }
Map Exception into an response .
228,280
public function getConfig ( $ key = null , $ def = null ) { return Config :: get ( 'exceptions' . ( empty ( $ key ) ? "" : "." . $ key ) , $ def ) ; }
Get exceptions configuration
228,281
protected function getResponse ( Request $ request , Exception $ exception , Exception $ transformed ) { $ id = UniversalBuilder :: resolve ( 'exceptions.identifier' ) -> identify ( $ exception ) ; $ flattened = FlattenException :: create ( $ transformed ) ; $ code = $ flattened -> getStatusCode ( ) ; $ headers = $ fla...
Get the appropriate response object .
228,282
public function check ( ) { if ( $ this -> _session -> has ( 'auth' ) ) { $ s = [ 'session' => $ this -> _session -> get ( 'SCARA_SESSION' ) , 'token' => $ this -> _session -> get ( 'SCARA_SESSION_TOKEN' ) , ] ; $ ua = $ this -> _ssl -> untokenize ( $ s [ 'token' ] , $ s [ 'session' ] ) ; if ( $ ua === hash ( 'sha256' ...
Checks if a user is authenticated .
228,283
public function setCallback ( $ object , $ callbackFunction , $ parameters = array ( ) ) { $ this -> callbackObject = $ object ; $ this -> callbackFunction = $ callbackFunction ; $ this -> callbackParameters = $ parameters ; return $ this ; }
Set cache callback
228,284
public function executeCallback ( ) { if ( method_exists ( $ this -> callbackObject , $ this -> callbackFunction ) ) { return call_user_func_array ( array ( $ this -> callbackObject , $ this -> callbackFunction ) , $ this -> callbackParameters ) ; } return null ; }
Activate the callback function
228,285
protected function moveFilesIntoTargetFolder ( $ sourcePath , $ targetPath ) { $ filesystem = new \ Symfony \ Component \ Filesystem \ Filesystem ( ) ; $ filesystem -> mirror ( $ sourcePath , $ targetPath ) ; $ finder = new \ Symfony \ Component \ Finder \ Finder ( ) ; $ iterator = $ finder -> files ( ) -> ignoreUnread...
Moves files into another folder
228,286
protected function setArrayToArrayKbr ( array $ aElements ) { $ aReturn = [ ] ; foreach ( $ aElements as $ key => $ value ) { $ aReturn [ str_replace ( ' ' , '<br/>' , $ key ) ] = $ value ; } return $ aReturn ; }
Replace space with break line for each key element
228,287
public function setArrayToJson ( array $ inArray ) { $ rtrn = utf8_encode ( json_encode ( $ inArray , JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ) ; $ jsonError = $ this -> setJsonErrorInPlainEnglish ( ) ; if ( $ jsonError == '' ) { $ jsonError = $ rtrn ; } return $ jsonError ; }
Converts an array into JSON string
228,288
protected function setJsonErrorInPlainEnglish ( ) { $ knownErrors = [ JSON_ERROR_NONE => '' , JSON_ERROR_DEPTH => 'Maximum stack depth exceeded' , JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch' , JSON_ERROR_CTRL_CHAR => 'Unexpected control character found' , JSON_ERROR_SYNTAX => 'Syntax error, malformed...
Provides a list of all known JSON errors and their description
228,289
public function similarCsvFile ( TableNode $ filepath ) { $ file = fopen ( $ filepath , "r" ) ; $ expected = CSVTable :: fromStream ( $ file ) ; fclose ( $ file ) ; $ this -> compareCsv ( $ expected ) ; }
CSV download with loose match .
228,290
public function getComparators ( TableNode $ table ) { $ comparators = [ ] ; $ headers = $ table -> getRow ( 0 ) ; foreach ( $ headers as $ header ) { $ comparators [ $ header ] = function ( $ expected , $ actual ) { if ( substr ( $ expected , 0 , 1 ) === "/" ) { return preg_match ( $ expected , $ actual ) ; } else { r...
Helper method to generate generic regex comparators .
228,291
public function indexAction ( ) { $ results = array ( ) ; $ key = '' ; $ db = '-1' ; if ( $ this -> getRequest ( ) -> isMethod ( 'POST' ) ) { $ key = $ this -> getRequest ( ) -> get ( 'key' ) ; $ db = $ this -> getRequest ( ) -> get ( 'database' ) ; $ keys = $ this -> getWorker ( ) -> keys ( $ key , $ db ) ; if ( empty...
Search index action
228,292
protected function setLogger ( ) { $ settings = $ this -> module -> getSettings ( 'dev' ) ; $ this -> logger -> printError ( ! empty ( $ settings [ 'print_error' ] ) ) -> errorToException ( ! empty ( $ settings [ 'error_to_exception' ] ) ) -> printBacktrace ( ! empty ( $ settings [ 'print_error_backtrace' ] ) ) ; }
Configure system logger
228,293
static public function buildExpression ( $ property , $ operator , $ parameter = null ) { FilterOperator :: isValid ( $ operator , true ) ; $ expr = new Expr ( ) ; switch ( intval ( $ operator ) ) { case FilterOperator :: NOT_EQUAL : return $ expr -> neq ( $ property , $ parameter ) ; case FilterOperator :: LOWER_THAN ...
Builds the query builder expression .
228,294
static public function buildParameterValue ( $ operator , $ value ) { FilterOperator :: isValid ( $ operator , true ) ; switch ( intval ( $ operator ) ) { case FilterOperator :: LIKE : case FilterOperator :: NOT_LIKE : return sprintf ( '%%%s%%' , $ value ) ; case FilterOperator :: START_WITH : case FilterOperator :: NO...
Builds the query builder parameter value .
228,295
public function escape ( string $ target = EscapeTarget :: HTML ) { switch ( $ target ) { case EscapeTarget :: ATTRIBUTE : return $ this -> escapeAttribute ( ) ; case EscapeTarget :: JS : return $ this -> escapeJS ( ) ; case EscapeTarget :: HTML : default : return $ this -> escapeHTML ( ) ; } }
Get an escaped version of the value .
228,296
protected function initializeValue ( $ value ) { if ( $ this -> isEmpty ( $ value ) && ! $ this -> flags & Value :: CAN_BE_EMPTY ) { throw FailedToValidate :: fromValueForClass ( $ value , $ this ) ; } if ( ! $ this -> isEmpty ( $ value ) ) { $ value = $ this -> validate ( $ value ) ; } if ( null === $ value ) { throw ...
Initialize the value .
228,297
protected function validateEncoding ( ) : string { if ( function_exists ( 'mb_check_encoding' ) && mb_check_encoding ( $ this -> value , 'UTF-8' ) ) { return $ this -> value ; } return function_exists ( 'iconv' ) ? iconv ( 'utf-8' , 'utf-8' , $ this -> value ) : '' ; }
Make sure the value is correctly encoded UTF - 8 .
228,298
protected function escapeAttribute ( ) : string { $ value = $ this -> validateEncoding ( ) ; $ value = strip_tags ( $ value ) ; return htmlspecialchars ( $ value , ENT_QUOTES ) ; }
Escape the value to be used as a HTML attribute .
228,299
protected function escapeJS ( ) : string { $ value = $ this -> validateEncoding ( ) ; $ value = htmlspecialchars ( $ value , ENT_COMPAT ) ; $ value = preg_replace ( '/&#(x)?0*(?(1)27|39);?/i' , '\'' , stripslashes ( $ value ) ) ; $ value = str_replace ( "\r" , '' , $ value ) ; return str_replace ( "\n" , '\\n' , addsla...
Escape the value to be used within JavaScript .