idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
58,300
public function notFound ( $ package = 'DefaultPackage' , $ class = 'Error' , $ method = 'notFound' ) { $ this -> response -> setStatus ( 404 ) ; $ this -> view -> setPackage ( $ package ) ; $ this -> view -> setClass ( $ class ) ; $ this -> view -> setScriptName ( $ method ) ; return ; }
When you need to send a not found in your runnable you can call this directly . Optionally you can specify the package name class name and method name to render accordingly .
58,301
function parent ( $ new = null , $ return_entity = false ) { if ( isset ( $ new ) ) { if ( $ new instanceof Entity ) { $ this -> _parent = $ new ; $ new = $ new -> uri ( ) ; } else { $ this -> _parent = null ; } if ( $ new != $ this -> _attributes [ 'parent' ] ) { $ this -> change ( 'parent' , $ new ) ; $ this -> chang...
Parent of this object
58,302
function proto ( $ new = null , $ return_entity = false ) { if ( isset ( $ new ) ) { if ( $ new instanceof Entity ) { $ this -> _proto = $ new ; $ new = $ new -> uri ( ) ; } else { $ this -> _proto = null ; } if ( $ new != $ this -> _attributes [ 'proto' ] ) { $ this -> change ( 'proto' , $ new ) ; } } if ( $ return_en...
Prototype of this object
58,303
function author ( $ new = null , $ return_entity = false ) { if ( isset ( $ new ) ) { if ( $ new instanceof Entity ) { $ this -> _author = $ new ; $ new = $ new -> uri ( ) ; } else { $ this -> _author = null ; } if ( $ new != $ this -> _attributes [ 'author' ] ) { $ this -> change ( 'author' , $ new ) ; } } if ( $ retu...
Author of this object
58,304
function is_link ( $ new = null , $ return_entity = false ) { if ( isset ( $ new ) && ( $ this -> _attributes [ 'is_link' ] != $ new ) ) { $ this -> change ( 'is_link' , ( bool ) $ new ) ; } if ( $ return_entity ) { if ( ! isset ( $ this -> _link ) ) { if ( empty ( $ this -> _attributes [ 'is_link' ] ) ) { $ this -> _l...
Object referenced by this object
58,305
public function add ( $ name , $ class , $ description = null ) { if ( array_key_exists ( $ name , $ this -> data ) ) { $ this -> logger -> warning ( "Skipping duplicate task $name ($class)" ) ; return false ; } if ( empty ( $ name ) || empty ( $ class ) || ! class_exists ( $ class ) ) { $ this -> logger -> warning ( "...
Add a new task to table
58,306
public function delete ( $ name ) { if ( array_key_exists ( $ name , $ this -> data ) ) { unset ( $ this -> data [ $ name ] ) ; return true ; } return false ; }
Delete a task from table
58,307
public function addBulk ( array $ tasks ) { $ result = [ ] ; foreach ( $ tasks as $ name => $ task ) { if ( empty ( $ task [ 'class' ] ) ) { $ this -> logger -> warning ( "Missing class for task $name" ) ; $ result [ ] = false ; } else { $ result [ ] = $ this -> add ( $ name , $ task [ 'class' ] , empty ( $ task [ 'des...
Load a bulk task list into the table
58,308
public function random ( ) { $ arr = $ this -> getArrayCopy ( ) ; $ rand = array_rand ( $ arr ) ; return isset ( $ arr [ $ rand ] ) ? $ arr [ $ rand ] : FALSE ; }
Return random collection item
58,309
public function toArray ( $ attributes = FALSE , $ relations = array ( ) , $ recursive = FALSE ) { $ arr = array ( ) ; $ it = $ this -> getIterator ( ) ; while ( $ it -> valid ( ) ) { $ arr [ $ it -> key ( ) ] = $ it -> current ( ) -> toArray ( $ attributes , $ relations , $ recursive ) ; $ it -> next ( ) ; } return $ ...
Return a multidimensional array with objects and their attributes
58,310
private function prepareOptions ( $ options , $ forceOptions = [ ] ) { $ optionString = '' ; foreach ( $ forceOptions as $ option => $ value ) { if ( is_numeric ( $ option ) ) { $ options [ $ value ] = null ; } else { $ options [ $ option ] = $ value ; } } foreach ( $ options as $ option => $ value ) { if ( is_null ( $...
Prepares the options string .
58,311
private function prepareInstallationDirectory ( $ directory ) { if ( ! $ this -> files -> exists ( $ directory ) ) { $ this -> files -> makeDirectory ( $ directory . DIRECTORY_SEPARATOR , 0755 , true ) ; return ; } $ this -> files -> deleteDirectory ( $ directory , true ) ; $ this -> checkInstallationDirectory ( $ dire...
Prepares the installation directory .
58,312
private function checkInstallationDirectory ( $ directory ) { if ( $ this -> installationAttempts >= $ this -> breakAtInstallationAttempt ) { $ this -> log -> error ( 'Installation directory checks failed at max attempts' , [ 'attempts' => $ this -> installationAttempts ] ) ; throw new PackageInstallationException ( nu...
Checks the installation directory to make sure it is ready .
58,313
public function installPackage ( $ packageName , $ options = [ ] ) { $ process = $ this -> getProcess ( ) ; $ processCommand = trim ( $ this -> findComposer ( ) . ' create-project ' . $ packageName . ' "' . $ this -> workingPath . '" ' . $ this -> prepareOptions ( $ options , [ '--no-ansi' , '--no-install' ] ) ) ; $ pr...
Installs a Composer package placing it in NewUp s template storage .
58,314
public function updatePackageDependencies ( $ options = [ ] ) { $ process = $ this -> getProcess ( ) ; $ processCommand = trim ( $ this -> findComposer ( ) . ' update ' . $ this -> prepareOptions ( $ options , [ '--no-progress' , '--no-ansi' ] ) ) ; $ process -> setCommandLine ( $ processCommand ) ; chdir ( $ this -> w...
Updates the packages dependencies by running composer update .
58,315
public function getVersion ( ) { $ process = $ this -> getProcess ( ) ; $ processCommand = trim ( $ this -> findComposer ( ) . ' --version' ) ; $ process -> setCommandLine ( $ processCommand ) ; $ this -> log -> info ( 'Running Composer command' , [ 'command' => $ processCommand ] ) ; $ process -> run ( ) ; if ( $ proc...
Gets the Composer version .
58,316
public function selfUpdate ( ) { $ beforeVersion = $ this -> getVersion ( ) ; $ process = $ this -> getProcess ( ) ; $ processCommand = trim ( $ this -> findComposer ( ) . ' self-update' ) ; $ process -> setCommandLine ( $ processCommand ) ; $ this -> log -> info ( 'Running Composer command' , [ 'command' => $ processC...
Attempts to update Composer .
58,317
public function get ( $ index = 0 ) { if ( is_integer ( $ index ) ) { if ( $ index + 1 > $ this -> count ( ) ) { return null ; } else { return Arrays :: first ( array_slice ( $ this -> _items , $ index , 1 ) ) ; } } else { if ( $ this -> has ( $ index ) ) { return $ this -> _items [ $ index ] ; } } return null ; }
Get item by numeric index
58,318
public function keyBy ( $ keyBy ) { $ results = array ( ) ; foreach ( $ this -> _items as $ item ) { $ key = dataGet ( $ item , $ keyBy ) ; $ results [ $ key ] = $ item ; } return new self ( $ results ) ; }
Key an associative array by a field .
58,319
public function extend ( $ name , Closure $ callback ) { if ( count ( $ this -> _items ) ) { $ collection = array ( ) ; foreach ( $ this -> _items as $ item ) { if ( $ item instanceof Container ) { $ item -> fn ( $ name , $ callback ) ; } array_push ( $ collection , $ item ) ; } return new self ( $ collection ) ; } ret...
extends each Container item of this collection with a Closure .
58,320
public function toJson ( $ render = false ) { $ json = json_encode ( $ this -> toArray ( true , true ) ) ; if ( false === $ render ) { return $ json ; } else { header ( 'content-type: application/json; charset=utf-8' ) ; die ( $ json ) ; } }
Export all items to a json string
58,321
public static function cacheHeaders ( $ expires = '+1 hour' ) { if ( ! headers_sent ( ) ) { header ( 'Cache-Control: private, max-age=3600' ) ; header ( 'Pragma: public' ) ; header ( 'Last-Modified: ' . date ( DATE_RFC822 , strtotime ( '-1 second' ) ) ) ; header ( 'Expires: ' . date ( DATE_RFC822 , strtotime ( $ expire...
Write cache headers
58,322
public function enumerate ( $ methods = [ ] , $ params = [ ] ) { if ( is_array ( $ methods ) ) { $ return = [ ] ; foreach ( $ methods as $ key => $ value ) { if ( is_array ( $ value ) ) { $ return [ $ key ] = $ this -> $ key ( ... $ value ) ; } else { $ return [ $ value ] = $ this -> $ value ( ) ; } } return $ return ;...
Enumerate multiple methods saves on HTTP calls
58,323
public function system_updates ( ) { if ( file_exists ( $ this -> tmp_path . '/check-updates' ) ) { unlink ( $ this -> tmp_path . '/check-updates' ) ; } if ( $ this -> host_os === 'WINDOWS' ) { $ updSess = new \ COM ( "Microsoft.Update.Session" ) ; $ updSrc = $ updSess -> CreateUpdateSearcher ( ) ; $ result = $ updSrc ...
Check system for updates
58,324
public function total_disk_space ( $ path = '/' ) { $ ds = 0 ; if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ disks = $ wmi -> ExecQuery ( "Select * from Win32_LogicalDisk" ) ; foreach ( $ disks as $ d ) { if ( $ d -> Name == $ path ) { $ ds = $ d -> Size ; } } } else {...
Get total diskspace
58,325
public function memory_stats ( ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ os = $ wmi -> ExecQuery ( "SELECT * FROM Win32_OperatingSystem" ) ; foreach ( $ os as $ m ) { $ mem_total = $ m -> TotalVisibleMemorySize ; $ mem_free = $ m -> FreePhysicalMemory ; } $ pre...
Get memory usage
58,326
public function memory_total ( ) { $ mem_total = 0 ; if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ os = $ wmi -> ExecQuery ( "SELECT * FROM Win32_OperatingSystem" ) ; foreach ( $ os as $ m ) { $ mem_total = $ m -> TotalVisibleMemorySize ; } } else { $ fh = fopen ( '/pr...
Get memory total kB
58,327
public function cpu_usage ( ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ cpus = $ wmi -> ExecQuery ( "SELECT LoadPercentage FROM Win32_Processor" ) ; foreach ( $ cpus as $ cpu ) { $ return = $ cpu -> LoadPercentage ; } } else { $ return = shell_exec ( 'top -d 0.5 ...
Get CPU usage in percentage
58,328
public function netstat ( $ parse = true ) { $ result = trim ( shell_exec ( 'netstat -pant' ) ) ; if ( $ parse ) { $ lines = explode ( PHP_EOL , $ result ) ; unset ( $ lines [ 0 ] ) ; unset ( $ lines [ 1 ] ) ; $ columns = [ 'Proto' , 'Recv-Q' , 'Send-Q' , 'Local Address' , 'Foreign Address' , 'State' , 'PID/Program' , ...
Get netstat output
58,329
public function arch ( ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ cpu = $ wmi -> ExecQuery ( "Select * from Win32_Processor" ) ; foreach ( $ cpu as $ c ) { $ arch = '32-bit' ; $ cpu_arch = $ c -> AddressWidth ; if ( $ cpu_arch != 32 ) { $ os = $ wmi -> ExecQuery...
Get system architecture
58,330
public function hostname ( ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ computer = $ wmi -> ExecQuery ( "SELECT * FROM Win32_ComputerSystem" ) ; foreach ( $ computer as $ c ) { $ hostname = $ c -> Name ; } } else { $ hostname = shell_exec ( 'hostname' ) ; } return...
Get system hostname
58,331
public function logins ( $ parse = true ) { $ result = trim ( shell_exec ( 'last' ) ) ; if ( $ parse ) { $ lines = explode ( PHP_EOL , $ result ) ; $ end = 0 ; foreach ( $ lines as $ no => $ line ) { if ( trim ( $ line ) == '' ) { $ end = $ no ; break ; } } foreach ( range ( $ end , count ( $ lines ) ) as $ key ) { uns...
Get system last logins
58,332
public function top ( $ parse = true ) { if ( ! file_exists ( $ this -> tmp_path . '/system' ) ) { mkdir ( $ this -> tmp_path . '/system' , 0755 , true ) ; } shell_exec ( 'top -n 1 -b > ' . $ this -> tmp_path . '/system/top-output' ) ; usleep ( 25000 ) ; $ result = trim ( file_get_contents ( $ this -> tmp_path . '/syst...
Get system top output
58,333
public function cpu_info ( $ parse = true ) { $ lines = trim ( shell_exec ( 'lscpu' ) ) ; if ( ! $ parse ) { return $ lines ; } if ( empty ( $ lines ) ) { return [ ] ; } $ lines = explode ( PHP_EOL , $ lines ) ; $ return = [ ] ; foreach ( $ lines as $ line ) { $ parts = explode ( ':' , $ line ) ; $ return [ trim ( $ pa...
Get system CPU info
58,334
public function disks ( $ parse = true ) { if ( $ this -> host_os !== 'WINDOWS' ) { $ result = shell_exec ( 'df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs' ) ; } else { $ result = '' ; } if ( $ parse ) { if ( empty ( $ result ) ) { return [ ] ; } $ lines = explode ( PHP_EOL , trim ( $ r...
Get disk file system table
58,335
public function uptime ( $ option = '-p' ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ os = $ wmi -> ExecQuery ( "SELECT * FROM Win32_OperatingSystem" ) ; foreach ( $ os as $ o ) { $ date = explode ( '.' , $ o -> LastBootUpTime ) ; $ uptime_date = DateTime :: creat...
Get system uptime
58,336
public function ping ( $ host = '' , $ port = 80 ) { $ start = microtime ( true ) ; $ file = @ fsockopen ( $ host , $ port , $ errno , $ errstr , 5 ) ; $ stop = microtime ( true ) ; $ status = 0 ; if ( ! $ file ) { $ status = - 1 ; } else { fclose ( $ file ) ; $ status = round ( ( ( $ stop - $ start ) * 1000 ) , 2 ) ; ...
Ping a server and return timing
58,337
public function distro ( ) { if ( file_exists ( '/etc/redhat-release' ) ) { $ centos_array = explode ( ' ' , file_get_contents ( '/etc/redhat-release' ) ) ; return strtoupper ( $ centos_array [ 0 ] ) ; } if ( file_exists ( '/etc/os-release' ) ) { preg_match ( '/ID=([a-zA-Z]+)/' , file_get_contents ( '/etc/os-release' )...
Get system distro
58,338
public function reboot ( ) { if ( ! file_exists ( $ this -> tmp_path . '/reboot.sh' ) ) { file_put_contents ( $ this -> tmp_path . '/reboot.sh' , '#!/bin/bash' . PHP_EOL . '/sbin/shutdown -r now' ) ; chmod ( $ this -> tmp_path . '/reboot.sh' , 0750 ) ; } shell_exec ( $ this -> tmp_path . '/reboot.sh' ) ; return true ; ...
Reboot the system
58,339
public function localeToLanguage ( string $ locale ) : string { if ( empty ( $ locale ) ) { throw new InvalidArgumentException ( "Locale must be a non-emptystring." ) ; } $ result = ( string ) preg_replace ( '/(_|@|\.).*$/' , '' , strtolower ( $ locale ) ) ; $ result = strtolower ( $ result ) ; return $ result ; }
Convert locale to language
58,340
public function isRtl ( string $ language ) : bool { $ result = false ; $ language = $ this -> localeToLanguage ( $ language ) ; if ( in_array ( $ language , $ this -> getRtl ( ) ) ) { $ result = true ; } return $ result ; }
Check if given language is right - to - left
58,341
public function getAvailable ( ) : array { $ result = [ ] ; $ dbLanguages = $ this -> find ( 'list' , [ 'keyField' => 'code' , 'valueField' => 'name' ] ) -> where ( [ 'trashed IS' => null ] ) -> toArray ( ) ; $ supportedLanguages = $ this -> getSupported ( ) ; $ result = array_diff_assoc ( $ supportedLanguages , $ dbLa...
Get a list of all available languages
58,342
public function getName ( string $ code ) : string { $ result = $ code ; if ( empty ( $ code ) ) { throw new InvalidArgumentException ( "Code must be a non-empty string." ) ; } $ languages = $ this -> getSupported ( ) ; if ( ! empty ( $ languages [ $ code ] ) ) { $ result = $ languages [ $ code ] ; } return $ result ; ...
Get language name by code
58,343
public function addOrRestore ( array $ data ) : \ Translations \ Model \ Entity \ Language { if ( empty ( $ data [ 'code' ] ) ) { throw new InvalidArgumentException ( "Language data is missing 'code' key" ) ; } if ( empty ( $ data [ 'is_rtl' ] ) ) { $ data [ 'is_rtl' ] = $ this -> isRtl ( $ data [ 'code' ] ) ; } if ( e...
Add a new language or restore a deleted one
58,344
public function scan_table ( $ table_name = '' ) { if ( empty ( $ table_name ) ) return false ; $ this -> _l_table_name = strtolower ( $ table_name ) ; $ this -> table_name = $ table_name ; $ this -> tpl_replacements [ 'table_name' ] = $ table_name ; $ sql = "SHOW FULL COLUMNS FROM `$table_name`" ; $ res = $ this -> db...
fetches a numeric table list
58,345
public function get_type_value ( $ type = null , $ type_cast = false ) { if ( empty ( $ type ) ) return "null" ; if ( strpos ( strtolower ( $ type ) , 'int' ) !== false ) { return ( $ type_cast ) ? '(int)' : 0 ; } if ( strpos ( strtolower ( $ type ) , 'float' ) !== false ) { return ( $ type_cast ) ? '(float)' : 0 ; } i...
get type value parses the mysql type and returns
58,346
public function generate_primary_key_statement ( ) { if ( empty ( $ this -> primary_key ) ) return false ; if ( count ( $ this -> primary_key ) == 1 ) { $ this -> tpl_replacements [ 'primary_key_assign_statement' ] = "'{$this->primary_key[0]}'" ; $ this -> tpl_replacements [ 'primary_key_if_statement' ] = 'empty($this-...
generates the primary key statement
58,347
public function getQueueConfigurationScopes ( ) { $ configurations = array ( ) ; $ uniqueStores = array ( ) ; foreach ( Mage :: app ( ) -> getStores ( true ) as $ store ) { $ amqpConfig = $ this -> getStoreLevelAmqpConfigurations ( $ store ) ; if ( ! in_array ( $ amqpConfig , $ configurations , true ) ) { $ configurati...
Get an array of stores with unique AMQP configuration .
58,348
public function updateLastTimestamp ( ITestMessage $ payload , Mage_Core_Model_Store $ store ) { list ( $ scope , $ scopeId ) = $ this -> getScopeForStoreSettings ( $ store ) ; return Mage :: getModel ( 'core/config_data' ) -> addData ( array ( 'path' => $ this -> _amqpConfigMap -> getPathForKey ( 'last_test_message_ti...
Update the core_config_data setting for timestamp from the last test message received . Value should be saved in the most appropriate scope for the store being processed . E . g . if the store is the default store or has the same AMQP configuration as the default store the timestamp should be updated in the default sco...
58,349
public function listAction ( RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository , EntityReflectionInterface $ entity ) { $ name = $ this -> get ( 'orchestra.resolver.repository_name' ) -> getName ( $ repository_definition ) ; if ( false === $ entity -> isListable ( ) ) { throw new ...
Action used when a repository listing is called
58,350
public function repositoryQueryAction ( RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository , EntityReflectionInterface $ entity , $ repository_method ) { return $ this -> render ( 'RomaricDrigonOrchestraBundle:Generic:dashboard.html.twig' , [ ] ) ; }
Action used when a method on en Repository is called
58,351
public function repositoryCommandAction ( Request $ request , RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository , $ repository_method , CommandInterface $ command ) { $ form = $ this -> createForm ( 'orchestra_command_type' , $ command , [ 'command' => $ command ] ) ; $ repoName =...
Action used when a method accepting a Command on en Repository is called
58,352
public function entityCommandAction ( Request $ request , CommandInterface $ command , EntityReflectionInterface $ entity , $ entity_method , EntityInterface $ object = null ) { if ( null === $ object ) { throw new NotFoundHttpException ( ) ; } $ form = $ this -> createForm ( 'orchestra_command_type' , $ command , [ 'c...
Action used when a method accepting a Command on en Entity is called
58,353
public function entityEventAction ( EntityReflectionInterface $ entity , $ entity_method , EntityInterface $ object = null , RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository ) { if ( null === $ object ) { throw new NotFoundHttpException ( ) ; } $ event = call_user_func ( [ $ obje...
Action used when a method with a EmitEvent annotations is called
58,354
protected function controlsFieldset ( ) { return $ this -> grid -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> legend ( 'Sample Module Configuration' ) ; $ fieldset -> control ( 'input:text' , 'name' ) -> label ( trans ( 'antares/sample_module::messages.configuration.labels.name' ) ) -> attributes ( [ '...
creates main controls fieldset
58,355
public static function send ( $ filePath , $ remoteFileSystem ) { return ( new Client ( ) ) -> put ( $ remoteFileSystem , [ 'body' => fopen ( $ filePath , self :: READ_BINARY ) ] ) -> getStatusCode ( ) == HttpHelper :: STATUS_OK ; }
Send a file
58,356
public static function receive ( $ savePath , RequestContract $ request = null ) { file_put_contents ( $ savePath , $ request ? $ request -> getRawContent ( ) : RequestKit :: getRawContent ( ) ) ; }
Receive a file
58,357
public static function copy ( $ src , $ dst , $ context = null ) { return self :: resourceExists ( $ src ) ? copy ( $ src , $ dst , $ context ) : false ; }
Copy a file or a directory
58,358
public static function move ( $ oldName , $ newName , $ context = null ) { return self :: rename ( $ oldName , $ newName , $ context ) ; }
Move a file or a directory
58,359
public static function rename ( $ oldName , $ newName , $ context = null ) { return self :: resourceExists ( $ oldName ) ? rename ( $ oldName , $ newName , $ context ) : false ; }
Rename a file or a directory
58,360
protected function getListeners ( $ eventName ) { if ( isset ( $ this -> listeners [ $ eventName ] ) ) { return $ this -> listeners [ $ eventName ] ; } return null ; }
Gets all registered listeners for an event name .
58,361
public function log ( $ level , $ message , array $ context = array ( ) ) { $ level = static :: toNumberLevel ( $ level ) ; return $ this -> addRecord ( $ level , $ message , $ context ) ; }
Adds a log record at an arbitrary level . This method allows for compatibility with common interfaces .
58,362
public static function diffDates ( $ date1 , $ date2 ) { $ ts1 = strtotime ( $ date1 ) ; $ ts2 = strtotime ( $ date2 ) ; $ seconds_diff = $ ts2 - $ ts1 ; return floor ( $ seconds_diff / 3600 / 24 ) ; }
diff in days
58,363
public static function readFileToArray ( $ url , $ delm = ";" , $ encl = "\"" , $ head = false ) { $ csvxrow = file ( $ url ) ; $ csvxrow [ 0 ] = chop ( $ csvxrow [ 0 ] ) ; $ csvxrow [ 0 ] = str_replace ( $ encl , '' , $ csvxrow [ 0 ] ) ; $ keydata = explode ( $ delm , $ csvxrow [ 0 ] ) ; $ keynumb = count ( $ keydata ...
read file to array
58,364
public static function w1250_to_utf8 ( $ text ) { $ map = array ( chr ( 0x8A ) => chr ( 0xA9 ) , chr ( 0x8C ) => chr ( 0xA6 ) , chr ( 0x8D ) => chr ( 0xAB ) , chr ( 0x8E ) => chr ( 0xAE ) , chr ( 0x8F ) => chr ( 0xAC ) , chr ( 0x9C ) => chr ( 0xB6 ) , chr ( 0x9D ) => chr ( 0xBB ) , chr ( 0xA1 ) => chr ( 0xB7 ) , chr ( ...
PL chars conv iso8859 - 2 = > win1250 = > utf8
58,365
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof \ SmartyFilter \ Model \ SmartyFilterQuery ) { return $ criteria ; } $ query = new \ SmartyFilter \ Model \ SmartyFilterQuery ( ) ; if ( null !== $ modelAlias ) { $ query -> setModelAlias ( $ modelAlias ) ; } if ( $ c...
Returns a new ChildSmartyFilterQuery object .
58,366
public function filterByActive ( $ active = null , $ comparison = null ) { if ( is_array ( $ active ) ) { $ useMinMax = false ; if ( isset ( $ active [ 'min' ] ) ) { $ this -> addUsingAlias ( SmartyFilterTableMap :: ACTIVE , $ active [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ active...
Filter the query on the active column
58,367
public function filterByFiltertype ( $ filtertype = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ filtertype ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ filtertype ) ) { $ filtertype = str_replace ( '*' , '%' , $ filtertype ) ; $ comparison = Criteria :...
Filter the query on the filtertype column
58,368
public function filterBySmartyFilterI18n ( $ smartyFilterI18n , $ comparison = null ) { if ( $ smartyFilterI18n instanceof \ SmartyFilter \ Model \ SmartyFilterI18n ) { return $ this -> addUsingAlias ( SmartyFilterTableMap :: ID , $ smartyFilterI18n -> getId ( ) , $ comparison ) ; } elseif ( $ smartyFilterI18n instance...
Filter the query by a related \ SmartyFilter \ Model \ SmartyFilterI18n object
58,369
public function useSmartyFilterI18nQuery ( $ relationAlias = null , $ joinType = 'LEFT JOIN' ) { return $ this -> joinSmartyFilterI18n ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SmartyFilterI18n' , '\SmartyFilter\Model\SmartyFilterI18nQuery' ) ; }
Use the SmartyFilterI18n relation SmartyFilterI18n object
58,370
public function renderDropDownMenu ( $ container = null , array $ options = array ( ) ) { $ menu = $ this -> getNavigationMenu ( ) -> renderMenu ( $ container , $ options ) ; $ query = new Query ( $ menu , strtolower ( mb_detect_encoding ( $ menu ) ) ) ; $ uls = $ query -> execute ( 'li>ul' ) ; foreach ( $ uls as $ key...
Render a dropdown menu
58,371
protected function addCss ( $ css , \ DOMElement $ el ) { $ el -> setAttribute ( 'class' , $ el -> getAttribute ( 'class' ) ? $ el -> getAttribute ( 'class' ) . ' ' . $ css : $ css ) ; return $ el ; }
Add css to a DomElement
58,372
public function flushQueue ( $ table , $ onduplicate = null ) { if ( gettype ( $ table ) != 'string' ) { throw new Exception ( 'First parameter should be string, ' . gettype ( $ table ) . ' given.' ) ; } if ( isset ( $ this -> queue [ $ table ] ) && $ this -> queue [ $ table ] ) { $ query = "INSERT INTO `" . $ table . ...
Bulk insert logic
58,373
public function deleteFromList ( $ key_array = array ( ) ) { if ( empty ( $ key_array ) ) return false ; foreach ( $ key_array as $ key_del ) { if ( empty ( $ this -> cacheListing ) ) break ; foreach ( $ this -> cacheListing as $ key ) { if ( mb_strpos ( mb_strtolower ( $ key ) , mb_strtolower ( $ key_del ) ) !== false...
delete memcached values based on an input array
58,374
public function handle ( Specification $ spec ) { $ factory = $ this -> registry -> getFactory ( $ spec ) ; return $ factory -> create ( $ spec , $ this -> qb ) ; }
handle specification for queryfactory
58,375
public static function isValid ( $ value ) { if ( __CLASS__ === get_called_class ( ) ) { throw new \ RuntimeException ( 'Cannot call isValid() on ' . __CLASS__ ) ; } $ reflectionClass = new \ ReflectionClass ( get_called_class ( ) ) ; $ validValues = $ reflectionClass -> getConstants ( ) ; if ( static :: isBitFlag ( ) ...
Checks if the value is valid according to the enumeration .
58,376
public function withCode ( string $ code ) : ViewSource { $ context = clone $ this ; $ context -> code = $ code ; return $ context ; }
Get source copy with redefined code .
58,377
public function setRedirect ( $ url , $ code = 302 ) { $ this -> canSendHeaders ( true ) ; $ this -> setHeader ( 'Location' , $ url , true ) -> setHttpResponseCode ( $ code ) ; return $ this ; }
Set redirect URL
58,378
public function sendHeaders ( ) { if ( count ( $ this -> _headersRaw ) || count ( $ this -> _headers ) || ( 200 != $ this -> _httpResponseCode ) ) { $ this -> canSendHeaders ( true ) ; } elseif ( 200 == $ this -> _httpResponseCode ) { return $ this ; } $ httpCodeSent = false ; foreach ( $ this -> _headersRaw as $ heade...
Send all headers
58,379
public function setBody ( $ content , $ name = null ) { if ( ( null === $ name ) || ! is_string ( $ name ) ) { $ this -> _body = array ( 'default' => ( string ) $ content ) ; } else { $ this -> _body [ $ name ] = ( string ) $ content ; } return $ this ; }
Set body content
58,380
public function appendBody ( $ content , $ name = null ) { if ( ( null === $ name ) || ! is_string ( $ name ) ) { if ( isset ( $ this -> _body [ 'default' ] ) ) { $ this -> _body [ 'default' ] .= ( string ) $ content ; } else { return $ this -> append ( 'default' , $ content ) ; } } elseif ( isset ( $ this -> _body [ $...
Append content to the body content
58,381
public function clearBody ( $ name = null ) { if ( null !== $ name ) { $ name = ( string ) $ name ; if ( isset ( $ this -> _body [ $ name ] ) ) { unset ( $ this -> _body [ $ name ] ) ; return true ; } return false ; } $ this -> _body = array ( ) ; return true ; }
Clear body array
58,382
public function append ( $ name , $ content ) { if ( ! is_string ( $ name ) ) { throw new \ Exception ( 'Invalid body segment key ("' . gettype ( $ name ) . '")' ) ; } if ( isset ( $ this -> _body [ $ name ] ) ) { unset ( $ this -> _body [ $ name ] ) ; } $ this -> _body [ $ name ] = ( string ) $ content ; return $ this...
Append a named body segment to the body content array
58,383
public function insert ( $ name , $ content , $ parent = null , $ before = false ) { if ( ! is_string ( $ name ) ) { throw new \ Exception ( 'Invalid body segment key ("' . gettype ( $ name ) . '")' ) ; } if ( ( null !== $ parent ) && ! is_string ( $ parent ) ) { throw new \ Exception ( 'Invalid body segment parent key...
Insert a named segment into the body content array
58,384
public function hasExceptionOfType ( $ type ) { foreach ( $ this -> _exceptions as $ e ) { if ( $ e instanceof $ type ) { return true ; } } return false ; }
Does the response object contain an exception of a given type?
58,385
public function hasExceptionOfMessage ( $ message ) { foreach ( $ this -> _exceptions as $ e ) { if ( $ message == $ e -> getMessage ( ) ) { return true ; } } return false ; }
Does the response object contain an exception with a given message?
58,386
public function hasExceptionOfCode ( $ code ) { $ code = ( int ) $ code ; foreach ( $ this -> _exceptions as $ e ) { if ( $ code == $ e -> getCode ( ) ) { return true ; } } return false ; }
Does the response object contain an exception with a given code?
58,387
public function getExceptionByType ( $ type ) { $ exceptions = array ( ) ; foreach ( $ this -> _exceptions as $ e ) { if ( $ e instanceof $ type ) { $ exceptions [ ] = $ e ; } } if ( empty ( $ exceptions ) ) { $ exceptions = false ; } return $ exceptions ; }
Retrieve all exceptions of a given type
58,388
public function getExceptionByMessage ( $ message ) { $ exceptions = array ( ) ; foreach ( $ this -> _exceptions as $ e ) { if ( $ message == $ e -> getMessage ( ) ) { $ exceptions [ ] = $ e ; } } if ( empty ( $ exceptions ) ) { $ exceptions = false ; } return $ exceptions ; }
Retrieve all exceptions of a given message
58,389
public function getExceptionByCode ( $ code ) { $ code = ( int ) $ code ; $ exceptions = array ( ) ; foreach ( $ this -> _exceptions as $ e ) { if ( $ code == $ e -> getCode ( ) ) { $ exceptions [ ] = $ e ; } } if ( empty ( $ exceptions ) ) { $ exceptions = false ; } return $ exceptions ; }
Retrieve all exceptions of a given code
58,390
public function sendResponse ( ) { $ this -> sendHeaders ( ) ; if ( $ this -> isException ( ) && $ this -> renderExceptions ( ) ) { $ exceptions = '' ; foreach ( $ this -> getException ( ) as $ e ) { $ exceptions .= $ e -> __toString ( ) . "\n" ; } echo $ exceptions ; return ; } $ this -> outputBody ( ) ; }
Send the response including all headers rendering exceptions if so requested .
58,391
private function getContaoFile ( $ uuid ) { $ uuid = StringUtil :: deserialize ( $ uuid ) ; if ( is_array ( $ uuid ) ) return FilesModel :: findMultipleByUuids ( $ uuid ) ; return FilesModel :: findByUuid ( $ uuid ) ; }
Always return a contao file model since its more suitable when working with contao
58,392
private function setContaoFile ( $ file ) { if ( is_array ( $ file ) ) { return serialize ( array_map ( [ __CLASS__ , 'setContaoFile' ] , $ file ) ) ; } if ( $ file instanceof FilesModel ) { return $ file -> uuid ; } if ( Validator :: isStringUuid ( $ file ) ) { return StringUtil :: uuidToBin ( $ file ) ; } return $ fi...
we check if its a file model and extract the uuid . If its a string we convert it .
58,393
public function resolveSnippet ( $ name , array & $ parameters ) { $ name = strtoupper ( $ name ) ; if ( isset ( $ this -> clauses [ $ name ] ) ) { $ snippet = $ this -> clauses [ $ name ] -> resolveClauses ( $ parameters ) ; } elseif ( isset ( $ this -> snippets [ $ name ] ) ) { $ snippet = $ this -> snippets [ $ name...
Resolve template snippet .
58,394
public function resolveParameter ( $ idx , $ type , $ name ) { return $ this -> dialect -> resolveParameter ( $ idx , $ type , $ name ) ; }
Resolve query parameter .
58,395
protected function addClause ( $ name , $ sql , array $ parameters , $ joiner , $ prefix = '' , $ postfix = '' , $ is_inclusive = false ) { $ name = strtoupper ( $ name ) ; if ( ! isset ( $ this -> clauses [ $ name ] ) ) { $ this -> clauses [ $ name ] = new \ Octris \ Sqlbuilder \ Clauses ( $ joiner , $ prefix , $ post...
Add clause .
58,396
public function addPaging ( $ limit , $ page = 1 ) { $ this -> addClause ( 'PAGING' , $ this -> dialect -> getLimitString ( $ limit , ( $ page - 1 ) * $ limit ) , [ ] , '' , '' , "\n" , false ) ; return $ this ; }
Add paging .
58,397
public function requestPdo ( $ request , $ param = null ) { $ this -> result = $ this -> tableGateway -> requestPdo ( $ request , $ param ) ; return $ this -> result ; }
Excecute request directly by PDO .
58,398
public function selectWith ( \ Zend \ Db \ Sql \ Select $ select ) { if ( $ this -> usePaginator === true ) { return $ this -> initPaginator ( $ select ) ; } $ this -> result = $ this -> tableGateway -> selectWith ( $ select ) ; return $ this -> result ; }
Select request .
58,399
public function fetchAll ( ) { if ( $ this -> usePaginator === true ) { return $ this -> initPaginator ( $ this -> tableGateway -> getSql ( ) -> select ( ) ) ; } $ this -> result = $ this -> tableGateway -> select ( ) ; return $ this -> result ; }
Fetch All .