idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
9,800
|
private function acquireAccessToken ( ) { if ( isset ( $ this -> accessToken ) && $ this -> accessToken -> getRefreshToken ( ) ) { return $ this -> provider -> getAccessToken ( new RefreshToken ( ) , [ 'refresh_token' => $ this -> accessToken -> getRefreshToken ( ) ] ) ; } return $ this -> provider -> getAccessToken ( $ this -> grant , $ this -> grantOptions ) ; }
|
Acquire a new access token using a refresh token or the configured grant .
|
9,801
|
public function withParameters ( array $ parameters ) : self { $ query = $ this ; foreach ( $ parameters as $ key => $ parameter ) { $ query = $ query -> withParameter ( $ key , $ parameter ) ; } return $ query ; }
|
Attach parameters to this query
|
9,802
|
public function withParameter ( string $ key , $ parameter ) : self { if ( Str :: of ( $ key ) -> empty ( ) ) { throw new DomainException ; } $ query = new self ( $ this -> cypher ) ; $ query -> parameters = $ this -> parameters -> put ( $ key , new Parameter ( $ key , $ parameter ) ) ; return $ query ; }
|
Attach the given parameter to this query
|
9,803
|
public function filterResult ( callable $ filter ) { $ result = [ ] ; foreach ( $ this -> files as $ file ) { if ( $ filter ( $ file ) ) { $ result [ ] = $ file ; } } return $ result ; }
|
Further filtering the find result set
|
9,804
|
private function setHeaderContentType ( ) { $ fileName = basename ( $ this -> fileName ) ; if ( $ this -> contentDisposition !== null && $ this -> contentDisposition -> fileName !== null ) { $ fileName = $ this -> contentDisposition -> fileName ; } $ this -> setHeader ( 'Content-Type' , $ this -> contentType . '/' . $ this -> mimeType . '; ' . 'name="' . $ fileName . '"' ) ; }
|
Sets the Content - Type header .
|
9,805
|
public function setMargins ( $ marginLeft , $ marginRight , $ marginTop , $ marginBottom ) { $ this -> setLeftMargin ( $ marginLeft ) ; $ this -> setRightMargin ( $ marginRight ) ; $ this -> setTopMargin ( $ marginTop ) ; $ this -> setBottomMargin ( $ marginBottom ) ; return $ this ; }
|
Set new margin in the given units
|
9,806
|
public function setFont ( \ ZendPdf \ Resource \ Font \ AbstractFont $ font , $ fontSize = null ) { if ( is_null ( $ fontSize ) ) { $ fontSize = $ this -> getFontSize ( ) ; } return parent :: setFont ( $ font , $ fontSize ) ; }
|
Sets a new font family and optionally a new font size as well
|
9,807
|
public function wordWrapText ( $ text , $ wrapWidth ) { $ wrappedText = '' ; foreach ( explode ( PHP_EOL , $ text ) as $ line ) { $ words = explode ( ' ' , $ line ) ; $ currentLine = array_shift ( $ words ) ; while ( count ( $ words ) > 0 ) { $ word = array_shift ( $ words ) ; if ( $ this -> getTextWidth ( $ currentLine . ' ' . $ word ) > $ wrapWidth ) { $ wrappedText .= PHP_EOL . $ currentLine ; $ currentLine = $ word ; } else { $ currentLine .= ' ' . $ word ; } } $ wrappedText .= PHP_EOL . $ currentLine ; } return ltrim ( $ wrappedText , PHP_EOL ) ; }
|
Word - wrap a text to a certain width using the current font properties
|
9,808
|
public function transform ( ProjectDescriptor $ project , Transformation $ transformation ) { $ artifact = $ transformation -> getTransformer ( ) -> getTarget ( ) . DIRECTORY_SEPARATOR . ( $ transformation -> getArtifact ( ) ? $ transformation -> getArtifact ( ) : 'source' ) ; foreach ( $ project -> getFiles ( ) as $ file ) { $ filename = $ file -> getPath ( ) ; $ source = $ file -> getSource ( ) ; $ root = str_repeat ( '../' , count ( explode ( DIRECTORY_SEPARATOR , $ filename ) ) ) ; $ path = $ artifact . DIRECTORY_SEPARATOR . $ filename ; if ( ! file_exists ( dirname ( $ path ) ) ) { mkdir ( dirname ( $ path ) , 0755 , true ) ; } $ source = htmlentities ( $ source ) ; file_put_contents ( $ path . '.html' , <<<HTML<html> <head> <script type="text/javascript" src="{$root}js/jquery-1.4.2.min.js"> </script> <script type="text/javascript" src="{$root}syntax_highlighter/scripts/shCore.js"> </script> <script type="text/javascript" src="{$root}syntax_highlighter/scripts/shBrushJScript.js"> </script> <script type="text/javascript" src="{$root}syntax_highlighter/scripts/shBrushPhp.js"> </script> <script type="text/javascript" src="{$root}syntax_highlighter/scripts/shBrushXml.js"> </script> <link href="{$root}syntax_highlighter/styles/shCore.css" rel="stylesheet" type="text/css" /> <link href="{$root}syntax_highlighter/styles/shCoreEclipse.css" rel="stylesheet" type="text/css" /> <link href="{$root}syntax_highlighter/styles/shThemeWordpress.css" rel="stylesheet" type="text/css" /> </head> <body> <pre class="brush: php">$source</pre> <script type="text/javascript"> SyntaxHighlighter.all(); jQuery('.gutter div').each(function(key, data){ jQuery(data).prepend('<a name="L'+jQuery(data).text()+'"/>'); }); </script> </body></html>HTML ) ; } }
|
This method writes every source code entry in the structure file to a highlighted file .
|
9,809
|
private function setHeaderAttributes ( array $ mailHeader ) { $ mailHeader = array_filter ( $ mailHeader , function ( $ property ) { return property_exists ( $ this , $ property ) ; } , ARRAY_FILTER_USE_KEY ) ; foreach ( $ mailHeader as $ property => $ header ) { $ this -> { $ property } = $ header ; } }
|
Set attributes on email from header
|
9,810
|
public function header ( $ key , $ default = null ) { if ( array_key_exists ( $ key , $ this -> headers ) ) { return $ this -> headers [ $ key ] ; } return $ default ; }
|
Get a header value . Return given default if none found
|
9,811
|
public function body ( $ mimeType = 'html' ) { $ body = [ ] ; foreach ( $ this -> body as $ part ) { if ( $ part -> mime_type === $ mimeType ) { $ body [ ] = $ part -> body ; } } return implode ( static :: partSeparator ( $ mimeType ) , $ body ) ; }
|
Render the email body as the given mime - type
|
9,812
|
public function _render ( $ textOnly ) { $ tracingLinkNum = count ( $ this -> tracingLinks ) ; $ str = "" ; if ( $ textOnly ) { $ str .= "\nFeature Traceability\n====================\n" . "The following $tracingLinkNum tracing links were found:\n\n" ; $ maxLen = fphp \ Helper \ _String :: getMaxLength ( $ this -> tracingLinks , "getFeatureName" ) + fphp \ Helper \ _String :: getMaxLength ( $ this -> tracingLinks , "getType" ) ; foreach ( $ this -> tracingLinks as $ tracingLink ) $ str .= $ this -> analyzeTracingLink ( $ tracingLink , true , $ maxLen ) ; } else { $ str .= "<h2>Feature Traceability</h2>" ; $ str .= "<p>The following $tracingLinkNum tracing links were found:</p>" ; $ str .= "<table cellpadding='2'>" ; $ str .= "<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>" ; foreach ( $ this -> tracingLinks as $ tracingLink ) $ str .= $ this -> analyzeTracingLink ( $ tracingLink ) ; $ str .= "</table>" ; } return $ str ; }
|
Returns the tracing link analysis .
|
9,813
|
private function analyzeTracingLink ( $ tracingLink , $ textOnly = false , $ maxLen = 0 ) { $ maxLen += strlen ( $ this -> defaultColor ) ; if ( $ textOnly ) return sprintf ( "$this->accentColor%-{$maxLen}s %s\n%{$maxLen}s %s\n" , $ tracingLink -> getFeatureName ( ) . "$this->defaultColor " . $ tracingLink -> getType ( ) , $ tracingLink -> getSourcePlace ( ) -> getSummary ( ) , $ this -> defaultColor , $ tracingLink -> getTargetPlace ( ) -> getSummary ( ) ) ; else return "<tr><td><span class='feature'>" . $ tracingLink -> getFeatureName ( ) . "</span></td><td>" . $ tracingLink -> getType ( ) . "</td><td>" . $ tracingLink -> getSourcePlace ( ) -> getSummary ( ) . "</td><td>" . $ tracingLink -> getTargetPlace ( ) -> getSummary ( ) . "</td></tr>" ; }
|
Analyzes a single tracing link .
|
9,814
|
public function parse ( $ string ) { global $ matchedNotes ; $ keyPrefixLen = $ this -> keyPrefix ? strlen ( $ this -> keyPrefix ) : 0 ; $ data = array ( ) ; $ toDelete = [ ] ; $ lines = preg_split ( '@\n@' , $ string , null , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE ) ; foreach ( $ lines as list ( $ l , $ offset ) ) { $ len = strlen ( $ l ) ; $ l = trim ( $ l ) ; $ offset += $ len - strlen ( $ l ) ; if ( $ l && $ l [ 0 ] == '@' ) { $ curDelete = trim ( $ l ) ; $ l = substr ( $ l , 1 ) ; $ d = preg_split ( '/\s+/' , $ l , 2 , PREG_SPLIT_OFFSET_CAPTURE ) ; $ key = $ d [ 0 ] [ 0 ] ; if ( $ this -> keyPrefix ) { if ( strpos ( $ key , $ this -> keyPrefix ) !== 0 ) continue ; $ key = substr ( $ key , $ keyPrefixLen ) ; } $ key = preg_split ( "/( \]\[ | \[ | \]\. # when php style abuts dot notation (foo[a].b) | \] | \.) /x" , rtrim ( $ key , ']' ) ) ; if ( isset ( $ d [ 1 ] ) ) { $ value = $ d [ 1 ] [ 0 ] ; } else { $ value = $ this -> defaultValue ; } $ current = & $ data ; $ found = array ( ) ; foreach ( $ key as $ part ) { if ( $ current && ! is_array ( $ current ) ) { throw new RewriteException ( "Key at path " . implode ( '.' , $ found ) . " already had non-array value, tried to set key $part" ) ; } if ( ! $ found ) { if ( in_array ( $ part , $ matchedNotes ) ) { $ toDelete [ ] = $ curDelete ; } } $ found [ ] = $ part ; if ( $ part !== "" ) $ current = & $ current [ $ part ] ; else $ current = & $ current [ ] ; } if ( $ current === null ) $ current = $ value ; elseif ( ! is_array ( $ current ) ) $ current = array ( $ current , $ value ) ; else $ current [ ] = $ value ; unset ( $ current ) ; } } return [ $ data , $ toDelete ] ; }
|
will do for now but it s definitely one to revisit .
|
9,815
|
public function addField ( array $ attributes ) { $ field = $ this -> fields ( ) -> create ( $ attributes ) ; $ this -> save ( ) ; return $ field ; }
|
Add a field to the node type
|
9,816
|
public function offsetGet ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> variables ) ) { $ this -> variables [ $ name ] = new Variable ( $ name ) ; } return $ this -> variables [ $ name ] ; }
|
Retrieve a variable by name .
|
9,817
|
public function garbageCollect ( Collection $ collection ) { $ projectRoot = $ collection -> getProjectRoot ( ) ; $ filenames = $ collection -> getFilenames ( ) ; foreach ( $ filenames as & $ name ) { $ name = self :: FILE_PREFIX . md5 ( substr ( $ name , strlen ( $ projectRoot ) ) ) ; } $ iteratorInterface = $ this -> getCache ( ) -> getIterator ( ) ; if ( $ iteratorInterface -> valid ( ) ) { foreach ( $ this -> getCache ( ) as $ item ) { if ( substr ( $ item , 0 , strlen ( self :: FILE_PREFIX ) ) === self :: FILE_PREFIX && ! in_array ( $ item , $ filenames ) ) { $ this -> getCache ( ) -> removeItem ( $ item ) ; } } } }
|
Removes all files in cache that do not occur in the given FileSet Collection .
|
9,818
|
protected function addRoute ( $ methods , $ uri , $ action ) { $ route = $ this -> createRoute ( $ methods , $ uri , $ action ) ; $ route -> setPrefixUri ( $ this -> processGroupsUri ( ) ) ; $ this -> routes -> addRoute ( $ route ) ; return $ route ; }
|
Create and register a route
|
9,819
|
public function match ( Request $ request ) { foreach ( $ this -> routes -> filterByMethod ( $ request -> getMethod ( ) ) as $ route ) { if ( $ route -> isMatch ( $ request -> getPathInfo ( ) ) ) { return $ route ; } } return null ; }
|
Chack matching requested uri by registered routes .
|
9,820
|
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( CustomerGroupI18nTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ CustomerGroup \ Model \ CustomerGroupI18n ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( CustomerGroupI18nTableMap :: DATABASE_NAME ) ; if ( count ( $ values ) == count ( $ values , COUNT_RECURSIVE ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ value ) { $ criterion = $ criteria -> getNewCriterion ( CustomerGroupI18nTableMap :: ID , $ value [ 0 ] ) ; $ criterion -> addAnd ( $ criteria -> getNewCriterion ( CustomerGroupI18nTableMap :: LOCALE , $ value [ 1 ] ) ) ; $ criteria -> addOr ( $ criterion ) ; } } $ query = CustomerGroupI18nQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { CustomerGroupI18nTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { CustomerGroupI18nTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; }
|
Performs a DELETE on the database given a CustomerGroupI18n or Criteria object OR a primary key value .
|
9,821
|
public function created ( $ user ) { if ( ! $ baseName = $ user -> baseRole ) { return ; } if ( method_exists ( $ user , 'attachRole' ) ) { $ user -> attachRole ( $ baseName ) ; } }
|
Listen to the User created event .
|
9,822
|
public function get ( $ queue , $ noAck = false ) : Observable { $ promise = $ this -> channel -> get ( $ queue , $ noAck ) ; return Observable :: fromPromise ( $ promise ) -> map ( function ( BaseMessage $ message ) { return new Message ( $ this -> channel , $ message ) ; } ) ; }
|
Pop one element from the queue .
|
9,823
|
protected function getCacheFilename ( $ name ) { $ class = substr ( $ this -> generateClassName ( $ name ) , strlen ( static :: CLASS_PREFIX ) ) ; return str_replace ( '/' , DIRECTORY_SEPARATOR , sprintf ( '%s/%s/%s/%s.php' , $ this -> getCacheDir ( ) , substr ( $ class , 0 , 2 ) , substr ( $ class , 2 , 2 ) , substr ( $ class , 4 ) ) ) ; }
|
Generates PHP filename based on given resource name
|
9,824
|
public function index ( ) { $ this -> authorize ( 'readList' , User :: class ) ; $ input = $ this -> validator -> validate ( 'list' ) ; $ params = $ this -> processor -> process ( $ input ) -> getProcessedFields ( ) ; $ results = $ this -> userRepo -> getUsers ( $ params [ 'filter' ] , $ params [ 'orderBy' ] , $ params [ 'page' ] , $ params [ 'perPage' ] ) ; return $ this -> respondWithSuccess ( $ results , new UserTransformer ) ; }
|
Display list of users
|
9,825
|
public function find ( $ id ) { $ response = $ this -> client -> request ( 'GET' , sprintf ( '/%s/%s' , $ this -> name , $ id ) ) ; $ json = ( string ) $ response -> getBody ( ) ; if ( 404 === $ response -> getStatusCode ( ) ) { throw new Exception ( 'Document does not exist' ) ; } return JSONEncoder :: decode ( $ json ) ; }
|
Find a document by a id .
|
9,826
|
public function findAll ( $ limit = null , $ startKey = null ) { $ path = "/{$this->name}/_all_docs?include_docs=true" ; if ( null !== $ limit ) { $ path .= '&limit=' . ( integer ) $ limit ; } if ( null !== $ startKey ) { $ path .= '&startkey=' . ( string ) $ startKey ; } $ json = ( string ) $ this -> client -> request ( 'GET' , $ path ) -> getBody ( ) ; $ docs = JSONEncoder :: decode ( $ json ) ; return $ docs ; }
|
Find all documents from the database .
|
9,827
|
public function findDocuments ( array $ ids , $ limit = null , $ offset = null ) { $ path = "/{$this->name}/_all_docs?include_docs=true" ; if ( null !== $ limit ) { $ path .= '&limit=' . ( integer ) $ limit ; } if ( null !== $ offset ) { $ path .= '&skip=' . ( integer ) $ offset ; } $ response = $ this -> client -> request ( 'POST' , $ path , [ 'body' => JSONEncoder :: encode ( [ 'keys' => $ ids ] ) , 'headers' => [ 'Content-Type' => 'application/json' ] , ] ) ; return JSONEncoder :: decode ( ( string ) $ response -> getBody ( ) ) ; }
|
Find a documents by a id .
|
9,828
|
public function insert ( array & $ doc ) { if ( isset ( $ doc [ '_id' ] ) ) { $ clone = $ doc ; unset ( $ clone [ '_id' ] ) ; $ response = $ this -> client -> request ( 'PUT' , "/{$this->name}/{$doc['_id']}" , [ 'body' => JSONEncoder :: encode ( $ clone ) , 'headers' => [ 'Content-Type' => 'application/json' ] , ] ) ; } else { $ response = $ this -> client -> request ( 'POST' , "/{$this->name}/" , [ 'body' => JSONEncoder :: encode ( $ doc ) , 'headers' => [ 'Content-Type' => 'application/json' ] , ] ) ; } if ( 201 !== $ response -> getStatusCode ( ) ) { throw new Exception ( 'Unable to save document' ) ; } $ value = JSONEncoder :: decode ( ( string ) $ response -> getBody ( ) ) ; $ doc [ '_id' ] = $ value [ 'id' ] ; $ doc [ '_rev' ] = $ value [ 'rev' ] ; }
|
Insert a new document .
|
9,829
|
public function update ( $ id , array & $ doc ) { $ json = JSONEncoder :: encode ( $ doc ) ; $ response = $ this -> client -> request ( 'PUT' , "/{$this->name}/{$id}" , [ 'body' => $ json , 'headers' => [ 'Content-Type' => 'application/json' ] , ] ) ; if ( 201 !== $ response -> getStatusCode ( ) ) { throw new Exception ( 'Unable to save document' ) ; } $ value = JSONEncoder :: decode ( ( string ) $ response -> getBody ( ) ) ; $ doc [ '_id' ] = $ value [ 'id' ] ; $ doc [ '_rev' ] = $ value [ 'rev' ] ; }
|
Updates a document .
|
9,830
|
public function getInfo ( ) { $ json = ( string ) $ this -> client -> request ( 'GET' , "/{$this->name}/" ) -> getBody ( ) ; return JSONEncoder :: decode ( $ json ) ; }
|
Return the database informations .
|
9,831
|
public function getChanges ( ) { $ response = $ this -> client -> request ( 'GET' , "/{$this->name}/_changes" ) ; if ( 200 !== $ response -> getStatusCode ( ) ) { throw new Exception ( 'Request wasn\'t successfull' ) ; } return JSONEncoder :: decode ( ( string ) $ response -> getBody ( ) ) ; }
|
Return informations about the last changes from the database .
|
9,832
|
public function setDefaultsFromConfiguration ( ) { if ( $ this -> options [ 'dsn' ] ) { $ dsn = explode ( ':' , $ this -> options [ 'dsn' ] ) ; $ this -> setSQLDialect ( $ dsn [ 0 ] ) ; } $ this -> setTablePrefix ( $ this -> options [ 'table_prefix' ] ) ; }
|
Update builder settings from active configuration .
|
9,833
|
public function execute ( $ query = null , array $ params = [ ] ) : object { if ( is_array ( $ query ) ) { $ params = $ query ; $ query = null ; } if ( ! $ query ) { $ query = $ this -> getSQL ( ) ; } return parent :: execute ( $ query , $ params ) ; }
|
Execute a SQL - query .
|
9,834
|
private function get_old_path ( File $ file ) { if ( Config :: $ store_dir === null AND Config :: $ file_dir === null ) { throw new \ Exception ( 'Set a path first in "Config::$file_dir"' ) ; } $ subpath = substr ( base_convert ( $ file -> md5sum , 16 , 10 ) , 0 , 3 ) ; $ subpath = implode ( '/' , str_split ( $ subpath ) ) . '/' ; if ( \ Skeleton \ File \ Config :: $ file_dir !== null ) { $ path = \ Skeleton \ File \ Config :: $ file_dir . '/' . $ subpath . $ file -> id . '-' . \ Skeleton \ File \ Util :: sanitize_filename ( $ file -> name ) ; } else { $ path = \ Skeleton \ File \ Config :: $ store_dir . '/file/' . $ subpath . $ file -> id . '-' . \ Skeleton \ File \ Util :: sanitize_filename ( $ file -> name ) ; } return $ path ; }
|
Get the old path
|
9,835
|
protected function generate ( ) { $ this -> password = '' ; $ chars = range ( 'a' , 'z' ) ; $ symbols = Array ( '*' , '&' , '^' , '%' , '$' , '#' , '@' , '!' ) ; $ chars = array_merge ( $ chars , $ symbols ) ; unset ( $ chars [ 11 ] ) ; unset ( $ chars [ 14 ] ) ; $ chars = array_values ( $ chars ) ; $ chars_length = count ( $ chars ) ; foreach ( range ( 1 , $ this -> length ) as $ char ) { $ char = '' ; $ integer = rand ( 2 , 9 ) . '' ; $ new_char = $ chars [ rand ( 0 , $ chars_length - 1 ) ] ; if ( strstr ( $ this -> password , $ new_char ) ) { $ char = $ new_char ; } elseif ( strstr ( $ this -> password , $ integer ) ) { $ char = $ integer ; } else { $ char = rand ( 0 , 1 ) ? $ new_char : $ integer ; } $ this -> password .= $ char ; } $ this -> password = substr_replace ( $ this -> password , array_rand ( $ symbols ) , rand ( 0 , strlen ( $ this -> password ) ) , 1 ) ; }
|
Generates the password randomly
|
9,836
|
protected function randomlyCapitalize ( ) { $ chars = str_split ( $ this -> password ) ; $ letter_positions = Array ( ) ; foreach ( $ chars as $ key => $ char ) { if ( ! is_numeric ( $ char ) ) { $ letter_positions [ ] = $ key ; } } $ random_letter = $ letter_positions [ array_rand ( $ letter_positions ) ] ; $ chars [ $ random_letter ] = ucwords ( $ chars [ $ random_letter ] ) ; $ this -> password = implode ( '' , $ chars ) ; }
|
Randomly capitalize one of the letters in the password
|
9,837
|
public function convert ( \ DOMElement $ parent , ConstantDescriptor $ constant ) { $ fullyQualifiedNamespaceName = $ constant -> getNamespace ( ) instanceof NamespaceDescriptor ? $ constant -> getNamespace ( ) -> getFullyQualifiedStructuralElementName ( ) : $ parent -> getAttribute ( 'namespace' ) ; $ child = new \ DOMElement ( 'constant' ) ; $ parent -> appendChild ( $ child ) ; $ child -> setAttribute ( 'namespace' , ltrim ( $ fullyQualifiedNamespaceName , '\\' ) ) ; $ child -> setAttribute ( 'line' , $ constant -> getLine ( ) ) ; $ child -> appendChild ( new \ DOMElement ( 'name' , $ constant -> getName ( ) ) ) ; $ child -> appendChild ( new \ DOMElement ( 'full_name' , $ constant -> getFullyQualifiedStructuralElementName ( ) ) ) ; $ child -> appendChild ( new \ DOMElement ( 'value' ) ) -> appendChild ( new \ DOMText ( $ constant -> getValue ( ) ) ) ; $ this -> docBlockConverter -> convert ( $ child , $ constant ) ; return $ child ; }
|
Export the given reflected constant definition to the provided parent element .
|
9,838
|
public function setScope ( $ scope ) { if ( ! is_array ( $ scope ) ) { $ this -> scopes = explode ( ' ' , $ scope ) ; } else { $ this -> scopes = $ scope ; } return $ this ; }
|
Sets the scope .
|
9,839
|
public function addScope ( $ scope ) { if ( ! is_array ( $ scope ) ) { $ scope = explode ( ' ' , $ scope ) ; } $ this -> scopes = array_unique ( array_merge ( $ this -> scopes , $ scope ) ) ; return $ this ; }
|
Adds a scope .
|
9,840
|
public function getResponse ( $ code , $ forceNew = false ) { if ( ! $ this -> oauthResponse || $ forceNew ) { $ form_params = [ 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> clientSecret , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ this -> getRedirectUri ( ) , 'code' => $ code , 'state' => $ this -> getState ( ) , ] ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> authURL ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ form_params ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ crl , CURLOPT_CONNECTTIMEOUT , 5 ) ; $ result = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ data = json_decode ( $ result , true ) ; if ( json_last_error ( ) != JSON_ERROR_NONE ) { throw new \ UnexpectedValueException ( 'Received data is not json' ) ; return ; } $ status = $ data [ 'status' ] ; if ( strrpos ( $ status , 20 , - strlen ( $ status ) ) === false ) { throw new Exceptions \ BadResponseException ( 'Received bad response (' . $ data [ 'status' ] . '): ' . $ data [ 'message' ] ) ; return ; } $ this -> OAuthResponse = new OAuthResponse ( $ data ) ; } return $ this -> OAuthResponse ; }
|
Returns the OAuthResponse object that contains the access_token registered scopes and the refresh_token .
|
9,841
|
public function checkScope ( $ scope ) { if ( $ this -> OAuthResponse ) { return $ this -> OAuthResponse -> hasScope ( $ scope ) ; } return in_array ( $ scope , $ this -> getScope ( ) ) ; }
|
Checks if the scope is registered .
|
9,842
|
public function getUrl ( ) { $ url = $ this -> baseAuthUrl ; $ url .= '?response_type=code' ; $ url .= '&client_id=' . $ this -> clientId ; $ url .= '&redirect_uri=' . $ this -> redirectUri ; $ url .= '&scope=' . implode ( ' ' , $ this -> scopes ) ; $ url .= '&state=' . $ this -> state ; return $ url ; }
|
Builds the OAuth URL .
|
9,843
|
public static function group ( $ route , $ callback , $ options = [ ] ) { app ( ) -> router -> group ( $ route , $ callback , $ options ) ; }
|
Adds group route .
|
9,844
|
public function get ( $ type , $ key ) { if ( array_key_exists ( $ key , self :: $ store ) ) { return self :: $ store [ $ key ] [ 'value' ] ; } return null ; }
|
Retrieve a value from the data store .
|
9,845
|
public function set ( $ type , $ key , $ value , $ expire = null ) { self :: $ store [ $ key ] = [ 'type' => $ type , 'value' => $ value , 'expire' => $ expire ] ; }
|
Save a value to the data store .
|
9,846
|
public function customers ( $ id ) { $ customers = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_OPERACIONAL . '/setorcomercial/' . $ id . '/clientes' ) ; return $ customers ; }
|
Lists all customers linked to the commercial sector
|
9,847
|
public function setLocale ( $ locale , array $ alternates = array ( ) ) { $ this -> insertMeta ( 'set' , 'locale' , $ locale ) ; if ( ! empty ( $ alternates ) ) { foreach ( $ alternates as $ alternate ) { $ this -> insertStructure ( 'append' , 'locale' , array ( 'alternate' => $ alternate ) ) ; } } return $ this ; }
|
Set locale property .
|
9,848
|
public function onRequestTerminate ( ) { $ lasterror = error_get_last ( ) ; if ( ! is_null ( $ lasterror ) ) { if ( $ lasterror [ 'type' ] & ( E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR ) ) { $ memlim = Web2All_PHP_INI :: getBytes ( ini_get ( 'memory_limit' ) ) ; if ( $ memlim != - 1 ) { ini_set ( 'memory_limit' , $ memlim + 1000000 ) ; } $ error = Web2All_Manager_Error :: getInstance ( ) ; $ exception = new Web2All_Manager_TriggerException ( $ lasterror [ 'type' ] , $ lasterror [ 'message' ] , $ lasterror [ 'file' ] , $ lasterror [ 'line' ] , array ( ) ) ; if ( $ error ) { $ error -> setState ( $ exception , $ lasterror [ 'type' ] ) ; } } } }
|
Gets executed when request terminates
|
9,849
|
public static function error_log_wrap ( $ message ) { $ msglen = strlen ( $ message ) ; $ i = 0 ; while ( $ msglen > 0 ) { if ( $ msglen > 8000 ) { error_log ( substr ( $ message , $ i * 8000 , 8000 ) ) ; $ msglen = $ msglen - 8000 ; } else { error_log ( substr ( $ message , $ i * 8000 ) ) ; $ msglen = 0 ; } $ i ++ ; } }
|
Log the message to the error_log but wrap at 8000 bytes to prevent automatic cutoff by the PHP error_log function
|
9,850
|
public function debugLogCPU ( $ message = '' ) { $ dat = getrusage ( ) ; $ message .= '[u:' . substr ( ( $ dat [ "ru_utime.tv_sec" ] * 1e6 + $ dat [ "ru_utime.tv_usec" ] ) - $ this -> startUserCPU , 0 , - 3 ) . 'ms / s:' . substr ( ( $ dat [ "ru_stime.tv_sec" ] * 1e6 + $ dat [ "ru_stime.tv_usec" ] ) - $ this -> startSystemCPU , 0 , - 3 ) . 'ms]' ; $ this -> debugLog ( $ message ) ; }
|
Debug log the CPU used by the script
|
9,851
|
public function getGlobalStorage ( $ name ) { if ( ! $ this -> GlobalStorageExists ( $ name ) ) { return false ; } return $ this -> global_data -> get ( $ name ) ; }
|
Retrieve from Global storage
|
9,852
|
public static function includeClass ( $ classname , $ loadscheme = 'Web2All' , $ package = '' , $ set_includedir = false ) { $ path = '' ; $ filename = $ classname ; if ( strpos ( $ classname , '\\' ) ) { $ path_parts = explode ( '\\' , $ classname ) ; $ part_count = count ( $ path_parts ) ; $ filename = $ path_parts [ $ part_count - 1 ] ; $ classname_without_namespaces = $ filename ; for ( $ i = 0 ; ( $ i < $ part_count - 1 ) ; $ i ++ ) { $ path .= $ path_parts [ $ i ] . DIRECTORY_SEPARATOR ; } } else { $ classname_without_namespaces = $ classname ; } if ( $ loadscheme != 'PLAIN' ) { $ path_parts = explode ( "_" , $ classname_without_namespaces ) ; $ part_count = count ( $ path_parts ) ; $ filename = $ path_parts [ $ part_count - 1 ] ; for ( $ i = 0 ; ( $ i < $ part_count - 1 ) ; $ i ++ ) { $ path .= $ path_parts [ $ i ] . DIRECTORY_SEPARATOR ; } } $ classfilesuffixes = array ( '.class.php' , '.php' ) ; switch ( $ loadscheme ) { case 'PEAR' : case 'PLAIN' : $ classfilesuffixes = array ( '.php' ) ; break ; case 'INC' : $ classfilesuffixes = array ( '.inc.php' ) ; break ; } foreach ( self :: $ frameworkRoots as $ include_path ) { if ( $ package ) { $ include_path .= $ package . DIRECTORY_SEPARATOR ; } foreach ( $ classfilesuffixes as $ classfilesuffix ) { if ( is_readable ( $ include_path . $ path . $ filename . $ classfilesuffix ) ) { if ( $ set_includedir ) { $ pathArray = explode ( PATH_SEPARATOR , get_include_path ( ) ) ; if ( ! in_array ( $ include_path , $ pathArray ) ) { $ pathArray [ ] = $ include_path ; set_include_path ( implode ( PATH_SEPARATOR , $ pathArray ) ) ; } } include_once ( $ include_path . $ path . $ filename . $ classfilesuffix ) ; return ; } } } }
|
Load the classfile for the given class
|
9,853
|
public static function loadClass ( $ classname , $ loadscheme = 'Web2All' , $ package = '' , $ set_includedir = false ) { $ class_exists = class_exists ( $ classname ) || interface_exists ( $ classname ) ; if ( $ class_exists && ! $ set_includedir ) { return ; } self :: includeClass ( $ classname , $ loadscheme , $ package , $ set_includedir ) ; }
|
Include php file for Web2All_Manager_Plugin
|
9,854
|
public function initClass ( $ classname , $ arguments = array ( ) , $ isplugin = true ) { $ this -> loadClass ( $ classname ) ; if ( ! class_exists ( $ classname ) ) { throw new Exception ( "Class whith name '$classname' does not exists. Cannot initialise $classname" , E_USER_ERROR ) ; } $ reflectionObj = new ReflectionClass ( $ classname ) ; if ( $ reflectionObj -> isSubclassOf ( 'Web2All_Manager_Plugin' ) || $ isplugin ) { array_unshift ( $ arguments , $ this ) ; } elseif ( $ reflectionObj -> implementsInterface ( 'Web2All_Manager_PluginInterface' ) ) { $ obj = call_user_func_array ( array ( & $ reflectionObj , 'newInstance' ) , $ arguments ) ; $ obj -> setWeb2All ( $ this ) ; return $ obj ; } return call_user_func_array ( array ( & $ reflectionObj , 'newInstance' ) , $ arguments ) ; }
|
Initialize Web2All_Manager_Plugin returns Web2All_Manager_Plugin object
|
9,855
|
public static function registerIncludeRoot ( $ root = null ) { if ( is_null ( $ root ) ) { $ root = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ; } if ( ! in_array ( $ root , self :: $ frameworkRoots ) ) { self :: $ frameworkRoots [ ] = $ root ; return true ; } return false ; }
|
Registers an include root directory
|
9,856
|
public static function unregisterIncludeRoot ( $ root ) { $ found_key = array_search ( $ root , self :: $ frameworkRoots , true ) ; if ( $ found_key !== false ) { unset ( self :: $ frameworkRoots [ $ found_key ] ) ; return true ; } return false ; }
|
Unregisters an include root directory
|
9,857
|
public static function registerAutoloader ( $ root = null ) { self :: registerIncludeRoot ( $ root ) ; if ( ! self :: $ autoloaderAdded ) { self :: $ autoloaderAdded = true ; return spl_autoload_register ( array ( 'Web2All_Manager_Main' , 'loadClass' ) ) ; } return true ; }
|
Registers an autoloader for the Web2All framework
|
9,858
|
public function notifyObservers ( ) { $ this -> Web2All -> restoreErrorHandlers ( ) ; foreach ( $ this -> observers as $ observer ) { $ observer -> update ( $ this ) ; } foreach ( $ this -> observer_names as $ classname ) { $ this -> Web2All -> PluginGlobal -> $ classname -> update ( $ this ) ; } $ this -> Web2All -> setErrorHandlers ( ) ; }
|
If this object has changed as indicated by the hasChanged method then start observers as needed and notify them and then call the clearChanged method to indicate that this object has no longer changed .
|
9,859
|
public function flushEmailErrors ( ) { foreach ( $ this -> observers as $ observer ) { if ( get_class ( $ observer ) == 'Web2All_ErrorObserver_Email' ) { $ observer -> flushErrors ( ) ; } } foreach ( $ this -> observer_names as $ classname ) { if ( $ classname == 'Web2All_ErrorObserver_Email' ) { $ this -> Web2All -> PluginGlobal -> $ classname -> flushErrors ( ) ; } } }
|
flush e - mail errors if any
|
9,860
|
public static function loadClassname ( $ classname , $ loadscheme = 'Web2All' , $ package = '' , $ set_includedir = false ) { Web2All_Manager_Main :: loadClass ( $ classname , $ loadscheme , $ package , $ set_includedir ) ; }
|
Include php file
|
9,861
|
public static function getBytes ( $ size_str ) { switch ( substr ( $ size_str , - 1 ) ) { case 'M' : case 'm' : return ( int ) $ size_str * 1048576 ; case 'K' : case 'k' : return ( int ) $ size_str * 1024 ; case 'G' : case 'g' : return ( int ) $ size_str * 1073741824 ; default : return $ size_str ; } }
|
converts possible shorthand notations from the php ini to bytes .
|
9,862
|
public function notifyPasswordReset ( User $ user , $ plainPassword ) { $ fromEmail = $ this -> container -> getParameter ( "default_mail_from" ) ; $ fromName = $ this -> container -> getParameter ( "default_mail_from_name" ) ; $ appName = $ this -> container -> getParameter ( "default_app_name" ) ; $ subject = "[$appName] Cambio de datos" ; $ toEmail = $ user -> getEmail ( ) ; $ toName = $ user -> getFirstname ( ) ; $ body = $ this -> container -> get ( 'templating' ) -> render ( 'FlowcodeUserBundle:Email:notifyPasswordReset.html.twig' , array ( 'user' => $ user , 'plainPassword' => $ plainPassword ) ) ; $ this -> mailSender -> send ( $ toEmail , $ toName , $ fromEmail , $ fromName , $ subject , $ body , true ) ; }
|
Notify Password reset .
|
9,863
|
public function fireOnSendingRequest ( HttpRequest $ request ) { $ event = EnumEvent :: REQUEST ; if ( isset ( $ this -> listeners [ $ event ] ) && is_array ( $ this -> listeners [ $ event ] ) ) { foreach ( $ this -> listeners [ $ event ] as $ l ) { $ ret = $ l ( $ request ) ; if ( $ ret instanceof HttpRequest ) { $ request = $ ret ; } } } return $ request ; }
|
Fire event before sending HTTP request
|
9,864
|
public function fireOnReceivedVerbose ( $ strerr , $ header , $ output ) { $ event = EnumEvent :: VERBOSE ; if ( isset ( $ this -> listeners [ $ event ] ) && is_array ( $ this -> listeners [ $ event ] ) ) { foreach ( $ this -> listeners [ $ event ] as $ l ) { $ l ( $ strerr , $ header , $ output ) ; } } }
|
Fire event after received verbose
|
9,865
|
public function fireOnReceivedResponse ( HttpResponse $ response ) { $ event = EnumEvent :: RESPONSE ; if ( isset ( $ this -> listeners [ $ event ] ) && is_array ( $ this -> listeners [ $ event ] ) ) { foreach ( $ this -> listeners [ $ event ] as $ l ) { $ l ( $ response ) ; } } }
|
Fire event after received HTTP response
|
9,866
|
public function filterByCustomerCustomerGroup ( $ customerCustomerGroup , $ comparison = null ) { if ( $ customerCustomerGroup instanceof \ CustomerGroup \ Model \ CustomerCustomerGroup ) { return $ this -> addUsingAlias ( CustomerGroupTableMap :: ID , $ customerCustomerGroup -> getCustomerGroupId ( ) , $ comparison ) ; } elseif ( $ customerCustomerGroup instanceof ObjectCollection ) { return $ this -> useCustomerCustomerGroupQuery ( ) -> filterByPrimaryKeys ( $ customerCustomerGroup -> getPrimaryKeys ( ) ) -> endUse ( ) ; } else { throw new PropelException ( 'filterByCustomerCustomerGroup() only accepts arguments of type \CustomerGroup\Model\CustomerCustomerGroup or Collection' ) ; } }
|
Filter the query by a related \ CustomerGroup \ Model \ CustomerCustomerGroup object
|
9,867
|
public function useCustomerCustomerGroupQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinCustomerCustomerGroup ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'CustomerCustomerGroup' , '\CustomerGroup\Model\CustomerCustomerGroupQuery' ) ; }
|
Use the CustomerCustomerGroup relation CustomerCustomerGroup object
|
9,868
|
public function filterByCustomerGroupI18n ( $ customerGroupI18n , $ comparison = null ) { if ( $ customerGroupI18n instanceof \ CustomerGroup \ Model \ CustomerGroupI18n ) { return $ this -> addUsingAlias ( CustomerGroupTableMap :: ID , $ customerGroupI18n -> getId ( ) , $ comparison ) ; } elseif ( $ customerGroupI18n instanceof ObjectCollection ) { return $ this -> useCustomerGroupI18nQuery ( ) -> filterByPrimaryKeys ( $ customerGroupI18n -> getPrimaryKeys ( ) ) -> endUse ( ) ; } else { throw new PropelException ( 'filterByCustomerGroupI18n() only accepts arguments of type \CustomerGroup\Model\CustomerGroupI18n or Collection' ) ; } }
|
Filter the query by a related \ CustomerGroup \ Model \ CustomerGroupI18n object
|
9,869
|
public function useCustomerGroupI18nQuery ( $ relationAlias = null , $ joinType = 'LEFT JOIN' ) { return $ this -> joinCustomerGroupI18n ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'CustomerGroupI18n' , '\CustomerGroup\Model\CustomerGroupI18nQuery' ) ; }
|
Use the CustomerGroupI18n relation CustomerGroupI18n object
|
9,870
|
public function filterByCustomer ( $ customer , $ comparison = Criteria :: EQUAL ) { return $ this -> useCustomerCustomerGroupQuery ( ) -> filterByCustomer ( $ customer , $ comparison ) -> endUse ( ) ; }
|
Filter the query by a related Customer object using the customer_customer_group table as cross reference
|
9,871
|
public function getMaxRank ( ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getReadConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ this -> addSelectColumn ( 'MAX(' . CustomerGroupTableMap :: RANK_COL . ')' ) ; $ stmt = $ this -> doSelect ( $ con ) ; return $ stmt -> fetchColumn ( ) ; }
|
Get the highest rank
|
9,872
|
public function getMaxRankArray ( ConnectionInterface $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } $ this -> addSelectColumn ( 'MAX(' . CustomerGroupTableMap :: RANK_COL . ')' ) ; $ stmt = $ this -> doSelect ( $ con ) ; return $ stmt -> fetchColumn ( ) ; }
|
Get the highest rank by a scope with a array format .
|
9,873
|
static public function doSelectOrderByRank ( Criteria $ criteria = null , $ order = Criteria :: ASC , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getReadConnection ( CustomerGroupTableMap :: DATABASE_NAME ) ; } if ( null === $ criteria ) { $ criteria = new Criteria ( ) ; } elseif ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } $ criteria -> clearOrderByColumns ( ) ; if ( Criteria :: ASC == $ order ) { $ criteria -> addAscendingOrderByColumn ( CustomerGroupTableMap :: RANK_COL ) ; } else { $ criteria -> addDescendingOrderByColumn ( CustomerGroupTableMap :: RANK_COL ) ; } return ChildCustomerGroupQuery :: create ( null , $ criteria ) -> find ( $ con ) ; }
|
Return an array of sortable objects ordered by position
|
9,874
|
private function createEditForm ( UserGroup $ entity ) { $ form = $ this -> createForm ( new UserGroupType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_usergroup_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; }
|
Creates a form to edit a UserGroup entity .
|
9,875
|
public function deleteAction ( Request $ request , $ id ) { $ form = $ this -> createDeleteForm ( $ id ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ userGroup = $ em -> getRepository ( 'AmulenUserBundle:UserGroup' ) -> find ( $ id ) ; if ( ! $ userGroup ) { throw $ this -> createNotFoundException ( 'Unable to find UserGroup entity.' ) ; } $ var = $ em -> getRepository ( 'AmulenUserBundle:User' ) -> findByGroup ( $ userGroup ) ; echo $ var ; die ( "123" ) ; $ users = $ this -> getUsersByUserGroup ( $ userGroup ) ; if ( count ( $ users ) == 0 ) { $ em -> remove ( $ userGroup ) ; $ em -> flush ( ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'warning' , "El grupo de roles no pude eliminarse debido a que posee usuarios asociados." ) ; return $ this -> redirect ( $ request -> getUri ( ) ) ; } } return $ this -> redirect ( $ this -> generateUrl ( 'admin_usergroup' ) ) ; }
|
Deletes a UserGroup entity .
|
9,876
|
private function createCreateForm ( UserGroup $ entity ) { $ options = array ( 'action' => $ this -> generateUrl ( 'admin_usergroup_create' ) , 'method' => 'POST' ) ; $ form = $ this -> createForm ( new UserGroupType ( ) , $ entity , $ options ) ; return $ form ; }
|
Creates a form to create a UserGroup entity .
|
9,877
|
private function getUsersByUserGroup ( UserGroup $ userGroup ) { return 10 ; $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ query = $ em -> createQuery ( 'SELECT ' . ' u, g ' . ' FROM Flowcode\UserBundle\Entity\User u' . ' join u.groups g ' . ' WHERE ' . ' g.name = ' . $ userGroup -> getName ( ) . '' ) ; $ users = $ query -> getResult ( ) ; return $ users ; }
|
Get Users by user group . Dado un grupo de roles de usuario retorna todos los usuarios que pertenecen al grupo .
|
9,878
|
protected function rewriteRoutingCheckRoute ( \ MvcCore \ IRoute & $ route , array $ additionalInfo ) { list ( $ requestMethod ) = $ additionalInfo ; $ routeMethod = $ route -> GetMethod ( ) ; if ( $ routeMethod !== NULL && $ routeMethod !== $ requestMethod ) return TRUE ; $ modules = $ route -> GetAdvancedConfigProperty ( \ MvcCore \ Ext \ Routers \ Modules \ IRoute :: CONFIG_ALLOWED_MODULES ) ; if ( is_array ( $ modules ) && ! in_array ( $ this -> currentModule , $ modules ) ) return TRUE ; return FALSE ; }
|
Return TRUE if there is possible by additional info array records to route request by given route as first argument . For example if route object has defined http method and request has the same method or not or if route is allowed in currently routed module .
|
9,879
|
function getStream ( ) { if ( $ err = $ this -> getError ( ) !== UPLOAD_ERR_OK ) throw new \ RuntimeException ( sprintf ( 'Cannot retrieve stream due to upload error. error: (%s).' , getUploadErrorMessageFromCode ( $ err ) ) ) ; if ( $ this -> isFileMoved ) throw new \ RuntimeException ( 'Cannot retrieve stream after it has already been moved' ) ; if ( $ this -> stream ) return $ this -> stream ; $ givenFileResource = $ this -> _c_givenResource ; if ( ! $ givenFileResource instanceof StreamInterface ) $ givenFileResource = new Stream ( $ givenFileResource , 'r' ) ; return $ this -> stream = $ givenFileResource ; }
|
Get Streamed Object Of Uploaded File
|
9,880
|
protected function setTmpName ( $ filepath ) { $ this -> tmpName = ( string ) $ filepath ; $ this -> stream = null ; $ this -> _c_givenResource = $ filepath ; return $ this ; }
|
Set tmp_name of Uploaded File
|
9,881
|
protected function setType ( $ type ) { if ( $ type == '*/*' || $ type == 'application/octet-stream' ) { $ type = \ Module \ HttpFoundation \ getMimeTypeOfFile ( $ this -> getTmpName ( ) , false ) ; if ( empty ( $ type ) ) if ( null !== $ solved = \ Module \ HttpFoundation \ getMimeTypeOfFile ( $ this -> getClientFilename ( ) ) ) $ type = $ solved ; else $ type = 'application/octet-stream' ; } $ this -> type = ( string ) $ type ; return $ this ; }
|
Set File Type
|
9,882
|
protected function setError ( $ errorStatus ) { if ( ! is_int ( $ errorStatus ) || 0 > $ errorStatus || 8 < $ errorStatus ) throw new \ InvalidArgumentException ( 'Invalid error status for UploadedFile; must be an UPLOAD_ERR_* constant' ) ; $ this -> error = $ errorStatus ; return $ this ; }
|
Set Error Status Code
|
9,883
|
protected function gatherCSSFiles ( ) { $ this -> output -> writeln ( 'Scanning theme "' . $ this -> theme . '" for CSS files' ) ; $ this -> finder -> files ( ) -> in ( $ this -> themeDir ) -> name ( '*.css' ) -> notName ( '*.blubber.css' ) -> notName ( '*.lean.css' ) ; foreach ( $ this -> finder as $ file ) { $ filename = basename ( $ file -> getRealPath ( ) ) ; if ( $ this -> output -> ask ( "Include the file <caution>$filename</caution>?" ) ) { $ this -> cssFiles [ ] = $ file -> getRealPath ( ) ; } } }
|
Collects all the CSS files per the user s approval
|
9,884
|
protected function loadTemplates ( ) { $ manifest = SS_TemplateLoader :: instance ( ) -> getManifest ( ) ; $ templates = $ manifest -> getTemplates ( ) ; $ total = sizeof ( $ templates ) ; $ count = 0 ; $ this -> output -> clearProgress ( ) ; foreach ( $ templates as $ name => $ data ) { foreach ( $ manifest -> getCandidateTemplate ( $ name , $ this -> theme ) as $ template ) { $ this -> samples [ ] = $ template ; } $ count ++ ; $ this -> output -> updateProgressPercent ( $ count , $ total ) ; } $ this -> output -> writeln ( ) ; }
|
Loads all the static . ss templates as HTML into memory
|
9,885
|
protected function loadURLs ( ) { $ omissions = self :: config ( ) -> omit ; $ dataobjects = self :: config ( ) -> extra_dataobjects ; $ i = 0 ; $ classes = ClassInfo :: subclassesFor ( 'SiteTree' ) ; array_shift ( $ classes ) ; $ sampler = Sampler :: create ( $ classes ) -> setDefaultLimit ( self :: config ( ) -> default_limit ) -> setOmissions ( self :: config ( ) -> omit ) -> setLimits ( self :: config ( ) -> limits ) ; $ list = $ sampler -> execute ( ) ; $ totalPages = $ list -> count ( ) ; $ this -> output -> clearProgress ( ) ; foreach ( $ list as $ page ) { $ i ++ ; if ( $ html = $ this -> getSampleForObject ( $ page ) ) { $ this -> samples [ ] = $ html ; } $ this -> output -> updateProgress ( "$i / $totalPages" ) ; } $ this -> output -> writeln ( ) ; if ( ! empty ( $ dataobjects ) ) { $ this -> output -> clearProgress ( ) ; $ i = 0 ; $ sampler -> setClasses ( $ dataobjects ) ; $ list = $ sampler -> execute ( ) ; $ totalPages = $ list -> count ( ) ; $ this -> output -> write ( "Loading $totalPages DataObject URLs..." ) ; foreach ( $ list as $ object ) { if ( ! $ object -> hasMethod ( 'Link' ) ) { $ this -> output -> writeln ( "<error>{$object->ClassName} has no Link() method. Skipping.</error>" ) ; continue ; } if ( $ html = $ this -> getSampleForObject ( $ object ) ) { $ this -> samples [ ] = $ html ; } $ i ++ ; $ this -> output -> updateProgressPercent ( $ i , $ totalPages ) ; } $ this -> output -> writeln ( ) ; } }
|
Loads all URLs to sample rendered content per confirguration
|
9,886
|
protected function getSampleForObject ( DataObject $ record ) { $ response = Director :: test ( $ record -> Link ( ) ) ; if ( $ response -> getStatusCode ( ) === 200 ) { return $ response -> getBody ( ) ; } return false ; }
|
Given a DataObject get an actual SS_HTTPResponse of rendered HTML
|
9,887
|
public static function get_appui_option_id ( ) { return bbn \ appui \ options :: get_instance ( ) -> from_code ( ... self :: _treat_args ( func_get_args ( ) , true ) ) ; }
|
Returns The option s ID of a category i . e . direct children of option s root
|
9,888
|
public function getDefault ( string $ type ) { switch ( $ type ) { case self :: TYPE_NULL : return null ; case self :: TYPE_BOOLEAN : return false ; case self :: TYPE_INTEGER : case self :: TYPE_FLOAT : return 0 ; case self :: TYPE_STRING : case self :: TYPE_BINARY : return '' ; case self :: TYPE_ARRAY : case self :: TYPE_OBJECT : return [ ] ; } throw new InvalidValueException ( "Invalid value type: $type" ) ; }
|
Return the default value for a given type .
|
9,889
|
public function validate ( string $ type , $ value ) : bool { switch ( $ type ) { case self :: TYPE_NULL : return is_null ( $ value ) ; case self :: TYPE_BOOLEAN : return is_bool ( $ value ) ; case self :: TYPE_INTEGER : return is_integer ( $ value ) ; case self :: TYPE_FLOAT : return is_float ( $ value ) ; case self :: TYPE_STRING : return is_string ( $ value ) ; case self :: TYPE_ARRAY : if ( ! is_array ( $ value ) ) { return false ; } return $ this -> isArrayType ( $ value ) ; case self :: TYPE_OBJECT : if ( ! is_array ( $ value ) ) { return false ; } return $ this -> isObjectType ( $ value ) ; case self :: TYPE_BINARY : return is_string ( $ value ) ; } throw new InvalidValueException ( "Invalid value type: $type" ) ; }
|
Validates a value against a type .
|
9,890
|
public static function camelize ( $ word ) { $ upper = function ( $ matches ) { return strtoupper ( $ matches [ 0 ] ) ; } ; $ word = preg_replace ( '/([a-z])([A-Z])/' , '$1_$2' , $ word ) ; $ camelized = str_replace ( ' ' , '' , ucwords ( str_replace ( [ '_' , '-' ] , ' ' , strtolower ( $ word ) ) ) ) ; return preg_replace_callback ( '/(\\\[a-z])/' , $ upper , $ camelized ) ; }
|
Takes a under_scored word and turns it into a camelcased word .
|
9,891
|
public static function slug ( $ string , $ replacement = '-' ) { $ transliterated = static :: transliterate ( $ string ) ; $ spaced = preg_replace ( '/[^\w\s]/' , ' ' , $ transliterated ) ; return preg_replace ( '/\\s+/' , $ replacement , trim ( $ spaced ) ) ; }
|
Returns a string with all spaces converted to given replacement and non word characters removed . Maps special characters to ASCII using transliterator_transliterate .
|
9,892
|
public static function parameterize ( $ string , $ replacement = '-' ) { $ transliterated = static :: transliterate ( $ string ) ; return strtolower ( static :: slug ( $ string , $ replacement ) ) ; }
|
Returns a lowercased string with all spaces converted to given replacement and non word characters removed . Maps special characters to ASCII using transliterator_transliterate .
|
9,893
|
protected static function _inflect ( $ type , $ rule , $ replacement , $ locale ) { $ rules = & static :: $ { $ type } ; if ( ! isset ( $ rules [ $ locale ] ) ) { $ rules [ $ locale ] = [ ] ; } $ rules [ $ locale ] = [ $ rule => $ replacement ] + $ rules [ $ locale ] ; }
|
Set a new inflection rule and its replacement .
|
9,894
|
protected static function _inflectize ( $ rules , $ word , $ locale ) { if ( ! $ word || ! isset ( $ rules [ $ locale ] ) ) { return $ word ; } $ result = $ word ; foreach ( $ rules [ $ locale ] as $ rule => $ replacement ) { $ result = preg_replace ( $ rule , $ replacement , $ word , - 1 , $ count ) ; if ( $ count ) { return $ result ; } } return $ result ; }
|
Changes the form of a word .
|
9,895
|
public static function irregular ( $ singular , $ plural , $ locale = 'default' ) { $ rules = ! is_array ( $ singular ) ? [ $ singular => $ plural ] : $ singular ; $ len = min ( strlen ( $ singular ) , strlen ( $ plural ) ) ; $ prefix = '' ; $ index = 0 ; while ( $ index < $ len && ( $ singular [ $ index ] === $ plural [ $ index ] ) ) { $ prefix .= $ singular [ $ index ] ; $ index ++ ; } if ( ! $ sSuffix = substr ( $ singular , $ index ) ) { $ sSuffix = '' ; } if ( ! $ pSuffix = substr ( $ plural , $ index ) ) { $ pSuffix = '' ; } static :: singular ( "/({$singular})$/i" , "\\1" , $ locale ) ; static :: singular ( "/({$prefix}){$pSuffix}$/i" , "\\1{$sSuffix}" , $ locale ) ; static :: plural ( "/({$plural})$/i" , "\\1" , $ locale ) ; static :: plural ( "/({$prefix}){$sSuffix}$/i" , "\\1{$pSuffix}" , $ locale ) ; }
|
Set a new exception in inflection .
|
9,896
|
public static function reset ( $ lang = null ) { if ( is_string ( $ lang ) ) { unset ( static :: $ _singular [ $ lang ] ) ; unset ( static :: $ _plural [ $ lang ] ) ; return ; } static :: $ _singular = [ ] ; static :: $ _plural = [ ] ; if ( $ lang === true ) { return ; } Inflector :: singular ( '/([^s])s$/i' , '\1' , 'default' ) ; Inflector :: plural ( '/([^s])$/i' , '\1s' , 'default' ) ; Inflector :: singular ( '/(x|z|s|ss|ch|sh)es$/i' , '\1' , 'default' ) ; Inflector :: plural ( '/(x|z|ss|ch|sh)$/i' , '\1es' , 'default' ) ; Inflector :: singular ( '/ies$/i' , 'y' , 'default' ) ; Inflector :: plural ( '/([^aeiouy]|qu)y$/i' , '\1ies' , 'default' ) ; Inflector :: plural ( '/(meta|data)$/i' , '\1' , 'default' ) ; Inflector :: irregular ( 'child' , 'children' , 'default' ) ; Inflector :: irregular ( 'equipment' , 'equipment' , 'default' ) ; Inflector :: irregular ( 'information' , 'information' , 'default' ) ; Inflector :: irregular ( 'man' , 'men' , 'default' ) ; Inflector :: irregular ( 'news' , 'news' , 'default' ) ; Inflector :: irregular ( 'person' , 'people' , 'default' ) ; Inflector :: irregular ( 'woman' , 'women' , 'default' ) ; }
|
Clears all inflection rules .
|
9,897
|
protected function setupScriptForDefaultView ( $ templateScript ) { $ removeClass = NestedForm :: REMOVE_FLAG_CLASS ; $ defaultKey = NestedForm :: DEFAULT_KEY_NAME ; $ script = <<<EOTvar index = 0;$('#has-many-{$this->column}').on('click', '.add', function () { var tpl = $('template.{$this->column}-tpl'); index++; var template = tpl.html().replace(/{$defaultKey}/g, index); $('.has-many-{$this->column}-forms').append(template); {$templateScript}});$('#has-many-{$this->column}').on('click', '.remove', function () { $(this).closest('.has-many-{$this->column}-form').hide(); $(this).closest('.has-many-{$this->column}-form').find('.$removeClass').val(1);});EOT ; Merchant :: script ( $ script ) ; }
|
Setup default template script .
|
9,898
|
public function parse ( $ inputFile ) { $ DCNamespace = 'http://purl.org/rss/1.0/modules/content/' ; $ WPNamespace = 'http://wordpress.org/export/1.2/' ; $ reader = new \ XMLReader ( ) ; $ dom = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ reader -> open ( $ inputFile ) ; while ( $ reader -> read ( ) && $ reader -> name !== 'item' ) ; while ( $ reader -> name == 'item' ) { $ xml = simplexml_import_dom ( $ dom -> importNode ( $ reader -> expand ( ) , true ) ) ; $ wpItems = $ xml -> children ( $ WPNamespace ) ; $ content = $ xml -> children ( $ DCNamespace ) -> encoded ; $ categories = [ ] ; $ tags = [ ] ; foreach ( $ xml -> category as $ category ) { if ( 'category' == $ category -> attributes ( ) -> domain ) { $ categories [ ] = ( string ) $ category ; } if ( 'post_tag' == $ category -> attributes ( ) -> domain ) { $ tags [ ] = ( string ) $ category ; } } if ( $ wpItems ) { $ post_type = ( string ) $ wpItems -> post_type ; $ data = [ 'type' => $ post_type , 'post_date' => new \ DateTime ( ( string ) $ wpItems -> post_date ) , 'title' => ( string ) $ xml -> title , 'content' => ( string ) $ content , 'tags' => $ tags , 'categories' => $ categories , ] ; yield $ data ; } $ reader -> next ( 'item' ) ; } }
|
Parses a specific XML file
|
9,899
|
public function query ( $ inbox = 'INBOX' , callable $ queryCall = null ) { $ query = new Query ; if ( ! is_null ( $ queryCall ) ) { $ query = $ queryCall ( $ query ) ; } return $ query -> get ( $ this -> factory -> create ( $ inbox ) , $ this -> mailFactory ) ; }
|
Execute query on a new connection and wrap results in Mail wrappers .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.