idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
239,200 | protected function removeImportFiles ( array $ importFiles , array $ config ) { foreach ( $ config as $ item ) { if ( in_array ( $ item , $ importFiles ) ) { unset ( $ importFiles [ array_search ( $ item , $ importFiles ) ] ) ; } } return $ importFiles ; } | Remove import files from the import config . |
239,201 | public static function checkPermission ( $ userId = false ) { $ user = \ Phramework \ Phramework :: getUser ( ) ; if ( ! $ user ) { throw new \ Phramework \ Exceptions \ UnauthorizedException ( ) ; } if ( $ userId !== false && $ user -> id != $ userId ) { throw new PermissionException ( 'Insufficient permissions' ) ; }... | Check if current request is authenticated |
239,202 | public static function requireParameters ( $ parameters , $ required ) { if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } $ missing = [ ] ; if ( ! is_array ( $ required ) ) { $ required = [ $ required ] ; } foreach ( $ required as $ key ) { if ( ! isset ( $ parameters [ $ key ] ) ) { array_... | Check if required parameters are set |
239,203 | public static function resourceId ( $ parameters , $ UINTEGER = true ) { if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } if ( isset ( $ parameters [ 'resource_id' ] ) && preg_match ( Validate :: REGEXP_RESOURCE_ID , $ parameters [ 'resource_id' ] ) !== false ) { if ( $ UINTEGER ) { return ... | Require id parameter if it s set else return NULL it uses resource_id or id parameter if available |
239,204 | public static function requireId ( $ parameters , $ UINTEGER = true ) { if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } if ( isset ( $ parameters [ 'resource_id' ] ) && preg_match ( Validate :: REGEXP_RESOURCE_ID , $ parameters [ 'resource_id' ] ) !== false ) { $ parameters [ 'id' ] = $ pa... | Require id parameter it uses resource_id or id parameter if available |
239,205 | public static function parseModel ( $ parameters , $ model ) { if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } $ required_fields = [ ] ; foreach ( $ model as $ key => $ value ) { if ( in_array ( 'required' , $ value , true ) === true || in_array ( 'required' , $ value , true ) == true ) { ... | Required required values and parse provided parameters into an array Validate the provided request model and return the |
239,206 | public static function toStudlyCase ( $ input ) { $ input = trim ( $ input , '-_' ) ; return ucfirst ( preg_replace_callback ( '/([A-Z-_][a-z]+)/' , function ( $ matches ) { return ucfirst ( str_replace ( [ '-' , '_' ] , '' , $ matches [ 0 ] ) ) ; } , $ input ) ) ; } | Transforms a given input into StudlyCase |
239,207 | public static function pluralize ( $ input ) { if ( self :: $ pluralizer === null ) { self :: $ pluralizer = new StandardEnglishSingularizer ( ) ; } return self :: $ pluralizer -> getPluralForm ( $ input ) ; } | Returns the plural form of the input |
239,208 | public static function singularize ( $ input ) { if ( self :: $ pluralizer === null ) { self :: $ pluralizer = new StandardEnglishSingularizer ( ) ; } return self :: $ pluralizer -> getSingularForm ( $ input ) ; } | Returns the singular form of the input |
239,209 | public function linkNames ( String $ prev , String $ next , String $ first , String $ last ) : Paginator { $ this -> settings [ 'prevName' ] = $ prev ; $ this -> settings [ 'nextName' ] = $ next ; $ this -> settings [ 'firstName' ] = $ first ; $ this -> settings [ 'lastName' ] = $ last ; return $ this ; } | Change the names of links . |
239,210 | public function settings ( Array $ config = [ ] ) : Paginator { foreach ( $ config as $ key => $ value ) { $ this -> $ key = $ value ; } $ this -> class = array_merge ( $ this -> config [ 'class' ] , $ this -> class ?? [ ] ) ; $ this -> style = array_merge ( $ this -> config [ 'style' ] , $ this -> style ?? [ ] ) ; if ... | Configures all settings of the page . |
239,211 | public function create ( $ start = NULL , Array $ settings = [ ] ) : String { $ settings = array_merge ( $ this -> config , $ this -> settings , $ settings ) ; if ( ! empty ( $ settings ) ) { $ this -> settings ( $ settings ) ; } $ startRowNumber = $ this -> getStartRowNumber ( $ start ) ; $ this -> limit = $ this -> l... | Creates the pagination . |
239,212 | protected function createBasicPaginationBar ( $ startRowNumber ) { if ( $ this -> isPrevLink ( $ startRowNumber ) ) { $ this -> addPrevLink ( $ startRowNumber , $ prevLink ) ; } else { $ this -> removeLinkFromPagingationBar ( $ prevLink ) ; } if ( $ this -> isNextLink ( $ this -> getPerPage ( ) , $ startRowNumber ) ) {... | Protected create basic pagination bar |
239,213 | protected function createAdvancedPaginationBar ( $ startRowNumber ) { if ( $ this -> isAdvancedPrevLink ( $ startRowNumber ) ) { $ this -> addPrevLink ( $ startRowNumber , $ prevLink ) ; } else { $ this -> removeLinkFromPagingationBar ( $ prevLink ) ; } if ( $ this -> isAdvancedNextLink ( $ startRowNumber ) ) { $ this ... | Protected create advanced pagination bar |
239,214 | protected function addLastLink ( & $ lastLink ) { $ lastLink = $ this -> getLink ( $ this -> calculatePageRowNumberForLastLink ( ) , $ this -> getStyleClassAttributes ( 'last' ) , $ this -> lastName ) ; } | Protected get last link |
239,215 | protected function addPrevLink ( $ startRowNumber , & $ prevLink ) { $ prevLink = $ this -> getLink ( $ this -> decrementPageRowNumber ( $ startRowNumber ) , $ this -> getStyleClassAttributes ( 'prev' ) , $ this -> prevName ) ; } | Protected get prev link |
239,216 | protected function addNextLink ( $ startRowNumber , & $ nextLink ) { $ nextLink = $ this -> getLink ( $ this -> incrementPageRowNumber ( $ startRowNumber ) , $ this -> getStyleClassAttributes ( 'next' ) , $ this -> nextName ) ; } | Protected get advanced next link |
239,217 | protected function getStartRowNumber ( $ start ) { if ( $ this -> start !== NULL ) { $ start = ( int ) $ this -> start ; } if ( empty ( $ start ) && ! is_numeric ( $ start ) ) { return ! is_numeric ( $ segment = URI :: segment ( - 1 ) ) ? 0 : $ segment ; } return ! is_numeric ( $ start ) ? 0 : $ start ; } | Protected get start row number |
239,218 | protected function getAdvancedPerPage ( $ pageIndex , & $ nextLink , & $ lastLink ) { $ perPage = $ this -> countLinks + $ pageIndex - 1 ; if ( $ perPage >= ( $ getPerPage = $ this -> getPerPage ( ) ) ) { $ this -> removeLinkFromPagingationBar ( $ nextLink ) ; $ this -> removeLinkFromPagingationBar ( $ lastLink ) ; $ p... | Protected advanced per page . |
239,219 | protected function getNumberLinks ( $ perPage , $ startRowNumber , $ startIndexNumber = 1 ) { $ numberLinks = NULL ; for ( $ i = $ startIndexNumber ; $ i <= $ perPage ; $ i ++ ) { $ page = ( $ i - 1 ) * $ this -> limit ; if ( $ i - 1 == floor ( ( int ) $ startRowNumber / $ this -> limit ) ) { $ currentLink = $ this -> ... | Protected get number links |
239,220 | protected function calculatePageRowNumberForLastLink ( ) { $ mod = $ this -> totalRows % $ this -> limit ; return ( $ this -> totalRows - $ mod ) - ( $ mod == 0 ? $ this -> limit : 0 ) ; } | Protected page row number for last link |
239,221 | protected function checkGetRequest ( $ page ) { $ this -> url .= $ this -> explodeRequestGetValue ( ) ; if ( strstr ( $ this -> url , '?' ) ) { $ urlEx = explode ( '?' , $ this -> url ) ; return Base :: suffix ( $ urlEx [ 0 ] ) . $ page . '?' . rtrim ( $ urlEx [ 1 ] , '/' ) ; } return $ this -> type === 'ajax' ? $ this... | Protected check get request |
239,222 | protected function getLink ( $ var , $ fix , $ val ) { return $ this -> getHtmlLiElement ( $ this -> getHtmlAnchorElement ( $ var , $ fix , $ val ) , $ fix ) ; } | Protected get link |
239,223 | protected function getHtmlAnchorElement ( $ var , $ attr , $ val ) { if ( $ this -> output === 'bootstrap' ) { $ attr = NULL ; } return '<a href="' . $ this -> checkGetRequest ( $ var ) . '"' . $ this -> getAttributesForAjaxProcess ( $ var ) . $ attr . '>' . $ val . '</a>' ; } | Protected get html anchor element |
239,224 | protected function generatePaginationBar ( ... $ numberLinks ) { $ links = $ this -> implodeLinks ( ... $ numberLinks ) ; if ( $ this -> output === 'bootstrap' ) { return '<ul class="pagination">' . $ links . '</ul>' ; } return $ links ; } | Protected get html ul element |
239,225 | protected function getStyleLinkAttribute ( $ var , $ type = 'style' ) { $ getAttribute = ( ! empty ( $ this -> { $ type } [ $ var ] ) ) ? $ this -> { $ type } [ $ var ] . ' ' : '' ; if ( $ type === 'class' ) { $ this -> classAttribute = $ getAttribute ; } else { $ this -> styleAttribute = $ getAttribute ; } return $ th... | Protected get style link attribute |
239,226 | protected function getClassAttribute ( $ var , $ type = 'class' ) { $ status = trim ( ( $ type === 'class' ? $ this -> classAttribute : $ this -> styleAttribute ) . $ this -> { $ type } [ $ var ] ) ; return $ this -> createAttribute ( $ status , $ type ) ; } | Protected get class attribute |
239,227 | protected function createAttribute ( $ condition , $ key , $ value = NULL ) { return ! empty ( $ condition ) ? ' ' . $ key . '="' . trim ( $ value ?? $ condition ) . '"' : '' ; } | Protcted create attribute |
239,228 | final public function finalise ( ) { if ( $ this -> view -> isEnabled ( ) ) { $ this -> view -> setResponse ( $ this -> response ) ; $ this -> view -> render ( ) ; } return true ; } | Called at the end of the process . |
239,229 | final public function urlFor ( $ routeName , array $ params = array ( ) ) { if ( null === $ this -> router ) { return '' ; } return $ this -> router -> urlFor ( $ routeName , $ params ) ; } | Get a route path by a given name |
239,230 | 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 . |
239,231 | 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 |
239,232 | 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 |
239,233 | 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 |
239,234 | 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 |
239,235 | 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 |
239,236 | public function delete ( $ name ) { if ( array_key_exists ( $ name , $ this -> data ) ) { unset ( $ this -> data [ $ name ] ) ; return true ; } return false ; } | Delete a task from table |
239,237 | 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 |
239,238 | public function random ( ) { $ arr = $ this -> getArrayCopy ( ) ; $ rand = array_rand ( $ arr ) ; return isset ( $ arr [ $ rand ] ) ? $ arr [ $ rand ] : FALSE ; } | Return random collection item |
239,239 | 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 |
239,240 | 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 . |
239,241 | 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 . |
239,242 | 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 . |
239,243 | 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 . |
239,244 | 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 . |
239,245 | 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 . |
239,246 | 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 . |
239,247 | 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 |
239,248 | 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 . |
239,249 | 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 . |
239,250 | 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 |
239,251 | 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 |
239,252 | 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 |
239,253 | 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 |
239,254 | 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 |
239,255 | 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 |
239,256 | 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 |
239,257 | 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 |
239,258 | 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 |
239,259 | 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 |
239,260 | 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 |
239,261 | 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 |
239,262 | 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 |
239,263 | 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 |
239,264 | 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 |
239,265 | 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 |
239,266 | 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 |
239,267 | 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 |
239,268 | 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 |
239,269 | 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 |
239,270 | 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 |
239,271 | 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 |
239,272 | 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 |
239,273 | 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 |
239,274 | 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 |
239,275 | 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 |
239,276 | 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 |
239,277 | 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 . |
239,278 | 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... |
239,279 | 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 |
239,280 | 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 |
239,281 | 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 |
239,282 | 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 |
239,283 | 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 |
239,284 | 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 |
239,285 | public static function send ( $ filePath , $ remoteFileSystem ) { return ( new Client ( ) ) -> put ( $ remoteFileSystem , [ 'body' => fopen ( $ filePath , self :: READ_BINARY ) ] ) -> getStatusCode ( ) == HttpHelper :: STATUS_OK ; } | Send a file |
239,286 | public static function receive ( $ savePath , RequestContract $ request = null ) { file_put_contents ( $ savePath , $ request ? $ request -> getRawContent ( ) : RequestKit :: getRawContent ( ) ) ; } | Receive a file |
239,287 | public static function copy ( $ src , $ dst , $ context = null ) { return self :: resourceExists ( $ src ) ? copy ( $ src , $ dst , $ context ) : false ; } | Copy a file or a directory |
239,288 | public static function move ( $ oldName , $ newName , $ context = null ) { return self :: rename ( $ oldName , $ newName , $ context ) ; } | Move a file or a directory |
239,289 | public static function rename ( $ oldName , $ newName , $ context = null ) { return self :: resourceExists ( $ oldName ) ? rename ( $ oldName , $ newName , $ context ) : false ; } | Rename a file or a directory |
239,290 | protected function getListeners ( $ eventName ) { if ( isset ( $ this -> listeners [ $ eventName ] ) ) { return $ this -> listeners [ $ eventName ] ; } return null ; } | Gets all registered listeners for an event name . |
239,291 | 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 . |
239,292 | 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 |
239,293 | 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 |
239,294 | 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 |
239,295 | 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 . |
239,296 | 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 |
239,297 | 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 |
239,298 | 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 |
239,299 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.