idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
22,700 | public function updateTableColumn ( $ writerId , $ tableId , $ column , array $ configuration ) { $ allowedConfigurationOptions = [ 'title' , 'type' , 'reference' , 'schemaReference' , 'format' , 'dateDimension' ] ; foreach ( $ configuration as $ k => $ v ) { if ( ! in_array ( $ k , $ allowedConfigurationOptions ) ) { throw new ClientException ( "Option '$k' is not allowed, choose from: " . implode ( ', ' , $ allowedConfigurationOptions ) ) ; } } $ params = [ 'writerId' => $ writerId , 'tableId' => $ tableId , 'column' => $ column ] ; $ params = array_merge ( $ params , $ configuration ) ; return $ this -> getCommand ( 'UpdateTableColumn' , $ params ) -> execute ( ) ; } | Update table column configuration |
22,701 | public function updateTableColumns ( $ writerId , $ tableId , array $ columns ) { $ allowedConfigurationOptions = [ 'name' , 'title' , 'type' , 'reference' , 'schemaReference' , 'format' , 'dateDimension' ] ; foreach ( $ columns as $ column ) { if ( ! isset ( $ column [ 'name' ] ) ) { throw new ClientException ( "One of the columns is missing 'name' parameter" ) ; } foreach ( $ column as $ k => $ v ) { if ( ! in_array ( $ k , $ allowedConfigurationOptions ) ) { throw new ClientException ( "Option '$k' for column '$column' is not allowed, choose from: " . implode ( ', ' , $ allowedConfigurationOptions ) ) ; } } } $ params = [ 'writerId' => $ writerId , 'tableId' => $ tableId , 'columns' => $ columns ] ; return $ this -> getCommand ( 'UpdateTableColumns' , $ params ) -> execute ( ) ; } | Update table columns configuration |
22,702 | public function uploadProjectAsync ( $ writerId , $ incrementalLoad = null , $ queue = 'primary' ) { return $ this -> getCommand ( 'UploadProject' , [ 'writerId' => $ writerId , 'incrementalLoad' => $ incrementalLoad , 'queue' => $ queue ] ) -> execute ( ) ; } | Upload project to GoodData |
22,703 | public function uploadProject ( $ writerId , $ incrementalLoad = null , $ queue = 'primary' ) { $ job = $ this -> uploadProjectAsync ( $ writerId , $ incrementalLoad , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Upload project job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; } | Upload project to GoodData and wait for result |
22,704 | public function uploadTableAsync ( $ writerId , $ tableId , $ incrementalLoad = null , $ queue = 'primary' ) { return $ this -> getCommand ( 'UploadTable' , [ 'writerId' => $ writerId , 'tableId' => $ tableId , 'incrementalLoad' => $ incrementalLoad , 'queue' => $ queue ] ) -> execute ( ) ; } | Upload table to GoodData |
22,705 | public function uploadTable ( $ writerId , $ tableId , $ incrementalLoad = null , $ queue = 'primary' ) { $ job = $ this -> uploadTableAsync ( $ writerId , $ tableId , $ incrementalLoad , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Upload table job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; } | Upload table to GoodData and wait for result |
22,706 | public function updateModelAsync ( $ writerId , $ tableId , $ queue = 'primary' ) { return $ this -> getCommand ( 'UpdateModel' , [ 'writerId' => $ writerId , 'tableId' => $ tableId , 'queue' => $ queue ] ) -> execute ( ) ; } | Update model of table in GoodData |
22,707 | public function updateModel ( $ writerId , $ tableId , $ queue = 'primary' ) { $ job = $ this -> updateModelAsync ( $ writerId , $ tableId , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Update model job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; } | Update model of table in GoodData and wait for result |
22,708 | public function loadDataAsync ( $ writerId , array $ tables , $ incrementalLoad = null , $ queue = 'primary' ) { return $ this -> getCommand ( 'LoadData' , [ 'writerId' => $ writerId , 'tables' => $ tables , 'incrementalLoad' => $ incrementalLoad , 'queue' => $ queue ] ) -> execute ( ) ; } | Load data to table in GoodData |
22,709 | public function loadData ( $ writerId , array $ tables , $ incrementalLoad = null , $ queue = 'primary' ) { $ job = $ this -> loadDataAsync ( $ writerId , $ tables , $ incrementalLoad , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Load data job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; } | Load data to table in GoodData and wait for result |
22,710 | public function getJobs ( $ writerId , $ since = null , $ until = null ) { $ url = parse_url ( $ this -> getBaseUrl ( ) ) ; $ componentName = substr ( $ url [ 'path' ] , 1 ) ; $ url = "https://{$url['host']}/queue/jobs?component={$componentName}&q=params.writerId={$writerId}" ; if ( $ since ) { $ url .= '&since=' . urlencode ( $ since ) ; } if ( $ until ) { $ url .= '&until=' . urlencode ( $ until ) ; } return $ this -> get ( $ url ) -> send ( ) -> json ( ) ; } | Return list of jobs for given writerId |
22,711 | public function getJob ( $ jobId ) { $ url = parse_url ( $ this -> getBaseUrl ( ) ) ; return $ this -> get ( "https://{$url['host']}/queue/job/{$jobId}" ) -> send ( ) -> json ( ) ; } | Return detail of given job |
22,712 | public function waitForJob ( $ url ) { $ jobFinished = false ; $ i = 1 ; do { $ jobInfo = $ jobInfo = $ this -> get ( $ url ) -> send ( ) -> json ( ) ; if ( isset ( $ jobInfo [ 'status' ] ) && ! in_array ( $ jobInfo [ 'status' ] , [ 'waiting' , 'processing' ] ) ) { $ jobFinished = true ; } if ( ! $ jobFinished ) { usleep ( ( 1 << $ i ) * 1000000 + rand ( 0 , 1000000 ) ) ; } $ i ++ ; } while ( ! $ jobFinished ) ; return $ jobInfo ; } | Ask repeatedly for job status until it is finished |
22,713 | public static function unknownLogger ( string $ name , \ Exception $ previous = null ) : self { return new self ( "could not find logger \"{$name}\"" , self :: UNKNOWN_LOGGER , $ previous ) ; } | Creates an exception if the logger with the given name could not be found by the log manager . |
22,714 | public static function invalidFileName ( string $ fileName , \ Exception $ previous = null ) : self { return new self ( "invalid log file \"{$fileName}\"" , self :: INVALID_FILENAME , $ previous ) ; } | Creates an exception if an invalid file name was set in configuration of a file logger . |
22,715 | public function searchCacheDir ( File $ origDir ) { if ( isset ( $ this -> autoDirPathMap [ \ md5 ( $ origDir -> getAbsolutePath ( ) ) ] ) ) { $ entry = $ this -> autoDirPathMap [ \ md5 ( $ origDir -> getAbsolutePath ( ) ) ] ; return $ entry [ 1 ] ; } else { return null ; } } | Search the cache directory by mapping original directory |
22,716 | public function searchOrigDir ( File $ cacheDir ) { foreach ( $ this -> autoDirPathMap as $ entry_set ) { $ orig_dir = $ entry_set [ 0 ] ; $ cache_dir = $ entry_set [ 1 ] ; if ( $ cacheDir -> getAbsolutePath ( ) === $ cache_dir -> getAbsolutePath ( ) ) { return $ orig_dir ; } } return null ; } | Search the original directory by mapping cached directory |
22,717 | public function matchUrl ( $ method , $ url ) { if ( $ this -> method == $ method ) { if ( preg_match ( '/^' . $ this -> url . '$/' , $ url , $ matches ) ) { $ params = $ this -> prepareParams ( $ matches ) ; $ this -> execute ( $ params ) ; return true ; } return false ; } } | Checks if the passed url matches the route . If it maches the class will be created and the function called with the arguments extracted from the url |
22,718 | public function remove ( $ property ) { $ property = trim ( strtolower ( $ property ) ) ; unset ( $ this -> css [ $ property ] ) ; return $ this ; } | Removes CSS property . |
22,719 | public function set ( $ css , $ value = NULL ) { $ css = trim ( strtolower ( $ css ) ) ; if ( func_num_args ( ) == 1 ) { $ elements = explode ( ';' , $ css ) ; foreach ( $ elements as $ element ) { if ( ! $ element = trim ( $ element ) ) { continue ; } $ element = explode ( ':' , $ element ) ; if ( ! $ element [ 0 ] = trim ( @ $ element [ 0 ] ) ) { continue ; } $ element [ 1 ] = trim ( @ $ element [ 1 ] ) ; $ this -> set ( $ element [ 0 ] , $ element [ 1 ] ) ; } return ; } $ css = strtolower ( $ css ) ; $ this -> css [ $ css ] = $ value ; return $ this ; } | Sets CSS value . |
22,720 | public function render ( ) { $ result = NULL ; foreach ( $ this -> css as $ name => $ value ) { if ( ! $ value = trim ( $ value ) ) { continue ; } $ result .= "{$name}:{$value};" ; } return $ result ? $ result : '' ; } | Creates CSS string |
22,721 | public static function escapeStr ( $ inp ) { if ( is_array ( $ inp ) ) { return array_map ( __METHOD__ , $ inp ) ; } if ( ! empty ( $ inp ) && is_string ( $ inp ) ) { $ badchr = array ( "\xc2" , "\x80" , "\x98" , "\x99" , "\x8c" , "\x9d" , "\x96" , "\x97" ) ; $ goodchr = array ( '' , '' , '\'' , '\'' , '"' , '"' , '-' , '-' ) ; $ inp = str_replace ( $ badchr , $ goodchr , $ inp ) ; } return $ inp ; } | must test this |
22,722 | public function attach ( ObserverInterface $ observer ) { $ observers = $ this -> getObservers ( ) ; foreach ( $ observer -> getEvents ( ) as $ event ) { $ observers [ $ event ] [ ] = $ observer ; } $ this -> setObservers ( $ observers ) ; } | Method responsible for adding observers to event manager |
22,723 | public function detach ( ObserverInterface $ observer ) { $ observers = $ this -> getObservers ( ) ; foreach ( $ observer -> getEvents ( ) as $ event ) { $ count = count ( $ observers [ $ event ] ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ observers [ $ event ] [ $ i ] == $ observer ) { unset ( $ observers [ $ event ] [ $ i ] ) ; } } } $ this -> setObservers ( $ observers ) ; } | Method responsible for removing observers from event manager |
22,724 | public function notify ( $ event , $ params ) { $ observers = $ this -> getObservers ( ) ; if ( isset ( $ observers [ $ event ] ) ) { foreach ( $ observers [ $ event ] as $ observer ) { $ observer -> setTriggeredEvent ( $ event ) ; $ observer -> setTriggeredEventParams ( $ params ) ; $ observer -> setBag ( $ this -> getBag ( ) ) ; $ observer -> run ( ) ; } } } | Method responsible for notifying observers upon event trigger |
22,725 | public static function shouldReceive ( ) { $ name = static :: getConcreteBinding ( ) ; if ( static :: isMock ( ) ) { $ mock = static :: $ instance [ $ name ] ; } else { $ mock = static :: createFreshMockInstance ( $ name ) ; } return call_user_func_array ( [ $ mock , 'shouldReceive' ] , func_get_args ( ) ) ; } | Initiate a mock expectation on the proxy . |
22,726 | protected static function resolveProxyInstance ( $ name ) { if ( is_object ( $ name ) ) return $ name ; if ( isset ( static :: $ instance [ $ name ] ) ) { return static :: $ instance [ $ name ] ; } return static :: $ instance [ $ name ] = static :: $ container [ $ name ] ; } | Resolve the proxy binding instance from the container . |
22,727 | private static function discoverPackages ( string $ vendorPath , string $ manifestPath ) : void { $ installedPackages = [ ] ; if ( file_exists ( $ path = $ vendorPath . '/composer/installed.json' ) ) { $ installedPackages = json_decode ( file_get_contents ( $ path ) , true ) ; } $ discoverPackages = [ ] ; foreach ( $ installedPackages as $ package ) { if ( ! empty ( $ package [ 'extra' ] [ 'chiron' ] ) ) { $ packageInfo = $ package [ 'extra' ] [ 'chiron' ] ; $ discoverPackages [ $ package [ 'name' ] ] = $ packageInfo ; } } if ( ! is_writable ( dirname ( $ manifestPath ) ) ) { throw new \ RuntimeException ( 'The directory "' . dirname ( $ manifestPath ) . '" must be present and writable.' ) ; } file_put_contents ( $ manifestPath , '<?php return ' . var_export ( $ discoverPackages , true ) . ';' ) ; } | Discover and Write the found packages in a manifest array file to disk . |
22,728 | public static function copyFiles ( array $ paths ) : void { foreach ( $ paths as $ source => $ target ) { $ target = ( array ) $ target ; echo "Copying file $source to $target[0] - " ; if ( ! is_file ( $ source ) ) { echo "source file not found.\n" ; continue ; } if ( is_file ( $ target [ 0 ] ) && empty ( $ target [ 1 ] ) ) { echo "target file exists - skip.\n" ; continue ; } elseif ( is_file ( $ target [ 0 ] ) && ! empty ( $ target [ 1 ] ) ) { echo 'target file exists - overwrite - ' ; } try { if ( ! is_dir ( dirname ( $ target [ 0 ] ) ) ) { mkdir ( dirname ( $ target [ 0 ] ) , 0777 , true ) ; } if ( copy ( $ source , $ target [ 0 ] ) ) { echo "done.\n" ; } } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) . "\n" ; } } } | Copy files to specified locations . |
22,729 | static public function stopLongExecutable ( $ agentMaxExecuteTime = null ) { if ( $ agentMaxExecuteTime === null ) { $ agentMaxExecuteTime = \ Yii :: $ app -> cmsAgent -> agentMaxExecuteTime ; } $ time = \ Yii :: $ app -> formatter -> asTimestamp ( time ( ) ) - ( int ) $ agentMaxExecuteTime ; $ running = static :: find ( ) -> where ( [ 'is_running' => Cms :: BOOL_Y ] ) -> orderBy ( 'priority' ) -> all ( ) ; ; $ stoping = 0 ; if ( $ running ) { foreach ( $ running as $ agent ) { if ( $ agent -> next_exec_at <= $ time ) { if ( $ agent -> stop ( ) ) { $ stoping ++ ; } else { \ Yii :: error ( 'Not stopped long agent: ' . $ agent -> name , 'skeeks/agent' ) ; } } } } return $ stoping ; } | Stop long executable agents |
22,730 | public function setMask ( $ mask , $ protect = null ) { if ( ! is_null ( $ protect ) ) { $ this -> setPregQuote ( $ protect ) ; } $ this -> mask = $ mask ; return $ this ; } | Set the mask to test for values The mask can be escaped by the preg_quote function setting the second argument on TRUE . |
22,731 | protected function buildErrorString ( ) { $ args = func_get_args ( ) ; $ error_str = array_shift ( $ args ) ; $ ref_suffix = array_shift ( $ args ) ; if ( ! empty ( $ this -> mask_reference ) ) { array_push ( $ args , $ this -> mask_reference ) ; $ error_str .= $ ref_suffix ; } array_unshift ( $ args , $ error_str ) ; return call_user_func_array ( 'sprintf' , $ args ) ; } | Build an error string adding the mask reference if known |
22,732 | public function getArguments ( $ arguments = array ( ) ) { $ _results = array ( 'original' => $ arguments , 'rebuilt' => array ( ) , 'options' => array ( ) , ) ; $ _options = array ( ) ; for ( $ _i = 0 , $ _count = count ( $ arguments ) ; $ _i < $ _count ; $ _i ++ ) { $ _argument = $ arguments [ $ _i ] ; $ _value = trim ( substr ( $ _argument , 0 , strpos ( $ _argument , '=' ) ) ) ; if ( $ _value && $ _value [ 0 ] == '-' && $ _value [ 1 ] == '-' ) { $ _options [ substr ( $ _value , 2 ) ] = str_replace ( $ _value . '=' , '' , $ _argument ) ; } elseif ( $ _value && $ _value [ 0 ] == '-' ) { $ _options [ substr ( $ _value , 1 ) ] = str_replace ( $ _value . '=' , '' , $ _argument ) ; } else { $ _results [ 'rebuilt' ] [ ] = $ arguments [ $ _i ] ; } } $ _results [ 'options' ] = $ _options ; return $ _results ; } | Processes the command line arguments |
22,733 | protected function _processArguments ( $ arguments ) { $ _className = array_shift ( $ arguments ) ; $ _options = $ this -> getArguments ( $ arguments ) ; $ arguments = array_merge ( array ( $ _className ) , $ _options [ 'rebuilt' ] ) ; $ this -> set ( $ _options ) ; return $ arguments ; } | Process arguments passed in |
22,734 | public static function sign ( RequestInterface $ request , Credentials $ credentials ) { $ signatureHeaders = [ ] ; $ base64Md5 = '' ; $ contentLength = '' ; if ( $ request -> getBody ( ) -> getSize ( ) !== 0 ) { $ base64Md5 = Hmac :: md5HashBase64 ( $ request -> getBody ( ) -> getContents ( ) ) ; $ contentLength = strlen ( ( string ) $ request -> getBody ( ) ) ; $ signatureHeaders = array_merge ( $ signatureHeaders , [ 'content-type' => $ request -> getHeader ( 'content-type' ) , 'content-md5' => $ base64Md5 , 'content-length' => $ contentLength ] ) ; } $ parsedUrl = parse_url ( $ request -> getUri ( ) ) ; $ targetUrl = $ parsedUrl [ "path" ] ; if ( ! empty ( $ parsedUrl [ "query" ] ) ) { $ targetUrl = $ targetUrl . "?" . $ parsedUrl [ "query" ] ; } $ requestLine = $ request -> getMethod ( ) . " " . $ targetUrl . " HTTP/1.1" ; $ signatureHeaders [ 'date' ] = $ date = gmdate ( "D, d M Y H:i:s" , time ( ) ) . " GMT" ; $ signatureHeaders [ 'request-line' ] = $ requestLine ; $ headersString = Hmac :: getHeadersString ( $ signatureHeaders ) ; $ signatureString = Hmac :: getSignatureString ( $ signatureHeaders ) ; $ signatureHash = Hmac :: shaHashBase64 ( $ signatureString , $ credentials -> getSecret ( ) ) ; $ authHeader = sprintf ( 'hmac username="%s", algorithm="hmac-%s", headers="%s", signature="%s"' , $ credentials -> getAccessKey ( ) , Hmac :: ALGORITHM_SHA256 , $ headersString , $ signatureHash ) ; $ request = $ request -> withHeader ( 'Authorization' , $ authHeader ) -> withHeader ( 'Date' , $ date ) ; if ( $ request -> getBody ( ) -> getSize ( ) ) { return $ request -> withHeader ( 'Content-Type' , $ request -> getHeader ( 'content-type' ) ) -> withHeader ( 'Content-MD5' , $ base64Md5 ) -> withHeader ( 'Content-Length' , $ contentLength ) ; } return $ request ; } | Signs the request with the credentials . |
22,735 | public static function shaHashBase64 ( $ signature , $ secret ) { return base64_encode ( hash_hmac ( Hmac :: ALGORITHM_SHA256 , $ signature , $ secret , true ) ) ; } | Base64 of signature hashed with HMAC using SHA hash . |
22,736 | public static function getSignatureString ( array $ signatureHeaders ) { $ signature = '' ; foreach ( $ signatureHeaders as $ header => $ value ) { if ( $ signature !== '' ) { $ signature .= "\n" ; } if ( is_array ( $ value ) ) { $ value = $ value [ 0 ] ; } $ signature = mb_strtolower ( $ header ) === "request-line" ? "{$signature}{$value}" : $ signature . mb_strtolower ( $ header ) . ": {$value}" ; } return $ signature ; } | Builds signature string used for signing of the request . |
22,737 | public function getSubdirectories ( ) { $ directories = array ( ) ; if ( $ directoryHandle = opendir ( $ this -> m_sPath ) ) { while ( false !== ( $ sFileName = readdir ( $ directoryHandle ) ) ) { if ( $ sFileName != "." && $ sFileName != ".." && ( is_dir ( $ this -> m_sPath . "/" . $ sFileName ) ) ) { array_push ( $ directories , $ sFileName ) ; } } } sort ( $ directories ) ; return $ directories ; } | Returns the subdirectories of the current directory . |
22,738 | public function createSubDirectoryIfNotExists ( $ p_sName ) { $ subdirectoryPath = $ this -> m_sPath . "/" . $ p_sName ; $ subdirectory = new MDirectory ( $ subdirectoryPath ) ; if ( ! $ subdirectory -> exists ( ) ) { mkdir ( $ subdirectoryPath ) ; } return $ subdirectory ; } | Creates a subdirectory in the present directory . |
22,739 | public function equalTo ( $ expected ) : Expect { $ this -> testsTheEqualityAgainstAValue = true ; $ this -> expected = $ expected ; return $ this ; } | Asserts that we are testing an equality against a particular value . |
22,740 | public function getDsn ( ) : string { $ _dsn = $ this -> getDriver ( ) . ':' . 'host=' . $ this -> GetHost ( ) . ';' . 'port=' . ( $ this -> GetPort ( ) != 0 ? $ this -> GetPort ( ) . ':' : '26257' ) . 'dbname=' . $ this -> GetSchema ( ) . ';' . 'sslmode=' . $ this -> getSSLMode ( ) ; $ this -> setDsn ( $ _dsn ) ; return $ this -> pdo_dsn ; } | Get DSN - CockraochDb formatting |
22,741 | protected function validateSimpleAction ( EarthIT_CMIPREST_RESTAction $ act ) { if ( $ act instanceof EarthIT_CMIPREST_RESTAction_ResourceAction ) { $ rc = $ act -> getResourceClass ( ) ; if ( ! $ rc -> hasRestService ( ) ) { throw new EarthIT_CMIPREST_ResourceNotExposedViaService ( $ act , array ( 'message' => "'" . $ rc -> getName ( ) . "' records are not exposed via services" ) ) ; } } else if ( $ act instanceof EarthIT_CMIPREST_RESTAction_InvalidAction ) { throw new EarthIT_CMIPREST_ActionInvalid ( $ act , $ act -> getErrorDetails ( ) ) ; } else { throw new EarthIT_CMIPREST_ActionInvalid ( $ act , array ( array ( 'class' => 'ClientError/ActionInvalid' , 'message' => 'Unrecognized action class: ' . get_class ( $ act ) ) ) ) ; } } | Ensure that the given action is structurally valid so that assumptions made while authorizing hold true . Will throw an exception otherwise . |
22,742 | protected function assembleSimpleResult ( $ act , $ rc , array $ items , $ ctx ) { $ assembler = $ act -> getResultAssembler ( ) ; if ( $ assembler === null ) { throw new Exception ( "No result assembler specified by " . get_class ( $ act ) ) ; } return $ assembler -> assembleResult ( new EarthIT_CMIPREST_StorageResult ( $ rc , array ( 'root' => array ( ) ) , array ( 'root' => $ items ) ) , $ act , $ ctx ) ; } | Assemble results with no johns . i . e . a simple collection of one type of objects |
22,743 | public function uploadFormAction ( Request $ request ) { $ userId = ( $ this -> getUser ( ) != null ) ? $ this -> getUser ( ) -> getId ( ) : rand ( ) ; $ partner = ( $ this -> getUser ( ) != null ) ? $ this -> getUser ( ) -> getPartner ( ) : null ; $ smDatas = $ this -> get ( 'dacorp.manager.dacorp_media' ) -> setupDacorpMediaManager ( $ userId , DacorpMediaManager :: PARTNER_MEDIA_ID ) ; if ( $ this -> getRequest ( ) -> getMethod ( ) != 'POST' ) { } $ pictureForm = $ this -> createForm ( new DacorpMediaType ( ) , $ partner , array ( 'editId' => $ smDatas [ 'editId' ] , 'existingFiles' => json_encode ( $ smDatas [ 'existingFiles' ] ) ) ) ; return array ( 'pictureFormView' => $ pictureForm -> createView ( ) , 'pictureForm' => $ pictureForm -> createView ( ) , 'smDatas' => $ smDatas ) ; } | Simple action for form Upload rendering |
22,744 | public static function addListener ( $ action , $ callback ) { if ( ! is_callable ( $ callback ) && ! is_array ( $ callback ) ) { throw new Exception ( "Invalid callback for [{$action}]" ) ; } if ( ! isset ( static :: $ listeners [ $ action ] ) ) { static :: $ listeners [ $ action ] = [ ] ; } static :: $ listeners [ $ action ] [ ] = $ callback ; } | Add a listener to the action . |
22,745 | public static function dispatch ( $ action , array $ parameters = [ ] ) { if ( isset ( static :: $ listeners [ $ action ] ) ) { foreach ( static :: $ listeners [ $ action ] as $ callback ) { $ response = call_user_func_array ( $ callback , $ parameters ) ; if ( $ response !== null ) { return $ response ; } } } } | Dispatch the event name and pass the parameters to the callbacks . |
22,746 | public static function SendContentType ( string $ mimetype = 'text/html' , string $ charset = 'utf-8' ) { if ( empty ( $ charset ) ) { \ header ( 'Content-Type: ' . $ mimetype ) ; } else { \ header ( 'Content-Type: ' . $ mimetype . '; charset=' . $ charset ) ; } } | Sends the defined Content - Type header with a optional chaset . |
22,747 | public static function SendDownloadHeader ( string $ file , int $ filesize = null ) { \ header ( 'Expires: 0' ) ; \ header ( 'Cache-Control: private' ) ; \ header ( 'Pragma: cache' ) ; \ header ( 'Content-Disposition: attachment; filename="' . \ rawurlencode ( \ basename ( $ file ) ) . '"' ) ; static :: SendContentType ( MimeTypeTool :: GetByFileName ( $ file ) , null ) ; if ( empty ( $ filesize ) && \ file_exists ( $ file ) ) { $ filesize = \ filesize ( $ file ) ; } if ( ! empty ( $ filesize ) ) { \ header ( 'Content-Length: ' . $ filesize ) ; } } | Sends all HTTP headers required to sending a file download to current client . |
22,748 | public static function SendRedirect ( $ url , int $ waitSeconds = 3 , bool $ exitHere = false ) { \ header ( "refresh:{$waitSeconds};url={$url}" ) ; if ( $ exitHere ) { exit ; } } | Send a none standards conform refresh header . Most browser supports it BUT THERE IS NO GUARANTEE that they also handle it in newer releases! |
22,749 | public static function SendLocation ( string $ path , string $ host = null , bool $ exitHere = true ) { if ( empty ( $ host ) || ! \ is_string ( $ host ) ) { if ( ! isset ( $ _SERVER [ 'HTTP_HOST' ] ) ) { exit ( 'Could not send a Location header if no host is defined!' ) ; } $ host = $ _SERVER [ 'HTTP_HOST' ] ; } \ header ( 'Location: http://' . $ host . '/' . \ ltrim ( $ path , '/' ) ) ; if ( $ exitHere ) { exit ; } } | Sends a valid HTTP Location header for doing a redirect . |
22,750 | public static function SendMultipleChoice ( string $ newLocation = null , bool $ exitHere = false ) { $ pType = static :: GetSupportedHttpVersion ( ) ; \ header ( "{$pType} 300 Multiple Choice" ) ; if ( ! empty ( $ newLocation ) ) { \ header ( "Location: {$newLocation}" ) ; exit ( ) ; } if ( $ exitHere ) { exit ; } } | Sends a 300 Multiple Choice HTTP - Header . |
22,751 | public static function SendCacheControl ( bool $ doCache = false , bool $ mustRevalidate = true ) { \ header ( 'Cache-Control: ' . ( $ doCache ? 'cache' : 'no-cache' ) . ( $ mustRevalidate ? ', must-revalidate' : '' ) ) ; } | Sends a Cache - Control HTTP header . |
22,752 | public static function SendExpires ( $ expireStamp = null ) { if ( \ is_null ( $ expireStamp ) || empty ( $ expireStamp ) ) { $ expireStamp = \ time ( ) ; } if ( \ is_int ( $ expireStamp ) ) { \ header ( 'Expires: ' . \ date ( 'D, d M Y H:i:s O' , $ expireStamp ) ) ; } else if ( $ expireStamp instanceof \ DateTimeInterface ) { \ header ( 'Expires: ' . $ expireStamp -> format ( 'D, d M Y H:i:s O' ) ) ; } else if ( TypeTool :: IsInteger ( $ expireStamp ) ) { \ header ( 'Expires: ' . \ date ( 'D, d M Y H:i:s O' , \ intval ( $ expireStamp ) ) ) ; } else if ( TypeTool :: IsStringConvertible ( $ expireStamp , $ str ) ) { $ stamp = \ strtotime ( $ str ) ; if ( $ stamp > 0 ) { \ header ( 'Expires: ' . \ date ( 'D, d M Y H:i:s O' , $ stamp ) ) ; } } } | Sends a Expires HTTP header . |
22,753 | public static function forProfile ( string $ name , ? \ Throwable $ previous = null ) : self { $ example = self :: getExample ( $ name ) ; $ message = sprintf ( "Undefined profile: %s\n%s" , $ name , $ example ) ; return new static ( $ message , $ previous ) ; } | Crea una instancia con un mensae que indica que el perfil indicado no existe |
22,754 | public static function findByExactMeta ( $ meta_key , $ meta_value , $ post_type = PostTypes :: ANY ) { return get_posts ( array ( 'post_type' => $ post_type , 'meta_key' => $ meta_key , 'meta_value' => $ meta_value ) ) ; } | Finds one or more pages by exactly matching the meta value |
22,755 | public function container ( $ name ) { if ( ! isset ( $ this -> container [ $ name ] ) ) { $ this -> container [ $ name ] = IOC :: resolve ( $ name ) ; } return $ this -> container [ $ name ] ; } | Gets an object from the container Resolves it through IOC if that didn t happen yet |
22,756 | public function load ( array $ files = null ) : ApplicationInterface { $ this -> callLoad ( $ files ) || parent :: load ( $ files ) ; return $ this ; } | Dispatch load event |
22,757 | public function execute ( string $ uri = null ) : ApplicationInterface { $ this -> callExecute ( $ uri ) || parent :: execute ( $ uri ) ; return $ this ; } | Dispatch execute event |
22,758 | public function store ( CategoryGroup $ categoryGroup , CategoryRequest $ request ) : JsonResponse { $ category = $ categoryGroup -> categories ( ) -> create ( $ request -> only ( 'icon' ) ) ; foreach ( $ request -> file ( 'icons' , [ ] ) as $ key => $ file ) { if ( $ categoryGroup -> hasFileIcon ( $ key ) && $ file ) { $ category -> icons ( ) -> create ( [ 'key' => $ key , 'icon' => $ file , ] ) ; } } $ this -> modifySlugs ( $ request ) ; $ category -> storeTranslations ( $ request -> input ( 'translations' ) ) ; if ( $ request -> has ( 'parent_id' ) && $ parent = Category :: find ( $ request -> input ( 'parent_id' ) ) ) { $ parent -> appendNode ( $ category ) ; } dispatch ( new RegenerateCategoryFullSlugs ( $ category ) ) ; $ this -> clearCache ( ) ; return response ( ) -> json ( [ 'state' => 'success' , ] ) ; } | Store category in the database . |
22,759 | public function update ( CategoryRequest $ request , CategoryGroup $ categoryGroup , Category $ category ) : JsonResponse { if ( $ category -> category_group_id !== $ categoryGroup -> id ) { abort ( 404 ) ; } $ category -> update ( $ request -> only ( 'icon' ) ) ; foreach ( $ request -> file ( 'icons' , [ ] ) as $ key => $ file ) { if ( $ categoryGroup -> hasFileIcon ( $ key ) && $ file ) { $ category -> icons ( ) -> updateOrCreate ( [ 'key' => $ key ] , [ 'icon' => $ file ] ) ; } } $ this -> modifySlugs ( $ request ) ; $ category -> updateTranslations ( $ request -> input ( 'translations' ) ) ; dispatch ( new RegenerateCategoryFullSlugs ( $ category ) ) ; $ this -> clearCache ( ) ; return response ( ) -> json ( [ 'state' => 'success' , ] ) ; } | Update category in the database . |
22,760 | public function destroy ( CategoryGroup $ categoryGroup , Category $ category ) : JsonResponse { $ categories = $ categoryGroup -> categories ( ) -> descendantsAndSelf ( $ category -> id ) ; foreach ( $ categories as $ item ) { $ item -> delete ( ) ; } ; $ this -> clearCache ( ) ; return response ( ) -> json ( [ 'state' => 'success' , ] ) ; } | Delete category and it s descendants . |
22,761 | public function updateOrder ( Request $ request ) : JsonResponse { Category :: rebuildTree ( $ request -> input ( 'tree' ) ) ; $ this -> clearCache ( ) ; $ movedNode = Category :: findOrFail ( $ request -> input ( 'moved' ) ) ; dispatch ( new RegenerateCategoryFullSlugs ( $ movedNode ) ) ; return response ( ) -> json ( [ 'state' => 'success' , ] ) ; } | Rebuild categories tree . |
22,762 | public function fetchCategories ( CategoryGroup $ categoryGroup ) { $ isTreeOpened = config ( 'netcore.module-category.tree.opened_by_default' , false ) ; $ suffixHelper = config ( 'netcore.module-category.tree.name_suffix_helper_function' , null ) ; $ language = TransHelper :: getLanguage ( ) ; $ categories = $ categoryGroup -> categories ( ) -> defaultOrder ( ) -> get ( ) ; $ categories = $ categories -> map ( function ( Category $ category ) use ( $ isTreeOpened , $ suffixHelper , $ language , $ categoryGroup ) { $ categoryName = trans_model ( $ category , $ language , 'name' ) ; if ( $ suffixHelper && function_exists ( $ suffixHelper ) ) { $ categoryName .= $ suffixHelper ( $ category ) ; } $ icons = [ ] ; if ( $ categoryGroup -> has_icons ) { $ icons = $ category -> icons -> mapWithKeys ( function ( CategoryIcon $ categoryIcon ) { return [ $ categoryIcon -> key => $ categoryIcon -> icon -> url ( ) ] ; } ) ; } return [ 'id' => $ category -> id , 'parent' => $ category -> parent_id ? : '#' , 'text' => $ categoryName , 'icon' => $ category -> icon , 'li_attr' => [ ] , 'a_attr' => [ ] , 'translations' => $ category -> translations , 'state' => [ 'opened' => $ isTreeOpened , 'disabled' => false , 'selected' => false , ] , 'icons' => $ icons , ] ; } ) ; return $ categories ; } | Get data for JsTree . |
22,763 | public static function getPageFolder ( ) { $ folder = self :: path ( ) . self :: $ pageFolder ; return rtrim ( realpath ( $ folder ) , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; } | Get the page folder |
22,764 | public static function getCacheFolder ( ) { $ folder = self :: path ( ) . self :: $ cacheFolder ; return rtrim ( realpath ( $ folder ) , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; } | Get the cache folder |
22,765 | public static function getTemplateFolder ( ) { $ folder = self :: path ( ) . self :: $ templateFolder ; return rtrim ( realpath ( $ folder ) , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; } | Get the template folder |
22,766 | static public function create_list ( $ string = NULL , $ addThis = NULL , $ delimiter = ", " ) { if ( count ( func_get_args ( ) ) > 3 ) { trigger_error ( __METHOD__ . ": argument 'useSqlQuotes' is deprecated and no longer utilized" ) ; } if ( strlen ( $ string ) ) { $ retVal = $ string . $ delimiter . $ addThis ; } else { $ retVal = $ addThis ; } return ( $ retVal ) ; } | Returns a list delimited by the given delimiter . Does the work of checking if the given variable has data in it already that needs to be added to vs . setting the variable with the new content . |
22,767 | static public function debug_print ( $ input = NULL , $ printItForMe = NULL , $ removeHR = NULL , $ usePreTags = true ) { if ( ! is_numeric ( $ removeHR ) ) { $ removeHR = ToolBox :: $ debugRemoveHr ; } if ( ! is_numeric ( $ printItForMe ) ) { $ printItForMe = ToolBox :: $ debugPrintOpt ; } ob_start ( ) ; print_r ( $ input ) ; $ output = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( $ usePreTags === true ) { $ output = "<pre class='cs debug'>$output</pre>" ; } if ( ! isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) || ! $ _SERVER [ 'SERVER_PROTOCOL' ] ) { $ output = strip_tags ( $ output ) ; $ hrString = "\n***************************************************************\n" ; } else { $ hrString = "<hr>" ; } if ( $ removeHR ) { $ hrString = NULL ; ; } if ( $ printItForMe ) { print "$output" . $ hrString . "\n" ; } return ( $ output ) ; } | A way of printing out human - readable information especially arrays & objects either to a web browser or via the command line . |
22,768 | static public function clean_url ( $ url = NULL ) { if ( strlen ( $ url ) ) { if ( defined ( 'APPURL' ) && strlen ( constant ( 'APPURL' ) ) ) { $ dropThis = preg_replace ( '/^\//' , '' , constant ( 'APPURL' ) ) ; $ dropThis = preg_replace ( '/\//' , '\\/' , $ dropThis ) ; $ url = preg_replace ( '/^' . $ dropThis . '/' , '' , $ url ) ; } if ( $ url [ 0 ] == '/' ) { $ url = substr ( $ url , 1 , strlen ( $ url ) ) ; } if ( $ url [ strlen ( $ url ) - 1 ] == '/' ) { $ url = substr ( $ url , 0 , strlen ( $ url ) - 1 ) ; } if ( preg_match ( '/\?/' , $ url ) ) { $ url = preg_split ( '/\?/' , $ url ) ; $ url = $ url [ 0 ] ; } if ( preg_match ( "/\./" , $ url ) ) { $ tArr = explode ( '/' , $ url ) ; $ tUrl = null ; foreach ( $ tArr as $ tUrlPart ) { $ temp = explode ( "." , $ tUrlPart ) ; if ( strlen ( $ temp [ 0 ] ) ) { $ tUrlPart = $ temp [ 0 ] ; } $ tUrl = ToolBox :: create_list ( $ tUrl , $ tUrlPart , '/' ) ; } $ url = $ tUrl ; } } else { $ url = null ; } return ( $ url ) ; } | Removes all the crap from the url so we can figure out what section we need to load templates & includes for . |
22,769 | protected function invokeSetter ( ReflectionProperty $ property , $ value ) : void { $ methodName = $ this -> generateSetterName ( $ property -> getName ( ) ) ; if ( $ this -> hasInternalMethod ( $ methodName ) ) { $ this -> $ methodName ( $ value ) ; return ; } throw new UndefinedPropertyException ( sprintf ( 'No "%s"() method available for property "%s"' , $ methodName , $ property -> getName ( ) ) ) ; } | Invoke the given property s setter - method |
22,770 | private static function getYears ( ) : array { $ years = [ - 1 => static :: getConstant ( 'TXT_DATETIME_YYYY' , 'TXT_DATETIME_YYYY' ) ] ; for ( $ i = 1978 ; $ i <= 2037 ; $ i ++ ) { $ years [ $ i ] = $ i ; } return $ years ; } | Returns years array |
22,771 | private static function getMonths ( ) : array { $ months = [ - 1 => static :: getConstant ( 'TXT_DATETIME_MMM' , 'TXT_DATETIME_MMM' ) ] ; for ( $ i = 1 ; $ i <= 12 ; $ i ++ ) { $ months [ $ i ] = static :: getConstant ( 'TXT_DATETIME_MONTH_' . $ i . '_SHORT' , 'TXT_DATETIME_MONTH_' . $ i . '_SHORT' ) ; } return $ months ; } | Returns months array |
22,772 | private static function getDays ( int $ maxDays = 31 ) : array { $ days = [ - 1 => static :: getConstant ( 'TXT_DATETIME_DD' , 'TXT_DATETIME_DD' ) ] ; for ( $ i = 1 ; $ i <= $ maxDays ; $ i ++ ) { $ days [ $ i ] = \ sprintf ( '%02s' , $ i ) ; } return $ days ; } | Returns days array |
22,773 | private static function getHours ( ) : array { $ hours = [ - 1 => static :: getConstant ( 'TXT_DATETIME_HH' , 'TXT_DATETIME_HH' ) ] ; for ( $ i = 0 ; $ i <= 23 ; $ i ++ ) { $ hours [ $ i ] = \ sprintf ( '%02s' , $ i ) ; } return $ hours ; } | Returns hours array |
22,774 | private static function getMinutes ( ) : array { $ minutes = [ - 1 => static :: getConstant ( 'TXT_DATETIME_II' , 'TXT_DATETIME_II' ) ] ; for ( $ i = 0 ; $ i <= 59 ; $ i ++ ) { $ minutes [ $ i ] = \ sprintf ( '%02s' , $ i ) ; } return $ minutes ; } | Returns minutes array |
22,775 | private static function getSeconds ( ) : array { $ seconds = [ - 1 => static :: getConstant ( 'TXT_DATETIME_SS' , 'TXT_DATETIME_SS' ) ] ; for ( $ i = 0 ; $ i <= 59 ; $ i ++ ) { $ seconds [ $ i ] = \ sprintf ( '%02s' , $ i ) ; } return $ seconds ; } | Returns seconds array |
22,776 | public static function getDefault ( ) { $ smtp = new self ( config ( 'mail.host' ) , config ( 'mail.port' ) , config ( 'mail.encryption' ) , config ( 'mail.username' ) , config ( 'mail.password' ) , config ( 'mail.from' ) [ 'adresse' ] , config ( 'mail.from' ) [ 'name' ] ) ; return $ smtp ; } | Init the SMTP class by getting gefualt values from Config surface . |
22,777 | private static function check ( $ smtp ) { exception_if ( empty ( $ smtp -> host ) , SmtpParameterNotFoundException :: class , 'host' ) ; exception_if ( empty ( $ smtp -> port ) , SmtpParameterNotFoundException :: class , 'port' ) ; exception_if ( empty ( $ smtp -> encryption ) , SmtpParameterNotFoundException :: class , 'encryption' ) ; exception_if ( empty ( $ smtp -> username ) , SmtpParameterNotFoundException :: class , 'username' ) ; exception_if ( empty ( $ smtp -> password ) , SmtpParameterNotFoundException :: class , 'password' ) ; exception_if ( empty ( $ smtp -> sender_email ) , SmtpParameterNotFoundException :: class , 'sender email' ) ; exception_if ( empty ( $ smtp -> sender_name ) , SmtpParameterNotFoundException :: class , 'sender name' ) ; return true ; } | Check if SMTP configurated . |
22,778 | private function createEditForm ( Category $ entity ) { $ form = $ this -> createForm ( $ this -> get ( "amulen.classification.form.category" ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_category_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; } | Creates a form to edit a Category entity . |
22,779 | protected function mapRoutes ( ) { $ this -> app [ 'events' ] -> listen ( 'kernel.handling' , function ( ) { $ file_route = app_path ( 'routes.php' ) ; if ( files ( ) -> exists ( $ file_route ) ) { require $ file_route ; } router ( ) -> group ( [ 'middleware' => [ 'web' ] ] , function ( Router $ router ) { event ( ) -> fire ( new PublicRegisterRoutes ( $ router ) ) ; event ( ) -> fire ( new PublicTenantRegisterRoutes ( $ router ) ) ; event ( ) -> fire ( new PrivateRegisterRoutes ( $ router ) ) ; } ) ; router ( ) -> group ( [ 'middleware' => [ 'api' ] , 'prefix' => 'api' ] , function ( Router $ router ) { event ( ) -> fire ( new ApiRegisterRoutes ( $ router ) ) ; } ) ; } ) ; } | Mapear as rotas do sistema . |
22,780 | protected function shareRequestInUrl ( ) { $ this -> app [ 'events' ] -> listen ( 'Illuminate\Routing\Events\RouteMatched' , function ( RouteMatched $ event ) { foreach ( $ event -> route -> parameters ( ) as $ k => $ v ) { $ this -> app [ 'url' ] -> share ( $ k , $ v ) ; } } ) ; } | Register request params in url . |
22,781 | public function getModel ( ) { $ namePath = $ this -> getModelClass ( ) ; $ model = new $ namePath ( ) ; if ( ! ( $ model instanceof EntityDataModel ) ) { throw new \ Exception ( $ this -> valueClass . ' is not an instance of EntityModel.' ) ; } return $ model ; } | Model Factory . |
22,782 | public function addEntity ( $ entity ) { $ this -> collection [ ] = $ entity ; $ this -> setCount ( count ( $ this -> collection ) ) ; return $ this ; } | Adds a single entity . |
22,783 | private static function summariseArray ( array $ var , $ depth = 1 ) { static $ depth = 1 ; if ( $ depth == 2 ) { return 'Array(' . count ( $ var ) . ')' ; } elseif ( ( $ count = count ( $ var ) ) > 0 ) { $ key = array_keys ( $ var ) ; $ key = $ key [ 0 ] ; $ value = array_values ( $ var ) ; $ value = $ value [ 0 ] ; $ mask = 'Array(%1$s){' ; if ( is_string ( $ key ) ) { $ mask .= '%2$s: ' ; } $ mask .= '%3$s}' ; $ depth = 2 ; $ return = sprintf ( $ mask , $ count , $ key , self :: summarise ( $ value ) ) ; $ depth = 1 ; return $ return ; } return 'Array(0){}' ; } | Summarises an array |
22,784 | public function loadDomainCode ( string $ domainName ) { $ domainClassName = DomainActionNameGenerator :: getDomainClassName ( $ domainName ) ; return $ this -> load ( $ this -> domainsPath . "/" . $ domainClassName . ".php" ) ; } | Load code from a specified ClassDomain |
22,785 | public function addEvent ( $ event , $ callable ) { if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s expects parameter 2 to be callable, %s given: %s' , __METHOD__ , gettype ( $ callable ) , print_r ( $ callable , true ) ) ) ; } if ( ! isset ( $ this -> events [ $ event ] ) ) { $ this -> events [ $ event ] = array ( ) ; } $ this -> events [ $ event ] [ ] = $ callable ; } | Add an event and its callback |
22,786 | public function initWebSocketServer ( ) { $ webSocketServer = $ this -> getWebSocketServer ( ) ; $ webSocketServer -> setLogger ( $ this -> getLogger ( ) ) ; if ( $ this -> getNodeClass ( ) !== null ) { $ webSocketServer -> getConnection ( ) -> setNodeName ( $ this -> getNodeClass ( ) ) ; } $ socket = $ webSocketServer -> getConnection ( ) -> getSocket ( ) ; $ this -> getLogger ( ) -> log ( '<fg=yellow>Starting server...</fg=yellow>' ) ; $ this -> getLogger ( ) -> log ( 'Environment: <fg=green>%s</fg=green>' , $ this -> kernelEnvironment ) ; $ this -> getLogger ( ) -> log ( 'Class used:' ) ; $ this -> getLogger ( ) -> log ( ' Logger : %s' , get_class ( $ this -> getLogger ( ) ) ) ; $ this -> getLogger ( ) -> log ( ' Runner : %s' , get_class ( $ this ) ) ; $ this -> getLogger ( ) -> log ( ' WebSocket Server : %s' , get_class ( $ webSocketServer ) ) ; $ this -> getLogger ( ) -> log ( ' Socket Server : %s' , get_class ( $ socket ) ) ; $ this -> getLogger ( ) -> log ( ' Node : %s' , ltrim ( $ webSocketServer -> getConnection ( ) -> getNodeName ( ) , '\\' ) ) ; $ this -> getLogger ( ) -> log ( '<fg=yellow>Listening on %s:%d</fg=yellow>' , $ socket -> getAddress ( ) , $ socket -> getPort ( ) ) ; $ webSocketServer -> on ( 'open' , xcallable ( $ this , 'onOpen' ) ) ; $ webSocketServer -> on ( 'message' , xcallable ( $ this , 'onMessage' ) ) ; $ webSocketServer -> on ( 'binary-message' , xcallable ( $ this , 'onBinaryMessage' ) ) ; $ webSocketServer -> on ( 'ping' , xcallable ( $ this , 'onPing' ) ) ; $ webSocketServer -> on ( 'error' , xcallable ( $ this , 'onError' ) ) ; $ webSocketServer -> on ( 'close' , xcallable ( $ this , 'onClose' ) ) ; $ this -> loadEvents ( ) ; return $ webSocketServer ; } | Initialize WebSocket server |
22,787 | public function launchModuleAction ( $ event , Module \ ModuleInterface $ module , $ method , Bucket $ bucket , $ additionnalData = null ) { $ module -> setBucket ( $ bucket ) ; return call_user_func ( array ( $ module , $ method ) , $ additionnalData ) ; } | Launch module action |
22,788 | public function onError ( Bucket $ bucket ) { $ data = $ bucket -> getData ( ) ; if ( isset ( $ data [ 'exception' ] ) && $ data [ 'exception' ] instanceof Quit ) { throw $ data [ 'exception' ] ; } $ this -> onEvent ( 'error' , $ bucket ) ; } | Fire a error event |
22,789 | public function run ( ) { try { $ this -> initWebSocketServer ( ) -> run ( ) ; return true ; } catch ( Exception \ Quit $ e ) { $ this -> getLogger ( ) -> success ( $ e -> getMessage ( ) ) ; return true ; } catch ( \ Exception $ e ) { $ traces = array_reverse ( explode ( PHP_EOL , $ e -> getTraceAsString ( ) ) ) ; foreach ( $ traces as $ key => $ trace ) { $ trace = explode ( ' ' , $ trace , 2 ) ; $ traces [ $ key ] = sprintf ( '#%s > %s' , str_pad ( $ key + 1 , strlen ( count ( $ traces ) ) , '0' , STR_PAD_LEFT ) , $ trace [ 1 ] ) ; } $ this -> getLogger ( ) -> error ( "%s: %s\n%s" , get_class ( $ e ) , $ e -> getMessage ( ) , implode ( "\n" , $ traces ) ) ; return false ; } } | Run this server |
22,790 | public function write ( $ content = '' ) { $ content = preg_split ( '/\R/' , $ content ) ; foreach ( $ content as $ line ) { $ this -> source .= PHP_EOL . str_repeat ( ' ' , $ this -> depth ) . $ line ; } return $ this ; } | Write a new line of code . The new line is added before the content . A block of code can also be wrote in one shot . |
22,791 | public function string ( $ string , $ singleLine = false ) { $ string = sprintf ( '"%s"' , addcslashes ( $ string , "\0\t\"\$\\" ) ) ; if ( $ singleLine === true ) { $ string = preg_replace ( '/\n/' , '\n' , $ string ) ; } $ this -> source .= $ string ; return $ this ; } | Adds a string to the source code . |
22,792 | public function checkDisk ( $ fixErrors = false , $ vigorousIndexCheck = true , $ skipFolderCycle = true , $ forceDismount = false , $ recoverBadSectors = false , $ runAtBootup = false ) { $ result = $ this -> variant -> chkdsk ( $ fixErrors , $ vigorousIndexCheck , $ skipFolderCycle , $ forceDismount , $ recoverBadSectors , $ runAtBootup ) ; switch ( $ result ) { case 0 : return true ; case 1 : return true ; } return false ; } | Invokes the Chkdsk operation on the current volume . |
22,793 | public function contentBlockFilter ( $ defaultContent , $ name , $ type = 'line' , $ locale = null , $ useLocaleFallback = null ) { $ block = $ this -> contentService -> getOrCreateContentBlock ( $ name , $ locale , $ useLocaleFallback , $ type , $ defaultContent ) ; if ( null === $ locale || ( null !== $ this -> translator && $ this -> translator -> getLocale ( ) == $ locale ) ) { return $ this -> renderContent ( $ block ) ; } return '' ; } | Fetch content block with the given default content and name . This allows to wrap existing content with a filter block . |
22,794 | protected function renderContent ( ContentBlock $ block ) { $ content = $ block -> getContent ( ) ; switch ( $ block -> getType ( ) ) { case 'line' : $ content = htmlspecialchars ( $ content ) ; break ; case 'text' : $ content = htmlspecialchars ( $ content ) ; $ content = str_replace ( "\n" , '<br>' , $ content ) ; break ; case 'markdown' : $ content = $ this -> markdownHelper -> transform ( $ content ) ; break ; case 'html' : break ; default : throw new \ InvalidArgumentException ( 'Unknown content block type: ' . $ block -> getType ( ) ) ; } return $ content ; } | Render the given ContentBlock HTML - escaping the content where necessary . |
22,795 | public function contentBlockFilterLine ( $ defaultContent , $ name , $ locale = null , $ useLocaleFallback = null ) { return $ this -> contentBlockFilter ( $ defaultContent , $ name , 'line' , $ locale , $ useLocaleFallback ) ; } | Shortcut to contentBlockFilter using line rendering . |
22,796 | public function contentBlockFilterText ( $ defaultContent , $ name , $ locale = null , $ useLocaleFallback = null ) { return $ this -> contentBlockFilter ( $ defaultContent , $ name , 'text' , $ locale , $ useLocaleFallback ) ; } | Shortcut to contentBlockFilter using text rendering . |
22,797 | public function contentBlockFilterMarkdown ( $ defaultContent , $ name , $ locale = null , $ useLocaleFallback = null ) { return $ this -> contentBlockFilter ( $ defaultContent , $ name , 'markdown' , $ locale , $ useLocaleFallback ) ; } | Shortcut to contentBlockFilter using markdown rendering . |
22,798 | public function contentBlockFilterHtml ( $ defaultContent , $ name , $ locale = null , $ useLocaleFallback = null ) { return $ this -> contentBlockFilter ( $ defaultContent , $ name , 'html' , $ locale , $ useLocaleFallback ) ; } | Shortcut to contentBlockFilter using html rendering . |
22,799 | public function getNextNumber ( ) { if ( 0 === ( int ) $ this -> countTotal ( ) ) { return 1 ; } $ qb = $ this -> getQueryBuilder ( ) -> select ( 'MAX(i.invoiceNumber) + 1' ) ; return $ qb -> getQuery ( ) -> getSingleScalarResult ( ) ; } | Get next invoice number |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.