idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
56,000
|
private function writeLabels ( ) { $ this -> beginBatch ( ) ; foreach ( $ this -> nodeEntities as $ node ) { $ meta = $ this -> getMeta ( $ node ) ; $ label = $ this -> client -> makeLabel ( $ meta -> getName ( ) ) ; $ this -> everymanNodeCache [ $ this -> getHash ( $ node ) ] -> addLabels ( array ( $ label ) ) ; } $ this -> commitBatch ( ) ; }
|
Writes labels for every node that was saved or updated .
|
56,001
|
public function createIndex ( $ className ) { $ meta = $ this -> metaRepository -> fromClass ( $ className ) ; if ( $ meta instanceof NodeMeta ) { return new NodeIndex ( $ this -> client , $ className ) ; } else { return new RelationshipIndex ( $ this -> client , $ className ) ; } }
|
Creates a Everyman index based on the class name supplied .
|
56,002
|
private function index ( $ entity ) { $ meta = $ this -> getMeta ( $ entity ) ; $ class = $ meta -> getName ( ) ; $ index = $ this -> getRepository ( $ class ) -> getIndex ( ) ; if ( $ meta instanceof NodeMeta ) { $ en = $ this -> getEverymanNode ( $ entity ) ; } else { $ en = $ this -> getEverymanRelation ( $ entity ) ; } foreach ( $ meta -> getIndexedProperties ( ) as $ property ) { $ index -> add ( $ en , $ property -> getName ( ) , $ property -> getValue ( $ entity ) ) ; } $ pk = $ meta -> getPrimaryKey ( ) ; $ name = $ pk -> getName ( ) ; $ id = $ pk -> getValue ( $ entity ) ; $ index -> add ( $ en , $ name , $ id ) ; }
|
Adds indexes for the entity to the indexes stored in the classes repository .
|
56,003
|
private function writeIndexes ( ) { $ this -> beginBatch ( ) ; foreach ( $ this -> nodeEntities as $ entity ) { $ this -> index ( $ entity ) ; } foreach ( $ this -> relationEntities as $ entity ) { $ this -> index ( $ entity ) ; } foreach ( $ this -> repositories as $ repository ) { $ repository -> writeIndex ( ) ; } $ this -> commitBatch ( ) ; }
|
Writes index information to the database .
|
56,004
|
public function getRepository ( $ class ) { if ( ! isset ( $ this -> repositories [ $ class ] ) ) { $ meta = $ this -> metaRepository -> fromClass ( $ class ) ; $ repositoryClass = $ meta -> getRepositoryClass ( ) ; $ repository = new $ repositoryClass ( $ this , $ meta ) ; if ( ! ( $ repository instanceof Repository ) ) { throw new Exception ( "Requested repository class $repositoryClass does not extend the base repository class." ) ; } $ this -> repositories [ $ class ] = $ repository ; } return $ this -> repositories [ $ class ] ; }
|
Obtain the entity repository for the specified class .
|
56,005
|
public function loadNode ( $ node ) { if ( ! isset ( $ this -> nodeProxyCache [ $ node -> getId ( ) ] ) ) { $ labels = $ this -> client -> getLabels ( $ node ) ; $ class = $ labels [ 0 ] -> getName ( ) ; $ entity = $ this -> proxyFactory -> fromNode ( $ node , $ this -> metaRepository , $ class ) ; $ this -> nodeProxyCache [ $ node -> getId ( ) ] = $ entity ; $ this -> everymanNodeCache [ $ this -> getHash ( $ entity ) ] = $ node ; } return $ this -> nodeProxyCache [ $ node -> getId ( ) ] ; }
|
Loads a node using a proxy .
|
56,006
|
public function loadRelation ( $ relation ) { if ( ! isset ( $ this -> relationProxyCache [ $ relation -> getId ( ) ] ) ) { $ em = $ this ; $ entity = $ this -> proxyFactory -> fromRelation ( $ relation , $ this -> metaRepository , function ( $ node ) use ( $ em ) { return $ em -> loadNode ( $ node ) ; } ) ; $ this -> relationProxyCache [ $ relation -> getId ( ) ] = $ entity ; $ this -> everymanRelationCache [ $ this -> getHash ( $ entity ) ] = $ relation ; } return $ this -> relationProxyCache [ $ relation -> getId ( ) ] ; }
|
Loads a relation using a proxy .
|
56,007
|
public function reload ( $ entity ) { $ hash = $ this -> getHash ( $ entity ) ; $ meta = $ this -> getMeta ( $ entity ) ; $ id = $ meta -> getPrimaryKey ( ) -> getValue ( $ entity ) ; if ( $ meta instanceof NodeMeta ) { if ( isset ( $ this -> everymanNodeCache [ $ hash ] ) ) { return $ this -> loadNode ( $ this -> everymanNodeCache [ $ hash ] ) ; } elseif ( $ id ) { $ node = $ this -> client -> getNode ( $ id ) ; return $ this -> loadNode ( $ node ) ; } else { throw new Exception ( 'Cannot reload an unsaved node.' ) ; } } else { if ( isset ( $ this -> everymanRelationCache [ $ hash ] ) ) { return $ this -> loadRelation ( $ this -> everymanRelationCache [ $ hash ] ) ; } elseif ( $ id ) { $ rel = $ this -> client -> getRelationship ( $ id ) ; return $ this -> loadRelation ( $ rel ) ; } else { throw new Exception ( 'Cannot reload an unsaved relation.' ) ; } } }
|
Reload an entity . Exchanges an raw entity or an invalid proxy with an initialized proxy .
|
56,008
|
private function triggerEvent ( $ eventName , $ data ) { if ( isset ( $ this -> eventHandlers [ $ eventName ] ) ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; foreach ( $ this -> eventHandlers [ $ eventName ] as $ callback ) { $ clone = $ args ; call_user_func_array ( $ callback , $ clone ) ; } } }
|
Triggers an event held in the evertHandlers array .
|
56,009
|
public function cypherQuery ( $ string , $ parameters ) { try { $ start = microtime ( true ) ; $ query = new InternalCypherQuery ( $ this -> client , $ string , $ parameters ) ; $ rs = $ query -> getResultSet ( ) ; $ time = microtime ( true ) - $ start ; $ this -> triggerEvent ( self :: QUERY_RUN , $ query , $ parameters , $ time ) ; return $ rs ; } catch ( EverymanException $ e ) { $ message = $ e -> getMessage ( ) ; preg_match ( '/\[message\] => (.*)/' , $ message , $ parts ) ; throw new Exception ( 'Query execution failed: ' . $ parts [ 1 ] , 0 , $ e , $ query ) ; } }
|
Raw cypher query execution .
|
56,010
|
private function commitBatch ( ) { if ( count ( $ this -> batch -> getOperations ( ) ) ) { $ this -> client -> commitBatch ( ) ; } else { $ this -> client -> endBatch ( ) ; } $ this -> batch = null ; }
|
Commits a database batch .
|
56,011
|
protected function checkProperties ( ) { if ( ! $ this -> getRequestReader ( ) instanceof RequestReader ) { $ this -> throwException ( 'Class for RequestReader should be inherit from "%baseClass%" ' . '(see SmartLoad option/property "%option%")' , array ( '%baseClass%' => RequestReader :: className ( ) , '%option%' => 'requestReaderClassName' ) ) ; } $ supportedHashAlgorithms = hash_algos ( ) ; if ( is_string ( $ this -> hashMethod ) && ! in_array ( $ this -> hashMethod , $ supportedHashAlgorithms ) ) { $ this -> throwException ( 'Incorrect hashing method (see SmartLoad option/property "%option%"). ' . 'Supported hash algorithms: %hashAlgorithms% ' , array ( '%hashAlgorithms%' => join ( ', ' , $ supportedHashAlgorithms ) , '%option%' => 'hashMethod' ) ) ; } }
|
Checks properties values
|
56,012
|
protected function shouldBeLoaded ( $ resource , array $ excludeList ) { if ( in_array ( '*' , $ excludeList ) ) { return false ; } $ possibleEntries = array ( $ resource , $ this -> hashString ( $ resource ) ) ; if ( $ baseName = basename ( $ resource ) ) { $ possibleEntries [ ] = $ baseName ; } return ( count ( array_intersect ( $ possibleEntries , $ this -> alwaysReloadableResources ) ) > 0 ) || ( count ( array_intersect ( $ possibleEntries , $ excludeList ) ) === 0 ) ; }
|
Checks should be loaded given resource
|
56,013
|
protected function _cancelOrder ( ) { if ( $ this -> _order -> getId ( ) ) { $ this -> _order -> cancel ( ) -> save ( ) ; } else { $ this -> _order -> setState ( Mage_Sales_Model_Order :: STATE_CANCELED ) ; } return $ this ; }
|
Cancel the order if is in the current Magento store otherwise simply set the state of the order to a state of canceled .
|
56,014
|
protected function _logResponse ( ) { $ logMessage = "Order could not be canceled ROM order cancel response return this status '{$this->_response->getResponseStatus()}'." ; $ this -> _logger -> warning ( $ logMessage , $ this -> _logContext -> getMetaData ( __CLASS__ ) ) ; return $ this ; }
|
Log order cancel response status .
|
56,015
|
protected function displayInner ( ) { if ( $ this -> _template ) { extract ( $ this -> _vars ) ; include ( $ this -> _template ) ; } else { foreach ( $ this -> _vars as & $ child ) if ( $ child instanceof Component ) $ child -> display ( ) ; else echo $ child ; } }
|
This mechanism allows two stage display
|
56,016
|
public function getNestedGraph ( ) : NestedGraph { return $ this -> nestedGraph !== null ? $ this -> nestedGraph : ( $ this -> nestedGraph = $ this -> getRootGraph ( ) -> createNestedGraph ( $ this ) ) ; }
|
Get nested graph of this node . The graph is created if the node does not have any .
|
56,017
|
public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; if ( ! is_array ( $ controller ) ) { return ; } if ( $ controller [ 0 ] instanceof ResourceControllerInterface || $ controller [ 0 ] instanceof DashboardController ) { $ this -> aclOperator -> loadAcls ( ) ; } }
|
Kernel controller event handler .
|
56,018
|
public function current ( $ file = null ) { $ splFileInfo = $ file ? : parent :: current ( ) ; return $ this -> transformer -> transform ( $ splFileInfo ) ; }
|
Return the transformed file
|
56,019
|
public function getIterator ( ) { if ( is_null ( $ this -> iterator ) ) { $ finder = $ this -> finderFactory -> createFinder ( ) ; $ finder -> files ( ) -> in ( $ this -> path ) ; if ( false === empty ( $ this -> extensions ) ) { $ finder -> name ( $ this -> getExtensionsRegex ( ) ) ; } $ this -> iterator = $ finder -> getIterator ( ) ; } return $ this -> iterator ; }
|
Returns the iterator to be used as the inner iterator
|
56,020
|
protected function getExtensionsRegex ( ) { $ regex = '' ; $ last = count ( $ this -> extensions ) - 1 ; foreach ( $ this -> extensions as $ index => $ ext ) { $ regex .= '\.' . $ ext . '$' ; $ regex .= $ index !== $ last ? '|' : '' ; } return '(' . $ regex . ')' ; }
|
Returns regex used to filter files
|
56,021
|
public function isEmptyChanges ( ) { foreach ( $ this -> originals as $ name => $ orignial ) { if ( $ this -> hasChange ( $ name ) ) { return false ; } } return true ; }
|
Check if there are any changes
|
56,022
|
protected function logError ( $ message , $ severity = 0 , $ name = '' ) { if ( '' == $ name ) { $ this -> error [ ] = $ message ; } else { $ this -> error [ $ name ] = $ message ; } if ( $ severity > 0 ) { $ this -> logger -> log ( $ severity , $ message ) ; } }
|
Add an error to the array of errors . If a severity is entered the error will also be logged through the logging mechanism .
|
56,023
|
public function mimeType ( ) { if ( ! is_null ( $ this -> type ) ) { return $ this -> type ; } $ this -> downloadFile ( ) ; $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ finfo , $ this -> downloadFilePath ( ) ) ; finfo_close ( $ finfo ) ; return $ this -> type = $ mime ; }
|
Method that returns the MIME type of the download file .
|
56,024
|
public function setName ( $ name ) { $ pathinfo = pathinfo ( $ name ) ; $ filename = $ pathinfo [ 'filename' ] ; $ this -> name = $ filename . '.' . $ this -> extension ( ) ; return $ this ; }
|
Set the name for the download file
|
56,025
|
public function setDownloadDir ( $ dir ) { if ( is_null ( $ dir ) ) { return $ this ; } if ( ! is_dir ( $ dir ) ) { throw new \ Th \ FileDownloader \ Exceptions \ DownloadException ( \ Th \ FileDownloader :: INVALID_DOWNLOAD_DIR ) ; } $ this -> downloadDir = $ dir ; return $ this ; }
|
Method that sets the destination download directory . It checks if the requested directory is a valid directory if not it throws a new DownloadException .
|
56,026
|
public function validateFileType ( ) { if ( is_null ( $ this -> allowedTypes ( ) ) ) { return true ; } if ( ! is_array ( $ this -> allowedTypes ( ) ) || ! in_array ( $ this -> mimeType ( ) , $ this -> allowedTypes ( ) ) ) { throw new \ Th \ FileDownloader \ Exceptions \ DownloadException ( \ Th \ FileDownloader :: FILE_WRONG_MIME ) ; } return true ; }
|
Method that checks if the download file is of the allowed MIME type .
|
56,027
|
public function validateExtension ( ) { if ( is_null ( $ this -> allowedExtensions ( ) ) ) { return true ; } if ( ! is_array ( $ this -> allowedExtensions ( ) ) || ! in_array ( $ this -> extension ( ) , $ this -> allowedExtensions ( ) ) ) { throw new \ Th \ FileDownloader \ Exceptions \ DownloadException ( \ Th \ FileDownloader :: FILE_WRONG_EXTENSION ) ; } return true ; }
|
Method that checks if the download file is of the allowed extension .
|
56,028
|
public function download ( ) { $ this -> validateExtension ( ) ; $ this -> downloadFile ( ) ; try { $ this -> validateFileType ( ) ; } catch ( Exception $ exception ) { unlink ( $ this -> downloadFilePath ( ) ) ; throw $ exception ; } return true ; }
|
Method that downloads the file
|
56,029
|
protected function parse ( $ url ) { $ this -> url = $ url ; $ urlParsed = parse_url ( $ url ) ; $ pathinfo = pathinfo ( $ urlParsed [ 'path' ] ) ; $ this -> nameOriginal = $ pathinfo [ 'filename' ] ; $ this -> extension = $ pathinfo [ 'extension' ] ; return $ this ; }
|
Set the url original name and original extension based on the download url
|
56,030
|
protected function downloadFile ( ) { if ( file_exists ( $ this -> downloadFilePath ( ) ) ) { return ; } $ file = file_get_contents ( $ this -> url ( ) ) ; if ( $ file === false ) { throw new \ Th \ FileDownloader \ Exceptions \ DownloadException ( 99 ) ; } $ downloadResult = file_put_contents ( $ this -> downloadFilePath ( ) , $ file ) ; if ( $ downloadResult === false ) { throw new \ Th \ FileDownloader \ Exceptions \ DownloadException ( 99 ) ; } }
|
Helper function to download the file
|
56,031
|
public function setHeader ( $ name , $ value , $ override = true ) { if ( $ override == false ) { if ( array_key_exists ( $ name , $ this -> headers ) ) { return $ this ; } } $ this -> headers [ $ name ] = $ value ; }
|
Set a single response header
|
56,032
|
public function sendHeaders ( ) { $ codes = $ this -> getHttpResponseCodes ( ) ; if ( ! array_key_exists ( $ this -> status , $ codes ) ) { $ this -> status = 500 ; $ string = 'HTTP/1.0 500 ' . $ codes [ 500 ] ; } else { if ( $ this -> isValidRedirectStatus ( ) ) { throw new \ Exception ( 'You cannot send a redirect using a regular response. Use $this->response->redirect(url, status);' ) ; } $ string = 'HTTP/1.0 ' . $ this -> status . ' ' . $ codes [ $ this -> status ] ; } header ( $ string ) ; $ this -> outputHeaders ( ) ; }
|
Send the HTTP Response Headers
|
56,033
|
public function hasAllRequiredModules ( ) { $ required = $ this -> getRequiredModules ( ) ; $ available = array_keys ( $ this -> module -> getList ( ) ) ; $ difference = array_diff ( $ required , array_intersect ( $ required , $ available ) ) ; return empty ( $ difference ) ; }
|
Whether the current distribution contains all the required modules
|
56,034
|
public function installModules ( ) { foreach ( $ this -> getRequiredModules ( ) as $ module_id ) { if ( $ this -> getModuleModel ( ) -> install ( $ module_id ) !== true ) { $ error = $ this -> translation -> text ( 'Failed to install module @module_id' , array ( '@module_id' => $ module_id ) ) ; throw new RuntimeException ( $ error ) ; } } return true ; }
|
Install all required modules
|
56,035
|
public function setBaseService ( $ response , $ dbService , $ request ) { $ this -> response = $ response ; ini_set ( "log_errors_max_len" , 0 ) ; if ( $ dbService != null ) { $ this -> entityManager = $ dbService -> getEntityManager ( ) ; } $ this -> request = $ request ; }
|
We use this method to let user set their own constructor with injection
|
56,036
|
public static function register ( $ debug = false ) { if ( $ debug && class_exists ( '\Whoops\Run' ) ) { $ whoops = new \ Whoops \ Run ( ) ; $ whoops -> pushHandler ( new \ Whoops \ Handler \ PrettyPageHandler ( ) ) ; $ whoops -> register ( ) ; return ; } set_error_handler ( [ static :: class , 'errorHandler' ] , - 1 ) ; set_exception_handler ( [ static :: class , 'exceptionHandler' ] ) ; register_shutdown_function ( [ static :: class , 'shutdownHandler' ] ) ; }
|
Registers error handling functions .
|
56,037
|
public static function exceptionHandler ( \ Throwable $ throwable ) { self :: showError ( $ throwable ) ; Log :: error ( ( string ) $ throwable ) ; }
|
Exception handler . Shows error & log it .
|
56,038
|
private function createStringToSign ( $ self_key , $ client_id , $ scope , $ context ) { $ s2s = sprintf ( "SIGNER-HMAC-%s\n%s\n%s\n%s\n%s" , strtoupper ( $ this -> hash_algo ) , $ self_key , $ client_id , hash ( $ this -> hash_algo , $ scope ) , hash ( $ this -> hash_algo , $ context ) ) ; $ this -> logger -> debug ( __FUNCTION__ , [ 'string_to_sign' => $ s2s , ] ) ; return $ s2s ; }
|
Creates the string - to - sign based on a variety of factors .
|
56,039
|
private function createContext ( array $ payload ) { $ canonical_payload = [ ] ; foreach ( $ payload as $ k => $ v ) { $ k = strtolower ( $ k ) ; $ v = strtolower ( $ v ) ; $ canonical_payload [ $ k ] = sprintf ( '%s=%s' , $ k , $ v ) ; } ksort ( $ canonical_payload ) ; $ signed_headers_string = implode ( ';' , array_keys ( $ canonical_payload ) ) ; $ canonical_context = implode ( "\n" , $ canonical_payload ) . "\n\n" . $ signed_headers_string ; $ this -> logger -> debug ( __FUNCTION__ , [ 'payload' => $ payload , 'canonical_payload' => $ canonical_payload , 'signed_headers_string' => $ signed_headers_string , 'canonical_context' => $ canonical_context , ] ) ; return $ canonical_context ; }
|
An array of key - value pairs representing the data that you want to sign . All values must be scalar .
|
56,040
|
private function getSigningSalt ( $ self_key , $ client_id , $ client_secret ) { $ self_key_sign = hash_hmac ( $ this -> hash_algo , $ self_key , $ client_secret , true ) ; $ client_id_sign = hash_hmac ( $ this -> hash_algo , $ client_id , $ self_key_sign , true ) ; $ salt = hash_hmac ( $ this -> hash_algo , 'signer' , $ client_id_sign , true ) ; $ this -> logger -> debug ( __FUNCTION__ , [ 'input' => [ 'self_key' => $ self_key , 'client_id' => $ client_id , 'client_secret' => $ client_secret , ] , 'output' => [ 'self_key_sign' => $ self_key_sign , 'client_id_sign' => $ client_id_sign , 'salt' => $ salt , ] , ] ) ; return $ salt ; }
|
Gets the salt value that should be used for signing .
|
56,041
|
private function createScope ( $ self_key , $ client_id ) { $ scope = sprintf ( '%s/%s/signer' , $ self_key , $ client_id ) ; $ this -> logger -> debug ( __FUNCTION__ , [ 'scope' => $ scope , ] ) ; return $ scope ; }
|
Creates the scope in which the signature is valid .
|
56,042
|
public function makePath ( Node \ File $ node , ? string $ dir = null , string $ ext = '.php' ) : array { if ( is_null ( $ node -> class ) ) { throw new UnexpectedValueException ( 'File without class cannot be saved' ) ; } $ dir = $ dir ?? $ this -> baseDir ; $ path = str_replace ( '\\' , '/' , $ node -> namespace ) ; if ( ! empty ( $ path ) ) { $ dir .= '/' . $ path ; } return [ $ dir , $ this -> makeClassName ( $ node -> class ) . $ ext ] ; }
|
Makes path of file for save compiled file node
|
56,043
|
public function compile ( Node \ File $ node ) : array { if ( is_null ( $ node -> class ) ) { throw new UnexpectedValueException ( 'File without class cannot be saved' ) ; } $ result = $ node -> uses ; if ( is_a ( $ node -> class , Node \ Class_ :: class ) ) { $ result [ ] = $ this -> compileClass ( $ node -> class ) ; } else if ( is_a ( $ node -> class , Node \ Enum :: class ) ) { $ result [ ] = $ this -> compileEnum ( $ node -> class ) ; } if ( ! is_null ( $ node -> namespace ) ) { $ result = [ new PHPNode \ Stmt \ Namespace_ ( $ node -> namespace , $ result ) ] ; } return $ result ; }
|
Compiles file node to PHP AST
|
56,044
|
private function constructPathNameLexer ( ) { if ( $ this -> originalTwigLexer == null ) { $ this -> originalTwigLexer = $ this -> templateRenderer -> getStringEnvironment ( ) -> getLexer ( ) ; } if ( $ this -> pathLexer == null ) { $ this -> pathLexer = new \ Twig_Lexer ( $ this -> templateRenderer -> getStringEnvironment ( ) , [ 'tag_comment' => [ '{#' , '#}' ] , 'tag_block' => [ '{%' , '%}' ] , 'tag_variable' => [ '{' , '}' ] ] ) ; } $ this -> templateRenderer -> getStringEnvironment ( ) -> setLexer ( $ this -> pathLexer ) ; }
|
Makes a new Twig Lexer just for the path name stuff .
|
56,045
|
private function restoreOriginalLexer ( ) { if ( $ this -> originalTwigLexer != null ) { $ this -> templateRenderer -> getStringEnvironment ( ) -> setLexer ( $ this -> originalTwigLexer ) ; } }
|
Restores the original Twig lexer .
|
56,046
|
public function processPath ( $ path ) { $ path = $ this -> replaceDoubleOpeningBrackets ( $ path ) ; $ path = $ this -> convertSingleOpeningSquareBracketsToPipes ( $ path ) ; $ path = $ this -> replaceBracketEscapeSequenceWithSingleOpeningBrackets ( $ path ) ; $ this -> constructPathNameLexer ( ) ; $ path = $ this -> templateRenderer -> renderString ( $ path ) ; $ this -> restoreOriginalLexer ( ) ; $ path = $ this -> removeUnwantedCharactersFromString ( $ path ) ; return $ path ; }
|
Processes the provided path .
|
56,047
|
public function update ( Request $ request ) { $ this -> authorize ( 'update' , Settings :: class ) ; $ this -> validate ( $ request , [ 'text_editor' => 'required|in:plain-text,markdown,wysiwyg' , 'public_url' => 'required|max:255' , ] ) ; Settings :: first ( ) -> update ( [ 'text_editor' => $ request -> input ( 'text_editor' ) , 'public_url' => $ request -> input ( 'public_url' ) , ] ) ; return redirect ( ) -> route ( 'laralum::settings.index' , [ 'p' => 'Tickets' ] ) -> with ( 'success' , __ ( 'laralum_tickets::general.tickets_settings_updated' ) ) ; }
|
Update tickets settings .
|
56,048
|
public function getValidatorFor ( $ entity ) { $ rules = $ this -> getEntityRulesFor ( $ entity ) ; return $ this -> validator -> make ( $ this -> extract ( $ entity ) , $ rules -> rules ( $ entity ) , $ rules -> messages ( ) ) ; }
|
Creates a validator for the entity using any configured rules
|
56,049
|
protected function alterAction ( $ destination , $ action ) { if ( ! $ this -> exists ( ) || ! $ this -> isFilesystemWritable ( $ this -> full ) ) { return false ; } if ( $ this -> isDir ( $ destination ) ) { $ destination = rtrim ( $ destination , '/' ) . '/' . basename ( $ this -> path ) ; } $ res = $ this -> getDriver ( ) -> { $ action } ( $ this -> path , $ destination ) ; $ this -> resetError ( ) ; return ( bool ) $ res ; }
|
Do copy or rename in same filesystem
|
56,050
|
public function assertIsTrue ( $ value , $ message = '%s must be True' , $ exception = 'Asserts' ) { if ( is_bool ( $ value ) === false || $ value !== true ) { $ this -> throwException ( $ exception , $ message , $ value ) ; } }
|
Verifies that the specified condition is true . The assertion fails if the condition is false .
|
56,051
|
public static function create ( $ uri , $ method = 'GET' , $ parameters = array ( ) , $ cookies = array ( ) , $ files = array ( ) , $ server = array ( ) , $ content = null ) { $ defaults = array ( 'SERVER_NAME' => 'localhost' , 'SERVER_PORT' => 80 , 'HTTP_HOST' => 'localhost' , 'HTTP_USER_AGENT' => 'PhpAlchemy/1.0' , 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' , 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5' , 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' , 'REMOTE_ADDR' => '127.0.0.1' , 'SCRIPT_NAME' => '' , 'SCRIPT_FILENAME' => '' , 'SERVER_PROTOCOL' => 'HTTP/1.1' , 'REQUEST_TIME' => time ( ) , ) ; $ components = parse_url ( $ uri ) ; if ( isset ( $ components [ 'host' ] ) ) { $ defaults [ 'SERVER_NAME' ] = $ components [ 'host' ] ; $ defaults [ 'HTTP_HOST' ] = $ components [ 'host' ] ; } if ( isset ( $ components [ 'scheme' ] ) ) { if ( 'https' === $ components [ 'scheme' ] ) { $ defaults [ 'HTTPS' ] = 'on' ; $ defaults [ 'SERVER_PORT' ] = 443 ; } } if ( isset ( $ components [ 'port' ] ) ) { $ defaults [ 'SERVER_PORT' ] = $ components [ 'port' ] ; $ defaults [ 'HTTP_HOST' ] = $ defaults [ 'HTTP_HOST' ] . ':' . $ components [ 'port' ] ; } if ( isset ( $ components [ 'user' ] ) ) { $ defaults [ 'PHP_AUTH_USER' ] = $ components [ 'user' ] ; } if ( isset ( $ components [ 'pass' ] ) ) { $ defaults [ 'PHP_AUTH_PW' ] = $ components [ 'pass' ] ; } if ( ! isset ( $ components [ 'path' ] ) ) { $ components [ 'path' ] = '' ; } switch ( strtoupper ( $ method ) ) { case 'POST' : case 'PUT' : case 'DELETE' : $ defaults [ 'CONTENT_TYPE' ] = 'application/x-www-form-urlencoded' ; case 'PATCH' : $ request = $ parameters ; $ query = array ( ) ; break ; default : $ request = array ( ) ; $ query = $ parameters ; break ; } if ( isset ( $ components [ 'query' ] ) ) { parse_str ( html_entity_decode ( $ components [ 'query' ] ) , $ qs ) ; $ query = array_replace ( $ qs , $ query ) ; } $ queryString = http_build_query ( $ query , '' , '&' ) ; $ uri = $ components [ 'path' ] . ( '' !== $ queryString ? '?' . $ queryString : '' ) ; $ server = array_replace ( $ defaults , $ server , array ( 'REQUEST_METHOD' => strtoupper ( $ method ) , 'PATH_INFO' => '' , 'REQUEST_URI' => $ uri , 'QUERY_STRING' => $ queryString , ) ) ; return new static ( $ query , $ request , array ( ) , $ cookies , $ files , $ server , $ content ) ; }
|
Creates a Request based on a given URI and configuration .
|
56,052
|
protected function getFieldOneColumnValue ( ) { return function ( $ row ) { $ value = is_null ( $ row -> value ) ? null : array_get ( $ row -> value , 'field_1' ) ; if ( is_null ( $ value ) ) { return '---' ; } return array_get ( ModuleProcessor :: getOptions ( ) , $ value , '---' ) ; } ; }
|
Gets field 1 colum value
|
56,053
|
protected function getFieldRow ( $ label ) { return function ( $ row ) use ( $ label ) { if ( is_null ( $ row -> value ) ) { return '---' ; } $ value = array_get ( $ row -> value , $ label ) ; $ class = ( $ value ) ? 'success' : 'danger' ; $ label = ( $ value ) ? 'yes' : 'no' ; return '<span class = "label-basic label-basic--' . $ class . '">' . trans ( 'antares/foundation::messages.' . $ label ) . '</span >' ; } ; }
|
Gets field row decorator
|
56,054
|
protected function users ( ) { $ rows = \ Antares \ Modules \ SampleModule \ Model \ ModuleRow :: query ( ) -> groupBy ( 'user_id' ) -> with ( 'user' ) -> get ( ) ; $ return = [ '' => trans ( 'antares/users::messages.statuses.all' ) ] ; foreach ( $ rows as $ row ) { $ return [ $ row -> user_id ] = $ row -> user -> fullname ; } return $ return ; }
|
Creates select for statuses
|
56,055
|
public function addMany ( array $ attributes ) { if ( count ( $ attributes ) > 0 ) { foreach ( $ attributes as $ name => $ value ) { $ this -> add ( $ name , $ value ) ; } } return $ this ; }
|
Add many attributes to collection
|
56,056
|
private function makeAttribute ( $ name , $ value ) { $ attribute = Attribute :: make ( $ name , $ value ) ; $ this -> put ( $ attribute -> getName ( ) , $ attribute ) ; return $ this ; }
|
Adding a new attribute to collection
|
56,057
|
private function updateAttribute ( $ name , $ value ) { $ attribute = $ this -> getAttr ( $ name ) ; if ( ! is_null ( $ attribute ) ) { $ attribute -> addContent ( $ value ) ; $ this -> put ( $ name , $ attribute ) ; } return $ this ; }
|
Updating existing attribute
|
56,058
|
public function forgetValue ( $ name , $ value ) { if ( $ this -> has ( $ name ) ) { $ attr = $ this -> getAttr ( $ name ) ; $ attr -> forgetValue ( $ value ) ; } return $ this ; }
|
Forget an attribute value
|
56,059
|
public static function exists ( $ bundle ) { return $ bundle == DEFAULT_BUNDLE or Arrays :: in ( Inflector :: lower ( $ bundle ) , static :: names ( ) ) ; }
|
Determine if a bundle exists within the bundles directory .
|
56,060
|
public function findUser ( array $ params ) { $ userProvider = $ this -> container [ UserProvider :: class ] ; try { $ user = $ userProvider -> loadUserByUsername ( $ params [ 'username' ] ) ; } catch ( \ Exception $ e ) { return false ; } return $ user ; }
|
Find a specific user based on a set of parameters
|
56,061
|
public function authenticate ( User $ user , array $ params = [ ] ) { if ( $ user -> isEnabled ( ) && password_verify ( $ params [ 'password' ] , $ user -> getPassword ( ) ) ) { return $ user -> getId ( ) ; } return false ; }
|
Returns user id or false if unable to authenticate
|
56,062
|
public function bind ( $ name , Closure $ bind ) { $ app = $ this ; $ this -> container [ $ name ] = function ( $ c ) use ( $ app , $ bind ) { return $ bind ( $ app ) ; } ; return $ this ; }
|
Bind a service into the container .
|
56,063
|
protected function bootstrap ( ) { foreach ( $ this -> bootstraps as $ bClass ) { $ b = new $ bClass ; if ( $ b instanceof BootstrapperInterface ) { $ b -> bootstrap ( $ this ) ; } } return $ this ; }
|
Bootstrap default services into the container .
|
56,064
|
public function setTotalCountByQueryBuilder ( QueryBuilder $ queryBuilder ) { $ queryBuilder -> select ( sprintf ( 'COUNT(%s)' , $ queryBuilder -> getRootAliases ( ) [ 0 ] ) ) -> setMaxResults ( 1 ) ; return $ this -> setTotalCount ( intval ( $ queryBuilder -> getQuery ( ) -> getSingleScalarResult ( ) ) ) ; }
|
Set Total Count
|
56,065
|
public function getItemsArray ( ) { $ items = [ ] ; foreach ( $ this -> getItems ( ) as $ item ) { $ items [ ] = [ 'id' => $ item -> getId ( ) , 'text' => $ item -> getText ( ) , ] ; } return $ items ; }
|
Items as Array
|
56,066
|
public function init ( $ keepalive = false ) { $ this -> handshake ( ) ; $ this -> connect ( ) ; if ( $ keepalive ) { $ this -> keepAlive ( ) ; } else { return $ this ; } }
|
Initialize a new connection
|
56,067
|
public function keepAlive ( ) { while ( is_resource ( $ this -> fd ) ) { if ( $ this -> session [ 'heartbeat_timeout' ] > 0 && $ this -> session [ 'heartbeat_timeout' ] + $ this -> heartbeatStamp - 5 < time ( ) ) { $ this -> send ( self :: TYPE_HEARTBEAT ) ; $ this -> heartbeatStamp = time ( ) ; } $ r = array ( $ this -> fd ) ; $ w = $ e = null ; if ( stream_select ( $ r , $ w , $ e , 5 ) == 0 ) { continue ; } $ res = $ this -> read ( ) ; $ sess = explode ( ':' , $ res ) ; if ( ( int ) Arrays :: first ( $ sess ) === self :: TYPE_EVENT ) { unset ( Arrays :: first ( $ sess ) , $ sess [ 1 ] , $ sess [ 2 ] ) ; $ response = json_decode ( implode ( ':' , $ sess ) , true ) ; $ name = $ response [ 'name' ] ; $ data = Arrays :: first ( $ response [ 'args' ] ) ; $ this -> stdout ( 'debug' , 'Receive event "' . $ name . '" with data "' . $ data . '"' ) ; if ( ! empty ( $ this -> callbacks [ $ name ] ) ) { foreach ( $ this -> callbacks [ $ name ] as $ callback ) { call_user_func ( $ callback , $ data ) ; } } } } }
|
Keep the connection alive and dispatch events
|
56,068
|
public function on ( $ event , $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new Exception ( 'Socketio::on() type callback must be callable.' ) ; } if ( ! isset ( $ this -> callbacks [ $ event ] ) ) { $ this -> callbacks [ $ event ] = array ( ) ; } if ( in_array ( $ callback , $ this -> callbacks [ $ event ] ) ) { $ this -> stdout ( 'debug' , 'Skip existing callback' ) ; return ; } $ this -> callbacks [ $ event ] [ ] = $ callback ; }
|
Attach an event handler function for a given event
|
56,069
|
public function close ( ) { if ( is_resource ( $ this -> fd ) ) { $ this -> send ( self :: TYPE_DISCONNECT ) ; fclose ( $ this -> fd ) ; return true ; } return false ; }
|
Close the socket
|
56,070
|
private function stdout ( $ type , $ message ) { if ( ! defined ( 'STDOUT' ) || ! $ this -> debug ) { return false ; } $ typeMap = array ( 'debug' => array ( 36 , '- debug -' ) , 'info' => array ( 37 , '- info -' ) , 'error' => array ( 31 , '- error -' ) , 'ok' => array ( 32 , '- ok -' ) , ) ; if ( ! Arrays :: exists ( $ type , $ typeMap ) ) { throw new Exception ( 'Socketio::stdout $type parameter must be debug, info, error or success. Got ' . $ type ) ; } fwrite ( STDOUT , "\033[" . $ typeMap [ $ type ] [ 0 ] . "m" . $ typeMap [ $ type ] [ 1 ] . "\033[37m " . $ message . "\r\n" ) ; }
|
Send ANSI formatted message to stdout . First parameter must be either debug info error or ok
|
56,071
|
private function handshake ( ) { $ url = $ this -> socketIOUrl ; if ( ! empty ( $ this -> handshakeQuery ) ) { $ url .= $ this -> handshakeQuery ; } $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; if ( ! $ this -> checkSslPeer ) { curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , false ) ; } if ( ! is_null ( $ this -> handshakeTimeout ) ) { curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT_MS , $ this -> handshakeTimeout ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT_MS , $ this -> handshakeTimeout ) ; } $ res = curl_exec ( $ ch ) ; if ( $ res === false || $ res === '' ) { throw new \ Exception ( curl_error ( $ ch ) ) ; } $ sess = explode ( ':' , $ res ) ; $ this -> session [ 'sid' ] = $ sess [ 0 ] ; $ this -> session [ 'heartbeat_timeout' ] = $ sess [ 1 ] ; $ this -> session [ 'connection_timeout' ] = $ sess [ 2 ] ; $ this -> session [ 'supported_transports' ] = array_flip ( explode ( ',' , $ sess [ 3 ] ) ) ; if ( ! isset ( $ this -> session [ 'supported_transports' ] [ 'websocket' ] ) ) { throw new \ Exception ( 'This socket.io server do not support websocket protocol. Terminating connection...' ) ; } return true ; }
|
Handshake with socket . io server
|
56,072
|
public function setChannelIds ( array $ channelIds ) { foreach ( $ channelIds as $ channelId ) { if ( ! is_numeric ( $ channelId ) ) { throw new \ Exception ( 'Channel ID should be numeric.' ) ; } } $ this -> channels = $ channelIds ; return $ this ; }
|
Filter video list by one or multiple channel IDs .
|
56,073
|
public static function create ( $ path , $ code = null , BaseException $ previous = null ) { $ class = get_called_class ( ) ; return new $ class ( sprintf ( "The path '%s' doesn't exist." , $ path ) , is_int ( $ code ) ? $ code : null , $ previous ) ; }
|
Create a new InvalidPathException
|
56,074
|
public function getRemaining ( ) { $ speed = $ this -> getSpeed ( ) ; $ notHandledCount = $ this -> all - $ this -> handled ; $ remainingSeconds = $ speed != 0 ? $ notHandledCount / $ speed : $ notHandledCount ; return round ( $ remainingSeconds ) ; }
|
Get remaining seconds
|
56,075
|
public function getStatus ( ) { $ speed = round ( $ this -> getSpeed ( ) , 2 ) ; $ remaining = $ this -> getRemaining ( ) ; $ remainingTime = $ this -> getFormatTime ( $ remaining ) ; $ handled = str_pad ( $ this -> handled , $ this -> allCountLength , ' ' , STR_PAD_LEFT ) ; return "Handled: $handled/$this->all\tRemaining: $remainingTime\tSpeed: $speed/sec" ; }
|
Get status message
|
56,076
|
protected function getFormatTime ( $ time ) { $ hours = str_pad ( floor ( $ time / 60 / 60 ) , 2 , '0' , STR_PAD_LEFT ) ; $ minutes = str_pad ( floor ( ( $ time - ( ( int ) $ hours * 60 * 60 ) ) / 60 ) , 2 , '0' , STR_PAD_LEFT ) ; $ seconds = str_pad ( floor ( ( $ time - ( ( int ) $ hours * 60 * 60 ) - ( ( int ) $ minutes * 60 ) ) ) , 2 , '0' , STR_PAD_LEFT ) ; return "$hours:$minutes:$seconds" ; }
|
Get formatted time
|
56,077
|
public function showStatus ( $ frequency = null ) { if ( $ frequency !== null && $ this -> handled % $ frequency !== 0 ) { return ; } $ this -> stdout ( $ this -> getStatus ( ) . PHP_EOL , static :: FG_YELLOW ) ; }
|
Output status message
|
56,078
|
public function showFinish ( ) { $ processingTime = $ this -> getFormatTime ( $ this -> diffBetweenStart ( ) ) ; $ message = "Finished after $processingTime\tHandled: $this->handled items" ; $ this -> stdout ( PHP_EOL . $ message . PHP_EOL , static :: FG_GREEN ) ; }
|
Output finih message
|
56,079
|
public function reset ( $ newAllCount = null ) { if ( $ newAllCount !== null ) { $ this -> all = $ newAllCount ; $ this -> allCountLength = strlen ( "$newAllCount" ) ; } $ this -> start = microtime ( true ) ; $ this -> handled = 0 ; }
|
Reset current time log
|
56,080
|
public function presentParent ( ) { if ( ( int ) $ this -> post_parent === 0 ) { return null ; } $ parent = get_post ( $ this -> post_parent ) ; return new self ( $ parent , false ) ; }
|
Return the parent page as PagePresenter instance
|
56,081
|
public function presentChildren ( ) { $ childrenPages = new \ WP_Query ( array ( 'post_type' => 'page' , 'post_parent' => $ this -> ID , 'post_status' => 'publish' , 'orderby' => 'menu_order' , 'order' => 'ASC' , 'posts_per_page' => - 1 ) ) ; if ( count ( $ childrenPages -> posts ) == 0 || ! $ childrenPages ) { return null ; } $ pages = array ( ) ; foreach ( $ childrenPages -> posts as $ p ) { $ pages [ ] = new self ( $ p , false ) ; } return Collection :: make ( $ pages ) ; }
|
Return direct children of the page as PagePresenter instances
|
56,082
|
private function buildQuery ( array $ parameters ) { if ( empty ( $ parameters ) ) { return '' ; } $ keys = self :: urlencode_rfc3986 ( array_keys ( $ parameters ) ) ; $ values = self :: urlencode_rfc3986 ( array_values ( $ parameters ) ) ; $ parameters = array_combine ( $ keys , $ values ) ; uksort ( $ parameters , 'strcmp' ) ; foreach ( $ parameters as $ key => $ value ) { if ( Arrays :: is ( $ value ) ) $ parameters [ $ key ] = natsort ( $ value ) ; } foreach ( $ parameters as $ key => $ value ) { $ chunks [ ] = $ key . '=' . str_replace ( '%25' , '%' , $ value ) ; } return implode ( '&' , $ chunks ) ; }
|
Format the parameters as a querystring
|
56,083
|
private function calculateHeader ( array $ parameters , $ url ) { $ parts = parse_url ( ( string ) $ url ) ; $ chunks = array ( ) ; foreach ( $ parameters as $ key => $ value ) { $ chunks [ ] = str_replace ( '%25' , '%' , self :: urlencode_rfc3986 ( $ key ) . '="' . self :: urlencode_rfc3986 ( $ value ) . '"' ) ; } $ return = 'Authorization: OAuth realm="", ' ; $ return .= implode ( ',' , $ chunks ) ; return $ return ; }
|
Build the Authorization header
|
56,084
|
private function doOAuthCall ( $ url , array $ parameters = null , $ method = 'POST' , $ expectJSON = true ) { $ url = ( string ) $ url ; $ parameters [ 'oauth_consumer_key' ] = $ this -> getApplicationKey ( ) ; $ parameters [ 'oauth_signature_method' ] = 'PLAINTEXT' ; $ parameters [ 'oauth_version' ] = '1.0' ; $ parameters [ 'oauth_signature' ] = $ this -> getApplicationSecret ( ) . '&' . $ this -> getOAuthTokenSecret ( ) ; if ( $ method == 'POST' ) { $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = $ parameters ; } else { $ options [ CURLOPT_POST ] = 0 ; unset ( $ options [ CURLOPT_POSTFIELDS ] ) ; if ( ! empty ( $ parameters ) ) $ url .= '?' . $ this -> buildQuery ( $ parameters ) ; } $ options [ CURLOPT_URL ] = self :: API_URL . '/' . $ url ; $ options [ CURLOPT_PORT ] = self :: API_PORT ; $ options [ CURLOPT_USERAGENT ] = $ this -> getUserAgent ( ) ; if ( ini_get ( 'open_basedir' ) == '' && ini_get ( 'safe_mode' == 'Off' ) ) { $ options [ CURLOPT_FOLLOWLOCATION ] = true ; } $ options [ CURLOPT_RETURNTRANSFER ] = true ; $ options [ CURLOPT_TIMEOUT ] = ( int ) $ this -> getTimeOut ( ) ; $ options [ CURLOPT_SSL_VERIFYPEER ] = false ; $ options [ CURLOPT_SSL_VERIFYHOST ] = false ; $ options [ CURLOPT_HTTPHEADER ] = array ( 'Expect:' ) ; $ this -> curl = curl_init ( ) ; curl_setopt_array ( $ this -> curl , $ options ) ; $ response = curl_exec ( $ this -> curl ) ; $ headers = curl_getinfo ( $ this -> curl ) ; $ errorNumber = curl_errno ( $ this -> curl ) ; $ errorMessage = curl_error ( $ this -> curl ) ; if ( $ errorNumber != '' ) throw new Exception ( $ errorMessage , $ errorNumber ) ; if ( $ expectJSON ) return json_decode ( $ response , true ) ; return $ response ; }
|
Make an call to the oAuth
|
56,085
|
private static function urlencode_rfc3986 ( $ value ) { if ( Arrays :: is ( $ value ) ) { return array_map ( array ( __CLASS__ , 'urlencode_rfc3986' ) , $ value ) ; } else { return str_replace ( '%7E' , '~' , rawurlencode ( $ value ) ) ; } }
|
URL - encode method for internal use
|
56,086
|
public function metadata ( $ path = '' , $ fileLimit = 10000 , $ hash = false , $ list = true , $ includeDeleted = false , $ rev = null , $ locale = null , $ sandbox = false ) { $ url = '1/metadata/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; $ parameters = null ; $ parameters [ 'file_limit' ] = ( int ) $ fileLimit ; if ( ( bool ) $ hash ) $ parameters [ 'hash' ] = '' ; $ parameters [ 'list' ] = ( $ list ) ? 'true' : 'false' ; if ( ( bool ) $ includeDeleted ) $ parameters [ 'include_deleted' ] = 'true' ; if ( $ rev !== null ) $ parameters [ 'rev' ] = ( string ) $ rev ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return ( array ) $ this -> doCall ( $ url , $ parameters ) ; }
|
Retrieves file and folder metadata .
|
56,087
|
public function restore ( $ path , $ rev , $ locale = null , $ sandbox = false ) { $ url = '1/restore/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; $ parameters [ 'rev' ] = ( string ) $ rev ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return ( array ) $ this -> doCall ( $ url , $ parameters ) ; }
|
Restores a file path to a previous revision . Unlike downloading a file at a given revision and then re - uploading it this call is atomic . It also saves a bunch of bandwidth .
|
56,088
|
public function search ( $ path , $ query , $ fileLimit = 1000 , $ includeDeleted = null , $ locale = null , $ sandbox = false ) { $ url = '1/search/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; $ parameters [ 'query' ] = ( string ) $ query ; $ parameters [ 'file_limit' ] = ( int ) $ fileLimit ; if ( $ includeDeleted !== null ) $ parameters [ 'include_deleted' ] = ( ( bool ) $ includeDeleted ) ? 'true' : 'false' ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return ( array ) $ this -> doCall ( $ url , $ parameters ) ; }
|
Returns metadata for all files and folders whose filename contains the given search string as a substring . Searches are limited to the folder path and its sub - folder hierarchy provided in the call .
|
56,089
|
public function shares ( $ path , $ shortUrl = true , $ locale = null , $ sandbox = false ) { $ url = '1/shares/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; $ parameters [ 'short_url' ] = ( ( bool ) $ shortUrl ) ? 'true' : 'false' ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return ( array ) $ this -> doCall ( $ url , $ parameters , 'POST' ) ; }
|
Creates and returns a Dropbox link to files or folders users can use to view a preview of the file in a web browser .
|
56,090
|
public function copyRef ( $ path , $ sandbox = false ) { $ url = '1/copy_ref/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; return ( array ) $ this -> doCall ( $ url ) ; }
|
Creates and returns a copy_ref to a file . This reference string can be used to copy that file to another user s Dropbox by passing it in as the fromCopyRef parameter on fileopsCopy .
|
56,091
|
public function thumbnails ( $ path , $ size = 'small' , $ format = 'jpeg' , $ sandbox = false ) { $ url = '1/thumbnails/' ; $ url .= ( $ sandbox ) ? 'sandbox/' : 'dropbox/' ; $ url .= trim ( ( string ) $ path , '/' ) ; $ parameters [ 'size' ] = ( string ) $ size ; $ parameters [ 'format' ] = ( string ) $ format ; return $ this -> doCall ( $ url , $ parameters , 'GET' , null , false , true ) ; }
|
Gets a thumbnail for an image .
|
56,092
|
public function fileopsCopy ( $ fromPath = null , $ toPath , $ fromCopyRef = null , $ locale = null , $ sandbox = false ) { $ url = '1/fileops/copy' ; $ parameters [ 'root' ] = ( $ sandbox ) ? 'sandbox' : 'dropbox' ; if ( $ fromPath !== null ) $ parameters [ 'from_path' ] = ( string ) $ fromPath ; $ parameters [ 'to_path' ] = ( string ) $ toPath ; if ( $ fromCopyRef !== null ) $ parameters [ 'from_copy_ref' ] = ( string ) $ fromCopyRef ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return $ this -> doCall ( $ url , $ parameters , 'POST' ) ; }
|
Copies a file or folder to a new location .
|
56,093
|
public function fileopsMove ( $ fromPath , $ toPath , $ locale = null , $ sandbox = false ) { $ url = '1/fileops/move' ; $ parameters [ 'from_path' ] = ( string ) $ fromPath ; $ parameters [ 'to_path' ] = ( string ) $ toPath ; $ parameters [ 'root' ] = ( $ sandbox ) ? 'sandbox' : 'dropbox' ; if ( $ locale !== null ) $ parameters [ 'locale' ] = ( string ) $ locale ; return $ this -> doCall ( $ url , $ parameters , 'POST' ) ; }
|
Moves a file or folder to a new location .
|
56,094
|
public function getTokenAttribute ( $ value ) { if ( ! is_null ( $ value ) ) { $ value = json_decode ( $ value , true ) ; } return new Token ( $ value ) ; }
|
Get token attribute using accessor .
|
56,095
|
public function setTokenAttribute ( Token $ token ) { $ value = null ; if ( ! $ token -> isValid ( ) ) { $ value = $ token -> toJson ( ) ; } $ this -> attributes [ 'token' ] = $ value ; }
|
Set token attribute using mutator .
|
56,096
|
public function delete ( $ value ) { foreach ( array_keys ( $ this -> collection , $ value , true ) as $ key ) { unset ( $ this -> collection [ $ key ] ) ; } return $ this ; }
|
Deletes all elements containing a given value .
|
56,097
|
public function unserialize ( $ serialized ) { $ identifier = __CLASS__ . '@' ; if ( substr ( $ serialized , 0 , strlen ( $ identifier ) ) !== $ identifier ) { $ message = sprintf ( 'Serialized value doesn\'t represents an instance.of "%s".' , __CLASS__ ) ; throw new Exception \ InvalidArgumentException ( $ message ) ; } $ collection = unserialize ( substr ( $ serialized , strlen ( $ identifier ) ) ) ; if ( ! is_array ( $ collection ) ) { $ type = is_object ( $ collection ) ? get_class ( $ collection ) : gettype ( $ collection ) ; $ message = sprintf ( 'Unserialized value in "%s" must be an array; "%s" was given.' , __METHOD__ , $ type ) ; throw new Exception \ InvalidArgumentException ( $ message ) ; } $ this -> collection = $ collection ; return $ this ; }
|
Restores a serialized collection .
|
56,098
|
public function getUserCompnies ( $ user_id , $ status ) { $ criteria = new CDbCriteria ; $ criteria -> join .= "INNER JOIN profiles p ON p.person_id = ccuc_person_id AND ccuc_status='" . $ status . "'" ; $ criteria -> condition = 'p.user_id = ' . $ user_id ; return CcucUserCompany :: model ( ) -> findAll ( $ criteria ) ; }
|
get user companies by user and status
|
56,099
|
public function getPersonCompnies ( $ pprs_id , $ status ) { $ criteria = new CDbCriteria ; $ criteria -> condition = "t.ccuc_person_id = " . $ pprs_id . " and t.ccuc_status = '" . $ status . "'" ; return CcucUserCompany :: model ( ) -> findAll ( $ criteria ) ; }
|
get person companies by person and status
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.