idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
237,400
public function resetBGColor ( ) { static :: $ backgroundColorMap = [ LogLevel :: EMERGENCY => BackgroundColors :: RED ( ) , LogLevel :: ALERT => BackgroundColors :: RED ( ) , LogLevel :: CRITICAL => BackgroundColors :: YELLOW ( ) , LogLevel :: ERROR => null , LogLevel :: WARNING => null , LogLevel :: NOTICE => null , ...
Set background colors map to default ones
237,401
public function resetOutputStreams ( ) { defined ( 'STDOUT' ) || define ( 'STDOUT' , fopen ( 'php://stdout' , 'w' ) ) ; defined ( 'STDERR' ) || define ( 'STDERR' , fopen ( 'php://stderr' , 'w' ) ) ; static :: $ streamsMap = [ LogLevel :: EMERGENCY => STDERR , LogLevel :: ALERT => STDERR , LogLevel :: CRITICAL => STDERR...
Set output streams map to default map
237,402
public function setFGColor ( $ level , ForegroundColors $ color ) { if ( static :: $ foregroundColorMap === null ) { $ this -> resetFGColors ( ) ; } $ this -> checkLevel ( $ level ) ; static :: $ foregroundColorMap [ $ level ] = $ color ; return $ this ; }
Set foreground color for specified level
237,403
public function setBGColor ( $ level , ForegroundColors $ color ) { if ( static :: $ foregroundColorMap === null ) { $ this -> resetBGColor ( ) ; } $ this -> checkLevel ( $ level ) ; static :: $ foregroundColorMap [ $ level ] = $ color ; return $ this ; }
Set background color for specified level
237,404
public function setOutputStream ( $ level , $ stream ) { if ( static :: $ streamsMap === null ) { $ this -> resetOutputStreams ( ) ; } $ this -> checkLevel ( $ level ) ; if ( ! is_resource ( $ stream ) ) { throw new \ UnexpectedValueException ( "Argument '\$stream' must be a writable stream resource" ) ; } static :: $ ...
Set output stream for specified level
237,405
public function showAction ( ) { $ this -> isGranted ( 'VIEW' ) ; $ this -> container -> get ( 'ekyna_admin.menu.builder' ) -> breadcrumbAppend ( 'settings' , 'ekyna_setting.parameter.label.plural' ) ; $ manager = $ this -> getSettingsManager ( ) ; $ schemas = $ this -> getSettingsRegistry ( ) -> getSchemas ( ) ; $ set...
Show the parameters .
237,406
public function editAction ( Request $ request ) { $ this -> isGranted ( 'EDIT' ) ; $ this -> container -> get ( 'ekyna_admin.menu.builder' ) -> breadcrumbAppend ( 'settings' , 'ekyna_setting.parameter.label.plural' ) ; $ manager = $ this -> getSettingsManager ( ) ; $ schemas = $ this -> getSettingsRegistry ( ) -> getS...
Edit the parameters .
237,407
public function title ( ) { $ model_name = $ this -> model_name ; if ( isset ( $ this -> $ model_name -> title ) ) { return $ this -> $ model_name -> title ; } return Arr :: path ( $ this -> tanuki ( ) , 'title' ) ; }
Set HTML title tag
237,408
public function setupMessage ( Message $ message ) { $ this -> addRecipients ( $ message ) ; $ this -> setSubject ( $ message ) ; $ this -> callCustomBuilder ( $ message ) ; }
This method will be called by the returned closure
237,409
protected function addRecipients ( Message $ message ) { if ( $ overwriteTo = $ this -> getOverwriteTo ( ) ) { $ message -> to ( $ overwriteTo ) ; return ; } $ first = true ; foreach ( $ this -> recipients as $ recipient ) { if ( $ first ) { $ message -> to ( $ recipient ) ; } else { $ message -> bcc ( $ recipient ) ; ...
Adds the recipients to the message
237,410
protected function setSubject ( Message $ message ) { if ( ! isset ( $ this -> data [ 'subject' ] ) ) { throw new OutOfBoundsException ( "You have to pass a subject key and value in your view data" ) ; } $ message -> subject ( $ this -> data [ 'subject' ] ) ; }
Sets tzhe subject of the message
237,411
public function generatePivotTable ( ) { $ tables = [ $ this -> getManager ( ) -> getTable ( ) , $ this -> getWith ( ) -> getTable ( ) ] ; sort ( $ tables ) ; return implode ( "_" , $ tables ) ; }
Builds the name of a has - and - belongs - to - many association table
237,412
public function glob ( $ pattern ) { foreach ( glob ( $ pattern ) as $ result ) { $ this -> builder -> add ( $ result ) ; } }
Expands the glob pattern and add the results as arguments .
237,413
public function tostr ( ... $ strings ) { $ new_string = '' ; foreach ( $ strings as $ temp ) { switch ( gettype ( $ temp ) ) { case "array" : $ it = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ temp ) ) ; foreach ( $ it as $ v ) { $ temp_str .= ' ' . $ this -> tostr ( $ v ) ; } break ; default : ...
Take n arguments and combine them into a single string and return that string
237,414
public function wordWrap ( $ string ) { return wordwrap ( $ string , $ this -> line_length , $ this -> break_string , $ this -> split_mid_word ) ; }
Return a string wrapped either at a word or close to the words completion using the break_string defined on the object
237,415
public function massColor ( array $ strings , string $ color ) { $ len_array = count ( $ strings ) ; for ( $ i = 0 ; $ i < $ len_array ; $ i ++ ) { $ strings [ $ i ] = $ this -> colorize -> { $ color } ( $ strings [ $ i ] ) ; } return $ strings ; }
Mass colorize an array of strings
237,416
public function setRGB ( $ rgbValue ) : Color { if ( \ is_string ( $ rgbValue ) ) { $ this -> setRGBString ( $ rgbValue ) ; } else if ( \ is_array ( $ rgbValue ) && \ count ( $ rgbValue ) > 2 ) { $ this -> setRGBArray ( $ rgbValue ) ; } else { throw new ArgumentError ( 'rgbValue' , $ rgbValue , 'Drawing' , 'Illegal RGB...
Sets a new color defined by a valid RGB value .
237,417
public static function FromString ( $ objectString ) { if ( false !== ( $ rgb = ColorTool :: Color2Rgb ( $ objectString ) ) ) { return new Color ( ColorTool :: Rgb2Hex ( $ rgb [ 0 ] , $ rgb [ 1 ] , $ rgb [ 2 ] ) ) ; } if ( false !== ( $ hex = self :: RgbStringToHex ( $ objectString ) ) ) { return new Color ( $ hex ) ; ...
Init a new instance from defined string .
237,418
public static function FromArray ( array $ objectData ) { if ( \ count ( $ objectData ) == 3 ) { if ( false !== ( $ hex = ColorTool :: Color2Hex ( $ objectData ) ) ) { return new Color ( $ hex ) ; } } $ rgb = array ( ) ; if ( isset ( $ objectData [ 'r' ] ) ) { $ rgb [ 0 ] = \ intval ( $ objectData [ 'r' ] ) ; } else if...
Init a new instance from defined array .
237,419
public static function FromGdValueWithAlpha ( $ gdValueWithAlpha ) { $ a = ( $ gdValueWithAlpha >> 24 ) & 0xFF ; $ r = ( $ gdValueWithAlpha >> 16 ) & 0xFF ; $ g = ( $ gdValueWithAlpha >> 8 ) & 0xFF ; $ b = $ gdValueWithAlpha & 0xFF ; if ( $ a == 0 ) { $ o = 0 ; } else if ( $ a == 127 ) { $ o = 100 ; } else { $ o = \ in...
Converts a GD integer value as color with alpha channel to an \ Beluga \ Drawing \ Color instance .
237,420
protected function _getData ( $ key ) { $ separator = $ this -> _getPathSegmentSeparator ( ) ; $ path = $ this -> _normalizePath ( $ key , $ separator ) ; $ store = $ this -> _getDataStore ( ) ; return $ this -> _containerGetPath ( $ store , $ path ) ; }
Retrieves the data associated with the specified key or path .
237,421
public function findClassName ( $ className ) { if ( ! empty ( $ this -> lookupCache -> classes [ $ className ] ) ) { return $ this -> lookupCache -> classes [ $ className ] ; } if ( class_exists ( $ className ) ) return $ className ; $ startsWithSlash = ( $ className [ 0 ] == '\\' ) ; foreach ( $ this -> searchOrder a...
Find class name
237,422
public static function slugify ( $ str , $ replace = array ( ) , $ delimiter = '-' ) { if ( ! empty ( $ replace ) ) { $ str = str_replace ( ( array ) $ replace , ' ' , $ str ) ; } $ clean = iconv ( 'UTF-8' , 'ASCII//TRANSLIT//IGNORE' , $ str ) ; $ clean = preg_replace ( "/[^a-zA-Z0-9\/_|+ -]/" , '' , $ clean ) ; $ clea...
Convert a string to url friendly slug
237,423
public static function iconByFileType ( $ fileType ) { foreach ( self :: $ fileTypeIcons as $ needle => $ icon ) { if ( strpos ( $ fileType , $ needle ) !== false ) { return $ icon ; } } return 'file-o' ; }
Selects the right font - awesome icon for each filetype
237,424
public static function humanFileSize ( $ size , $ unit = '' ) { if ( self :: isHumanFilesizeUnitGb ( $ size , $ unit ) ) { return number_format ( $ size / ( 1 << 30 ) , 2 ) . 'GB' ; } if ( self :: isHumanFilesizeUnitMb ( $ size , $ unit ) ) { return number_format ( $ size / ( 1 << 20 ) , 2 ) . 'MB' ; } if ( self :: isH...
Converts an amount of bytes to a human readable format
237,425
protected function render ( $ tmpl , $ in_data = array ( ) ) { try { $ data = array ( ) ; $ app = array ( ) ; $ app [ 'content' ] = $ in_data ; $ app [ 'settings' ] = $ this -> _viewData [ 'settings' ] ; $ data [ 'app' ] = $ app ; $ data [ 'global' ] = array ( 'styles' => $ this -> _viewData [ 'styles' ] ) ; $ data [ '...
Renders a given template along with input data .
237,426
private function syncFilesystemConfig ( ) { foreach ( $ this -> config ( ) -> get ( 'arcanesoft.media.filesystem.disks' , [ ] ) as $ disk => $ config ) { $ this -> config ( ) -> set ( "filesystems.disks.$disk" , $ config ) ; } }
Sync the filesystem config .
237,427
public function loadFile ( string $ file ) { $ path = $ this -> basePath . '/' . $ file . '.phtml' ; if ( ! is_readable ( $ path ) ) { throw new TemplateException ( sprintf ( 'Template engine could not read the file "%s"' , $ path ) ) ; } ; if ( ( $ this -> contents = file_get_contents ( $ path ) ) === false ) { throw ...
Loads a template file into memory
237,428
public function write ( ) { $ capfile = '' ; foreach ( $ this -> parameters as $ namespace ) { $ line = str_replace ( '<requirement>' , $ namespace , self :: $ template ) ; $ capfile = sprintf ( '%s%s%s' , $ capfile , PHP_EOL , $ line ) ; } $ capfile .= self :: $ importTemplate ; fwrite ( $ this -> file , $ this -> add...
Writes Capfile .
237,429
public static function fromString ( $ cookie ) { $ data = self :: $ defaults ; $ pieces = array_filter ( array_map ( 'trim' , explode ( ';' , $ cookie ) ) ) ; if ( empty ( $ pieces ) || ! strpos ( $ pieces [ 0 ] , '=' ) ) { return new self ( $ data ) ; } foreach ( $ pieces as $ part ) { $ cookieParts = explode ( '=' , ...
Create a new SetCookie object from a string
237,430
public function setExpires ( $ timestamp ) { $ this -> data [ 'Expires' ] = is_numeric ( $ timestamp ) ? ( int ) $ timestamp : strtotime ( $ timestamp ) ; return $ this ; }
Set the unix timestamp for which the cookie will expire
237,431
public function setImage ( $ file ) { if ( false === is_string ( $ file ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ file ) ) , E_USER_ERROR ) ; } if ( false === is_file ( $ file ) ) { return trigger_error ( sprintf ( 'File "%s" pas...
Set a new image
237,432
public function flip ( $ mode = self :: FLIP_HORIZONTAL ) { if ( false === in_array ( $ mode , [ self :: FLIP_HORIZONTAL , self :: FLIP_VERTICAL , self :: FLIP_BOTH ] ) ) { return trigger_error ( sprintf ( 'Unknown mode passed %s(), "%s" given' , __METHOD__ , gettype ( $ mode ) ) , E_USER_ERROR ) ; } $ this -> add ( __...
Flip the current image horizontal vertical or both
237,433
private function call ( ) { if ( null === $ this -> driver ) { return trigger_error ( 'Driver is not set. Set the driver with the setDriver() method' , E_USER_ERROR ) ; } if ( null === $ this -> image ) { return trigger_error ( 'Image has not been set. Set the image with the setImage() method' , E_USER_ERROR ) ; } if (...
Check if image and driver is set and returns the driver
237,434
private function getQuality ( $ quality , $ extension ) { if ( false === ( '-' . intval ( $ quality ) == '-' . $ quality ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ quality ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ ext...
Validates and returns quality based on image extension
237,435
public function output ( ) { $ methodName = 'http_' . $ this -> request -> httpMethod ( ) ; if ( method_exists ( $ this , $ methodName ) ) { return $ this -> $ methodName ( ) ; } else { return $ this -> response -> send ( 405 , 'The requested resource does not support the HTTP method' . ' "' . $ this -> request -> http...
Generate the output of the requested Resource instance .
237,436
public static function fromOption ( $ option ) { $ message = sprintf ( 'Could not add invalid Option of type "%1$s" to option repository.' , is_object ( $ option ) ? get_class ( $ option ) : gettype ( $ option ) ) ; return new static ( $ message ) ; }
Get a new exception based on the type of an invalid option .
237,437
public function middleware ( $ name ) { if ( is_string ( $ name ) ) { app ( ) -> addRouteMiddleware ( $ name ) ; } else if ( is_array ( $ name ) ) { foreach ( $ name as $ middlewareName ) { app ( ) -> addRouteMiddleware ( $ middlewareName ) ; } } }
Middlewares to add .
237,438
public static function createNormalizer ( $ key = 'default' ) { return isset ( self :: $ instancePool [ $ key ] ) ? self :: $ instancePool [ $ key ] : self :: $ instancePool [ $ key ] = new static ( PropertyAccess :: createPropertyAccessor ( ) ) ; }
Create and return an instantiated normalizer returns always the same throught this call .
237,439
private function createReadingDelegate ( ) { return $ this -> readDelegate ? : $ this -> readDelegate = function ( $ property , PropertyAccessor $ propertyAccessor ) { switch ( true ) { case $ propertyAccessor -> isReadable ( $ this , $ property ) : return $ propertyAccessor -> getValue ( $ this , $ property ) ; case p...
Create and return a Closure available to read an object property through a property path or a private property .
237,440
public function normalize ( $ object , $ scope = 'default' ) { switch ( true ) { case ! is_object ( $ object ) : return $ object ; case $ object instanceof StdClass : return ( array ) $ object ; case $ object instanceof \ DateTime : return $ object -> format ( \ DateTime :: ISO8601 ) ; case ! $ object instanceof Normal...
Normalize given object using given scope .
237,441
public function scopify ( NormalizableInterface $ object , $ scope ) { $ scopes = $ object -> getScopes ( ) ; if ( ! isset ( $ scopes [ $ scope ] ) ) { throw new ScopeNotFoundException ( sprintf ( 'Invalid scope for %s object, only ["%s"] supported, "%s" given.' , get_class ( $ object ) , implode ( '", "' , array_keys ...
Normalize given normalizable following given scope .
237,442
private function createWrittingDelegate ( ) { return $ this -> writeDelegate ? : $ this -> writeDelegate = function ( PropertyPathInterface $ property , $ value , PropertyAccessor $ propertyAccessor ) { switch ( true ) { case $ propertyAccessor -> isWritable ( $ this , $ property ) : return $ propertyAccessor -> setVal...
Create and return a Closure available to write an object property through a property path or a private property .
237,443
public function getModuleHydrator ( ) { if ( $ this -> moduleHydrator == null ) { $ moduleHydratorClass = $ this -> getOptions ( ) -> getPuppetModuleHydratorClass ( ) ; $ this -> moduleHydrator = new $ moduleHydratorClass ; } return $ this -> moduleHydrator ; }
Get ModuleHydrator .
237,444
public function getClassHydrator ( ) { if ( $ this -> classHydrator == null ) { $ classHydratorClass = $ this -> getOptions ( ) -> getPuppetClassHydratorClass ( ) ; $ this -> classHydrator = new $ classHydratorClass ; } return $ this -> classHydrator ; }
Get ClassHydrator .
237,445
protected function validateType ( $ relType ) { $ valid = [ 'one' , 'many' ] ; if ( ! in_array ( $ relType , $ valid ) ) { throw MetadataException :: invalidRelType ( $ relType , $ valid ) ; } return true ; }
Validates the relationship type .
237,446
public function getConfigurationParameterName ( $ value = null ) { $ output = '' ; if ( ! empty ( $ this -> _parent ) && $ this -> _parent instanceof Parameter ) { $ output .= $ this -> _parent -> getConfigurationParameterName ( ) ; } if ( ! empty ( $ this -> _name ) ) { if ( ! empty ( $ output ) ) $ output .= '->' ; $...
Get name of configuration value
237,447
public function flattenResult ( ) { $ output = [ ] ; $ vars = ( array ) $ this ; foreach ( $ vars as $ field => $ value ) { if ( ord ( $ field [ 0 ] ) == 0 ) continue ; if ( $ value instanceof Parameter ) { $ output [ $ field ] = $ value -> flattenResult ( ) ; } else { $ output [ $ field ] = $ value ; } } return $ outp...
Get flattened scalars from a configuration parameter recursively
237,448
public function toArray ( ) { if ( ! $ this -> getMethod ( ) ) { throw new \ InvalidArgumentException ( 'Method must be provided for request' ) ; } $ data = array ( 'jsonrpc' => self :: VERSION , 'method' => $ this -> getMethod ( ) , ) ; if ( $ this -> getParams ( ) ) { $ data [ 'params' ] = $ this -> getParams ( ) ; }...
Serialize into array
237,449
public function isSerialized ( $ string ) { if ( ! is_string ( $ string ) ) { return false ; } $ string = trim ( $ string ) ; if ( $ string === 'N;' ) { return true ; } $ string_encoding = mb_detect_encoding ( $ string ) ; $ length = mb_strlen ( $ string , $ string_encoding ) ; $ last_char = mb_substr ( $ string , - 1 ...
Is serialized string .
237,450
public function addLink ( $ url , $ title , $ icon = NULL , $ priority = 0 ) { $ link = [ "moduleUrl" => str_replace ( "#" , NULL , substr ( $ url , 0 , strpos ( $ url , ":" ) ) ) , "url" => $ url , "title" => $ title , "icon" => $ icon , "priority" => $ priority ] ; $ this -> links [ ] = $ link ; }
Adds link to mainPanel
237,451
public function render ( Exception $ e , $ debug ) { $ e = FlattenException :: create ( $ e ) ; $ handler = new SymfonyExceptionHandler ( $ debug ) ; $ status = $ e -> getStatusCode ( ) ; $ response = SymfonyResponse :: create ( $ handler -> getHtml ( $ e ) , $ status , $ e -> getHeaders ( ) ) ; $ rex = explode ( "\n" ...
Renders the error .
237,452
public function multiGet ( array $ keys , $ localOnly = false ) { $ keys = array_unique ( $ keys ) ; $ results = array ( ) ; $ others = array ( ) ; foreach ( $ keys as $ key ) { $ cacheKey = $ this -> cacheKey ( $ key ) ; if ( $ this -> keepLocalCache && array_key_exists ( $ cacheKey , $ this -> localCache ) ) $ result...
Returns an array of nodes from cache specified by key
237,453
public function put ( $ key , $ value , $ duration , $ localOnly = false ) { $ cacheKey = $ this -> cacheKey ( $ key ) ; if ( $ this -> keepLocalCache ) $ this -> localCache [ $ cacheKey ] = $ value ; if ( ! $ localOnly ) $ this -> cacheStore -> put ( $ cacheKey , $ value , $ duration ) ; }
Stores the value specified with the cacheKey given .
237,454
protected function translateRoutes ( array $ routes = [ ] ) { foreach ( $ routes as $ routeKey => $ routeParams ) { if ( isset ( $ routeParams [ 'description' ] ) ) { $ routes [ $ routeKey ] [ 'description' ] = $ this -> translator -> translate ( $ routeParams [ 'description' ] ) ; } if ( isset ( $ routeParams [ 'short...
Translate the route texts
237,455
public function writeApplicationBanner ( AdapterInterface $ console ) { $ console -> writeLine ( ) ; $ console -> writeLine ( str_pad ( '' , $ console -> getWidth ( ) - 1 , '=' , STR_PAD_RIGHT ) , Color :: GREEN ) ; $ console -> write ( '=' , Color :: GREEN ) ; $ console -> write ( str_pad ( '' . $ this -> name . ' - '...
Write application banner
237,456
public function writeApplicationFooter ( AdapterInterface $ console ) { $ console -> writeLine ( str_pad ( '' , $ console -> getWidth ( ) - 1 , '=' , STR_PAD_RIGHT ) , Color :: GREEN ) ; $ console -> writeLine ( ) ; }
Write application footer
237,457
public function clean ( $ string , $ allowedTags = null ) { if ( is_array ( $ string ) ) { $ new_array = array ( ) ; foreach ( $ string as $ key => $ val ) { $ new_array [ $ key ] = $ this -> clean ( $ val , $ allowedTags ) ; } return $ new_array ; } $ string = $ this -> cleanHTMLPurify ( $ string , $ allowedTags ) ; r...
Cleans XSS by removing all tags
237,458
protected function cleanHTMLPurify ( $ string , $ allowedTags = null ) { if ( strlen ( $ string ) == 0 ) return '' ; if ( $ allowedTags === null ) $ allowedTags = $ this -> defaultAllowedTags ; if ( $ allowedTags == '*' ) return $ string ; if ( is_null ( $ this -> purifier ) ) { require_once PATH_SYSTEM . '/vendors/HTM...
Produces a nicely - formatted HTML string with all non - matching tags stripped .
237,459
public function autoParagraph ( $ string , $ allowedTags = null , $ linkUrls = true ) { if ( is_null ( $ allowedTags ) ) $ allowedTags = $ this -> defaultAllowedTags ; if ( is_null ( $ this -> purifier ) ) { require_once PATH_SYSTEM . '/vendors/HTMLPurifier.php' ; $ this -> purifier = HTMLPurifier :: instance ( ) ; Fil...
Marks up a string with paragraphs and automatically links any urls .
237,460
public function unAutoParagraph ( $ string ) { $ string = str_replace ( array ( "<p>" , "</p>" , "<br/>" , "<br />" ) , array ( "" , "\n\n" , "\n" , "\n" ) , $ string ) ; $ string = preg_replace ( "/\<a href\=\"(" . URLUtils :: URL_MATCH . ")\"\>\\1\<\/a\>/i" , '$1' , $ string ) ; $ string = preg_replace_callback ( "/\...
Removes the markup added by autoParagraph .
237,461
public static function makeSetterGetterDoc ( Entity $ entity ) { $ properties = $ entity -> toArray ( false ) ; $ entityName = $ entity -> calledClassName ( ) ; echo "<pre>\n" ; foreach ( $ properties as $ name => $ value ) { $ methodName = ucfirst ( $ name ) ; $ type = $ entity -> typeof ( $ name ) ; echo " * @method ...
Generate the setter and getter method PHPDoc declaration to paste into your entity class .
237,462
public static function makePublicProperties ( array $ properties ) { echo '<pre>' . "\n" ; foreach ( $ properties as $ key => $ value ) { $ type = gettype ( $ value ) ; if ( $ type === 'object' ) { $ type = get_class ( $ value ) ; } echo <<<EODOC /** * @var $type */ public \$$key;EODOC ; } echo '</pre>' ...
Generate the public properties PHPDoc declarations to paste into your entity class .
237,463
final public static function getInstance ( ) { $ className = get_called_class ( ) ; if ( ! isset ( self :: $ _instances [ $ className ] ) ) { self :: $ _instances [ $ className ] = new static ( ) ; } self :: $ _instances [ $ className ] -> initialize ( ) ; return self :: $ _instances [ $ className ] ; }
Return event instance
237,464
final public static function clearInstance ( $ className ) { if ( isset ( self :: $ _instances [ $ className ] ) ) { $ name = self :: _configName ( $ className ) ; Config :: clearInstance ( $ name ) ; self :: $ _instances [ $ className ] -> _loadObservers ( ) ; } }
Unloads event instance .
237,465
final public function notify ( ) { $ observers = array_values ( $ this -> _observers ) ; foreach ( $ observers as $ observer ) { switch ( false ) { case is_array ( $ observer ) : case isset ( $ observer [ 0 ] ) : case isset ( $ observer [ 1 ] ) : case is_string ( $ observer [ 0 ] ) : break ; default : Loader :: loadCla...
Notify observers .
237,466
final public function attach ( $ observer ) { if ( ! in_array ( $ observer , $ this -> _observers ) ) { array_push ( $ this -> _observers , $ observer ) ; } return $ this ; }
Attach new observer .
237,467
final public function detach ( $ observer ) { $ key = array_search ( $ observer , $ this -> _observers ) ; if ( $ key !== false ) { unset ( $ this -> _observers [ $ key ] ) ; } return $ this ; }
Detach observer .
237,468
private function _loadObservers ( ) { $ class = $ this -> name ( ) ; $ name = self :: _configName ( $ class ) ; $ config = Config :: getInstance ( $ name ) ; $ this -> _observers = $ config -> valueOf ( ) ; }
Load observers .
237,469
public function getSystemLoadInfo ( ) { $ cpuMemDto = new CpuMemDto ( ) ; $ cpuMemDto = $ this -> getMemFree ( $ cpuMemDto ) ; $ cpuMemDto = $ this -> getCpuIdle ( $ cpuMemDto ) ; return $ cpuMemDto ; }
Get current cpu idle and memory free
237,470
public function getPidByPpid ( $ ppid ) { $ commandsDto = new CommandsExecutionDto ( ) ; $ commandsDto -> setCommandName ( CommandsConstants :: GET_PID_BY_PPID ) ; $ commandsDto -> setPid ( $ ppid ) ; return $ this -> getCommandExecutionResult ( $ commandsDto ) ; }
Return PID of the child s process by parent PID
237,471
public function write ( string $ filename , string $ contents ) : int { return ( int ) file_put_contents ( $ filename , $ contents ) ; }
Write the given contents to the given file .
237,472
public function ls ( string $ path ) : array { $ files = [ ] ; $ d = dir ( $ path ) ; while ( false !== ( $ entry = $ d -> read ( ) ) ) { if ( in_array ( $ entry , [ '.' , '..' ] , true ) ) { continue ; } $ entryPath = $ path . $ entry ; if ( is_dir ( $ entryPath ) ) { foreach ( $ this -> ls ( $ entryPath . DIRECTORY_S...
List all files in a directory and it s subdirectories .
237,473
public function qualityFactorComparator ( $ mediaType1 , $ mediaType2 ) { $ diff = $ mediaType2 [ 'q' ] - $ mediaType1 [ 'q' ] ; if ( $ diff > 0 ) { $ diff = 1 ; } elseif ( $ diff < 0 ) { $ diff = - 1 ; } return $ diff ; }
Comparator function for sorting a list of arrays by their q factor .
237,474
public function addAsset ( $ name , $ path ) { if ( ! is_file ( $ path ) ) { throw new \ RuntimeException ( 'The asset file "' . $ path . '" does not exist.' ) ; } $ this -> assets [ $ name ] = $ path ; }
Adds an asset .
237,475
public function copyTo ( $ path ) { foreach ( $ this -> assets as $ assetName => $ assetPath ) { $ outputPath = $ path . '/' . $ assetName ; $ this -> copyFromTo ( $ assetPath , $ outputPath ) ; } }
Copies all assets to the given path .
237,476
private function copyFromTo ( $ from , $ to ) { $ directory = dirname ( $ to ) ; if ( ! is_dir ( $ directory ) ) { mkdir ( $ directory , 0777 , true ) ; } copy ( $ from , $ to ) ; }
Copies a single asset from a path to a path .
237,477
private function setInput ( ) { $ this -> inputFile = $ _FILES [ $ this -> field ] [ 'name' ] ; $ this -> inputHash = hash_file ( 'md5' , $ _FILES [ $ this -> field ] [ 'tmp_name' ] ) ; }
Stores input informations
237,478
public function handleUpload ( & $ uploader ) { $ this -> uploader = & $ uploader ; $ this -> setInput ( ) ; $ this -> uploader -> setField ( $ this -> field ) ; $ this -> uploader -> setDestination ( sys_get_temp_dir ( ) ) ; foreach ( $ this -> validations as $ validation ) { $ options = isset ( $ validation [ 'option...
Handles an upload
237,479
public function text ( $ text ) { if ( false === is_string ( $ text ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ text ) ) , E_USER_ERROR ) ; } $ this -> text = $ text ; return $ this ; }
Set the text of the button
237,480
public function getLanguage ( string $ default = null ) : string { $ language = $ default ? : 'en' ; if ( TYPO3_MODE === 'FE' ) { if ( isset ( $ GLOBALS [ 'TSFE' ] -> lang ) ) { $ language = $ GLOBALS [ 'TSFE' ] -> lang ; } } elseif ( is_object ( $ GLOBALS [ 'LANG' ] ) ) { if ( isset ( $ GLOBALS [ 'LANG' ] -> lang ) ) ...
Gets the current language .
237,481
public function getLanguageUid ( int $ default = null ) : int { $ languageUid = $ default ? : 0 ; if ( TYPO3_MODE === 'FE' ) { if ( isset ( $ GLOBALS [ 'TSFE' ] -> sys_language_uid ) ) { $ languageUid = $ GLOBALS [ 'TSFE' ] -> sys_language_uid ; } } elseif ( is_object ( $ GLOBALS [ 'LANG' ] ) ) { if ( isset ( $ GLOBALS...
Gets the current language UID .
237,482
public function loadSchemaFile ( ) : Schema { if ( ! file_exists ( $ this -> schemaFile ) ) { return new Schema ( ) ; } $ content = file_get_contents ( $ this -> schemaFile ) ; $ desc = Yaml :: parse ( $ content ) ; if ( empty ( $ desc ) ) { return new Schema ( ) ; } $ builder = new SchemaBuilder ( ) ; return $ builder...
Load schema from config file .
237,483
public function applySchema ( bool $ strict = false ) : array { $ sqlStatements = $ this -> getMigrationSql ( ) ; foreach ( $ sqlStatements as $ sqlStatement ) { $ this -> connection -> exec ( $ sqlStatement ) ; } if ( $ strict ) { $ reorderSql = $ this -> reorderSql ( ) ; $ sqlStatements = array_merge ( $ sqlStatement...
Alter schema in database according to config file .
237,484
public function getSchemaDiff ( bool $ reverseDiff = false ) : SchemaDiff { $ currentSchema = $ this -> getCurrentSchema ( ) ; $ newSchema = $ this -> loadSchemaFile ( ) ; $ comparator = new Comparator ( ) ; if ( $ reverseDiff ) { return $ comparator -> compare ( $ newSchema , $ currentSchema ) ; } else { return $ comp...
Get diff between current schema and config file
237,485
public function dumpSchema ( ) { $ schema = $ this -> getCurrentSchema ( ) ; $ normalizer = new SchemaNormalizer ( ) ; $ desc = $ normalizer -> normalize ( $ schema ) ; $ yamlSchema = Yaml :: dump ( [ 'schema' => $ desc ] , 10 , 2 ) ; $ directory = dirname ( $ this -> schemaFile ) ; if ( ! file_exists ( $ directory ) )...
Write current database schema in config file
237,486
public function addDocumentType ( $ postValues ) { $ documentTypeObject = DocumentTypeFactory :: createDocumentTypeFromPostValues ( $ postValues ) ; $ documentTypes = $ this -> repository -> documentTypes ; $ documentTypes [ ] = $ documentTypeObject ; $ this -> repository -> documentTypes = $ documentTypes ; $ this -> ...
Add a document type from post values
237,487
public function deleteDocumentTypeBySlug ( $ slug ) { $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ key => $ documentTypeObject ) { if ( $ documentTypeObject -> slug == $ slug ) { unset ( $ documentTypes [ $ key ] ) ; } } $ documentTypes = array_values ( $ documentTypes ) ; $ ...
Delete document type
237,488
public function getDocumentTypeBySlug ( $ slug , $ getBricks = false ) { $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ documentType ) { if ( $ documentType -> slug == $ slug ) { if ( $ getBricks === true ) { foreach ( $ documentType -> bricks as $ key => $ brick ) { $ brickStr...
Get document type by its slug
237,489
public function saveDocumentType ( $ slug , $ postValues ) { $ documentTypeObject = DocumentTypeFactory :: createDocumentTypeFromPostValues ( $ postValues ) ; $ documentTypes = $ this -> repository -> documentTypes ; foreach ( $ documentTypes as $ key => $ documentType ) { if ( $ documentType -> slug == $ slug ) { $ do...
Save changes to a document type
237,490
public function addItem ( $ path , $ object = array ( ) , $ class = null ) { $ path = explode ( '/' , $ path ) ; $ object [ 'class' ] = $ class ; $ args = array ( ) ; foreach ( $ path as $ key ) { $ args [ ] = $ key ; $ args [ ] = 'children' ; } $ tree = eden ( 'registry' , $ this -> tree ) ; $ last = count ( $ args ) ...
Adds item to the tree
237,491
public function map ( $ modelList ) { $ self = $ this ; return $ this -> wrapInTransaction ( function ( ) use ( $ self , $ modelList ) { forward_static_call ( [ get_class ( $ self -> model ) , 'unguard' ] ) ; $ result = $ self -> mapTree ( $ modelList ) ; forward_static_call ( [ get_class ( $ self -> model ) , 'reguard...
Maps a tree structure into the database . Unguards & wraps in transaction .
237,492
public function mapTree ( $ modelList ) { $ tree = $ modelList instanceof Arrayable ? $ modelList -> toArray ( ) : $ modelList ; $ affectedKeys = [ ] ; $ result = $ this -> mapTreeRecursive ( $ tree , $ this -> model -> getKey ( ) , $ affectedKeys ) ; if ( $ result && count ( $ affectedKeys ) > 0 ) $ this -> deleteUnaf...
Maps a tree structure into the database without unguarding nor wrapping inside a transaction .
237,493
protected function SaveElement ( ) { $ this -> login -> SetNextUrl ( $ this -> selectorNext -> Save ( $ this -> login -> GetNextUrl ( ) ) ) ; $ this -> login -> SetPasswordUrl ( $ this -> selectorPassword -> Save ( $ this -> login -> GetPasswordUrl ( ) ) ) ; return $ this -> login ; }
Saves the login element and returns it
237,494
public function setMinLength ( string $ elementName , int $ minLength , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = sprintf ( __ ( 'ivopetkov.form.The length of this field must be atleast %s characters.' ) , $ minLength ) ; ...
Sets a minimum length requirement for an element
237,495
public function setMaxLength ( string $ elementName , int $ maxLength , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = sprintf ( __ ( 'ivopetkov.form.The length of this field must be atmost %s characters.' ) , $ maxLength ) ; }...
Sets a maximum length requirement for an element
237,496
public function setEmail ( string $ elementName , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = __ ( 'ivopetkov.form.This is not a valid email address.' ) ; } $ this -> data [ ] = [ 'email' , $ errorMessage , $ elementName ] ;...
Requires the element value to be a valid email address
237,497
public function setRegularExpression ( string $ elementName , string $ regularExpression , string $ errorMessage = null ) : \ IvoPetkov \ BearFrameworkAddons \ Form \ Constraints { if ( $ errorMessage === null ) { $ errorMessage = __ ( 'ivopetkov.form.This is not a valid value.' ) ; } $ this -> data [ ] = [ 'regExp' , ...
Performs a regular expression validation
237,498
public function validate ( array $ values , array & $ errorsList ) : bool { $ hasErrors = false ; foreach ( $ this -> data as $ item ) { $ type = $ item [ 0 ] ; $ errorMessage = $ item [ 1 ] ; $ elementName = $ item [ 2 ] ; $ value = isset ( $ values [ $ elementName ] ) ? ( string ) $ values [ $ elementName ] : '' ; $ ...
Validates the values passed
237,499
public function isDSAffiliate ( $ targetCountyCode ) { $ foundAffiliate = false ; $ affiliates = [ 'GB' , 'UK' , 'CA' , 'ID' , 'BW' , 'KE' , 'GH' , 'NG' , 'CD' , 'BR' , 'MX' , ] ; if ( in_array ( $ targetCountyCode , $ affiliates ) ) { $ affiliateURL = [ 'GB' => 'https://uk.dosomething.org' , 'UK' => 'https://uk.dosome...
Test if country code has a DoSomething affiliate .