idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
47,300
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 .
47,301
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 .
47,302
public static function getCurrentMonth ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'n' ) ; }
Get current month .
47,303
public static function getCurrentHour ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'G' ) ; }
Get current hour .
47,304
public static function getCurrentMinutes ( $ inUTC = false ) { $ tz = $ inUTC ? 'UTC' : null ; return ( int ) static :: now ( $ tz ) -> format ( 'i' ) ; }
Get current minutes .
47,305
public function targetSerialize ( $ target = self :: SER_DEFAULT , $ params = null ) { return $ this -> format ( $ this -> format ) ; }
Serialize object for given target .
47,306
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 .
47,307
static function construct ( $ name , $ id , $ aliases = [ ] ) { $ user = new NyaaUser ( ) ; $ user -> name = $ name ; $ user -> id = $ id ; $ user -> aliases = $ aliases ; return $ user ; }
Constructs a new NyaaUser
47,308
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
47,309
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
47,310
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 .
47,311
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 .
47,312
public static function applyFilter ( $ pageList , $ filterFunction = null ) { if ( isset ( $ filterFunction ) ) { $ pageList = array_filter ( $ pageList , $ filterFunction ) ; } return $ pageList ; }
Filter method .
47,313
public static function applyLimit ( $ pageList , $ limit = null ) { if ( isset ( $ limit ) ) { $ pageList = array_slice ( $ pageList , 0 , $ limit ) ; } return $ pageList ; }
Limit method .
47,314
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 .
47,315
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 .
47,316
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 .
47,317
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 .
47,318
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 .
47,319
private function match ( string $ uri , string $ routeUri ) : ? array { if ( $ uri === $ routeUri ) { return [ ] ; } return $ this -> getArguments ( $ uri , $ routeUri ) ; }
Matches the URI and route .
47,320
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 .
47,321
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 .
47,322
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 .
47,323
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 .
47,324
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 .
47,325
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
47,326
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
47,327
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
47,328
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
47,329
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
47,330
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
47,331
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
47,332
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
47,333
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
47,334
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
47,335
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
47,336
private function getParameters ( $ namespace ) { $ parameters = [ ] ; foreach ( $ this -> parameterRepository -> findBy ( [ 'namespace' => $ namespace ] ) as $ parameter ) { $ parameters [ $ parameter -> getName ( ) ] = $ parameter -> getValue ( ) ; } return $ parameters ; }
Load parameter from database .
47,337
public function get ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_GET ) ; }
Add HTTP GET method route
47,338
public function post ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_POST ) ; }
Add HTTP POST method route
47,339
public function put ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_PUT ) ; }
Add HTTP PUT method route
47,340
public function patch ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_PATCH ) ; }
Add HTTP PATCH method route
47,341
public function delete ( $ path , $ callable , $ name = null ) { return $ this -> add ( $ path , $ callable , $ name , self :: HTTP_METHOD_DELETE ) ; }
Add HTTP DELETE method route
47,342
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
47,343
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
47,344
public function dontReport ( $ exceptions ) { $ this -> dontReport = array_merge ( $ this -> dontReport , is_array ( $ exceptions ) ? $ exceptions : [ $ exceptions ] ) ; }
Adds an exception to not be reported
47,345
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 .
47,346
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 .
47,347
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 .
47,348
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 .
47,349
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 .
47,350
public function getConfig ( $ key = null , $ def = null ) { return Config :: get ( 'exceptions' . ( empty ( $ key ) ? "" : "." . $ key ) , $ def ) ; }
Get exceptions configuration
47,351
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 .
47,352
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 .
47,353
public function setCallback ( $ object , $ callbackFunction , $ parameters = array ( ) ) { $ this -> callbackObject = $ object ; $ this -> callbackFunction = $ callbackFunction ; $ this -> callbackParameters = $ parameters ; return $ this ; }
Set cache callback
47,354
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
47,355
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
47,356
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
47,357
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
47,358
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
47,359
public function similarCsvFile ( TableNode $ filepath ) { $ file = fopen ( $ filepath , "r" ) ; $ expected = CSVTable :: fromStream ( $ file ) ; fclose ( $ file ) ; $ this -> compareCsv ( $ expected ) ; }
CSV download with loose match .
47,360
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 .
47,361
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
47,362
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
47,363
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 .
47,364
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 .
47,365
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 .
47,366
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 .
47,367
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 .
47,368
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 .
47,369
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 .
47,370
public function sameValueAs ( ValueObjectInterface $ currency ) { if ( false === Util :: classEquals ( $ this , $ currency ) ) { return false ; } return $ this -> getCode ( ) -> toNative ( ) == $ currency -> getCode ( ) -> toNative ( ) ; }
Tells whether two Currency are equal by comparing their names
47,371
private function createBundleCacheWarmer ( $ warmerName ) { $ definition = new Definition ( Utility :: getBundleClass ( 'CacheWarmer\MetadataWarmer' ) , [ new Reference ( $ warmerName ) ] ) ; $ definition -> setPublic ( false ) ; $ definition -> addTag ( 'kernel.cache_warmer' ) ; return $ definition ; }
Creates the bundle cache warmer definition .
47,372
private function createCacheClearCommand ( $ warmerName ) { $ definition = new Definition ( Utility :: getBundleClass ( 'Command\Metadata\ClearCacheCommand' ) , [ new Reference ( $ warmerName ) ] ) ; $ definition -> addTag ( 'console.command' ) ; return $ definition ; }
Creates the cache clear command definition .
47,373
private function createFileCache ( $ subClassName , array $ cacheConfig , ContainerBuilder $ container ) { $ cacheDir = $ this -> getFileCacheDir ( $ cacheConfig , $ container ) ; Utility :: appendParameter ( 'dirs' , 'metadata_cache_dir' , $ cacheDir , $ container ) ; return new Definition ( Utility :: getLibraryClass...
Creates a file cache service definition .
47,374
private function getFileCacheDir ( array $ cacheConfig , ContainerBuilder $ container ) { $ dir = sprintf ( '%s/as3_modlr' , $ container -> getParameter ( 'kernel.cache_dir' ) ) ; if ( isset ( $ cacheConfig [ 'parameters' ] [ 'dir' ] ) ) { $ dir = $ cacheConfig [ 'parameters' ] [ 'dir' ] ; } return $ dir ; }
Gets the file cache directory .
47,375
private function loadCacheWarming ( ContainerBuilder $ container ) { $ warmerName = Utility :: getAliasedName ( 'metadata.cache.warmer' ) ; $ definition = $ this -> createCacheWarmer ( $ container ) ; $ container -> setDefinition ( $ warmerName , $ definition ) ; $ definition = $ this -> createBundleCacheWarmer ( $ war...
Loads cache warming services .
47,376
public static function has ( string $ key ) : bool { $ expect = explode ( '.' , $ key ) ; $ config = Config :: all ( ) ; foreach ( $ expect as $ setting ) { if ( ! isset ( $ config [ $ setting ] ) ) return false ; $ config = $ config [ $ setting ] ; } return true ; }
Check if setting exists
47,377
private function getUniqFilename ( $ path , $ filename , $ counter = 0 ) { if ( ( $ pos = mb_strrpos ( $ filename , '.' ) ) == FALSE ) { $ file = $ filename ; $ extension = '' ; } else { $ file = mb_substr ( $ filename , 0 , $ pos ) ; $ extension = mb_substr ( $ filename , $ pos ) ; } $ postfix = $ counter > 0 ? $ this...
Get uniq name for upload
47,378
public function getRequestedRoute ( $ basepath ) { if ( $ basepath == '/' ) { $ url = strtolower ( $ _SERVER [ 'REQUEST_URI' ] ) ; } else { $ url = explode ( $ basepath , strtolower ( $ _SERVER [ 'REQUEST_URI' ] ) ) [ 1 ] ; } return $ this -> _router -> getRoute ( $ url ) ; }
Gets the requested route for the controller .
47,379
public function createAction ( $ name ) { if ( ! $ this -> actions -> containsKey ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Any action registered under "%s" name, only ["%s"] are.' , $ name , implode ( '","' , $ this -> actions -> getKeys ( ) ) ) ) ; } return clone $ this -> actions -> get ( $ na...
Creates and return a new action under given name
47,380
public function render ( $ template , array $ data = array ( ) ) { $ data = array_merge ( $ data , $ this -> website -> helpers ( ) ) ; $ data [ 'config' ] = $ this -> website ; $ renderer = $ this -> website -> renderer ( ) ; return $ renderer -> render ( $ template , $ data ) ; }
Renders the partial template .
47,381
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ strMockedDate = $ request -> query -> get ( $ this -> mockParamName ) ) { return ; } $ this -> mock ( $ strMockedDate ) ; }
kernel request event handler
47,382
public function onConsoleCommand ( ConsoleCommandEvent $ event ) { $ input = $ event -> getInput ( ) ; if ( ! $ input -> hasOption ( $ this -> mockParamName ) ) { return ; } $ this -> mock ( $ input -> getOption ( $ this -> mockParamName ) ) ; }
console command event handler
47,383
public function sameValueAs ( ValueObjectInterface $ dateTimeWithTimeZone ) { if ( false === Util :: classEquals ( $ this , $ dateTimeWithTimeZone ) ) { return false ; } return $ this -> getDateTime ( ) -> sameValueAs ( $ dateTimeWithTimeZone -> getDateTime ( ) ) && $ this -> getTimeZone ( ) -> sameValueAs ( $ dateTime...
Tells whether two DateTimeWithTimeZone are equal by comparing their values
47,384
public function sameTimestampAs ( ValueObjectInterface $ dateTimeWithTimeZone ) { if ( false === Util :: classEquals ( $ this , $ dateTimeWithTimeZone ) ) { return false ; } return $ this -> toNativeDateTime ( ) == $ dateTimeWithTimeZone -> toNativeDateTime ( ) ; }
Tells whether two DateTimeWithTimeZone represents the same timestamp
47,385
public function toNativeDateTime ( ) { $ date = $ this -> getDateTime ( ) -> getDate ( ) ; $ time = $ this -> getDateTime ( ) -> getTime ( ) ; $ year = $ date -> getYear ( ) -> toNative ( ) ; $ month = $ date -> getMonth ( ) -> getNumericValue ( ) ; $ day = $ date -> getDay ( ) -> toNative ( ) ; $ hour = $ time -> getH...
Returns a native PHP \ DateTime version of the current DateTimeWithTimeZone
47,386
public function log ( $ level , $ message , array $ context = [ ] ) { if ( isset ( $ this -> psrToZendPriorityMap [ $ level ] ) ) { $ level = $ this -> psrToZendPriorityMap [ $ level ] ; } $ this -> externalLogger -> log ( $ level , $ message , $ this -> getExtraWithContextMerged ( $ context ) ) ; }
main log function
47,387
private function getExtraWithContextMerged ( array $ context = [ ] ) { $ extra = $ this -> getExtra ( ) ; if ( ! empty ( $ context ) ) { $ extra = array_merge ( $ extra , $ context ) ; } return $ extra ; }
merge extra with current context
47,388
public static function slugify ( $ slug ) { $ slug = preg_replace ( '/\xE3\x80\x80/' , ' ' , $ slug ) ; $ slug = str_replace ( '-' , ' ' , $ slug ) ; $ slug = preg_replace ( '#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#' , "\x20" , $ slug ) ; $ slug = str_replace ( '?' , '' , $ slug ) ; $ slug = trim ( mb_strtolower ( $ slug ,...
better than urlfriendly because & becomes amp then when making urls it can be translated?
47,389
public static function calcAverage ( $ small , $ big ) { $ average = 0 ; if ( $ big != 0 ) { $ x = 0 ; $ y = 0 ; $ average = 0 ; $ x = $ small / $ big ; $ y = $ x * 100 ; $ average = number_format ( ( float ) $ y , 2 , '.' , '' ) ; } return $ average ; }
calculates the average 0 to 100
47,390
protected function getFrontendThemesSettings ( ) { $ themes = $ this -> module -> getByType ( 'theme' , true ) ; unset ( $ themes [ $ this -> theme_backend ] ) ; return $ themes ; }
Returns an array of frontend themes
47,391
public static function getLogger ( array $ context = array ( ) ) { $ str = \ Wedeto \ Util \ Functions :: str ( $ context ) ; if ( self :: $ logger_factory === null ) return new NullLogger ( ) ; return self :: $ logger_factory -> get ( array ( $ context [ 'class' ] ?? "Wedeto.UndefinedLogger" ) ) ; }
This function is subscribed to the Wedeto . Util . GetLogger hook to obtain their logger .
47,392
public function getResponse ( ) { if ( empty ( $ this -> response ) ) $ this -> response = new StringResponse ( WF :: str ( $ this -> getPrevious ( ) ?? $ this ) , "text/plain" ) ; return $ this -> response ; }
Get the formatted response representing this error
47,393
public function getJsonProperty ( $ property , $ key = null , $ default = null ) { $ instance = $ this -> getJsonInstance ( $ property ) ; if ( $ key !== null ) { return $ instance -> get ( $ key , $ default ) ; } return $ instance ; }
Get instance for given property . If a key is given return the value or default .
47,394
public function isJsonProperty ( $ property , $ throwException = false ) { if ( is_string ( $ property ) && in_array ( $ property , $ this -> properties ) ) return true ; if ( $ throwException ) throw new JsonPropertyException ( "Requested property '{$property}' is not a valid for '" . get_class ( $ this ) . "'." ) ; r...
Check if requested property is bound to the model
47,395
private function getJsonInstance ( $ property ) { if ( ! $ this -> isJsonProperty ( $ property ) ) throw new JsonPropertyException ( "Requested property '{$property}' is not a valid for '" . get_class ( $ this -> model ) . "'." ) ; if ( ! array_key_exists ( $ property , $ this -> jsonInstances ) ) $ this -> jsonInstanc...
Instantiate the JsonProperty object or return the existing instance
47,396
private function buildConfig ( Request $ request ) { $ config = array ( 'mode' => $ request -> query -> get ( 'mode' , 'browse' ) , ) ; if ( null !== $ types = $ request -> query -> get ( 'types' , array ( ) ) ) { $ config [ 'types' ] = $ types ; } return $ config ; }
Builds the browser config .
47,397
public function listAction ( Request $ request ) { if ( ! $ request -> isXmlHttpRequest ( ) ) { throw new NotFoundHttpException ( ) ; } $ root = $ this -> getFolderRepository ( ) -> findRoot ( ) ; if ( null !== $ id = $ request -> query -> get ( 'folderId' ) ) { if ( ! $ this -> activateFolderById ( $ id , $ root ) ) {...
Lists the children folders .
47,398
private function activateFolderById ( $ id , FolderInterface $ folder ) { foreach ( $ folder -> getChildren ( ) as $ child ) { if ( $ child -> getId ( ) == $ id ) { $ child -> setActive ( true ) ; return true ; } if ( $ this -> activateFolderById ( $ id , $ child ) ) { return true ; } } return false ; }
Activate the folder by id .
47,399
public function createAction ( Request $ request ) { if ( ! $ request -> isXmlHttpRequest ( ) ) { throw new NotFoundHttpException ( ) ; } $ refFolder = $ this -> findFolderById ( $ request -> attributes -> get ( 'id' ) ) ; $ repo = $ this -> getFolderRepository ( ) ; $ newFolder = $ repo -> createNew ( ) ; $ newFolder ...
Creates the folder .